Changeset 633 for trunk/Modules/User/User.php
- Timestamp:
- Jan 5, 2014, 11:32:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r619 r633 81 81 'ScriptName' => $_SERVER['PHP_SELF'])); 82 82 83 // Logged permanently? 84 if(array_key_exists('LoginHash', $_COOKIE)) 85 { 86 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 87 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 88 if($DbResult->num_rows > 0) 89 { 90 $DbRow = $DbResult->fetch_assoc(); 91 if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 92 { 93 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); 94 $this->Database->query('UPDATE `UserOnline` SET `SessionId`="'.$SID.'" WHERE `Id`='.$DbRow['Id']); 95 } 96 } 97 } 98 83 99 // Check login 84 100 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); … … 195 211 else 196 212 { 197 $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 'LastIpAddress' => GetRemoteAddress())); 198 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'StayLogged' => $StayLogged)); 213 $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 214 'LastIpAddress' => GetRemoteAddress())); 215 $Hash = new PasswordHash(); 216 $StayLoggedSalt = $Hash->GetSalt(); 217 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array( 218 'User' => $Row['Id'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt)); 219 if($StayLogged) 220 { 221 setcookie('LoginUserId', $Row['Id'], time()+365*24*60*60); 222 setcookie('LoginHash', sha1($Row['Id'].$StayLoggedSalt), time()+365*24*60*60); 223 } else { 224 setcookie('LoginUserId', '', time() - 3600); 225 setcookie('LoginHash', '', time() - 3600); 226 } 199 227 200 228 $Result = USER_LOGGED_IN;
Note:
See TracChangeset
for help on using the changeset viewer.