You could always cheat and look at this one (made by Colby from Virst):
<?php
/*
Current / Most users online
Code copyright Virst, 2004 -
virst.net/forums/Made by Colby
*/
// This is the file that contains all the user data.
$userdata = 'userdata.txt';
// This is how many seconds until the script takes out the entry for that person if they have been unactive
$timeout = '300';
// This is your local time offset.
$local_offset = '-5';
$ip = $_SERVER['REMOTE_ADDR'];
// The if statement below is to make the time GMT.
$offset = date('Z');
if($offset>0){
$offset = substr($offset, 1);
$time = time() + $offset;
} else {
$time = time() - $offset;
}
if(!is_file($userdata)){
$handle = fopen($userdata, 'w');
fwrite($handle, "a:0:{}\na:2:{s:4:\"most\";i:0;s:4:\"time\";i:0;}");
fclose($handle);
}
$file = file($userdata);
$handle = fopen($userdata, 'w');
// Below is where everything is unserialized
$usersonline = unserialize($file['0']);
$mostusersonline = unserialize($file['1']);
// This will add/update the persons last visit.
$usersonline[$ip] = $time;
foreach($usersonline as $key => $val){
// Time2 is the amount of time between the users last visit and current time.
$time2 = $time - $val;
if($time2 >= $timeout){
unset($usersonline[$key]);
}
}
$usercount = count($usersonline);
if($usercount > $mostusersonline['most']){
$mostusersonline['most'] = $usercount;
$mostusersonline['time'] = $time;
}
$os2 = $local_offset * 3600;
if($local_offset>0){
$local_offset = substr($local_offset, 1);
$date = date("M d Y; h:i a", $mostusersonline['time'] - $os2);
} else {
$date = date("M d Y; h:i a", $mostusersonline['time'] + $os2);
}
$flatfile_data = serialize($usersonline)."\n".serialize($mostusersonline);
fwrite($handle, $flatfile_data);
echo '<hr size="1" color="#000000">Current users online: '.$usercount.'<br />
Most users ever online was '.$mostusersonline['most'].' on '.$date.'.';
fclose($handle);
?>
=P
I don't know if you coded it that way though.