Changeset 619 for trunk/Modules/User/User.php
- Timestamp:
- Dec 26, 2013, 7:37:44 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/User/User.php
r605 r619 42 42 function GetSalt() 43 43 { 44 mt_srand(microtime(true) *100000 + memory_get_usage(true));44 mt_srand(microtime(true) * 100000 + memory_get_usage(true)); 45 45 return sha1(uniqid(mt_rand(), true)); 46 46 } … … 53 53 var $Roles = array(); 54 54 var $User = array(); 55 var $OnlineStateTimeout = 600; // in seconds55 var $OnlineStateTimeout; 56 56 var $PermissionCache = array(); 57 57 var $PermissionGroupCache = array(); … … 63 63 { 64 64 parent::__construct($System); 65 $this->OnlineStateTimeout = 600; // in seconds 65 66 $this->PasswordHash = new PasswordHash(); 66 67 } … … 81 82 82 83 // Check login 83 $Query = $this->Database->select('UserOnline', '*', ' SessionId="'.$SID.'"');84 $Query = $this->Database->select('UserOnline', '*', '`SessionId`="'.$SID.'"'); 84 85 $Row = $Query->fetch_assoc(); 85 86 if($Row['User'] != '') 86 87 { 87 $Query = $this->Database->query('SELECT User.*, UserCustomerRel.Customer AS Member FROM User LEFT JOIN UserCustomerRel ON UserCustomerRel.User=User.Id WHERE User.Id='.$Row['User']); 88 $Query = $this->Database->query('SELECT `User`.*, `UserCustomerRel`.`Customer` AS `Member` FROM `User` '. 89 ' LEFT JOIN `UserCustomerRel` ON `UserCustomerRel`.`User`=`User`.`Id` WHERE `User`.`Id`='.$Row['User']); 88 90 $this->User = $Query->fetch_assoc(); 89 91 $Result = USER_LOGGED; … … 96 98 97 99 // Remove nonactive users 98 $DbResult = $this->Database->select('UserOnline', ' Id, User', 'ActivityTime < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)');100 $DbResult = $this->Database->select('UserOnline', '`Id`, `User`', '(`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.$this->OnlineStateTimeout.' SECOND)) AND (`StayLogged` = 0)'); 99 101 while($DbRow = $DbResult->fetch_array()) 100 102 { … … 181 183 } 182 184 183 function Login($Login, $Password )185 function Login($Login, $Password, $StayLogged = false) 184 186 { 185 187 $SID = session_id(); … … 194 196 { 195 197 $this->Database->update('User', 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()', 'LastIpAddress' => GetRemoteAddress())); 196 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'] ));198 $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'StayLogged' => $StayLogged)); 197 199 198 200 $Result = USER_LOGGED_IN;
Note:
See TracChangeset
for help on using the changeset viewer.