Close that document.
Open up notepad again and add the following script:
Code:
<?
$remote = $_SERVER["REMOTE_ADDR"];
$file = "usersonline.txt";
$timeoutseconds = 60; //how long the user stays on, before classed offline
$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 "Users Online: $online";
}else{
echo "Users Online: $online";
}
?>
Save this one as usersonline.php (it's not the same as the above one. both have different file extensions, so don't confuse one for the other, k.) Be sure you choose "All Files" option from the drop down box when saving so you can save it as a php file and not a text file! Also, make sure you save it where you saved the first one so you can upload it.
Now you'll need to upload both documents in the same directory you have your website pages on that you'd like to display this handy script on. Once you have uploaded both files, chmod usersonline.txt to 777.
Now just copy the following piece of code into your website page where you'd like the number of users online to show up at:
Code:
<?
include("usersonline.php");
?>



.com .info
We're the affordable, reliable place to host your site. And unlike the competition, there's no set up fee and no annual commitment.
Our highly trained, courteous support staff is waiting to help. We'll resolve any issue to your complete satisfaction.