]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/guest/what-login.php
Unnessarry addslashes() and SQL_ESCAPE() removed, some added, some bigintval() added
[mailer.git] / inc / modules / guest / what-login.php
index ad2c106e3a66db890f2a30f350e2cfa52a7a84c3..efaf745c31b68e4e2eec7f094356e73609993f2e 100644 (file)
@@ -39,7 +39,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Add description as navigation point
-ADD_DESCR("guest", basename(__FILE__));
+ADD_DESCR("guest", __FILE__);
 
 global $DATA, $FATAL;
 
@@ -52,7 +52,7 @@ if ((!empty($GLOBALS['userid'])) && (isSessionVariableSet('u_hash'))) {
        $uid = $GLOBALS['userid'];
 } elseif ((!empty($_POST['id'])) && (!empty($_POST['password'])) && (isset($_POST['ok']))) {
        // Set userid and crypt password when login data was submitted
-       $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".bigintval($_POST['id'])."") != $_POST['id']));
+       $probe_nickname = ((EXT_IS_ACTIVE("nickname")) && (("".($_POST['id'] + 0)."") != $_POST['id']));
        if ($probe_nickname === true) {
                // Nickname entered
                $uid = SQL_ESCAPE($_POST['id']);
@@ -88,7 +88,7 @@ if (IS_MEMBER()) {
        } // END - if
 
        // Check login data
-       $password = "";
+       $password = ""; $uid2 = ""; $dmy = "";
        if ($probe_nickname === true) {
                // Nickname entered
                $result = SQL_QUERY_ESC("SELECT userid, password, last_online".$LAST." FROM "._MYSQL_PREFIX."_user_data WHERE nickname='%s' AND status='CONFIRMED' LIMIT 1",
@@ -103,7 +103,10 @@ if (IS_MEMBER()) {
        }
 
        // Is there an entry?
-       if (SQL_NUMROWS($result) == 1) {
+       if ((SQL_NUMROWS($result) == 1) && ((($probe_nickname) && (!empty($uid2))) || ($dmy == $uid))) {
+               // Free result
+               SQL_FREERESULT($result);
+
                // By default the hash is empty
                $hash = "";
 
@@ -170,18 +173,18 @@ if (IS_MEMBER()) {
                                        // Procedure to checking for login data
                                        if (($BONUS) && (EXT_IS_ACTIVE("bonus"))) {
                                                // Bonus added (just displaying!)
-                                               $URL = URL."/modules.php?module=chk_login&mode=bonus";
+                                               $URL = URL."/modules.php?module=chk_login&mode=bonus";
                                        } else {
                                                // Bonus not added
-                                               $URL = URL."/modules.php?module=chk_login&mode=login";
+                                               $URL = URL."/modules.php?module=chk_login&mode=login";
                                        }
                                } else {
                                        // Cannot update counter!
-                                       $URL = URL."/modules.php?module=".$GLOBALS['module']."&what=login&login=".CODE_CNTR_FAILED;
+                                       $URL = URL."/modules.php?module=index&what=login&login=".CODE_CNTR_FAILED;
                                }
                        } else {
                                // Cookies not setable!
-                               $URL = URL."/modules.php?module=".$GLOBALS['module']."&what=login&login=".CODE_NO_COOKIES;
+                               $URL = URL."/modules.php?module=index&what=login&login=".CODE_NO_COOKIES;
                        }
                } else {
                        // Update failture counter
@@ -191,27 +194,27 @@ if (IS_MEMBER()) {
                        // Wrong password!
                        $ERROR = CODE_WRONG_PASS;
                }
-       } else {
+       } elseif ((($probe_nickname) && (!empty($uid2))) || ($dmy == $uid)) {
                // Other account status?
                $result = SQL_QUERY_ESC("SELECT status FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s LIMIT 1",
                 array($uid), __FILE__, __LINE__);
-               if (SQL_NUMROWS($result) == 1)
-               {
+
+               // Entry found?
+               if (SQL_NUMROWS($result) == 1) {
                        // Load status
                        list($status) = SQL_FETCHROW($result);
-                       switch ($status)
-                       {
-                       case "LOCKED":
-                               $ERROR = CODE_ID_LOCKED;
-                               break;
-
-                       case "UNCONFIRMED":
-                               $ERROR = CODE_ID_UNCONFIRMED;
-                               break;
-
-                       default:
-                               $ERROR = CODE_UNKNOWN_STATUS;
-                               break;
+                       switch ($status) {
+                               case "LOCKED":
+                                       $ERROR = CODE_ID_LOCKED;
+                                       break;
+
+                               case "UNCONFIRMED":
+                                       $ERROR = CODE_ID_UNCONFIRMED;
+                                       break;
+
+                               default:
+                                       $ERROR = CODE_UNKNOWN_STATUS;
+                                       break;
                        }
                } else {
                        // ID not found!
@@ -219,7 +222,10 @@ if (IS_MEMBER()) {
                }
 
                // Construct URL
-               $URL = URL."/modules.php?module=".$GLOBALS['module']."&what=login&login=".$ERROR;
+               $URL = URL."/modules.php?module=index&what=login&login=".$ERROR;
+       } else {
+               // ID not found!
+               $ERROR = CODE_WRONG_ID;
        }
 } elseif ((!empty($_POST['new_pass'])) && (isset($uid))) {
        // Compile email when found in address (only secure chars!)
@@ -233,11 +239,11 @@ if (IS_MEMBER()) {
        if ($probe_nickname) {
                // Nickname entered
                $result = SQL_QUERY_ESC("SELECT userid, status FROM "._MYSQL_PREFIX."_user_data WHERE nickname='%s' OR email='%s' LIMIT 1",
-                array(addslashes($uid), $_POST['email']), __FILE__, __LINE__);
+                       array($uid, $_POST['email']), __FILE__, __LINE__);
        } else {
                // Direct userid entered
                $result = SQL_QUERY_ESC("SELECT userid, status FROM "._MYSQL_PREFIX."_user_data WHERE userid=%s OR email='%s' LIMIT 1",
-                array($uid, $_POST['email']), __FILE__, __LINE__);
+                       array(bigintval($uid), $_POST['email']), __FILE__, __LINE__);
        }
 
        // Any entry found?
@@ -267,7 +273,7 @@ if (IS_MEMBER()) {
                        }
 
                        // Load URL
-                       LOAD_URL("modules.php?module=".$GLOBALS['module']."&what=login&login=".$MSG);
+                       LOAD_URL("modules.php?module=index&what=login&login=".$MSG);
                }
        } else {
                // ID or email is wrong