From: Roland Häder Date: Tue, 16 Sep 2008 20:29:30 +0000 (+0000) Subject: More queries now depends on UNIX_TIMESTAMP() SQL function, wrong index in autopurge... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e521a48cf5d2a3090bd8d7a9cb21dfbc2dfda257;p=mailer.git More queries now depends on UNIX_TIMESTAMP() SQL function, wrong index in autopurge extension fixed --- diff --git a/beg.php b/beg.php index d207d5cf54..fa82cafebe 100644 --- 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 diff --git a/inc/autopurge/purge-inact.php b/inc/autopurge/purge-inact.php index b60277c422..c7c658ea91 100644 --- a/inc/autopurge/purge-inact.php +++ b/inc/autopurge/purge-inact.php @@ -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 diff --git a/inc/databases.php b/inc/databases.php index f4149e4acc..fc854ecfc7 100644 --- a/inc/databases.php +++ b/inc/databases.php @@ -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); diff --git a/inc/extensions/ext-beg.php b/inc/extensions/ext-beg.php index 663f49da3b..a0dacc2855 100644 --- a/inc/extensions/ext-beg.php +++ b/inc/extensions/ext-beg.php @@ -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")) { diff --git a/inc/libs/bonus_functions.php b/inc/libs/bonus_functions.php index bde8c4836c..1404119753 100644 --- a/inc/libs/bonus_functions.php +++ b/inc/libs/bonus_functions.php @@ -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, ""); diff --git a/inc/libs/rallye_functions.php b/inc/libs/rallye_functions.php index 94485d633e..58dac3bafb 100644 --- a/inc/libs/rallye_functions.php +++ b/inc/libs/rallye_functions.php @@ -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); diff --git a/inc/libs/task_functions.php b/inc/libs/task_functions.php index 2eca98fd20..1aced16f60 100644 --- a/inc/libs/task_functions.php +++ b/inc/libs/task_functions.php @@ -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 diff --git a/inc/libs/transfer_functions.php b/inc/libs/transfer_functions.php index 9b3020f118..f8b65f32bd 100644 --- a/inc/libs/transfer_functions.php +++ b/inc/libs/transfer_functions.php @@ -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 diff --git a/inc/mails/birthday_mails.php b/inc/mails/birthday_mails.php index f28852b62b..634e41d3ba 100644 --- a/inc/mails/birthday_mails.php +++ b/inc/mails/birthday_mails.php @@ -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); } diff --git a/inc/modules/admin/what-autopurge.php b/inc/modules/admin/what-autopurge.php index 0ab6d46575..cb1e91f1d9 100644 --- a/inc/modules/admin/what-autopurge.php +++ b/inc/modules/admin/what-autopurge.php @@ -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']); diff --git a/inc/modules/admin/what-config_autopurge.php b/inc/modules/admin/what-config_autopurge.php index 4ab850216e..064151e00a 100644 --- a/inc/modules/admin/what-config_autopurge.php +++ b/inc/modules/admin/what-config_autopurge.php @@ -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")); diff --git a/inc/modules/admin/what-list_autopurge.php b/inc/modules/admin/what-list_autopurge.php index afc35102c6..8a5cf45583 100644 --- a/inc/modules/admin/what-list_autopurge.php +++ b/inc/modules/admin/what-list_autopurge.php @@ -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 diff --git a/inc/modules/admin/what-list_beg.php b/inc/modules/admin/what-list_beg.php index 338c8d7d67..fa3115f182 100644 --- a/inc/modules/admin/what-list_beg.php +++ b/inc/modules/admin/what-list_beg.php @@ -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"); diff --git a/inc/modules/admin/what-list_bonus.php b/inc/modules/admin/what-list_bonus.php index 274ec1999c..7b02b64a92 100644 --- a/inc/modules/admin/what-list_bonus.php +++ b/inc/modules/admin/what-list_bonus.php @@ -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"); diff --git a/inc/modules/admin/what-repair_amenu.php b/inc/modules/admin/what-repair_amenu.php index b9479f4e21..3168bd4628 100644 --- a/inc/modules/admin/what-repair_amenu.php +++ b/inc/modules/admin/what-repair_amenu.php @@ -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 diff --git a/inc/modules/admin/what-repair_gmenu.php b/inc/modules/admin/what-repair_gmenu.php index df8138112f..3913491ba3 100644 --- a/inc/modules/admin/what-repair_gmenu.php +++ b/inc/modules/admin/what-repair_gmenu.php @@ -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 diff --git a/inc/modules/admin/what-repair_mmenu.php b/inc/modules/admin/what-repair_mmenu.php index 5049c2654d..74ae23fdda 100644 --- a/inc/modules/admin/what-repair_mmenu.php +++ b/inc/modules/admin/what-repair_mmenu.php @@ -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 diff --git a/inc/modules/member/what-beg2.php b/inc/modules/member/what-beg2.php index 04e9633b47..6a250924d5 100644 --- a/inc/modules/member/what-beg2.php +++ b/inc/modules/member/what-beg2.php @@ -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"... diff --git a/inc/modules/member/what-bonus.php b/inc/modules/member/what-bonus.php index ca9002a733..66ae60cb37 100644 --- a/inc/modules/member/what-bonus.php +++ b/inc/modules/member/what-bonus.php @@ -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"... diff --git a/inc/modules/member/what-transfer.php b/inc/modules/member/what-transfer.php index 943ea95444..2901b4c8d9 100644 --- a/inc/modules/member/what-transfer.php +++ b/inc/modules/member/what-transfer.php @@ -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("

".SETTINGS_SAVED."

"); } + 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; diff --git a/inc/monthly/monthly_beg.php b/inc/monthly/monthly_beg.php index 55188d1175..be310f4d04 100644 --- a/inc/monthly/monthly_beg.php +++ b/inc/monthly/monthly_beg.php @@ -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 diff --git a/inc/monthly/monthly_bonus.php b/inc/monthly/monthly_bonus.php index e270061a96..c00a486e60 100644 --- a/inc/monthly/monthly_bonus.php +++ b/inc/monthly/monthly_bonus.php @@ -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']); } }