]> git.mxchange.org Git - mailer.git/blobdiff - inc/autopurge.php
Reset rewritten, SQL fixed, zeros are now numeric
[mailer.git] / inc / autopurge.php
index 39c630bdebd3f6f110c219283d75937dd55ef4c0..a0896be2c32a52c8911a8af81318a8ada6c813bd 100644 (file)
@@ -51,7 +51,7 @@ if (($_CONFIG['auto_purge_active'] == "Y") && ($_CONFIG['auto_purge'] > 0))
        }
 
        // Init variables
        }
 
        // Init variables
-       $admin_points = "0";
+       $admin_points = 0;
 
        // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
        $result = SQL_QUERY_ESC("SELECT s.id, s.userid, s.pool_id, t.price
 
        // Then check for outdated mail order. We don't delete them just the confirmation links will be deleted.
        $result = SQL_QUERY_ESC("SELECT s.id, s.userid, s.pool_id, t.price
@@ -63,11 +63,11 @@ WHERE s.timestamp_ordered <= %s ORDER BY s.userid",
        if (SQL_NUMROWS($result) > 0)
        {
                // Start deleting procedure
        if (SQL_NUMROWS($result) > 0)
        {
                // Start deleting procedure
-               $uid = "0"; $points = "0";
+               $uid = 0; $points = 0;
                while(list($mid, $sender, $pool, $price) = SQL_FETCHROW($result))
                {
                        // Check if confirmation links are purged or not
                while(list($mid, $sender, $pool, $price) = SQL_FETCHROW($result))
                {
                        // Check if confirmation links are purged or not
-                       $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%d LIMIT 1",
+                       $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s LIMIT 1",
                         array(bigintval($mid)), __FILE__, __LINE__);
                        if (SQL_NUMROWS($result_links) == 1)
                        {
                         array(bigintval($mid)), __FILE__, __LINE__);
                        if (SQL_NUMROWS($result_links) == 1)
                        {
@@ -79,17 +79,17 @@ WHERE s.timestamp_ordered <= %s ORDER BY s.userid",
                                {
                                        // Directly add points back to senders account
                                        AUTOPURGE_ADD_POINTS($uid, $points);
                                {
                                        // Directly add points back to senders account
                                        AUTOPURGE_ADD_POINTS($uid, $points);
-                                       $points = "0";
+                                       $points = 0;
                                }
                                // Add points
                                $uid = $sender; $points += $price; $admin_points += $price;
 
                                // Remove confirmation links from queue
                                }
                                // Add points
                                $uid = $sender; $points += $price; $admin_points += $price;
 
                                // Remove confirmation links from queue
-                               $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%d",
+                               $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE stats_id=%s",
                                 array(bigintval($mid)), __FILE__, __LINE__);
 
                                // Update status of order
                                 array(bigintval($mid)), __FILE__, __LINE__);
 
                                // Update status of order
-                               $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='DELETED' WHERE id=%d LIMIT 1",
+                               $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET data_type='DELETED' WHERE id=%s LIMIT 1",
                                 array(bigintval($pool)), __FILE__, __LINE__);
                        }
                }
                                 array(bigintval($pool)), __FILE__, __LINE__);
                        }
                }
@@ -110,11 +110,11 @@ WHERE s.timestamp_ordered <= %s ORDER BY s.userid",
                if (SQL_NUMROWS($result) > 0)
                {
                        // Start deleting procedure
                if (SQL_NUMROWS($result) > 0)
                {
                        // Start deleting procedure
-                       $points = "0";
+                       $points = 0;
                        while (list($bid, $price) = SQL_FETCHROW($result))
                        {
                                // Check if confirmation links are purged or not
                        while (list($bid, $price) = SQL_FETCHROW($result))
                        {
                                // Check if confirmation links are purged or not
-                               $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%d",
+                               $result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
                                 array(bigintval($bid)), __FILE__, __LINE__);
                                if (SQL_NUMROWS($result_links) > 0)
                                {
                                 array(bigintval($bid)), __FILE__, __LINE__);
                                if (SQL_NUMROWS($result_links) > 0)
                                {
@@ -125,11 +125,11 @@ WHERE s.timestamp_ordered <= %s ORDER BY s.userid",
                                        SQL_FREERESULT($result_links);
 
                                        // Remove confirmation links from queue
                                        SQL_FREERESULT($result_links);
 
                                        // Remove confirmation links from queue
-                                       $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%d",
+                                       $result_del = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_links WHERE bonus_id=%s",
                                         array(bigintval($bid)), __FILE__, __LINE__);
 
                                        // Update status of order
                                         array(bigintval($bid)), __FILE__, __LINE__);
 
                                        // Update status of order
-                                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='DELETED' WHERE id=%d LIMIT 1",
+                                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_bonus SET data_type='DELETED' WHERE id=%s LIMIT 1",
                                         array(bigintval($bid)), __FILE__, __LINE__);
                                }
                        }
                                         array(bigintval($bid)), __FILE__, __LINE__);
                                }
                        }
@@ -199,7 +199,7 @@ ORDER BY d.userid", array($since, $since, $since), __FILE__, __LINE__);
                        SEND_EMAIL($email, AUTOPURGE_MEMBER_INACTIVE_SUBJECT, $msg);
 
                        // Update this account
                        SEND_EMAIL($email, AUTOPURGE_MEMBER_INACTIVE_SUBJECT, $msg);
 
                        // Update this account
