Changeset 49 for trunk/www/user.php


Ignore:
Timestamp:
Jun 20, 2009, 4:22:51 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Sledování uživatelů online.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/user.php

    r46 r49  
    4545    $SID = session_id();
    4646
     47    // Lookup user record
     48    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
     49    if($Query->num_rows == 0)
     50      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
     51    //echo($this->Database->LastQuery);
     52
    4753    // Check login
    4854    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
     
    7076    // Lookup user record
    7177    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    72     if($Query->num_rows > 0)
    73     {
    74       // Refresh time of last access
    75       $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    76     } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
    77     //echo($this->Database->LastQuery);
    78 
    79     // Check login
    80     $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    81     $Row = $Query->fetch_assoc();
    82     if($Row['User'] != $this->AnonymousUserId)
    83     {
    84       $Query = $this->Database->select('User', '*', 'Id='.$Row['User']);
    85       $this->User = $Query->fetch_assoc();
    86       $Result = USER_LOGGED;
    87     } else
    88     {
    89       $Query = $this->Database->select('User', '*', 'Id='.$this->AnonymousUserId);
    90       $this->User = $Query->fetch_assoc();
    91       $Result = USER_NOT_LOGGED;
    92     }
     78    if($Query->num_rows == 0)
     79      $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'LoginTime' => 'NOW()', 'ActivityTime' => 'NOW()', 'IpAddress' => GetRemoteAddress(), 'HostName' => gethostbyaddr(GetRemoteAddress()), 'ScriptName' => $_SERVER['PHP_SELF']));
     80
     81    // Refresh time of last access
     82    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('ActivityTime' => 'NOW()'));
    9383
    9484    //$this->LoadPermission($this->User['Role']);
Note: See TracChangeset for help on using the changeset viewer.