hi there, i use this script to show how many visitors are on my site, unfortunatly it logs the same ip everytime the page is refreshed, so i need to make it so A) it only logs the same ip once, and 😎 erases the old ips, i use this script and a flat file db, i would idealy like to keep it flat file
<?php
$message = "You Are 1 Of $online Visitors";
$alonemess = "You Are Alone.";
$file = "online.dat";
$timeoutseconds = 30;
$timestamp = time();
$timeout = ($timestamp-$timeoutseconds);
$fp = fopen("$file", "a+");
$write = $REMOTE_ADDR."||".$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 "$alonemess";
}else{
echo "$message";
}
?>
Thanks
Chris