More queries now depends on UNIX_TIMESTAMP() SQL function, wrong index in autopurge...
authorRoland Häder <roland@mxchange.org>
Tue, 16 Sep 2008 20:29:30 +0000 (20:29 +0000)
committerRoland Häder <roland@mxchange.org>
Tue, 16 Sep 2008 20:29:30 +0000 (20:29 +0000)
22 files changed:
beg.php
inc/autopurge/purge-inact.php
inc/databases.php
inc/extensions/ext-beg.php
inc/libs/bonus_functions.php
inc/libs/rallye_functions.php
inc/libs/task_functions.php
inc/libs/transfer_functions.php
inc/mails/birthday_mails.php
inc/modules/admin/what-autopurge.php
inc/modules/admin/what-config_autopurge.php
inc/modules/admin/what-list_autopurge.php
inc/modules/admin/what-list_beg.php
inc/modules/admin/what-list_bonus.php
inc/modules/admin/what-repair_amenu.php
inc/modules/admin/what-repair_gmenu.php
inc/modules/admin/what-repair_mmenu.php
inc/modules/member/what-beg2.php
inc/modules/member/what-bonus.php
inc/modules/member/what-transfer.php
inc/monthly/monthly_beg.php
inc/monthly/monthly_bonus.php

diff --git a/beg.php b/beg.php
index d207d5cf542a3e959cc5d853b64a7efb3dba2822..fa82cafebef842886c2a9b62ed62d69034caddd6 100644 (file)
--- a/beg.php
+++ b/beg.php
@@ -116,7 +116,7 @@ if (defined('mxchange_installed') && (isBooleanConstantAndTrue('mxchange_install
                         array($uid), __FILE__, __LINE__);
 
                        // Check for last entry for userid w/o IP number
-                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_beg_ips WHERE (timeout > ".(time() - $_CONFIG['beg_timeout'])." OR (timeout > ".(time() - $_CONFIG['beg_uid_timeout'])." AND userid=%s)) AND remote_ip='%s' LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_beg_ips WHERE (timeout > (UNIX_TIMESTAMP() - ".$_CONFIG['beg_timeout'].") OR (timeout > (UNIX_TIMESTAMP() - ".$_CONFIG['beg_uid_timeout'].") AND userid=%s)) AND remote_ip='%s' LIMIT 1",
                         array($uid, getenv('REMOTE_ADDR')), __FILE__, __LINE__);
                        if ((SQL_NUMROWS($result) == 0) && ($points > 0) && (!$login)) {
                                // Free memory
index b60277c42202365655f09ff2133e2272805a46a0..c7c658ea9118b509aa705623d9ab4a4c3b332fa6 100644 (file)
@@ -46,7 +46,7 @@ if ((!EXT_IS_ACTIVE("autopurge")) || ($_CONFIG['auto_purge_active'] == "N")) {
 // Shall I look for inactive accounts and autopurge inactive accounts?
 if ($_CONFIG['ap_inactive'] == "Y") {
        // Ok, let's have a look...
-       $since = bigintval($_CONFIG['ap_in_since']);
+       $since = bigintval($_CONFIG['ap_inactive_since']);
        $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid'];
 
        // Check for more extensions
@@ -70,7 +70,7 @@ ORDER BY d.userid", array($since, $since, $since), __FILE__, __LINE__);
        if (SQL_NUMROWS($result_inactive) > 0) {
                // Prepare variables and constants...
                $UIDs = "";
-               define('__INACTIVE_SINCE', ($_CONFIG['ap_in_since'] / 60 / 60));
+               define('__INACTIVE_SINCE', ($_CONFIG['ap_inactive_since'] / 60 / 60));
                define('__INACTIVE_TIME' , ($_CONFIG['ap_in_time']  / 60 / 60));
 
                // Mark found accounts as inactive and send an email
index f4149e4acce56b10947831156e5d72708bff87c3..fc854ecfc733181270339aa85b1cda1f1a85462a 100644 (file)
@@ -113,7 +113,7 @@ define('USAGE_BASE', "usage");
 define('SERVER_URL', "http://www.mxchange.org");
 
 // This current patch level
-define('CURR_SVN_REVISION', "342");
+define('CURR_SVN_REVISION', "343");
 
 // Take a prime number which is long (if you know a longer one please try it out!)
 define('_PRIME', 591623);
index 663f49da3b5464d9c700aea4b976601bb7bff120..a0dacc28554230da307dd4790f43338e6b6784d7 100644 (file)
@@ -255,7 +255,7 @@ default: // Do stuff when extension is loaded
        // Remove old entries
        $OLD = $_CONFIG['beg_timeout'];
        if ($_CONFIG['beg_uid_timeout'] > $OLD) $OLD = $_CONFIG['beg_uid_timeout'];
-       $result_ext = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_beg_ips WHERE timeout < ".(time() - $OLD - 60*60), __FILE__, __LINE__);
+       $result_ext = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_beg_ips WHERE timeout < (UNIX_TIMESTAMP() -".($OLD - 60*60).")", __FILE__, __LINE__);
 
        // Check for beg rallye is active and send mails out
        if (($_CONFIG['beg_rallye'] == "Y") && ($_CONFIG['beg_new_mem_notify'] == "Y")) {
index bde8c4836cbe6b34bc44f6e66a13ee00ff5cbe46..14041197537088410364f5bdf19f86569af48595 100644 (file)
@@ -239,7 +239,7 @@ function BONUS_PURGE_EXPIRED_TURBO_BONUS()
 {
        global $_CONFIG;
        // Remove entries
-       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < ".(time() - $_CONFIG['bonus_timeout']), __FILE__, __LINE__);
+       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_bonus_turbo WHERE timemark < (UNIX_TIMESTAMP() - ".$_CONFIG['bonus_timeout'].")", __FILE__, __LINE__);
        if (SQL_AFFECTEDROWS() > 0) {
                // Send out email to admin
                SEND_ADMIN_NOTIFICATION(AUTOPURGE_ADMIN_TURBO_SUBJECT, "admin_autopurge_turbo", $DELETED, "");
index 94485d633e5d56d9f1190c35c72461f82f940cd4..58dac3bafb560cbac89d632d87c0e7971d7dc132 100644 (file)
@@ -194,7 +194,7 @@ function RALLYE_ADD_PRICES($rallye,$mode="email")
 function RALLYE_ADD_TOPUSERS($rallye,$default=0)
 {
        global $_CONFIG;
-       $since = (time() - $_CONFIG['ap_in_since']);
+       $since = (time() - $_CONFIG['ap_inactive_since']);
 
        // First check how many prices are set
        $result = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_rallye_prices WHERE rallye_id=%s ORDER BY price_level",
@@ -333,7 +333,7 @@ function RALLYE_EXPIRE_RALLYES($result)
        global $DATA, $_CONFIG;
 
        // Latest online time
-       $since = (time() - $_CONFIG['ap_in_since']);
+       $since = (time() - $_CONFIG['ap_inactive_since']);
 
        // Load rallye data
        list($id, $title, $start, $end, $notify, $min_users, $min_prices) = SQL_FETCHROW($result);
index 2eca98fd20baa12c5b80023f5dbe6bf681d0da83..1aced16f60ee5ed4cb060d3ad899bdd6d5992617 100644 (file)
@@ -272,7 +272,7 @@ function OUTPUT_ADVANCED_OVERVIEW (&$result_main)
 
        if (EXT_IS_ACTIVE("autopurge")) {
                // Start finding them...
-               $since = (time() - $_CONFIG['ap_in_since']);
+               $since = (time() - $_CONFIG['ap_inactive_since']);
                $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
 
                // Check for more extensions
@@ -354,10 +354,10 @@ ORDER BY d.userid";
 
                // Autopurge installed?
                $LAST = ""; $ONLINE = "";
-               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_in_since'] > 0)) {
+               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
                        // Use last online timestamp to keep inactive members away from here
                        $LAST   = " AND last_online >= ";
-                       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+                       $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
                }
 
                $SQLs[]   = "SELECT ".$USE." AS active_bonus FROM "._MYSQL_PREFIX."_user_data
@@ -373,10 +373,10 @@ ORDER BY active_bonus DESC, userid";
 
                // Autopurge installed?
                $LAST = ""; $ONLINE = "";
-               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_in_since'] > 0)) {
+               if ((EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
                        // Use last online timestamp to keep inactive members away from here
                        $LAST   = " AND last_online >= ";
-                       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+                       $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
                }
 
                $SQLs[]   = "SELECT userid FROM "._MYSQL_PREFIX."_user_data
index 9b3020f118bef7697dcfda0915afd465fdf198f7..f8b65f32bdc96e50a311abaac83dd3b3e90ec860 100644 (file)
@@ -38,22 +38,20 @@ if (!defined('__SECURITY')) {
 }
 
 //
-function TRANSFER_AUTPPURGE($max, $age)
-{
+function TRANSFER_AUTPPURGE($max, $age) {
        // First get total in-going lines
        $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_user_transfers_in ORDER BY id", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > $max)
-       {
+       if (SQL_NUMROWS($result) > $max) {
                // Update overdue transfers
                $remove = SQL_NUMROWS($result) - $max;
 
                // This will make it really old, so the final removal query will find it
                $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_user_transfers_in SET time_trans='0' ORDER BY id LIMIT ".$remove, __FILE__, __LINE__);
        }
+
        // Second get total out-going lines
        $result = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_user_transfers_out ORDER BY id", __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) > $max)
-       {
+       if (SQL_NUMROWS($result) > $max) {
                // Update overdue transfers
                $remove = SQL_NUMROWS($result) - $max;
 
@@ -62,11 +60,11 @@ function TRANSFER_AUTPPURGE($max, $age)
        }
 
        // Remove old in-going transfers
-       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_transfers_in WHERE time_trans < ".(time() - $age), __FILE__, __LINE__);
+       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_transfers_in WHERE time_trans < (UNIX_TIMESTAMP() - ".$age.")", __FILE__, __LINE__);
        $REMOVE = SQL_AFFECTEDROWS();
 
        // Remove old out-going transfers
-       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_transfers_out WHERE time_trans < ".(time() - $age), __FILE__, __LINE__);
+       $result = SQL_QUERY("DELETE LOW_PRIORITY FROM "._MYSQL_PREFIX."_user_transfers_out WHERE time_trans < (UNIX_TIMESTAMP() - ".$age.")", __FILE__, __LINE__);
        $REMOVE += SQL_AFFECTEDROWS();
 
        // Only send email to admin(s) when we have removed entries
index f28852b62b3f1138e6bdb387da63e5cfb3880834..634e41d3ba91cc5fc292692bbc1af6b02cf5c0a7 100644 (file)
@@ -50,41 +50,37 @@ $YEAR  = date('Y', time());
 
 // Shall I include only active members?
 $ADD = "%s"; $VALUE = "";
-if (($_CONFIG['birthday_active']) && (EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_in_since'] > 0) && ($_CONFIG['ap_inactive'] == "Y"))
-{
-       $ADD = " AND last_online >= %d";
-       $VALUE = bigintval(time() - $_CONFIG['ap_in_since']);
+if (($_CONFIG['birthday_active']) && (EXT_IS_ACTIVE("autopurge")) && ($_CONFIG['ap_inactive'] == "Y") && ($_CONFIG['ap_inactive_since'] > 0)) {
+       $ADD = " AND last_online >= (UNIX_TIMESTAP() - %s)";
+       $VALUE = $_CONFIG['ap_inactive_since'];
 }
 
 // Only confirmed members shall receive birthday mails...
 $result_birthday = SQL_QUERY_ESC("SELECT userid, email, birth_year
 FROM "._MYSQL_PREFIX."_user_data
-WHERE status='CONFIRMED' AND birth_day=%s AND birth_month=%s AND birthday_sent < ".(time() - (ONE_DAY*364)).$ADD."
+WHERE status='CONFIRMED' AND birth_day=%s AND birth_month=%s AND birthday_sent < (UNIX_TIMESTAMP() - ".(ONE_DAY * 364).")".$ADD."
 ORDER BY userid",
  array($DAY, $MONTH, $VALUE), __FILE__, __LINE__);
 
-if (SQL_NUMROWS($result_birthday) > 0)
-{
+if (SQL_NUMROWS($result_birthday) > 0) {
        // Start sending out birthday mails
-       while (list($uid, $email, $byear) = SQL_FETCHROW($result_birthday))
-       {
+       while (list($uid, $email, $byear) = SQL_FETCHROW($result_birthday)) {
                // Calculate own timestamp for birthday and today
-               $BD  = $byear + 12*$MONTH + 365*$DAY;
-               $NOW = $YEAR  + 12*$MONTH + 365*$DAY;
+               $BD  = $byear + 12 * $MONTH + 365 * $DAY;
+               $NOW = $YEAR  + 12 * $MONTH + 365 * $DAY;
 
                // Simply subtract both values and you got the age... :)
                $AGE = $NOW - $BD;
 
-               if ($_CONFIG['birthday_points'] > 0)
-               {
+               if ($_CONFIG['birthday_points'] > 0) {
                        // Prepare array for loading template
                        $content = array(
                                'age'    => $AGE,
                                'points' => $_CONFIG['birthday_points'],
                                'check'  => "",
                        );
-                       for ($idx = 0; $idx < 4; $idx++)
-                       {
+
+                       for ($idx = 0; $idx < 4; $idx++) {
                                $content['check'] .= GEN_RANDOM_CODE("8", rand(0, "$MONTH$DAY"), $uid, ($AGE*($idx+1)));
                        }
 
@@ -94,9 +90,7 @@ if (SQL_NUMROWS($result_birthday) > 0)
 
                        // Load email template with confirmation link
                        $msg = LOAD_EMAIL_TEMPLATE("member_birthday_confirm", $content, bigintval($uid));
-               }
-                else
-               {
+               } else {
                        // Load default email template and fill in the age
                        $msg = LOAD_EMAIL_TEMPLATE("member_birthday", $AGE, $uid);
                }
index 0ab6d465756dfaf4b8377613c51ca3c5f1c212bf..cb1e91f1d9d7a90e05aec04e1a4ecc9e362cbe6b 100644 (file)
@@ -55,7 +55,7 @@ if (isset($_POST['ok'])) {
                case 'Y': define('__YES_UN', " checked"); define('__NO_UN', "");         break;
                case 'N': define('__YES_UN', "");         define('__NO_UN', " checked"); break;
        }
-       define('__AP_IN_SINCE', $_CONFIG['ap_in_since']);
+       define('__AP_IN_SINCE', $_CONFIG['ap_inactive_since']);
        define('__AP_IN_TIME' , $_CONFIG['ap_in_time']);
        define('__AP_UN_TIME' , $_CONFIG['ap_un_time']);
 
index 4ab850216e58afe52852c4d7b23669e1e00fb1b1..064151e00a172fc3cf09110faab5a19730e051ab 100644 (file)
@@ -57,7 +57,7 @@ if (isset($_POST['ok'])) {
        define('__AP_NOTIFY_DEL_MAILS'     , ADD_SELECTION("yn", $_CONFIG['ap_dm_notify']  , "ap_dm_notify"));
 
        // Output time selection boxes
-       define('__AP_IN_SINCE'      , CREATE_TIME_SELECTIONS($_CONFIG['ap_in_since']  , "ap_inactive_since"  , "MWDh"));
+       define('__AP_IN_SINCE'      , CREATE_TIME_SELECTIONS($_CONFIG['ap_inactive_since']  , "ap_inactive_since"  , "MWDh"));
        define('__AP_IN_TIME'       , CREATE_TIME_SELECTIONS($_CONFIG['ap_in_time']   , "ap_inactive_time"   , "MWDh"));
        define('__AP_UN_TIME'       , CREATE_TIME_SELECTIONS($_CONFIG['ap_un_time']   , "ap_unconfirmed_time", "MWDh"));
        define('__AP_TASK_TIME'     , CREATE_TIME_SELECTIONS($_CONFIG['ap_tasks_time'], "ap_tasks_time"      , "MWDh"));
index afc35102c663a93ba3402c8bec1a645f2bea9fc6..8a5cf455833369a05d7c82198f4b56c74fa8dbc0 100644 (file)
@@ -41,7 +41,7 @@ if ((!defined('__SECURITY')) || (!IS_ADMIN())) {
 ADD_DESCR("admin", basename(__FILE__));
 
 // Ok, let's have a look...
-$since = bigintval(time() - $_CONFIG['ap_in_since']);
+$since = bigintval(time() - $_CONFIG['ap_inactive_since']);
 $EXCLUDE_LIST = " AND d.userid != ".$_CONFIG['def_refid']."";
 
 // Check for more extensions
index 338c8d7d67599c764b71f76fa37480e7f22cdc90..fa3115f182da4cfb1451c42af32baf1e1a0a78a0 100644 (file)
@@ -58,7 +58,7 @@ if ($_CONFIG['beg_rallye'] == "Y")
        {
                // Use last online timestamp to keep inactive members away from here
                $LAST   = " AND last_online >= %s";
-               $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+               $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
        }
 
        // Check if at least one is in the active rallye
@@ -116,7 +116,7 @@ ORDER BY beg_points DESC, last_online DESC, userid",
                }
 
                // Prepare constant for timemark
-               define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_in_since'], "2"));
+               define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
 
                // Load final template
                LOAD_TEMPLATE("admin_list_beg");
index 274ec1999ca2d85971051fb00307af2d71e1341c..7b02b64a92348de6184214e81487d95ff74ce458 100644 (file)
@@ -70,7 +70,7 @@ if ($_CONFIG['bonus_active'] == "Y") {
        if (EXT_IS_ACTIVE("autopurge")) {
                // Use last online timestamp to keep inactive members away from here
                $LAST   = " AND last_online >= %s";
-               $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+               $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
        }
 
        // Check if at least one is in the active rallye
@@ -127,7 +127,7 @@ ORDER BY active_bonus DESC, last_online DESC, userid",
                }
 
                // Prepare constant for timemark
-               define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_in_since'], "2"));
+               define('__AUTOPURGE_TIMEOUT', MAKE_DATETIME(time() - $_CONFIG['ap_inactive_since'], "2"));
 
                // Load final template
                LOAD_TEMPLATE("admin_list_bonus");
index b9479f4e21ce8485e2bfead3d3b2053a67652bf6..3168bd4628d72dfe96cc09d2d67e293f82211483 100644 (file)
@@ -49,7 +49,8 @@ while(list($id, $act) = SQL_FETCHROW($result_fix)) {
        $ACTIONS[] = $act;
 
        // Fix weight
-       $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort='".$cnt."' WHERE id='".$id."' LIMIT 1", __FILE__, __LINE__);
+       $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort=%s WHERE id=%s LIMIT 1",
+               array($cnt, $id), __FILE__, __LINE__);
        $REP += SQL_AFFECTEDROWS();
 
        // Count one up
@@ -57,17 +58,17 @@ while(list($id, $act) = SQL_FETCHROW($result_fix)) {
 }
 
 // Set logout weight to 999
-$result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort='999' WHERE act='logout' AND (what='' OR what IS NULL) LIMIT 1", __FILE__, __LINE__);
+$result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort='999' WHERE action='logout' AND (what='' OR what IS NULL) LIMIT 1", __FILE__, __LINE__);
 
 // Now sort every each menu
-foreach ($ACTIONS as $act)
-{
-       $result_fix = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_admin_menu WHERE act='".$act."' AND what != '' AND what IS NOT NULL ORDER BY sort", __FILE__, __LINE__);
+foreach ($ACTIONS as $act) {
+       $result_fix = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_admin_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ORDER BY sort",
+               array($act), __FILE__, __LINE__);
        $cnt = 1;
-       while (list($id) = SQL_FETCHROW($result_fix))
-       {
+       while (list($id) = SQL_FETCHROW($result_fix)) {
                // Fix weight
-               $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort='".$cnt."' WHERE id='".$id."' LIMIT 1", __FILE__, __LINE__);
+               $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_admin_menu SET sort=%s WHERE id=%s LIMIT 1",
+                       array($cnt, $id), __FILE__, __LINE__);
                $REP += SQL_AFFECTEDROWS();
 
                // Count one up
index df8138112f98b7a052455b71c4dd04ad5daf24e9..3913491ba387ecd94c1ec126b8e1c95c1cc6dbfc 100644 (file)
@@ -57,17 +57,17 @@ while(list($id, $act) = SQL_FETCHROW($result_fix))
        $cnt++;
 }
 // Set logout weight to 999
-$result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_guest_menu SET sort='999' WHERE act='logout' AND (what='' OR what IS NULL) LIMIT 1", __FILE__, __LINE__);
+$result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_guest_menu SET sort='999' WHERE action='logout' AND (what='' OR what IS NULL) LIMIT 1", __FILE__, __LINE__);
 
 // Now sort every each menu
-foreach ($ACTIONS as $act)
-{
-       $result_fix = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_guest_menu WHERE act='".$act."' AND what != '' AND what IS NOT NULL ORDER BY sort", __FILE__, __LINE__);
+foreach ($ACTIONS as $act) {
+       $result_fix = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_guest_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ORDER BY sort",
+               array($act), __FILE__, __LINE__);
        $cnt = 1;
-       while (list($id) = SQL_FETCHROW($result_fix))
-       {
+       while (list($id) = SQL_FETCHROW($result_fix)) {
                // Fix weight
-               $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_guest_menu SET sort='".$cnt."' WHERE id='".$id."' LIMIT 1", __FILE__, __LINE__);
+               $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_guest_menu SET sort=%s WHERE id=%s LIMIT 1",
+                       array($cnt, $id), __FILE__, __LINE__);
                $REP += SQL_AFFECTEDROWS();
 
                // Count one up
index 5049c2654da910fd87b7a9fa02a0da4b842aed8b..74ae23fdda7bed6e90482cd09fa2c517005c4a62 100644 (file)
@@ -43,13 +43,13 @@ $ACTIONS = array();
 // First fix all main menus (what="")...
 $result_fix = SQL_QUERY("SELECT id, action FROM "._MYSQL_PREFIX."_member_menu WHERE (what='' OR what IS NULL) AND action != 'logout' ORDER BY sort ASC", __FILE__, __LINE__);
 $cnt = 0; $REP = 0;
-while(list($id, $act) = SQL_FETCHROW($result_fix))
-{
+while(list($id, $act) = SQL_FETCHROW($result_fix)) {
        // Store action value for later usage in sorting sub menus
        $ACTIONS[] = $act;
 
        // Fix weight
-       $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='".$cnt."' WHERE id='".$id."' LIMIT 1", __FILE__, __LINE__);
+       $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort=%s WHERE id=%s LIMIT 1",
+               array($cnt, $id), __FILE__, __LINE__);
        $REP += SQL_AFFECTEDROWS();
 
        // Count one up
@@ -59,14 +59,14 @@ while(list($id, $act) = SQL_FETCHROW($result_fix))
 $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='999' WHERE action='logout' AND (what='' OR what IS NULL) LIMIT 1", __FILE__, __LINE__);
 
 // Now sort every each menu
-foreach ($ACTIONS as $act)
-{
-       $result_fix = SQL_QUERY("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='".$act."' AND what != '' AND what IS NOT NULL ORDER BY sort", __FILE__, __LINE__);
+foreach ($ACTIONS as $act) {
+       $result_fix = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_member_menu WHERE action='%s' AND what != '' AND what IS NOT NULL ORDER BY sort",
+               array($act), __FILE__, __LINE__);
        $cnt = 1;
-       while (list($id) = SQL_FETCHROW($result_fix))
-       {
+       while (list($id) = SQL_FETCHROW($result_fix)) {
                // Fix weight
-               $result_sort = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_member_menu SET sort='".$cnt."' WHERE id='".$id."' LIMIT 1", __FILE__, __LINE__);
+               $result_sort = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_member_menu SET sort=%s WHERE id=%s LIMIT 1",
+                       array($cnt, $id), __FILE__, __LINE__);
                $REP += SQL_AFFECTEDROWS();
 
                // Count one up
index 04e9633b479bfe584a56765f0f0769c1f3061726..6a250924d50386cbb8a8d4e38a79788f1d943eb9 100644 (file)
@@ -51,7 +51,7 @@ if (EXT_IS_ACTIVE("autopurge"))
 {
        // Use last online timestamp to keep inactive members away from here
        $LAST   = " AND last_online >= %s";
-       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+       $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
 }
 
 // Let's check if there are some points left we can "pay"...
index ca9002a7335dd9264fcee3e490b77a6439f694b4..66ae60cb37ccf939fee6f73912e285e226bf802c 100644 (file)
@@ -68,7 +68,7 @@ if (EXT_IS_ACTIVE("autopurge"))
 {
        // Use last online timestamp to keep inactive members away from here
        $LAST   = " AND last_online >= %s";
-       $ONLINE = bigintval(time() - $_CONFIG['ap_in_since']);
+       $ONLINE = bigintval(time() - $_CONFIG['ap_inactive_since']);
 }
 
 // Let's check if there are some points left we can "pay"...
index 943ea9544442dceada1cc68479169de1307173ff..2901b4c8d985a8618329d4f5b5bc17c2c35aeaf6 100644 (file)
@@ -562,8 +562,7 @@ case "": // Overview page
                define('__TRANSFER_ALL_LINK', $total);
        }
 
-       if (isset($_POST['ok']))
-       {
+       if (isset($_POST['ok'])) {
                // Save settings
                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET opt_in='%s' WHERE userid=%s LIMIT 1",
                 array($_POST['opt_in'], $GLOBALS['userid']), __FILE__, __LINE__);
@@ -574,6 +573,7 @@ case "": // Overview page
                // "Settings saved..."
                OUTPUT_HTML("<P><STRONG class=\"member_done\">".SETTINGS_SAVED."</STRONG></P>");
        }
+
        switch ($opt_in)
        {
        case 'Y':
@@ -590,19 +590,17 @@ case "": // Overview page
        }
 
        // Check for latest out-transfers
-       $result = SQL_QUERY_ESC("SELECT time_trans FROM "._MYSQL_PREFIX."_user_transfers_out WHERE time_trans > ".(time() - $_CONFIG['transfer_timeout'])." AND userid=%s ORDER BY time_trans DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
-       if (SQL_NUMROWS($result) == 0)
-       {
+       $result = SQL_QUERY_ESC("SELECT time_trans FROM "._MYSQL_PREFIX."_user_transfers_out WHERE time_trans > (UNIX_TIMESTAMP() - ".$_CONFIG['transfer_timeout'].") AND userid=%s ORDER BY time_trans DESC LIMIT 1", array($GLOBALS['userid']), __FILE__, __LINE__);
+       if (SQL_NUMROWS($result) == 0) {
                // Load template
                define('__TRANSFER_SETTINGS_CONTENT', LOAD_TEMPLATE("member_transfer_settings", true));
-       }
-        else
-       {
+       } else {
                // Load newest transaction
                list($newest) = SQL_FETCHROW($result);
                SQL_FREERESULT($result);
                define('__TRANSFER_SETTINGS_CONTENT', TRANSFER_LATEST_IS_1.MAKE_DATETIME($newest, "3").TRANSFER_LATEST_IS_2);
        }
+
        // Load template
        LOAD_TEMPLATE("member_transfer_overview");
        break;
index 55188d1175994aa3db48cd225db7deb65353379e..be310f4d047ba26fa8c4102d4a01607ffdf36a1e 100644 (file)
@@ -51,41 +51,39 @@ if (($curr != $_CONFIG['last_month']) && ($_CONFIG['last_month'] > 0) && ($_CONF
 {
        // Extension "autopurge" is inactive or purging of inactive accounts is deactivated
        $whereStatement1 = "";
-       $whereStatement2 = 0;
-       $whereStatement3 = bigintval($_CONFIG['beg_ranks']);
+       $whereStatement2 = bigintval($_CONFIG['beg_ranks']);
 
        // Let's check if there are some points left we can "pay"...
        if (EXT_IS_ACTIVE("autopurge"))
        {
                // Use last online stamp only when autopurge for inactive members is activated
-               if (($_CONFIG['ap_in_since'] > 0) && ($_CONFIG['beg_active'] == "Y"))
+               if (($_CONFIG['ap_inactive_since'] > 0) && ($_CONFIG['beg_active'] == "Y"))
                {
                        // Okay, include last online timestamp
-                       $whereStatement1 = "AND last_online >=";
-                       $whereStatement2 = bigintval(time() - $_CONFIG['ap_in_since']);
-                       $whereStatement3 = bigintval($_CONFIG['beg_ranks']);
+                       $whereStatement1 = sprintf("AND last_online >= (UNIX_TIMESTAMP() - %s)", bigintval($_CONFIG['ap_inactive_since']));;
+                       $whereStatement2 = bigintval($_CONFIG['beg_ranks']);
                }
        }
 
        // SQL string to check for accounts
        $result_main = SQL_QUERY_ESC("SELECT userid, email, beg_points
-FROM "._MYSQL_PREFIX."_user_data WHERE status='CONFIRMED' ".$whereStatement1." %s AND beg_points > 0 ORDER BY beg_points DESC, userid LIMIT %s",
- array($whereStatement2, $whereStatement3), __FILE__, __LINE__);
+FROM "._MYSQL_PREFIX."_user_data
+WHERE status='CONFIRMED' ".$whereStatement1." AND beg_points > 0
+ORDER BY beg_points DESC, userid
+LIMIT %s",
+               array($whereStatement2), __FILE__, __LINE__);
 
-       if (SQL_NUMROWS($result_main) > 0)
-       {
+       if (SQL_NUMROWS($result_main) > 0) {
                // Load our winners...
                $UIDs = "";
-               while(list($uid, $email, $points) = SQL_FETCHROW($result_main))
-               {
+               while(list($uid, $email, $points) = SQL_FETCHROW($result_main)) {
                        // Add points to user's account directly
                        $result_data = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_points
 SET points=points+%s WHERE ref_depth=0 AND userid=%s LIMIT 1",
  array($points, bigintval($uid)), __FILE__, __LINE__);
 
                        // Update mediadata as well
-                       if (GET_EXT_VERSION("mediadata") >= "0.0.4")
-                       {
+                       if (GET_EXT_VERSION("mediadata") >= "0.0.4") {
                                // Update database
                                MEDIA_UPDATE_ENTRY(array("total_points"), "add", $points);
                        }
@@ -104,8 +102,7 @@ SET points=points+%s WHERE ref_depth=0 AND userid=%s LIMIT 1",
                if ($curr == "00") $curr = "12";
 
                // Reset accounts
-               $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_user_data SET beg_points=0.00000 WHERE beg_points > 0",
-                __FILE__, __LINE__);
+               $result = SQL_QUERY("UPDATE "._MYSQL_PREFIX."_user_data SET beg_points=0.00000 WHERE beg_points > 0", __FILE__, __LINE__);
        }
 
        // Free memory
index e270061a967abdfb8a03b81f0d569b60fc1e6c2c..c00a486e606ad53b5e7c1ca22f3d4d5de110a25d 100644 (file)
@@ -57,11 +57,11 @@ if (($curr != $_CONFIG['last_month']) && ($_CONFIG['bonus_ranks'] > 0) && ($CSS
        if (EXT_IS_ACTIVE("autopurge"))
        {
                // Use last online stamp only when autopurge for inactive members is activated
-               if ($_CONFIG['ap_in_since'] > 0)
+               if ($_CONFIG['ap_inactive_since'] > 0)
                {
                        // Okay, include last online timestamp
                        $whereStatement1 = "WHERE status='CONFIRMED' AND last_online >=";
-                       $whereStatement2 = bigintval(time() - $_CONFIG['ap_in_since']);
+                       $whereStatement2 = bigintval(time() - $_CONFIG['ap_inactive_since']);
                        $whereStatement3 = bigintval($_CONFIG['bonus_ranks']);
                }
        }