]> git.mxchange.org Git - mailer.git/commitdiff
Some rewrites, you don't need to do: bigintval(getUserData('some_id_column')) as...
authorRoland Häder <roland@mxchange.org>
Fri, 19 Oct 2012 14:57:07 +0000 (14:57 +0000)
committerRoland Häder <roland@mxchange.org>
Fri, 19 Oct 2012 14:57:07 +0000 (14:57 +0000)
16 files changed:
admin.php
inc/classes/resolver.class.php
inc/extensions/ext-mailid.php
inc/filter-functions.php
inc/filters.php
inc/functions.php
inc/libs/booking_functions.php
inc/libs/user_functions.php
inc/loader/load-extension.php
inc/module-functions.php
inc/modules/admin/admin-inc.php
inc/modules/admin/what-extensions.php
inc/modules/admin/what-welcome.php
inc/mysql-manager.php
inc/referral-functions.php
inc/template-functions.php

index c2a9b725269c6a0ade4968ab38b80659ec39050e..69af328cca0d1f6234ec35e7442746070ba96faf 100644 (file)
--- 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&amp;sql_patches=1');
index 33965be896e24f557afc807c99b118dd2327c975..8f48213a18d830ebdc1b1a142d7485d6718a8b7b 100644 (file)
@@ -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;
index 33387e646355331ea4d551139189b45cc277987a..8e08cb8c7d56ec923295b7d9b15fa574f4f42411 100644 (file)
@@ -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
index 39f980c2674c5a6fa9e577a7ff02e9b07ef8fea6..946d0a5ef5c143af77bce454f8b042f18a569a97 100644 (file)
@@ -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();
index 1a8a984f0c74f10a2fc4913ed7bc938878d122ef..99152510cfab6c584613dbdae95b5fc9c002a32c 100644 (file)
@@ -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'] .= '</head>';
 }
 
-// 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')) {
index 2a74c533cf6beaaa92d10b48105ee7fbd8ec10fa..321eddfaf5b202ee83831f3d022567d043277528 100644 (file)
@@ -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?
index 57741ef14aab2892d8804760b2fb85f062ab826a..9fc236d20866832d2fea5bc9408e8715e3a36183 100644 (file)
@@ -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;
index a8718292e43c448f0b280f646a970a85d3f2ca6e..f4558fa77f05bdbdbc22191fa51f07fcfb41f626 100644 (file)
@@ -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);
index a2cd8a9d17b952cd9871a083861a08fa917fdaad..8452a87aa2dae03c2af5fa091267e10045009372 100644 (file)
@@ -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`';
index c9c417467284459504b0c0a13ac40e517de469d9..a87301c9377c070a3d73481ccd4cf2ef9ba23004 100644 (file)
@@ -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!
index 7e4e709c95d1b5a613bc474537a19e499fb8d194..86c378e821b6e9723b28531ab24459336ea6e689 100644 (file)
@@ -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
index 7c914cb7cbfdcc764f5716c10dd770bae5bb771c..b087b047720c55f720074ca15a1d2171b8e8a97a 100644 (file)
@@ -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 {
index 1aeb156fcdc5e9845ab1cc7e9cd7f8f65f29e518..8eb96c0e960f95c80eecb02e7cd04fc5bda49921 100644 (file)
@@ -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--}');
index 21ddd007d23b0696aaaa51865f48eae3fbea452c..bcf674209b87f802cd4e703dbe1d55a1c3e02a60 100644 (file)
@@ -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__);
        }
index 26700a53061e710b70659489379f8742bb51b0d5..4774f9f7858a9e564d2f7b2924794d85d2be4854 100644 (file)
@@ -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);
        }
index 6f1006a2a5da7142c50d77236523eb1890d7d853..f2ee3db151f1033477ae58616e07e930090b505b 100644 (file)
@@ -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'] .= '<meta name="description" content="' . '{?MAIN_TITLE?} ' . trim(getConfig('title_middle')) . ' ' . getTitleFromMenu('guest', getWhat()) . '" />';