]> git.mxchange.org Git - mailer.git/blobdiff - inc/pool/pool-user.php
Rewrites/fixes for while() loops with merge_array() and SQL_FETCHARRAY() usage
[mailer.git] / inc / pool / pool-user.php
index b6b705170c7742eb14fd73847b6675a4d6037564..d3e009cb1f77260a07748144d08f96a8cde62442 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 12/12/2008 *
- * ===============                              Last change: 12/12/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 12/12/2008 *
+ * ===================                          Last change: 12/12/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : pool-user.php                                    *
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -61,7 +62,7 @@ if (isExtensionActive('html_mail')) {
 }
 
 // Reset variables
-$cnt2 = 0; $lastSentId = 0; $cnt_back = array(0); $pointsBack = array(0);
+$cnt2 = '0'; $lastSentId = '0'; $cnt_back = array(0); $pointsBack = array(0);
 if (SQL_NUMROWS($result_main) > 0) {
        // Parse all mails
        while ($DATA = SQL_FETCHARRAY($result_main, 0, false)) {
@@ -78,19 +79,19 @@ if (SQL_NUMROWS($result_main) > 0) {
                        // "Explode" all receivers into an array
                        if (ereg(';', $DATA['receivers'])) {
                                // There's more than one receiver in the list...
-                               $RECEIVERS = explode(';', $DATA['receivers']);
+                               $receiverS = explode(';', $DATA['receivers']);
                        } elseif (!empty($DATA['receivers'])) {
                                // Only one user left
-                               $RECEIVERS = array($DATA['receivers']);
+                               $receiverS = array($DATA['receivers']);
                        } else {
                                // No users left
-                               $RECEIVERS = array(0);
+                               $receiverS = array(0);
                        }
-                       $dummy = $RECEIVERS;
+                       $dummy = $receiverS;
 
-                       // Now, if we are good little boys and girls Santa left us some user-ids.
+                       // Now, if we are good little boys and girls Santa Claus left us some user-ids.
                        // We can now send mails to them...
-                       foreach ($RECEIVERS as $key => $userid) {
+                       foreach ($receiverS as $key => $userid) {
                                // Lookup user id
                                //* DEBUG: */ outputHtml("*L:".__LINE__.'/'.SQL_NUMROWS($result_user)."*<br />");
                                if (fetchUserData($userid)) {
@@ -100,7 +101,7 @@ if (SQL_NUMROWS($result_main) > 0) {
 
                                        // If there's no stats entry add it!
                                        //* DEBUG: */ outputHtml("!L:".__LINE__.'/'.SQL_NUMROWS($result_stats)."!<br />");
-                                       if (SQL_NUMROWS($result_stats) == 0) {
+                                       if (SQL_NUMROWS($result_stats) == '0') {
                                                // No entry was found, so we add him!
                                                SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_user_stats` (`pool_id` , `userid`, `cat_id`, `payment_id`, `subject`, `url` , `max_rec` , `timestamp_ordered`, `timestamp_sstart`) VALUES ('%s','%s','%s','%s','%s','%s','%s','%s' , UNIX_TIMESTAMP())",
                                                        array(bigintval($DATA['id']), bigintval($DATA['sender']), bigintval($DATA['cat_id']), bigintval($DATA['payment_id']), $DATA['subject'], $DATA['url'], $DATA['target_send'], bigintval($DATA['timestamp'])), __FILE__, __LINE__);
@@ -153,7 +154,7 @@ if (SQL_NUMROWS($result_main) > 0) {
 
                                                                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",
+                                                                       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
 
@@ -209,7 +210,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_stats` SET `timestamp_send`=UNIX_TIMESTAMP() WHERE `pool_id`=%s LIMIT 1",
                                                        array(bigintval($DATA['id'])), __FILE__, __LINE__);
 
-                                               $lastSentId = $DATA['id']; $GLOBALS['pool_cnt'] = 0;
+                                               $lastSentId = $DATA['id']; $GLOBALS['pool_cnt'] = '0';
                                                $cnt2 += $GLOBALS['pool_cnt'];
 
                                                // Update mediadata if version is 0.0.4 or higher
@@ -238,7 +239,7 @@ if (SQL_NUMROWS($result_main) > 0) {
                                        SQL_FREERESULT($result_stats);
                                } else {
                                        // User does not exists so we have add the sender's points back to sender's account
-                                       if (($RECEIVERS['id'] == 0) || (empty($RECEIVERS['id']))) {
+                                       if (($receiverS['id'] == '0') || (empty($receiverS['id']))) {
                                                // List was empty
                                                SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_pool` SET `data_type`='SEND' WHERE `id`=%s LIMIT 1",
                                                        array(bigintval($DATA['id'])), __FILE__, __LINE__);