PDA

View Full Version : How many are online...



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

pechie100
20-12-2005, 10:32 AM
online for what

Baving
20-12-2005, 10:35 AM
I think he means how many people are actually viewing the webpage at any one time.

icebox12
20-12-2005, 10:40 AM
I think he means how many people are actually viewing the webpage at any one time.

Exactly :eusa_ange

Steven.
20-12-2005, 10:40 AM
EDIT: Hangon ;o Im mistaken for how many habbos are in the hotel :p

Meh, sorry, i thought i knew it but i don't :'(

timROGERS
20-12-2005, 10:43 AM
I can do the how many habbos one, I worked that out ages ago :P

icebox12
20-12-2005, 10:52 AM
I can do the how many habbos one, I worked that out ages ago :P

Agreed, I know that but simple need the code to display how many habbo's are visiting a certain website.

Steven.
20-12-2005, 10:53 AM
Agreed, I know that but simple need the code to display how many habbo's are visiting a certain website.

Check the source code off Habbox's? :p

Dan Williamson
20-12-2005, 02:57 PM
Check the source code off Habbox's? :p

PHP Isn't viewable in the source code.

Matt, i'll write one up and then post it too you on MSN.

- Dan

Want to hide these adverts? Register an account for free!