View Full Version : How to know the # of users online
ssskaya
05-26-2003, 06:41 AM
Can someone please reply with a script that allows to know the # of the users online.
But I do not want others to view this information.
I would appreciate if this script tells me the #s like: most users ever online at the same time,... etc.
Thanks!
sleepingdanny
05-26-2003, 09:52 AM
I use a script that use timestamp to show how many users are currently online in the site... (It doesn't use Mysql, it uses a file+code).
Here is the code:
<?
$remote=$REMOTE_ADDR;
$file="online_log.php";
$timeoutseconds=300;
$timestamp=time();
$timeout=($timestamp-$timeoutseconds);
$fp=fopen("$file","a+");
$write=$remote."||".$timestamp."\n";
fwrite($fp,$write);
fclose($fp);
$online_array=array();
$file_array=file($file);
foreach($file_array as $newdata){
list($ip,$time)=explode("||",$newdata);
if($time>=$timeout){
array_push($online_array,$ip);
}
}
$online_array=array_unique($online_array);
$online=count($online_array);
if($online=="1"){
echo " "; // if only you online
}
else{
echo " "; // if more users online
}
?>
Users Online: <b><?=$online; ?></b><br>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.