From 29720f825150b6449a9bf5cb2024b65e5e86bd2d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Fri, 19 Dec 2008 13:30:17 +0000 Subject: [PATCH] Fix for undefined variable cnt in mails sending pool (Closed: #0000003) --- inc/databases.php | 2 +- inc/pool-update.php | 11 ++++------- inc/pool/pool-bonus.php | 26 +++++++++++++------------- inc/pool/pool-user.php | 37 ++++++++++++++++++++----------------- 4 files changed, 38 insertions(+), 38 deletions(-) diff --git a/inc/databases.php b/inc/databases.php index 43f22f101c..a7a03c1ed5 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -114,7 +114,7 @@ define('USAGE_BASE', "usage"); define('SERVER_URL', "http://www.mxchange.org"); // Current SVN revision -define('CURR_SVN_REVISION', "656"); +define('CURR_SVN_REVISION', "657"); // Take a prime number which is long (if you know a longer one please try it out!) define('_PRIME', 591623); diff --git a/inc/pool-update.php b/inc/pool-update.php index f54f84bf4d..b2fd7c8ca8 100644 --- a/inc/pool-update.php +++ b/inc/pool-update.php @@ -43,11 +43,8 @@ if (defined('__DAILY_RESET')) { return false; } // END - if -// Set some global variables -global $cnt, $msg; - -// Init counter and message -$cnt = 0; $msg = ""; +// Init counter +$GLOBALS['pool_cnt'] = 0; // Load more cache includes $INC_POOL = GET_DIR_AS_ARRAY(PATH."inc/pool/", "pool-"); @@ -55,8 +52,8 @@ $INC_POOL = GET_DIR_AS_ARRAY(PATH."inc/pool/", "pool-"); // Run the filter RUN_FILTER('load_includes'); -// Remove message (IMPORTANT!) -unset($msg); +// Remove counter again +unset($GLOBALS['pool_cnt']); // ?> diff --git a/inc/pool/pool-bonus.php b/inc/pool/pool-bonus.php index 19e15b1531..078a221073 100644 --- a/inc/pool/pool-bonus.php +++ b/inc/pool/pool-bonus.php @@ -47,7 +47,7 @@ if (defined('__DAILY_RESET')) { } // Only send bonus mail when bonus extension is active and maximum send-mails is not reached -if ($cnt < getConfig('max_send')) { +if ($GLOBALS['pool_cnt'] < getConfig('max_send')) { // Do we need to send out bonus mails? if (EXT_IS_ACTIVE("html_mail")) { // 0 1 2 3 4 5 6 7 8 9 10 11 @@ -113,19 +113,19 @@ if ($cnt < getConfig('max_send')) { ); // Prepare the mail - $msg = LOAD_EMAIL_TEMPLATE("bonus-mail", $content, $uid); + $mailText = LOAD_EMAIL_TEMPLATE("bonus-mail", $content, $uid); // Send mail away if (isset($DATA['html_msg'])) { // Send HTML? - SEND_EMAIL($email, $DATA['subject'], $msg, $DATA['html_msg']); + SEND_EMAIL($email, $DATA['subject'], $mailText, $DATA['html_msg']); } else { // No HTML mail! - SEND_EMAIL($email, $DATA['subject'], $msg); + SEND_EMAIL($email, $DATA['subject'], $mailText); } // Count one up and remove entry from dummy array - $cnt++; unset($dummy[$key]); + $GLOBALS['pool_cnt']++; unset($dummy[$key]); if (GET_EXT_VERSION("user") >= "0.1.4") { // Update mails received for receiver @@ -134,7 +134,7 @@ if ($cnt < getConfig('max_send')) { } // END - if // Do we have send maximum mails? - if (($cnt >= getConfig('max_send')) || (SELECTION_COUNT($dummy) == 0)) { + if (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || (SELECTION_COUNT($dummy) == 0)) { // Yes, we have //* DEBUG: */ echo "*EXIT/L:".__LINE__."
"; break; @@ -149,8 +149,8 @@ if ($cnt < getConfig('max_send')) { // Update mediadata if version is 0.0.4 or higher if (GET_EXT_VERSION("mediadata") >= "0.0.4") { // Update entry (or add missing - $P = $cnt; - if (!empty($cnt2) && empty($cnt)) $P = $cnt2; + $P = $GLOBALS['pool_cnt']; + if (!empty($cnt2) && empty($GLOBALS['pool_cnt'])) $P = $cnt2; //* DEBUG: */ echo "+MEDIA/L:".__LINE__."/".$P."+
"; MEDIA_UPDATE_ENTRY(array("total_send", "bonus_send"), "add", $P); } // END - if @@ -160,7 +160,7 @@ if ($cnt < getConfig('max_send')) { if (SELECTION_COUNT($dummy) == 0) { // Queue reached! $result_done = 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__); + array(bigintval($DATA['id'])), __FILE__, __LINE__); //* DEBUG: */ echo "*L:".__LINE__."*
"; // Update mediadata if version is 0.0.4 or higher @@ -169,7 +169,7 @@ if ($cnt < getConfig('max_send')) { //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*
"; MEDIA_UPDATE_ENTRY(array("total_orders", "bonus_orders"), "add", 1); } // END - if - } elseif ($cnt >= getConfig('max_send')) { + } elseif ($GLOBALS['pool_cnt'] >= getConfig('max_send')) { // Update bonus pool $result_done = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='NEW', target_send=%s, receivers='%s' WHERE id=%s LIMIT 1", array(SELECTION_COUNT($dummy), implode(";", $dummy), bigintval($DATA['id'])), __FILE__, __LINE__); @@ -183,10 +183,10 @@ if ($cnt < getConfig('max_send')) { // Free memory SQL_FREERESULT($result_bonus); -} -// Remove message (IMPORTANT!) -unset($msg); + // Remove variable + unset($mailText); +} // ?> diff --git a/inc/pool/pool-user.php b/inc/pool/pool-user.php index 5b79d256db..abdb16f260 100644 --- a/inc/pool/pool-user.php +++ b/inc/pool/pool-user.php @@ -150,10 +150,10 @@ if (SQL_NUMROWS($result_main) > 0) { ); // Load message template - $msg = LOAD_EMAIL_TEMPLATE("normal-mail", $content, bigintval($uid)); + $mailText = LOAD_EMAIL_TEMPLATE("normal-mail", $content, bigintval($uid)); // Send mail away - SEND_EMAIL($email, $DATA[2], $msg, $HTML); + SEND_EMAIL($email, $DATA[2], $mailText, $HTML); // Count sent mails... $result = SQL_QUERY_ESC("UPDATE `"._MYSQL_PREFIX."_user_data` SET emails_sent=emails_sent+1 WHERE userid=%s LIMIT 1", @@ -173,21 +173,21 @@ if (SQL_NUMROWS($result_main) > 0) { } // END - if // And count up the mail - $cnt++; - //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$cnt."*
"; + $GLOBALS['pool_cnt']++; + //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."*
"; break; case "already": // Entry already found, but we still count one up! - $cnt++; - //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$cnt."
"; + $GLOBALS['pool_cnt']++; + //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."
"; break; } } - // Do we have reached the maximum to send mails? || (getConfig('max_send') >= $cnt) - //* DEBUG: */ echo "*L:".__LINE__."/".$cnt.">=".$DATA[8]."/".getConfig('max_send').">=".$cnt."/".$LAST_SENT_ID."!=".$DATA[0]."*
"; - if ((($cnt >= $DATA[8])) && ($LAST_SENT_ID != $DATA[0])) { + // Do we have reached the maximum to send mails? || (getConfig('max_send') >= $GLOBALS['pool_cnt']) + //* DEBUG: */ echo "*L:".__LINE__."/".$GLOBALS['pool_cnt'].">=".$DATA[8]."/".getConfig('max_send').">=".$GLOBALS['pool_cnt']."/".$LAST_SENT_ID."!=".$DATA[0]."*
"; + if ((($GLOBALS['pool_cnt'] >= $DATA[8])) && ($LAST_SENT_ID != $DATA[0])) { // Prepare content $content = array( 'sender_uid' => $DATA[1], @@ -210,10 +210,10 @@ if (SQL_NUMROWS($result_main) > 0) { list($sname, $fname, $email) = SQL_FETCHROW($result_sender); // Load email template - $msg = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]); + $mailText = LOAD_EMAIL_TEMPLATE("done-member", $content, $DATA[1]); // Send it also waway - SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $msg); + SEND_EMAIL($email, MEMBER_SUBJ_SEND_DONE, $mailText); } // END - if // Free result @@ -227,8 +227,8 @@ if (SQL_NUMROWS($result_main) > 0) { $result_user = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_stats SET timestamp_send=UNIX_TIMESTAMP() WHERE pool_id=%s LIMIT 1", array(bigintval($DATA[0])), __FILE__, __LINE__); - $LAST_SENT_ID = $DATA[0]; $cnt = 0; - $cnt2 += $cnt; + $LAST_SENT_ID = $DATA[0]; $GLOBALS['pool_cnt'] = 0; + $cnt2 += $GLOBALS['pool_cnt']; // Update mediadata if version is 0.0.4 or higher if (GET_EXT_VERSION("mediadata") >= "0.0.4") { @@ -241,10 +241,10 @@ if (SQL_NUMROWS($result_main) > 0) { break; } // Do we have send maximum mails? - elseif (($cnt >= getConfig('max_send')) || ($cnt2 >= getConfig('max_send'))) { + elseif (($GLOBALS['pool_cnt'] >= getConfig('max_send')) || ($cnt2 >= getConfig('max_send'))) { // There are some mails left to send for next round, so we reset the status back to NEW (=still not fully delivered) $ADD = ""; - if ($cnt <= $DATA[8]) $ADD = ", target_send=target_send-".$cnt; + if ($GLOBALS['pool_cnt'] <= $DATA[8]) $ADD = ", target_send=target_send-".$GLOBALS['pool_cnt']; $result_queue = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='NEW', receivers='%s'".$ADD." WHERE id=%s LIMIT 1", array(implode(";", $dummy), bigintval($DATA[0])), __FILE__, __LINE__); @@ -308,10 +308,10 @@ if (SQL_NUMROWS($result_main) > 0) { SQL_FREERESULT($result); // User account does exists, so we can safely pay back! - $msg = LOAD_EMAIL_TEMPLATE("back-member", $content, bigintval($uid)); + $mailText = LOAD_EMAIL_TEMPLATE("back-member", $content, bigintval($uid)); // Send mail out to member - SEND_EMAIL($email, MEMBER_BACK_JACKPOT." (".$uid.")", $msg); + SEND_EMAIL($email, MEMBER_BACK_JACKPOT." (".$uid.")", $mailText); } else { // Add to jackpot ADD_JACKPOT($PB); @@ -327,5 +327,8 @@ if (SQL_NUMROWS($result_main) > 0) { // Free memory SQL_FREERESULT($result_main); +// Remove variable +unset($mailText); + // ?> -- 2.39.5