Have your own tutorial made for you, just fill out the form below!!








View request list!
The IBox is having technical difficulties
 


Online Users

Quite a long script for such a small result.

create a new file leave it blank, but save it as usersonline.txt

now make a new file, and add the following script:

<?
$remote = $_SERVER["REMOTE_ADDR"];
$file = "usersonline.txt";
$timeoutseconds = 60; //how long the user stays on, before classed offline which can be changed
$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 as usersonline.php

now, once you have uploaded both files, and chmoded usersonline.txt to 777. You should include the following script where you would like the number of users online to show up:

<?
include("usersonline.php");
?>

Example for this page:

Warning: fopen(usersonline.txt) [function.fopen]: failed to open stream: Permission denied in /home/stealth/public_html/php/usersonline.php on line 7

Warning: fwrite(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/usersonline.php on line 9

Warning: fclose(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/usersonline.php on line 10
Users Online: 0

STUCK ON CHMODDING? CLICK HERE



 
Latest Tutorial
Featured Site
[ Pimp-my-myspace]
Layout: 10/10
Content: 10/10
Stealth Statistics
Users Online
Staff
1
Photoshop Tutorials
61
PHP Tutorials
9
Affiliates
35
[ More Statistics ]