Click to See Complete Forum and Search --> : Online Users


marshy28
04-11-2003, 12:56 PM
Online Users
Message A few weeks ago on my website I had the number of online users showing up and everything worked fine but upon returning from hoilday I find that it has stopped working but i dont know why because I didnt do nothing.

I will post the code and .php file can anybody help with this

code line within my index page:
<?php include"/files/home1/douza/barrys/online/online.php";?>

.php (online.php):
<?


$ip = $REMOTE_ADDR;
$time = time();
$minutes = 15;
$found = 0;
$users = 0;
$user = "";

$tmpdata = $_SERVER['DOCUMENT_ROOT']."/files/home1/douza/barrys/online/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 "<strong><font face=Comic Sans Ms color=red>Online Visitors:&nbsp;$users</font></strong>";
?>



--
Best Regards,

Phil Marsh
email@douza.co.uk

Klyve1
04-12-2003, 10:07 AM
As a first pass (without looking at the code!) is the .txt file either unwriteable/unreadable/inaccessible? Or failing that does the directory still have write access?

marshy28
04-13-2003, 12:18 PM
The file is accessible and its chmod to 666

So I cant unserstand why it wont work?

Marshy

Klyve1
04-13-2003, 05:40 PM
Have you tried writing and reading from it by other means?

Another possibility is that it is too large and appending is blocked - just a thought

marshy28
04-14-2003, 01:58 PM
I think they must have updated their php

is there old code within my files or somthing can anybody see anything that needs changing

Marshy