Просмотр файла online/online/online.php

Размер файла: 1.02Kb
<?
/********* PHP OН-ЛАЙН  ************ 
Copyright 2005, Рыжий. 
E-mail: [email protected]
Wapsite: http://wap.xpcom.ru
**********************************************/ 
$ip = $REMOTE_ADDR;
$time = time();
$minutes = 15;
$found = 0;
$users = 0;
$user  = "";

$tmpdata = $DOCUMENT_ROOT."/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 "&#x41E;&#x43D;-&#x43B;&#x430;&#x439;&#x43D;:&nbsp;$users
";
?>