Location: PHPKode > scripts > AzDGOnlineUsers > azdgonlineusers/AzDGOnlineUsers.class.inc.php
<?php
//
///////////////////////////////////////////////////////
// AzDGOnline Users class (you may reset this comments)
// Questions: (AzDG Support) <hide@address.com>
///////////
class ou {
// Auth information - Please change
    var $host     = 'localhost';
    var $database = 'database';
    var $user     = 'user';
    var $password = 'password';
    var $table    = 'ou';
/////////////////    
    var $sec = 180;
/////////////////    
    function ou() {
        $this->db_connect();
        $this->update();                                                                               
    }
    function view($whats=NULL) {
        if ($whats == NULL) $whats="0";
        if ($this->UserNum == 1) 
        {
         switch ($whats)
                {
         case 1:    
                echo $this->TotalUserNum." User online in this site<br>";
                break;
         case 2:
                echo $this->TotalHits." hits in the site in last ".$this->sec." seconds <br>";   
                break;    
         default:    
                echo $this->TotalUserNum." User online in this site<br>";
                echo $this->TotalHits." hits in the site in last ".$this->sec." seconds <br>";   
                }
        } 
        else 
        {
         switch ($whats)
                {
         case 1:    
                echo $this->TotalUserNum." Users online in this site<br>";
                break;
         case 2:
                echo $this->TotalHits." hits in the site in last ".$this->sec." seconds <br>";   
                break;    
         default:    
                echo $this->TotalUserNum." Users online in this site<br>";
                echo $this->TotalHits." hits in the site in last ".$this->sec." seconds <br>";   
             }
        }
    }
    
    function db_connect() {
        mysql_connect($this->host, $this->user, $this->password)
            or die('Database Connect error');
             }
    function update() {
        global $REMOTE_ADDR;
		mysql_db_query($this->database,"INSERT INTO ".$this->table." VALUES (NOW(),INET_ATON('".$REMOTE_ADDR."'))") or die("Write Error<br>".mysql_error());       
        mysql_db_query($this->database, 
        "DELETE FROM ".$this->table." WHERE time < DATE_SUB(NOW(), INTERVAL $this->sec SECOND)")  or die("Delete Error<br>".mysql_error());
        
        $result = mysql_db_query($this->database,"SELECT count(DISTINCT ip) as total FROM ".$this->table) or die("Read Error<br>".mysql_error());
        $trows = mysql_fetch_array($result);
        $this->TotalUserNum = $trows[total]; 
        
        $result = mysql_db_query($this->database,"SELECT count(ip) as total FROM ".$this->table) or die("Read Error<br>".mysql_error());
        $trows = mysql_fetch_array($result);
        $this->TotalHits = $trows[total];
        } 
}
?>
Return current item: AzDGOnlineUsers