Ignore:
Timestamp:
Apr 13, 2010, 7:30:00 AM (15 years ago)
Author:
george
Message:
  • Upraveno: WowLua.exe lze použít pro enGB i pro enUS. Zrušeno rozlišení.
  • Upraveno: V třídě User volána databáze objektově přes mysqli.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/user.php

    r447 r454  
    1515  var $Redirecting;
    1616  var $Language;
     17  var $System;
    1718 
    18   function __construct()
     19  function __construct($System)
    1920  {
     21    $this->System = &$System;
    2022    if(isset($_SESSION)) $this->Restore();   
    2123      else $this->SetAnonymous();
     
    2931  function Login($Name, $Password)
    3032  {
    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)
    3535    {
    36       $User = mysql_fetch_assoc($DbResult);
     36      $User = $DbResult->fetch_assoc();
    3737      $this->Id = $User['ID'];     
    3838      $this->Load();
     
    4444  function Logout()
    4545  {
    46     global $Database;
    47 
    4846    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);
    5048    $this->SetAnonymous();
    5149  }
     
    5351  function Load()
    5452  {
    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();
    5955    // Security: Password and Salt hash should not be loaded to variables
    6056    $this->Id = $User['ID'];
     
    9894  function Licence($Licence)
    9995  {
    100     global $Database;
    101  
    10296    if(!isset($_SERVER['REMOTE_ADDR'])) return(true); // Execution from command line
    10397    else return($this->Role >= $Licence);   
     
    116110  function UpdateState()
    117111  {
    118     global $Database;
    119    
    120112    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);
    122114  }
    123115}
Note: See TracChangeset for help on using the changeset viewer.