From eba2a11e2315e55ad591d52a92d270befe7deb2a Mon Sep 17 00:00:00 2001 From: quix0r Date: Fri, 19 Oct 2012 14:57:07 +0000 Subject: [PATCH] Some rewrites, you don't need to do: bigintval(getUserData('some_id_column')) as the id column will mostly be BIGINT(20) which will always be a number --- admin.php | 2 +- inc/classes/resolver.class.php | 2 +- inc/extensions/ext-mailid.php | 2 +- inc/filter-functions.php | 2 +- inc/filters.php | 6 ++--- inc/functions.php | 2 +- inc/libs/booking_functions.php | 2 +- inc/libs/user_functions.php | 9 ++++--- inc/loader/load-extension.php | 2 +- inc/module-functions.php | 2 +- inc/modules/admin/admin-inc.php | 4 +-- inc/modules/admin/what-extensions.php | 2 +- inc/modules/admin/what-welcome.php | 2 +- inc/mysql-manager.php | 36 +++++++++++++-------------- inc/referral-functions.php | 2 +- inc/template-functions.php | 2 +- 16 files changed, 40 insertions(+), 39 deletions(-) diff --git a/admin.php b/admin.php index c2a9b72526..69af328cca 100644 --- a/admin.php +++ b/admin.php @@ -51,7 +51,7 @@ require('inc/config-global.php'); // Set content type for e.g. search engines setContentType('text/html'); -// Is the admin logged-in and no sql_patches installed? +// Is the admin logged-in and no ext-sql_patches installed? if ((isAdmin()) && (!isExtensionActive('sql_patches'))) { // Extension 'sql_patches' is missing! redirectToUrl('modules.php?module=admin&sql_patches=1'); diff --git a/inc/classes/resolver.class.php b/inc/classes/resolver.class.php index 33965be896..8f48213a18 100644 --- a/inc/classes/resolver.class.php +++ b/inc/classes/resolver.class.php @@ -44,7 +44,7 @@ if (!defined('__SECURITY')) { class HostnameResolver { // Resolve hostname -> IP address function resolveHostname ($hostname) { - // If sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted) + // If ext-sql_patches is not at least 0.7.0, abort here and return the hostname (gethostbyname() may return something unwanted) if (!isExtensionInstalledAndNewer('sql_patches', '0.7.0')) { // Abort here return $hostname; diff --git a/inc/extensions/ext-mailid.php b/inc/extensions/ext-mailid.php index 33387e6463..8e08cb8c7d 100644 --- a/inc/extensions/ext-mailid.php +++ b/inc/extensions/ext-mailid.php @@ -233,7 +233,7 @@ switch (getExtensionMode()) { break; case '0.3.4': // SQL queries for v0.3.4 - // This update depends on latest sql_patches version + // This update depends on latest ext-sql_patches version addExtensionDependency('sql_patches'); // Register points data diff --git a/inc/filter-functions.php b/inc/filter-functions.php index 39f980c267..946d0a5ef5 100644 --- a/inc/filter-functions.php +++ b/inc/filter-functions.php @@ -48,7 +48,7 @@ function initFilterSystem () { reportBug(__FUNCTION__, __LINE__, 'Filter system already initialized.'); } // END - if - // Load all saved filers if sql_patches is updated + // Load all saved filers if ext-sql_patches is updated if ((isset($GLOBALS['cache_array']['filter']['filter_name'])) && (!isset($GLOBALS['cache_array']['filter']['chains']))) { // Prepare filter array prepareFilterArray(); diff --git a/inc/filters.php b/inc/filters.php index 1a8a984f0c..99152510cf 100644 --- a/inc/filters.php +++ b/inc/filters.php @@ -58,7 +58,7 @@ function FILTER_FLUSH_FILTERS () { if ((!isInstallationPhase()) && ((!isExtensionInstalled('sql_patches')) || (isExtensionInstalledAndOlder('sql_patches', '0.5.9')))) { // Log only in debug mode if (isDebugModeEnabled()) { - logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9'))); + logDebugMessage(__FUNCTION__, __LINE__, 'Cannot flush filters, ext-sql_patches might be missing. isExtensionInstalled()=' . intval(isExtensionInstalled('sql_patches')) . ',isExtensionInstalledAndOlder()=' . intval(isExtensionInstalledAndOlder('sql_patches', '0.5.9'))); } // END - if // Abort silently here @@ -147,7 +147,7 @@ function FILTER_CALL_HANDLER_LOGIN_FAILTURES ($filterData) { return $content; } -// Filter for redirecting to logout if sql_patches has been installed +// Filter for redirecting to logout if ext-sql_patches has been installed function FILTER_REDIRECT_TO_LOGOUT_SQL_PATCHES () { // Remove this filter unregisterFilter(__FUNCTION__, __LINE__, 'shutdown', __FUNCTION__); @@ -1088,7 +1088,7 @@ function FILTER_FINISH_PAGE_HEADER () { $GLOBALS['__page_header'] .= ''; } -// Cleans up the DNS cache if sql_patches is at least 0.7.0 +// Cleans up the DNS cache if ext-sql_patches is at least 0.7.0 function FILTER_CLEANUP_DNS_CACHE () { // Is the latest version installed? if (isExtensionInstalledAndNewer('sql_patches', '0.7.0')) { diff --git a/inc/functions.php b/inc/functions.php index 2a74c533cf..321eddfaf5 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -569,7 +569,7 @@ function generateRandomCode ($length, $code, $userid, $extraData = '') { // Does only allow numbers function bigintval ($num, $castValue = TRUE, $abortOnMismatch = TRUE) { //* DEBUG: */ debugOutput('[' . __FUNCTION__ . ':' . __LINE__ . '] ' . 'num=' . $num . ',castValue=' . intval($castValue) . ',abortOnMismatch=' . intval($abortOnMismatch) . ' - ENTERED!'); - // Filter all numbers out + // Filter all non-number chars out, so only number chars will remain $ret = preg_replace('/[^0123456789]/', '', $num); // Shall we cast? diff --git a/inc/libs/booking_functions.php b/inc/libs/booking_functions.php index 57741ef14a..9fc236d208 100644 --- a/inc/libs/booking_functions.php +++ b/inc/libs/booking_functions.php @@ -42,7 +42,7 @@ if (!defined('__SECURITY')) { // Add a record entry ('pointsMode' can be add/sub!) function addBookingRecord ($subject, $userid, $points, $pointsMode) { - // Is the sql_patches updated? + // Is the ext-sql_patches updated? if (isExtensionInstalledAndOlder('sql_patches', '0.5.7')) { // Abort here return; diff --git a/inc/libs/user_functions.php b/inc/libs/user_functions.php index a8718292e4..f4558fa77f 100644 --- a/inc/libs/user_functions.php +++ b/inc/libs/user_functions.php @@ -439,7 +439,7 @@ function doNewUserPassword ($email, $userid) { } elseif ((isValidUserId($userid)) && (empty($email))) { // Direct userid entered $accountFound = fetchUserData($userid); - } else { + } elseif (isDebugModeEnabled()) { // Userid not set! logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . $userid . ',email=' . $email . ': Important variables are empty.'); } @@ -453,14 +453,17 @@ function doNewUserPassword ($email, $userid) { // Update database SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `password`='%s' WHERE `userid`=%s LIMIT 1", - array(generateHash($NEW_PASS), getUserData('userid')), __FUNCTION__, __LINE__); + array( + generateHash($NEW_PASS), + getUserData('userid') + ), __FUNCTION__, __LINE__); // Prepare data and message for email $message = loadEmailTemplate('guest_new_password', array( 'new_pass' => $NEW_PASS, 'nickname' => $userid - ), bigintval(getUserData('userid'))); + ), getUserData('userid')); // ... and send it away sendEmail(bigintval(getUserData('userid')), '{--GUEST_NEW_PASSWORD--}', $message); diff --git a/inc/loader/load-extension.php b/inc/loader/load-extension.php index a2cd8a9d17..8452a87aa2 100644 --- a/inc/loader/load-extension.php +++ b/inc/loader/load-extension.php @@ -136,7 +136,7 @@ if (($GLOBALS['cache_instance']->loadCacheFile('extension')) && ($GLOBALS['cache // Create cache file here $GLOBALS['cache_instance']->init(); - // Add more if sql_patches is recent enougth + // Add more if ext-sql_patches is recent enougth $add = ''; if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { $add = ',`ext_has_css` AS `ext_css`'; diff --git a/inc/module-functions.php b/inc/module-functions.php index c9c4174672..a87301c937 100644 --- a/inc/module-functions.php +++ b/inc/module-functions.php @@ -386,7 +386,7 @@ function ifModuleHasMenu ($module, $forceDb = FALSE) { // Free memory SQL_FREERESULT($result); } elseif (!isExtensionInstalled('sql_patches')) { - // No sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered? + // No ext-sql_patches installed, so maybe in admin/guest/member/sponsor area or no admin registered? $ret = in_array($module, array('admin', 'index', 'login', 'sponsor')); // Then there is a menu! } else { // Unsupported state! diff --git a/inc/modules/admin/admin-inc.php b/inc/modules/admin/admin-inc.php index 7e4e709c95..86c378e821 100644 --- a/inc/modules/admin/admin-inc.php +++ b/inc/modules/admin/admin-inc.php @@ -748,7 +748,7 @@ function adminGetMenuMode () { // Set the default menu mode as the mode for all admins $mode = 'global'; - // If sql_patches is up-to-date enough, use the configuration + // If ext-sql_patches is up-to-date enough, use the configuration if (isExtensionInstalledAndNewer('sql_patches', '0.3.2')) { $mode = getAdminMenu(); } // END - if @@ -1163,7 +1163,7 @@ function adminResetValidateHashLogin ($hash, $login) { // Reset the password for the login. Do NOT call this function without calling above function first! function doResetAdminPassword ($login, $password) { - // Generate hash (we already check for sql_patches in generateHash()) + // Generate hash (we already check for ext-sql_patches in generateHash()) $passHash = generateHash($password); // Prepare fake POST data diff --git a/inc/modules/admin/what-extensions.php b/inc/modules/admin/what-extensions.php index 7c914cb7cb..b087b04772 100644 --- a/inc/modules/admin/what-extensions.php +++ b/inc/modules/admin/what-extensions.php @@ -101,7 +101,7 @@ if (isGetRequestElementSet('reg_ext')) { // Update extension's record if (isExtensionInstalledAndNewer('sql_patches', '0.0.6')) { - // Update also CSS column when extensions sql_patches is newer or exact v0.0.6 + // Update also CSS column when extensions ext-sql_patches is newer or exact v0.0.6 SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_extensions` SET `ext_has_css`='%s',`ext_active`='%s' WHERE `id`=%s LIMIT 1", array(postRequestElement('css', $ext_id), $active, $ext_id), __FILE__, __LINE__); } else { diff --git a/inc/modules/admin/what-welcome.php b/inc/modules/admin/what-welcome.php index 1aeb156fcd..8eb96c0e96 100644 --- a/inc/modules/admin/what-welcome.php +++ b/inc/modules/admin/what-welcome.php @@ -40,7 +40,7 @@ if ((!defined('__SECURITY')) || (!isAdmin())) { die(); } // END - if -// Is sql_patches not yet installed? +// Is ext-sql_patches not yet installed? if (!isExtensionInstalled('sql_patches')) { // Output warning displayMessage('{--ADMIN_WARNING_SQL_PATCHES_MISSING--}'); diff --git a/inc/mysql-manager.php b/inc/mysql-manager.php index 21ddd007d2..bcf674209b 100644 --- a/inc/mysql-manager.php +++ b/inc/mysql-manager.php @@ -792,7 +792,7 @@ function getActionFromModuleWhat ($module, $what) { $data['action'] = ''; if (!isExtensionInstalledAndNewer('sql_patches', '0.0.5')) { - // sql_patches is missing so choose depending on mode + // ext-sql_patches is missing so choose depending on mode $what = determineWhat($module); } elseif ((empty($what)) && ($module != 'admin')) { // Use configured 'home' @@ -841,7 +841,7 @@ function getActionFromModuleWhat ($module, $what) { // Free memory SQL_FREERESULT($result); } elseif ((!isExtensionInstalled('sql_patches')) && ($module != 'admin') && ($module != 'unknown')) { - // No sql_patches installed, but maybe we need to register an admin? + // No ext-sql_patches installed, but maybe we need to register an admin? if (isAdminRegistered()) { // Redirect to admin area redirectToUrl('admin.php'); @@ -967,7 +967,7 @@ function removeReceiver (&$receivers, $key, $userid, $poolId, $statsId = 0, $isB $type ), __FUNCTION__, __LINE__); - // Update 'mails_sent' if sql_patches is updated + // Update 'mails_sent' if ext-sql_patches is updated if (isExtensionInstalledAndNewer('sql_patches', '0.7.4')) { // Update the pool SQL_QUERY_ESC('UPDATE `{?_MYSQL_PREFIX?}_pool` SET `mails_sent`=`mails_sent`+1 WHERE `id`=%s LIMIT 1', @@ -1243,7 +1243,7 @@ function getAdminDefaultAcl ($adminId) { // By default an invalid ACL value is returned $data['default_acl'] = 'NO-ACL'; - // Is sql_patches there and was it found in cache? + // Is ext-sql_patches there and was it found in cache? if (!isExtensionActive('sql_patches')) { // Not found, which is bad, so we need to allow all $data['default_acl'] = 'allow'; @@ -1280,7 +1280,7 @@ function getAdminMenuMode ($adminId) { // By default an invalid mode $data['la_mode'] = 'INVALID'; - // Is sql_patches there and was it found in cache? + // Is ext-sql_patches there and was it found in cache? if (!isExtensionActive('sql_patches')) { // Not found, which is bad, so we need to allow all $data['la_mode'] = 'global'; @@ -1418,9 +1418,9 @@ function deleteUserAccount ($userid, $reason) { $result = SQL_QUERY_ESC("SELECT (SUM(p.`points`) - d.`used_points`) AS `points` FROM - `{?_MYSQL_PREFIX?}_user_points` AS p + `{?_MYSQL_PREFIX?}_user_points` AS `p` LEFT JOIN - `{?_MYSQL_PREFIX?}_user_data` AS d + `{?_MYSQL_PREFIX?}_user_data` AS `d` ON p.`userid`=d.`userid` WHERE @@ -1782,7 +1782,10 @@ function reduceRecipientReceivedMails ($column, $id, $count) { if (count($userids) > 0) { // Now update all user accounts SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `emails_received`=`emails_received`-1 WHERE `userid` IN (%s) LIMIT %s", - array(implode(',', $userids), count($userids)), __FUNCTION__, __LINE__); + array( + implode(',', $userids), + count($userids) + ), __FUNCTION__, __LINE__); } else { // Nothing deleted displayMessage('{%message,ADMIN_MAIL_NOTHING_DELETED=' . $id . '%}'); @@ -1796,7 +1799,7 @@ function reduceRecipientReceivedMails ($column, $id, $count) { // Creates a new task function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = NULL, $strip = TRUE) { // Insert the task data into the database - SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s,%s,'NEW','%s','%s','%s', UNIX_TIMESTAMP())", + SQL_QUERY_ESC("INSERT INTO `{?_MYSQL_PREFIX?}_task_system` (`assigned_admin`, `userid`, `status`, `task_type`, `subject`, `text`, `task_created`) VALUES (%s, %s, 'NEW', '%s', '%s', '%s', UNIX_TIMESTAMP())", array( convertZeroToNull($adminId), convertZeroToNull($userid), @@ -1810,23 +1813,20 @@ function createNewTask ($subject, $notes, $taskType, $userid = NULL, $adminId = } // Updates last module / online time -function updateLastActivity($userid) { +function updateLastActivity ($userid) { // Is 'what' set? if (isWhatSet()) { // Run the update query SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET - `%s`='%s', + `{%%pipe,getUserLastWhatName%%}`='{%%pipe,getWhat%%}', `last_online`=UNIX_TIMESTAMP(), - `REMOTE_ADDR`='%s' + `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}' WHERE `userid`=%s LIMIT 1", array( - getUserLastWhatName(), - getWhat(), - detectRemoteAddr(), bigintval($userid) ), __FUNCTION__, __LINE__); } else { @@ -1834,15 +1834,13 @@ LIMIT 1", SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET - `%s`=NULL, + `{%%pipe,getUserLastWhatName%%}`=NULL, `last_online`=UNIX_TIMESTAMP(), - `REMOTE_ADDR`='%s' + `REMOTE_ADDR`='{%%pipe,detectRemoteAddr%%}' WHERE `userid`=%s LIMIT 1", array( - getUserLastWhatName(), - detectRemoteAddr(), bigintval($userid) ), __FUNCTION__, __LINE__); } diff --git a/inc/referral-functions.php b/inc/referral-functions.php index 26700a5306..4774f9f785 100644 --- a/inc/referral-functions.php +++ b/inc/referral-functions.php @@ -856,7 +856,7 @@ function determineReferralId () { //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using default refid (' . getDefRefid() . ')'); setReferralId(getDefRefid()); } else { - // No default id when sql_patches is not installed or none set + // No default id when ext-sql_patches is not installed or none set //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'Using NULL as refid'); setReferralId(NULL); } diff --git a/inc/template-functions.php b/inc/template-functions.php index 6f1006a2a5..f2ee3db151 100644 --- a/inc/template-functions.php +++ b/inc/template-functions.php @@ -1885,7 +1885,7 @@ function addPageHeaderFooter () { // Generates meta description for current module and 'what' value function generateMetaDescriptionCode () { - // Only include from guest area and if sql_patches has correct version + // Only include from guest area and if ext-sql_patches has correct version if ((getModule() == 'index') && (isExtensionInstalledAndNewer('sql_patches', '0.1.6'))) { // Output it directly $GLOBALS['__page_header'] .= ''; -- 2.39.5