Fix for undefined variable cnt in mails sending pool (Closed: #0000003)
authorRoland Häder <roland@mxchange.org>
Fri, 19 Dec 2008 13:30:17 +0000 (13:30 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 19 Dec 2008 13:30:17 +0000 (13:30 +0000)
inc/databases.php
inc/pool-update.php
inc/pool/pool-bonus.php
inc/pool/pool-user.php

index 43f22f1..a7a03c1 100644 (file)
@@ -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);
index f54f84b..b2fd7c8 100644 (file)
@@ -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']);
 
 //
 ?>
index 19e15b1..078a221 100644 (file)
@@ -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__."<br />";
                                                        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."+<br />";
                                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__."*<br />";
 
                                // Update mediadata if version is 0.0.4 or higher
@@ -169,7 +169,7 @@ if ($cnt < getConfig('max_send')) {
                                        //* DEBUG: */ echo "*MEDIA/L:".__LINE__."*<br />";
                                        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);
+}
 
 //
 ?>
index 5b79d25..abdb16f 100644 (file)
@@ -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."*<br />";
+                                                       $GLOBALS['pool_cnt']++;
+                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."*<br />";
                                                        break;
 
                                                case "already":
                                                        // Entry already found, but we still count one up!
-                                                       $cnt++;
-                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$cnt."<br />";
+                                                       $GLOBALS['pool_cnt']++;
+                                                       //* DEBUG: */ echo"*EXIT/L:".__LINE__."/".$GLOBALS['pool_cnt']."<br />";
                                                        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]."*<br />";
-                                       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]."*<br />";
+                                       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);
+
 //
 ?>