Does anyone know a script that displays how many people are viewing this site. So like "There are 67 people viewing this site"
++REP

Does anyone know a script that displays how many people are viewing this site. So like "There are 67 people viewing this site"
++REP
Get back imma let my gat go,
got a itchy finger... imma leave a fat hole.
- Giggs :: Ruthless Freestyle
I owe rep to - .:Jack120:. HabbDance
Make a folder called whosonline. In the folder make a file called online.php, insert this code into it.
Make another folder in the whoseonline folder and call it data. In that folder make a file called online.txt and put this in :PHP Code:<?
$ip = $REMOTE_ADDR;
$time = time();
$minutes = 15;
$found = 0;
$users = 0;
$user = "";
$tmpdata = $DOCUMENT_ROOT."/whosonline/data";
if (!is_file("$tmpdata/online.txt"))
{
$s = fopen("$tmpdata/online.txt","w");
fclose($s);
chmod("$tmpdata/online.txt",0666);
}
$f = fopen("$tmpdata/online.txt","r+");
flock($f,2);
while (!feof($f))
{
$user[] = chop(fgets($f,65536));
}
fseek($f,0,SEEK_SET);
ftruncate($f,0);
foreach ($user as $line)
{
list($savedip,$savedtime) = split("\|",$line);
if ($savedip == $ip) {$savedtime = $time;$found = 1;}
if ($time < $savedtime + ($minutes * 60))
{
fputs($f,"$savedip|$savedtime\n");
$users = $users + 1;
}
}
if ($found == 0)
{
fputs($f,"$ip|$time\n");
$users = $users + 1;
}
fclose ($f);
print "$users are online
";
?>
Now whichever page you want it to display on insert this:PHP Code:66.235.180.56|1116831431
NOTE: This isn't my script!PHP Code:<? include"http://www.yoursite.com/whosonline/online.php";?>
This script wouldn't work if you don't do any CHMODingCHMOD the online.txt file to 777
![]()
Kind Regards,
Guy__________________
Since 2007. Unbelievable Uptime. Web hosting, resellers, master resellers, linux VPS, windows VPS, shoutcasts, at the lowest prices on the net.
Tech-Hosts.co.uk.
Want to hide these adverts? Register an account for free!