I'm looking for a script which will show how many people are currently visting my site like the one on this site: http://www.pyropixel.com/tut040.php
thanx
thanx
<?php
$userip = $_SERVER['REMOTE_ADDR'];
$time = time();
$usersonline = 0;
$alreadyonline = 0;
$onlinetxt = fopen("./online.txt","r+");
flock($onlinetxt,2);
while (!feof($onlinetxt)) {
$user[] = chop(fgets($onlinetxt,65536));
}
fseek($onlinetxt,0,SEEK_SET);
ftruncate($onlinetxt,0);
foreach ($user as $line) {
@list($savedip,$savedtime) = split("|",$line);
if ($savedip == $userip) {
$savedtime = $time;
$alreadyonline = 1;
}
if ($time < $savedtime + ($session_length)) {
fputs($onlinetxt,"$savedip|$savedtime\n");
$usersonline = $usersonline + 1;
}
}
if (!$alreadyonline) {
fputs($onlinetxt,"$userip|$time\n");
$usersonline = $usersonline + 1;
}
fclose ($onlinetxt);
if($usersonline==1){
echo "<center> 1 user online </center>";
} else {
echo "<center> "$usersonline." users online</center>";
}
?>
that's not my script i just saw it on google, make sure you chmod 755 onlinecount.cgi and it should work and it needs to be stored on your cgi-bin folder not just on the root.tbl said:Jim I tried yours: http://tbldesign.net/online.php and I got Parse error: parse error, unexpected T_VARIABLE, expecting ',' or ';' in /home/tbltk/public_html/online.php on line 39
weblord I tried yours: http://tbldesign.net/onlinecount.cgi and I got a 500 error.
So not in a php pageweblord said:yes, make sure it's .shtml or .shtm and place this code:
Code:<!--#include virtual="/server_path_to/onlinecount.cgi" -->
HTH


