- // Check for old MD5 passwords
- if ((strlen($password) == 32) && (md5($_POST['password']) == $password))
- {
- // Just set the hash to the password from DB... :)
- $hash = $password;
- }
- else
- {
- // Encrypt hash for comparsion
- $hash = generateHash($_POST['password'], substr($password, 0, -40));
- }
-
- if ($hash == $password)
- {
- // New hashed password found so let's generate a new one
- $hash = generateHash($_POST['password']);
-
- // ... and update database
- $result_update = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_user_data SET password='%s' WHERE userid=%d AND status='CONFIRMED' LIMIT 1",
- array($hash, $UID), __FILE__, __LINE__);
-
- // No login bonus by default
- $BONUS = false;
-
- // Probe for last online timemark
- $probe = time() - $online;
- if (!empty($login)) $probe = time() - $login;
- if ((GET_EXT_VERSION("bonus") >= "0.2.2") && ($probe >= $CONFIG['login_timeout']))
- {
- // Add login bonus to user's account
- $ADD = ", login_bonus=login_bonus+'".$CONFIG['login_bonus']."'";
- $BONUS = true;
-
- // Subtract login bonus from userid's account or jackpot
- if ((GET_EXT_VERSION("bonus") >= "0.3.5") && ($CONFIG['bonus_mode'] != "ADD")) BONUS_POINTS_HANDLER('login_bonus');
- }
-
-
- // Secure lifetime from input form
- $l = bigintval($_POST['lifetime']);
- $life = "-1";
- if ($l > 0)
- {
- // Calculate lifetime of cookies
- $life = time() + $l;
-
- // Calculate new hash with the secret key and master salt together
- $hash = generatePassString($hash);
-
- // Update cookies
- $login = (@setcookie("userid" , $UID , $life, COOKIE_PATH)
- && @setcookie("u_hash" , $hash, $life, COOKIE_PATH)
- && @setcookie("lifetime", $l , $life, COOKIE_PATH));
+ // Is there an entry?
+ if (SQL_NUMROWS($result) == 1) {
+ // By default the hash is empty
+ $hash = "";
+
+ // Check for old MD5 passwords
+ if ((strlen($password) == 32) && (md5($_POST['password']) == $password)) {
+ // Just set the hash to the password from DB... :)
+ $hash = $password;
+ } else {
+ // Encrypt hash for comparsion
+ $hash = generateHash($_POST['password'], substr($password, 0, -40));
+ }