Login   Register  
PHP Classes
elePHPant
Icontem

File: count_users.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of bmpc  >  UsersOnline  >  count_users.php  >  Download  
File: count_users.php
Role: Example script
Content type: text/plain
Description: An example script that uses the class
Class: UsersOnline
This class calculates the number of users "online"
Author: By
Last change: Added example usage for the latest method, db_log.
Date: 12 years ago
Size: 782 bytes
 

Contents

Class file image Download
<?

//
//    bmpc@netcabo.pt
//
//    GPL'ed
//

require_once ( "users-online.php" );

//
// check if the user is behind an http proxy
//

if ( getenv'HTTP_X_FORWARDED_FOR' ) ) {
   
$IP_ADDR getenv'HTTP_X_FORWARDED_FOR' );
}
else if ( 
getenv'HTTP_CLIENT_IP' ) ) {
   
$IP_ADDR getenv'HTTP_CLIENT_IP' );
}
else {
   
$IP_ADDR getenv'REMOTE_ADDR' );
}

$o_user = new users_online $IP_ADDR );  // create the object and send user's IP

$o_user->main ();  // call the "main" method

?>

<b>Number of Users:</b> <?= $n_users $o_user->count (); ?>

<?

// log the result into the database

$o_user->db_log $n_users ); // feeding the method with the result from $o_user->count (above)

// can also be used as:

$o_user->db_log ();

?>