* Needs to be in all Files and every File needs "svn propset *
* svn:keywords Date Revision" (autoprobset!) at least!!!!!! *
* -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder *
+ * Copyright (c) 2003 - 2009 by Roland Haeder *
* For more information visit: http://www.mxchange.org *
* *
* This program is free software; you can redistribute it and/or modify *
// Some security stuff...
if (!defined('__SECURITY')) {
- $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
- require($INC);
+ die();
}
// Don't run on daily reset
if (isResetModeEnabled()) {
// Skip here
return false;
-} elseif (!EXT_IS_ACTIVE('bonus')) {
+} elseif (!isExtensionActive('bonus')) {
// Abort if extension bonus is not active
return false;
}
// Only send bonus mail when bonus extension is active and maximum send-mails is not reached
if ($GLOBALS['pool_cnt'] < getConfig('max_send')) {
// Do we need to send out bonus mails?
- if (EXT_IS_ACTIVE('html_mail')) {
+ if (isExtensionActive('html_mail')) {
// 0 1 2 3 4 5 6 7 8 9 10 11
- $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `html_msg` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__);
+ $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send`, `html_msg` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__);
} else {
// 0 1 2 3 4 5 6 7 8 9 10
- $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{!_MYSQL_PREFIX!}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__);
+ $result_bonus = SQL_QUERY("SELECT `id`, `subject`, `text`, `receivers`, `points`, `time`, `data_type`, `timestamp`, `url`, `cat_id`, `target_send` FROM `{?_MYSQL_PREFIX?}_bonus` WHERE `data_type`='NEW' ORDER BY `timestamp` DESC", __FILE__, __LINE__);
}
if (SQL_NUMROWS($result_bonus) > 0) {
// Send these mails away...
$cnt2 = '';
while ($DATA = SQL_FETCHARRAY($result_bonus)) {
- // Compile URL
- $DATA['url'] = COMPILE_CODE($DATA['url']);
-
// Message is active in queue
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='QUEUE' WHERE `id`=%s LIMIT 1",
array(bigintval($DATA['id'])), __FILE__, __LINE__);
// "Explode" all receivers into an array
$RECEIVERS = array($DATA['receivers']);
} else {
// No users left
- $RECEIVERS = array('0');
+ $RECEIVERS = array(0);
}
$dummy = $RECEIVERS;
// Now, if we are good little boys and girls Santa left us some user-ids.
// We can now send mails to them...
- foreach ($RECEIVERS as $key => $uid) {
+ foreach ($RECEIVERS as $key => $userid) {
// Load personal data
- //* DEBUG: */ echo "*L:".__LINE__.'/'.$uid."*<br />";
- $result_user = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{!_MYSQL_PREFIX!}_user_data` WHERE `userid`=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
+ //* DEBUG: */ print("*L:".__LINE__.'/'.$userid."*<br />");
+ $result_user = SQL_QUERY_ESC("SELECT `surname`, `family`, `email` FROM `{?_MYSQL_PREFIX?}_user_data` WHERE `userid`=%s LIMIT 1",
+ array(bigintval($userid)), __FILE__, __LINE__);
// Is his data available?
if (SQL_NUMROWS($result_user) == 1) {
// The final receiver does exists so we can continue...
- list($sname, $fname, $email) = SQL_FETCHROW($result_user);
- //* DEBUG: */ echo "OK!/L:".__LINE__."<br />";
+ list($surname, $family, $email) = SQL_FETCHROW($result_user);
+ //* DEBUG: */ print("OK!/L:".__LINE__."<br />");
// Mark this user as "spammed" ;-) And place a line for him...
- if (removeReceiver($dummy, $key, $uid, $DATA['id'], $DATA['id'], true) == 'done') {
+ if (removeReceiver($dummy, $key, $userid, $DATA['id'], $DATA['id'], true) == 'done') {
// Replace text variables
foreach ($GLOBALS['replacer'] as $key => $value) {
if (isset($DATA[$key])) $DATA['text'] = str_replace($value, $DATA[$key], $DATA['text']);
);
// Prepare the mail
- $mailText = LOAD_EMAIL_TEMPLATE('bonus-mail', $content, $uid);
+ $mailText = loadEmailTemplate('bonus-mail', $content, $userid);
// Send mail away
if (isset($DATA['html_msg'])) {
// Count one up and remove entry from dummy array
$GLOBALS['pool_cnt']++; unset($dummy[$key]);
- if (GET_EXT_VERSION('user') >= '0.1.4') {
+ if (getExtensionVersion('user') >= '0.1.4') {
// Update mails received for receiver
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_user_data` SET emails_received=emails_received+1 WHERE userid=%s LIMIT 1",
- array(bigintval($uid)), __FILE__, __LINE__);
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET emails_received=emails_received+1 WHERE `userid`=%s LIMIT 1",
+ array(bigintval($userid)), __FILE__, __LINE__);
} // END - if
// Do we have send maximum mails?
if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (countSelection($dummy) == 0)) {
// Yes, we have
- //* DEBUG: */ echo "*EXIT/L:".__LINE__."<br />";
+ //* DEBUG: */ print("*EXIT/L:".__LINE__."<br />");
break;
} // END - if
} // END - if
}
// Update mediadata if version is 0.0.4 or higher
- if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
+ if (getExtensionVersion('mediadata') >= '0.0.4') {
// Update entry (or add missing
$P = $GLOBALS['pool_cnt'];
if (!empty($cnt2) && empty($GLOBALS['pool_cnt'])) $P = $cnt2;
- //* DEBUG: */ echo "+MEDIA/L:".__LINE__.'/'.$P."+<br />";
- MEDIA_UPDATE_ENTRY(array("total_send", "bonus_send"), 'add', $P);
+ //* DEBUG: */ print("+MEDIA/L:".__LINE__.'/'.$P."+<br />");
+ updateMediadataEntry(array("total_send", "bonus_send"), 'add', $P);
} // END - if
// Close sending system
- //* DEBUG: */ echo "-L:".__LINE__.'/'.countSelection($dummy)."-<br />";
+ //* DEBUG: */ print("-L:".__LINE__.'/'.countSelection($dummy)."-<br />");
if (countSelection($dummy) == 0) {
// Queue reached!
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='SEND', `target_send`=0, `receivers`='' WHERE `id`=%s LIMIT 1",
array(bigintval($DATA['id'])), __FILE__, __LINE__);
- //* DEBUG: */ echo "*L:".__LINE__."*<br />";
+ //* DEBUG: */ print("*L:".__LINE__."*<br />");
// Update mediadata if version is 0.0.4 or higher
- if (GET_EXT_VERSION('mediadata') >= '0.0.4') {
+ if (getExtensionVersion('mediadata') >= '0.0.4') {
// Update entry (or add missing)
- //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
- MEDIA_UPDATE_ENTRY(array("total_orders", "bonus_orders"), 'add', 1);
+ //* DEBUG: */ print("*MEDIA/L:".__LINE__."*<br />");
+ updateMediadataEntry(array("total_orders", "bonus_orders"), 'add', 1);
} // END - if
} elseif ($GLOBALS['pool_cnt'] >= getConfig('max_send')) {
// Update bonus pool
- SQL_QUERY_ESC("UPDATE `{!_MYSQL_PREFIX!}_bonus` SET `data_type`='NEW', `target_send`=%s, `receivers`='%s' WHERE `id`=%s LIMIT 1",
+ SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_bonus` SET `data_type`='NEW', `target_send`=%s, `receivers`='%s' WHERE `id`=%s LIMIT 1",
array(countSelection($dummy), implode(';', $dummy), bigintval($DATA['id'])), __FILE__, __LINE__);
- //* DEBUG: */ echo "*L:".__LINE__."<pre>";
- //* DEBUG: */ print_r($dummy);
- //* DEBUG: */ echo "</pre>\n!!!<br />";
+ //* DEBUG: */ print("*L:".__LINE__."<pre>");
+ //* DEBUG: */ print(print_r($dummy, true));
+ //* DEBUG: */ print("</pre>\n!!!<br />");
break;
}
}