More fixes for missing variables, array elements and logical bugs...
authorRoland Häder <roland@mxchange.org>
Mon, 27 Jul 2009 20:56:16 +0000 (20:56 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 27 Jul 2009 20:56:16 +0000 (20:56 +0000)
inc/functions.php
inc/modules/login.php
inc/mysql-manager.php

index 9589c5e15cb849b91656a23e10d8f899f1ac6255..ab9fec7b50fa976d8310be6febcdc5958661ef98 100644 (file)
@@ -2386,6 +2386,12 @@ function getThemeId ($name) {
 
 // Generates an error code from given account status
 function generateErrorCodeFromUserStatus ($status) {
+       // @TODO The status should never be empty
+       if (empty($status)) {
+               // Something really bad happend here
+               debug_report_bug(__FUNCTION__ . ': status is empty.');
+       } // END - if
+
        // Default error code if unknown account status
        $errorCode = getCode('UNKNOWN_STATUS');
 
index 1c796983da8fd78f216d6af68b833c1993f33ca1..90a768f92259131d0543f138965fdfaa6e5857f3 100644 (file)
@@ -46,9 +46,9 @@ if (!defined('__SECURITY')) {
        redirectToUrl($URL);
 }
 
-if ($status != 'CONFIRMED') {
+if ($GLOBALS['status'] != 'CONFIRMED') {
        // If the status is different than confirmed move the user away from here
-       $errorCode = generateErrorCodeFromUserStatus($status);
+       $errorCode = generateErrorCodeFromUserStatus($GLOBALS['status']);
 
        // Load URL
        redirectToUrl('modules.php?module=index&amp;what=login&amp;login=' . $errorCode);
index 2fdeaa1ad8d9bae3074329f02eb28e5863af8e32..6d8037fa6c91dbe0f2044aab981c70ae9607401e 100644 (file)
@@ -510,21 +510,22 @@ function ADD_MENU ($mode, $act, $wht) {
 
 // Checks wether the current user is a member
 function IS_MEMBER () {
-       // @TODO Why is this global??? #100
-       global $status;
+       // By default no member
+       $ret = false;
 
        // Fix missing 'last' array, damn stupid code :(((
        // @TODO Try to rewrite this to one or more functions
        if ((!isset($GLOBALS['last'])) || (!is_array($GLOBALS['last']))) $GLOBALS['last'] = array();
 
-       $ret = false;
-
        // is the cache entry there?
-       if (isset($GLOBALS['cache_array']['is_member'])) {
+       if (isset($GLOBALS['is_member'])) {
                // Then return it
-               return $GLOBALS['cache_array']['is_member'];
+               return $GLOBALS['is_member'];
        } // END - if
 
+       // Init global 'status'
+       $GLOBALS['status'] = false;
+
        // Fix "deleted" cookies first
        fixDeletedCookies(array('userid', 'u_hash'));
 
@@ -532,23 +533,23 @@ function IS_MEMBER () {
        if ((isUserIdSet()) && (isSessionVariableSet('u_hash'))) {
                // Cookies are set with values, but are they valid?
                $result = SQL_QUERY_ESC("SELECT password, status, last_module, last_online FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s LIMIT 1",
-               array(getUserId()), __FUNCTION__, __LINE__);
+                       array(getUserId()), __FUNCTION__, __LINE__);
                if (SQL_NUMROWS($result) == 1) {
                        // Load data from cookies
-                       list($password, $status, $mod, $onl) = SQL_FETCHROW($result);
+                       list($password, $GLOBALS['status'], $mod, $onl) = SQL_FETCHROW($result);
 
                        // Validate password by created the difference of it and the secret key
                        $valPass = generatePassString($password);
 
                        // Transfer last module and online time
                        if ((!empty($mod)) && (empty($GLOBALS['last']['module']))) {
+                               // @TODO Try to rewrite this to one or more functions
                                $GLOBALS['last']['module'] = $mod;
                                $GLOBALS['last']['online'] = $onl;
                        } // END - if
 
                        // So did we now have valid data and an unlocked user?
-                       //* DEBUG: */ echo $valPass."<br />".getSession('u_hash')."<br />";
-                       if (($status == 'CONFIRMED') && ($valPass == getSession('u_hash'))) {
+                       if (($GLOBALS['status'] == 'CONFIRMED') && ($valPass == getSession('u_hash'))) {
                                // Account is confirmed and all cookie data is valid so he is definely logged in! :-)
                                $ret = true;
                        } else {
@@ -571,7 +572,7 @@ function IS_MEMBER () {
        }
 
        // Cache status
-       $GLOBALS['cache_array']['is_member'] = $ret;
+       $GLOBALS['is_member'] = $ret;
 
        // Return status
        return $ret;
@@ -1052,13 +1053,13 @@ function removeReceiver (&$receivers, $key, $uid, $pool_id, $stats_id='', $bonus
 
                        // Try to look the entry up
                        $result = SQL_QUERY_ESC("SELECT `id` FROM `{!_MYSQL_PREFIX!}_user_links` WHERE %s='%s' AND `userid`=%s AND link_type='%s' LIMIT 1",
-                       array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+                               array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
 
                        // Was it *not* found?
                        if (SQL_NUMROWS($result) == 0) {
                                // So we add one!
                                SQL_QUERY_ESC("INSERT INTO `{!_MYSQL_PREFIX!}_user_links` (%s, userid, link_type) VALUES ('%s','%s','%s')",
-                               array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
+                                       array($rowName, $stats_id, bigintval($uid), $type), __FUNCTION__, __LINE__);
                                $ret = 'done';
                        } else {
                                // Already found