<?

if(getenv("HTTP_X_FORWARDED_FOR")){ $agent = getenv("HTTP_X_FORWARDED_FOR"); }else{
if(getenv("REMOTE_ADDR")) $agent = getenv("REMOTE_ADDR");}
$ugent=htmlspecialchars(stripslashes(getenv('HTTP_USER_AGENT')));
$agent=$agent.'|'.$ugent;
$time=time();
$oftime=$time-600;

$bans0="MySql/base123/online.dat";
$lines0=file("$bans0");
$itogo0=count($lines0);

if($itogo0>="100"){
$fp=@fopen("MySql/base123/online.dat","w");
flock($fp,LOCK_EX);
fputs($fp,"$time#$agent#$log#");
flock($fp,LOCK_UN);
fclose($fp);
}


$den =date("d",$time);
$aron=@file("MySql/base123/online.dat");
$ton=0;
foreach($aron as $key => $val) {
$artext=@explode("#",$val);
if($artext[0]>$oftime & $agent!=$artext[1] & $artext[1]!=""){
$newar[$ton]=$val;
$ton=round($ton+1);}
if($agent==$artext[1] & $artext[0]>$oftime){$metod="xit";}}
$newar[$ton]=$time."#".$agent."#".$log."#\r\n";
$fp=@fopen("MySql/base123/online.dat","a+");
ftruncate($fp,0);
fclose($fp);
foreach($newar as $key => $val) {
$fp=@fopen("MySql/base123/online.dat","a");
flock($fp,LOCK_EX);
fputs($fp,$val);
flock($fp,LOCK_UN);
fclose($fp);}
$online=round($ton+1);

$str = @implode("",@file("MySql/base123/online.dat"));
$substr_count = substr_count($str,"##");
$bans="MySql/base123/online.dat";
$lines=file("$bans");
$itogo=count($lines);


?>
