]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/user_functions.php
Filter support added to template engine, functions renamed
[mailer.git] / inc / libs / user_functions.php
index ef117260fb334bb61239644b6b3acb072696cf80..8a0ede3f2971e6964e21455db252627efc260413 100644 (file)
@@ -99,8 +99,8 @@ function addSortLinks ($letter, $sortby, $colspan, $return=false) {
        // Prepare array with all possible sorters
        $list = array(
                'userid'      => getMessage('_UID'),
-               'family'      => getMessage('FAMILY_NAME'),
-               'email'       => getMessage('EMAIL_ADDRESS'),
+               'family'      => getMessage('FAMILY'),
+               'email'       => getMessage('EMAIL'),
                'REMOTE_ADDR' => getMessage('REMOTE_IP')
        );
 
@@ -300,18 +300,18 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
        if (!empty($content['userid'])) $userid = bigintval($content['userid']);
 
        // Is there an entry?
-       if (((isUserDataValid()) && (getUserData('status') == 'CONFIRMED') && (!empty($content['userid']))) || ($content['userid'] == $userid)) {
+       if ((isUserDataValid()) && (getUserData('status') == 'CONFIRMED') && (!empty($content['userid']))) {
                // Check for old MD5 passwords
-               if ((strlen($content['password']) == 32) && (md5($passwd) == $content['password'])) {
+               if ((strlen(getUserData('password')) == 32) && (md5($passwd) == getUserData('password'))) {
                        // Just set the hash to the password from DB... :)
-                       $content['hash'] = $content['password'];
+                       $content['hash'] = getUserData('password');
                } else {
                        // Hash password with improved way for comparsion
-                       $content['hash'] = generateHash($passwd, substr($content['password'], 0, -40));
+                       $content['hash'] = generateHash($passwd, substr(getUserData('password'), 0, -40));
                }
 
                // Does the password match the hash?
-               if ($content['hash'] == $content['password']) {
+               if ($content['hash'] == getUserData('password')) {
                        // New hashed password found so let's generate a new one
                        $content['hash'] = generateHash($passwd);
 
@@ -324,8 +324,9 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                        $GLOBALS['bonus_payed'] = false;
 
                        // Probe for last online timemark
-                       $probe = time() -  $content['last_online'];
-                       if (!empty($content['last_login'])) $probe = time() - $content['last_login'];
+                       $probe = time() -  getUserData('last_online');
+                       if (getUserData('last_login') > 0) $probe = time() - getUserData('last_login');
+
                        if ((isExtensionInstalledAndNewer('bonus', '0.2.2')) && ($probe >= getConfig('login_timeout'))) {
                                // Add login bonus to user's account
                                $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}';
@@ -378,18 +379,18 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                        // Wrong password!
                        $errorCode = getCode('WRONG_PASS');
                }
-       } elseif (((isExtensionActive('nickname')) && (isNicknameUsed($content['userid'])) && (!empty($content['userid']))) || ($content['userid'] == $userid)) {
-               // Other account status?
-               if (fetchUserData($userid)) {
-                       // Create an error code from given status
-                       $errorCode = generateErrorCodeFromUserStatus(getUserData('status'));
-               } else {
-                       // id not found!
-                       $errorCode = getCode('WRONG_ID');
-               }
-       } elseif ($errorCode == '0') {
-               // id not found!
+       } elseif (getUserData('status') != 'CONFIRMED') {
+               // Create an error code from given status
+               $errorCode = generateErrorCodeFromUserStatus(getUserData('status'));
+
+               // Set userid in session
+               setSession('current_userid', getUserData('userid'));
+       } elseif (!isUserDataValid()) {
+               // User id not found!
                $errorCode = getCode('WRONG_ID');
+       } else {
+               // Unknown error
+               $errorCode = getCode('UNKNOWN_ERROR');
        }
 
        // Error code provided?