TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 10-25-2008, 05:17 AM   #1 (permalink)
Super Moderator
Inquisitive 
 
codefreek's Avatar
 
Join Date: Sep 2007
Location: Near you.
Posts: 791
Thanks: 241
codefreek is on a distinguished road
Help how do you do a automatic status print on website like this

Hello ;)
how do you do a automatic status print on website like this,

70 Users visited site in the past 24 hours
Users Online 1 || Guest(s) online.32 || Total Online 33
website.com has 10816 members... and growing!



codefreek is offline  
Reply With Quote
Old 10-25-2008, 02:49 PM   #2 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default

Users online:
PHP Code:
        public function get_users_online() {
            
            
$sql "    SELECT
                            `"
.$this->db->col['user_id']."`,
                            `"
.$this->db->col['user_name']."`,
                            `"
.$this->db->col['user_access']."`
                        FROM
                            `"
.$this->db->table['users']."`
                        WHERE
                            `"
.$this->db->col['user_session']."` != ''";
                            
            
$query $this->db->query($sql) or die(mysql_error());
            
            if(
mysql_num_rows($query)) {
                
                
$i 0;
                
                while(
$row $this->db->fetch($query)) {
                    
                    
$this->users[$i]['user_id'] = $row['user_id'];
                    
$this->users[$i]['user_name'] = $row['user_name'];
                    
$this->users[$i]['user_access'] = $row['user_access'];
                    
                    
$i++;
                    
                }
                
                return 
$this->users;
                
            }
            
            return 
false;
            
        } 
Total members:
PHP Code:
        public function get_users_registered() {
            
            
$sql sprintf("    SELECT
                                    *
                                FROM
                                    `%s`"
,
                                    
                                
$this->db->table['users']);
                                
            
$query $this->db->query($sql);
            
            if(
mysql_num_rows($query)) {
                
                
$users = array();
                
$i 0;
                
                while(
$row $this->db->fetch($query)) {
                    
                    
$users[$i]['user_id'] = $row['user_id'];
                    
$users[$i]['user_name'] = $row['user_name'];
                    
$users[$i]['user_last_visit'] = $row['user_last_visit'];
                    
$users[$i]['user_email'] = $row['user_email'];
                    
$users[$i]['user_age'] = $row['user_age'];
                    
$users[$i]['user_country'] = $row['user_country'];
                    
$users[$i]['user_access'] = $row['user_access'];
                    
$users[$i]['user_session'] = $row['user_session'];
                    
                    
$i++;
                    
                }
                
                return 
$users;
                
            }
            
            return 
false;
            
        } 
Edit: This is ofcourse using sessions.. but you should be able to "translate" this to however you would want it if you're not using sessions

I haven't a function for user visitors.. and guests I'm not sure either..
__________________
Tanax is offline  
Reply With Quote
The Following User Says Thank You to Tanax For This Useful Post:
codefreek (10-26-2008)
Old 10-25-2008, 04:43 PM   #3 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

It's just a case of saving the data into a table, with a corresponding timestamp. You can then easily select from there, and also select where timestamp is over 24 hours ago, 5 minutes ago, etcetera.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
The Following User Says Thank You to Wildhoney For This Useful Post:
codefreek (10-26-2008)
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:37 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design