-                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ap_notified=UNIX_TIMESTAMP() WHERE userid=%d LIMIT 1",
+                       $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET ap_notified=UNIX_TIMESTAMP() WHERE userid=%s LIMIT 1",
                         array(bigintval($uid)), __FILE__, __LINE__);
                }
 
                         array(bigintval($uid)), __FILE__, __LINE__);
                }
 
@@ -311,8 +311,7 @@ if ((GET_EXT_VERSION("task") > "0.0") && ($_CONFIG['ap_tasks'] == "Y"))
 }
 
 // Search for mails from deleted members?
 }
 
 // Search for mails from deleted members?
-if ($_CONFIG['ap_del_mails'])
-{
+if ($_CONFIG['ap_del_mails']) {
        // Okay, let's check for them...
        $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
        $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
        // Okay, let's check for them...
        $since = bigintval(time() - $_CONFIG['ap_dm_timeout']);
        $result_mails = SQL_QUERY_ESC("SELECT sender FROM "._MYSQL_PREFIX."_pool WHERE data_type='DELETED' AND timestamp <= %s ORDER BY sender",
@@ -322,17 +321,14 @@ if ($_CONFIG['ap_del_mails'])
        $DELETED = 0;
 
        // Do we have "purged" mails?
        $DELETED = 0;
 
        // Do we have "purged" mails?
-       if (SQL_NUMROWS($result_mails) > 0)
-       {
+       if (SQL_NUMROWS($result_mails) > 0) {
                // Okay, check for their sender's
                // Okay, check for their sender's
-               while(list($sender) = SQL_FETCHROW($result_mails))
-               {
+               while(list($sender) = SQL_FETCHROW($result_mails)) {
                        // Check now...
                        // Check now...
-                       $fount = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
-                       if ($found == 0)
-                       {
+                       $fount = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
+                       if ($found == 0) {
                                // Okay we found some mails!
                                // Okay we found some mails!
-                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE sender=%d",
+                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_pool WHERE sender=%s",
                                 array(bigintval($sender)), __FILE__, __LINE__);
                                $DELETED += SQL_AFFECTEDROWS();
 
                                 array(bigintval($sender)), __FILE__, __LINE__);
                                $DELETED += SQL_AFFECTEDROWS();
 
@@ -353,17 +349,14 @@ if ($_CONFIG['ap_del_mails'])
         array($since), __FILE__, __LINE__);
 
        // Do we have "purged" mails?
         array($since), __FILE__, __LINE__);
 
        // Do we have "purged" mails?
-       if (SQL_NUMROWS($result_mails) > 0)
-       {
+       if (SQL_NUMROWS($result_mails) > 0) {
                // Okay, check for their sender's
                // Okay, check for their sender's
-               while(list($sender) = SQL_FETCHROW($result_mails))
-               {
+               while(list($sender) = SQL_FETCHROW($result_mails)) {
                        // Check now...
                        // Check now...
-                       $found = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%d LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
-                       if ($found == 0)
-                       {
+                       $found = SQL_NUMROWS(SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1", array(bigintval($sender)), __FILE__, __LINE__));
+                       if ($found == 0) {
                                // Okay we found some mails!
                                // Okay we found some mails!
-                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE sender=%d", array(bigintval($sender)), __FILE__, __LINE__);
+                               $result_remove = SQL_QUERY_ESC("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_stats WHERE sender=%s", array(bigintval($sender)), __FILE__, __LINE__);
                                $DELETED += SQL_AFFECTEDROWS();
 
                                // Reset query (to prevent possible errors) ...
                                $DELETED += SQL_AFFECTEDROWS();
 
                                // Reset query (to prevent possible errors) ...
@@ -378,25 +371,23 @@ if ($_CONFIG['ap_del_mails'])
        SQL_FREERESULT($result_mails);
 
        // Do we have deleted mails and the admin want's to receive a notification
        SQL_FREERESULT($result_mails);
 
        // Do we have deleted mails and the admin want's to receive a notification
-       if (($DELETED > 0) && ($_CONFIG['ap_dm_notify'] == "Y"))
-       {
+       if (($DELETED > 0) && ($_CONFIG['ap_dm_notify'] == "Y")) {
                // Send out email to admin
                SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT, "admin_autopurge_del_mails", $DELETED, "");
        }
 }
 
                // Send out email to admin
                SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_DEL_MAILS_SUBJECT, "admin_autopurge_del_mails", $DELETED, "");
        }
 }
 
-if (EXT_IS_ACTIVE("rallye"))
-{
+if (EXT_IS_ACTIVE("rallye")) {
        // Check expired rallyes (hard-coded 3 days limit for displaying expired rallyes!)
        require_once(PATH."inc/libs/rallye_functions.php");
        RALLYE_DELETE_EXPIRED_RALLYES();
 }
        // Check expired rallyes (hard-coded 3 days limit for displaying expired rallyes!)
        require_once(PATH."inc/libs/rallye_functions.php");
        RALLYE_DELETE_EXPIRED_RALLYES();
 }
-//
-if (EXT_IS_ACTIVE("bonus"))
-{
+
+if (EXT_IS_ACTIVE("bonus")) {
        // Check for expired turbo bonus lines
        require_once(PATH."inc/libs/bonus_functions.php");
        BONUS_PURGE_EXPIRED_TURBO_BONUS();
 }
        // Check for expired turbo bonus lines
        require_once(PATH."inc/libs/bonus_functions.php");
        BONUS_PURGE_EXPIRED_TURBO_BONUS();
 }
+
 //
 ?>
 //
 ?>