Changeset 725 for trunk/Modules/User/User.php
- Timestamp:
- Jan 7, 2014, 8:45:46 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r714 r725 120 120 $User = $DbResult->fetch_assoc(); 121 121 $this->Id = $User['ID']; 122 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $User['ID'], 'StayLogged' => $StayLogged)); 122 123 // Prepare cookies for permanent login 124 $StayLoggedSalt = $this->GetPasswordSalt(); 125 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array( 126 'User' => $User['ID'], 'StayLogged' => $StayLogged, 'StayLoggedHash' => $StayLoggedSalt)); 127 if($StayLogged) 128 { 129 setcookie('LoginUserId', $User['ID'], time()+365*24*60*60); 130 setcookie('LoginHash', sha1($User['ID'].$StayLoggedSalt), time()+365*24*60*60); 131 } else { 132 setcookie('LoginUserId', '', time() - 3600); 133 setcookie('LoginHash', '', time() - 3600); 134 } 135 123 136 $this->Database->query('UPDATE `UserTrace` SET '. 124 137 '`LastLogin` = NOW(), '. … … 216 229 'ScriptName' => $_SERVER['PHP_SELF'])); 217 230 218 // Check login 231 // Logged permanently? 232 if(array_key_exists('LoginHash', $_COOKIE)) 233 { 234 $DbResult = $this->Database->query('SELECT * FROM `UserOnline` WHERE `User`='.$_COOKIE['LoginUserId']. 235 ' AND `StayLogged`=1 AND SessionId!="'.$SID.'"'); 236 if($DbResult->num_rows > 0) 237 { 238 $DbRow = $DbResult->fetch_assoc(); 239 if(sha1($_COOKIE['LoginUserId'].$DbRow['StayLoggedHash']) == $_COOKIE['LoginHash']) 240 { 241 $this->Database->query('DELETE FROM `UserOnline` WHERE `SessionId`="'.$SID.'"'); 242 $this->Database->query('UPDATE `UserOnline` SET `SessionId`="'.$SID.'" WHERE `Id`='.$DbRow['Id']); 243 } 244 } 245 } 246 247 // Check login 219 248 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 220 249 $Row = $Query->fetch_assoc();
Note:
See TracChangeset
for help on using the changeset viewer.