PDA

View Full Version : Useronline Tutorial



sunny_ag
08-04-2006, 03:13 PM
This tutorial will teach you how to make and how to set up a useronline. / Useronline is used for you and others to no how many other people are browsing

<font size="1"><font face="Verdana, Arial, Helvetica, sans-serif"><?
$remote = $_SERVER["REMOTE_ADDR"];
$file = "usersonline.txt";
$timeoutseconds = 60; //how long the users online before classed as offline, you can edit this if you want to
$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 "<b>Users Online:</b> $online";
}else{
echo "<b>Users Online:</b> $online";
}
?></font></font>

Now create a .txt document in Notepad call this usersonline.txt then upload these two your directory.

d773hf82jhf721hf