Changeset 30 for user.php


Ignore:
Timestamp:
Dec 16, 2008, 8:15:34 AM (16 years ago)
Author:
george
Message:
  • Přidáno: Podpora pro určování v definicích krom tabulky také jméno databáze a jméno primárního identifikačního sloupce.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • user.php

    r28 r30  
    4141    $SID = session_id();
    4242    // Lookup user record
    43     $Query = $this->Database->select($this->TableUserOnline, '*', '`SessionId`="'.$SID.'"');
     43    $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"'));
    4444    if($Query->num_rows > 0)
    4545    {
    4646      // Refresh time of last access
    47       $this->Database->update($this->TableUserOnline, '`SessionId`="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    48     } else $this->Database->insert($this->TableUserOnline, array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress())));
     47      $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => '`SessionId`="'.$SID.'"'), array('ActivityTime' => 'NOW()'));
     48    } else $this->Database->insert(array('Table' => $this->TableUserOnline), array('SessionId' => $SID, 'User' => 0, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress())));
    4949    //echo($this->Database->LastQuery);
    5050
    5151    // Zkontroluj přihlášení
    52     $Query = $this->Database->select($this->TableUserOnline, '*', 'SessionId="'.$SID.'"');
     52    $Query = $this->Database->select(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'));
    5353    $Row = $Query->fetch_assoc();
    5454    if($Row['User'] != 0)
     
    6060    } else
    6161    {
    62       $Query = $this->Database->select($this->TableUser, '*', "`Id`=0");
     62      $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => "`Id`=0"));
    6363      $this->User = $Query->fetch_assoc();
    6464      $Result = USER_NOT_LOGGED;
     
    6666
    6767    // Odeber neaktivní uživatele
    68     $DbResult = $this->Database->select($this->TableUserOnline, 'User', '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)');
     68    $DbResult = $this->Database->select(array('Table' => $this->TableUserOnline, 'Columns' => 'User', 'Condition' => '`ActivityTime` < DATE_SUB(NOW(), INTERVAL '.USER_TIMEOUT.' SECOND)'));
    6969    while($DbRow = $DbResult->fetch_assoc())
    7070    {
    71       $this->Database->delete($this->TableUserOnline, '`User`='.$DbRow['User']);
     71      $this->Database->delete(array('Table' => $this->TableUserOnline, 'Condition' => '`User`='.$DbRow['User']));
    7272      //$this->System->Modules['Log']->Add('User', 'Logout');
    7373    }
     
    8787    {
    8888      // Je uživatel registrován?
    89       $Query = $this->Database->select($this->TableUser, '*', 'Name = "'.$Nick.'"');
     89      $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Name = "'.$Nick.'"'));
    9090      if($Query->num_rows > 0) $Result = NICK_USED;
    9191      else
    9292      {
    93         $Query = $this->Database->select($this->TableUser, '*', 'Email = "'.$Email.'"');
     93        $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'Email = "'.$Email.'"'));
    9494        if($Query->num_rows > 0) $Result = EMAIL_USED;
    9595        else
    9696        {
    97           $this->Database->insert($this->TableUser, array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
     97          $this->Database->insert(array('Table' => $this->TableUser), array('Name' => $Nick, 'FirstName' => $FirstName, 'SecondName' => $SecondName, 'Password' => $Password, 'Email' => $Email, 'RegistrationTime' => 'NOW()', 'Locked' => 1));
    9898          $UserId = $this->Database->insert_id;
    9999
     
    112112  function RegisterConfirm($Id, $Hash)
    113113  {
    114     $DbResult = $this->Database->select($this->TableUser, 'Id, Name, Password', 'Id = '.$Id);
     114    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id));
    115115    if($DbResult->num_rows > 0)
    116116    {
     
    118118      if($Hash == $Row['Password'])
    119119      {
    120         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Locked' => 0));
     120        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Locked' => 0));
    121121        $Output = USER_REGISTRATION_CONFIRMED;
    122122        //$this->System->Modules['Log']->NewRecord('User', 'RegisterConfirm', 'UserName='.$Row['Name']);
     
    130130    $SID = session_id();
    131131    // Je uživatel registrován?
    132     $Query = $this->Database->select($this->TableUser, '*', 'UserName="'.$Nick.'"');
     132    $Query = $this->Database->select(array('Table' => $this->TableUser, 'Condition' => 'UserName="'.$Nick.'"'));
    133133    if($Query->num_rows > 0)
    134134    {
     
    138138      else
    139139      {
    140         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('LastLoginTime' => 'NOW()'));
    141         $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => $Row['Id'], 'Id' => $Row['mId']));
     140        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('LastLoginTime' => 'NOW()'));
     141        $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => $Row['Id'], 'Id' => $Row['mId']));
    142142        // načtení stavu stromu
    143143        $Result = USER_LOGGED_IN;
     
    154154
    155155    $SID = session_id();
    156     $this->Database->update($this->TableUserOnline, 'SessionId="'.$SID.'"', array('User' => 0));
     156    $this->Database->update(array('Table' => $this->TableUserOnline, 'Condition' => 'SessionId="'.$SID.'"'), array('User' => 0));
    157157    //$this->System->Modules['Log']->NewRecord('User', 'Logout', $this->User['Name']);
    158158    $this->Check();
     
    164164    global $Config;
    165165
    166     $DbResult = $this->Database->select($this->TableUser, 'Name, Id, Email, Password', '`Name`="'.$Name.'" AND `Email`="'.$Email.'"');
     166    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Name, Id, Email, Password', 'Condition' => '`Name`="'.$Name.'" AND `Email`="'.$Email.'"'));
    167167    if($DbResult->num_rows > 0)
    168168    {
     
    182182  function PasswordRecoveryConfirm($Id, $Hash, $NewPassword)
    183183  {
    184     $DbResult = $this->Database->select($this->TableUser, 'Id, Name, Password', 'Id = '.$Id);
     184    $DbResult = $this->Database->select(array('Table' => $this->TableUser, 'Columns' => 'Id, Name, Password', 'Condition' => 'Id = '.$Id));
    185185    if($DbResult->num_rows > 0)
    186186    {
     
    189189      if(($NewPassword == $NewPassword2) and ($Hash == $Row['Password']))
    190190      {
    191         $this->Database->update($this->TableUser, 'Id='.$Row['Id'], array('Password' => $NewPassword, 'Locked' => 0));
     191        $this->Database->update(array('Table' => $this->TableUser, 'Condition' => 'Id='.$Row['Id']), array('Password' => $NewPassword, 'Locked' => 0));
    192192        $Output = USER_PASSWORD_RECOVERY_CONFIRMED;
    193193        //$this->System->Modules['Log']->NewRecord('User', 'PasswordRecoveryConfirm', 'UserName='.$Row['Name']);
Note: See TracChangeset for help on using the changeset viewer.