Changeset 454 for trunk/includes/user.php
- Timestamp:
- Apr 13, 2010, 7:30:00 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/user.php
r447 r454 15 15 var $Redirecting; 16 16 var $Language; 17 var $System; 17 18 18 function __construct( )19 function __construct($System) 19 20 { 21 $this->System = &$System; 20 22 if(isset($_SESSION)) $this->Restore(); 21 23 else $this->SetAnonymous(); … … 29 31 function Login($Name, $Password) 30 32 { 31 global $Database; 32 33 $DbResult = $Database->SQLCommand('SELECT `ID` FROM `User` WHERE LOWER(`Name`) = LOWER("'.$Name.'") AND `Pass` = '.$this->CryptPasswordSQL('"'.$Password.'"', '`Salt`')); 34 if(mysql_num_rows($DbResult) > 0) 33 $DbResult = $this->System->Database->query('SELECT `ID` FROM `User` WHERE LOWER(`Name`) = LOWER("'.$Name.'") AND `Pass` = '.$this->CryptPasswordSQL('"'.$Password.'"', '`Salt`')); 34 if($DbResult->num_rows > 0) 35 35 { 36 $User = mysql_fetch_assoc($DbResult);36 $User = $DbResult->fetch_assoc(); 37 37 $this->Id = $User['ID']; 38 38 $this->Load(); … … 44 44 function Logout() 45 45 { 46 global $Database;47 48 46 if($this->Role != LICENCE_ANONYMOUS) 49 $ Database->SQLCommand('UPDATE `User` SET `LastLogout` = NOW() WHERE `ID` = '.$this->Id);47 $this->System->Database->query('UPDATE `User` SET `LastLogout` = NOW() WHERE `ID` = '.$this->Id); 50 48 $this->SetAnonymous(); 51 49 } … … 53 51 function Load() 54 52 { 55 global $Database; 56 57 $DbResult = $Database->SQLCommand('SELECT * FROM `User` WHERE `ID` = '.$this->Id); 58 $User = mysql_fetch_assoc($DbResult); 53 $DbResult = $this->System->Database->query('SELECT * FROM `User` WHERE `ID` = '.$this->Id); 54 $User = $DbResult->fetch_assoc(); 59 55 // Security: Password and Salt hash should not be loaded to variables 60 56 $this->Id = $User['ID']; … … 98 94 function Licence($Licence) 99 95 { 100 global $Database;101 102 96 if(!isset($_SERVER['REMOTE_ADDR'])) return(true); // Execution from command line 103 97 else return($this->Role >= $Licence); … … 116 110 function UpdateState() 117 111 { 118 global $Database;119 120 112 if(array_key_exists('REMOTE_ADDR', $_SERVER)) 121 $ Database->SQLCommand('UPDATE `User` SET `LastIP` = "'.$_SERVER['REMOTE_ADDR'].'", `LastLogin` = NOW() WHERE `ID` = '.$this->Id);113 $this->System->Database->query('UPDATE `User` SET `LastIP` = "'.$_SERVER['REMOTE_ADDR'].'", `LastLogin` = NOW() WHERE `ID` = '.$this->Id); 122 114 } 123 115 }
Note:
See TracChangeset
for help on using the changeset viewer.