icebox12
20-12-2005, 10:30 AM
I need the code for it, I have one but it's rather long. Can anyone remember the shorter code?
$remote = $_SERVER["REMOTE_ADDR"];
$file = "log.txt"
;
$timeoutsecs = 30;
$timestamp = time();
$timeout = ($timestamp-$timeoutsecs);
$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 "People Online: $online";
} else {
echo "People Online: $online";
}
?>
--
Regards
$remote = $_SERVER["REMOTE_ADDR"];
$file = "log.txt"
;
$timeoutsecs = 30;
$timestamp = time();
$timeout = ($timestamp-$timeoutsecs);
$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 "People Online: $online";
} else {
echo "People Online: $online";
}
?>
--
Regards