Code cleanups, ext-booking continued:
[mailer.git] / inc / libs / user_functions.php
index 2fcebafc1d8d43e3f2c1a730badca505dff188ef..7c23a241634c11b1cb00b19d74a796893f0c2913 100644 (file)
@@ -329,18 +329,25 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                        // No login bonus by default
                        $GLOBALS['bonus_payed'] = false;
 
-                       // Probe for last online timemark
-                       $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?}';
-                               $GLOBALS['bonus_payed'] = true;
-
-                               // Subtract login bonus from userid's account or jackpot
-                               if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
-                                       handleBonusPoints('login_bonus');
+                       // Is bonus up-to-date?
+                       if (isExtensionInstalledAndNewer('bonus', '0.2.2')) {
+                               // Probe for last online timemark
+                               $probe = time() -  getUserData('last_online');
+                               if (getUserData('last_login') > 0) {
+                                       // Use timestamp from last login
+                                       $probe = time() - getUserData('last_login');
+                               } // END - if
+
+                               // Is the timeout reached?
+                               if ($probe >= getConfig('login_timeout')) {
+                                       // Add login bonus to user's account
+                                       $add = ', `login_bonus`=`login_bonus`+{?login_bonus?}';
+                                       $GLOBALS['bonus_payed'] = true;
+
+                                       // Subtract login bonus from userid's account or jackpot
+                                       if ((isExtensionInstalledAndNewer('bonus', '0.3.5')) && (getBonusMode() != 'ADD')) {
+                                               handleBonusPoints('login_bonus');
+                                       } // END - if
                                } // END - if
                        } // END - if
 
@@ -379,7 +386,7 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                                $errorCode = getCode('COOKIES_DISABLED');
                        }
                } elseif (isExtensionInstalledAndNewer('sql_patches', '0.6.1')) {
-                       // Update failture counter
+                       // Update failure counter
                        SQL_QUERY_ESC("UPDATE `{?_MYSQL_PREFIX?}_user_data` SET `login_failures`=`login_failures`+1,`last_failure`=NOW() WHERE `userid`=%s LIMIT 1",
                                array($userid), __FUNCTION__, __LINE__);
 
@@ -406,7 +413,9 @@ function doUserLogin ($userid, $passwd, $successUrl = '', $errorUrl = 'modules.p
                $url = $errorUrl . $errorCode;
 
                // Extension set? Then add it as well.
-               if (!empty($ext)) $url .= '&ext=' . $ext;
+               if (!empty($ext)) {
+                       $url .= '&ext=' . $ext;
+               } // END - if
        } // END - if
 
        // Return URL