View file chat/files/online.php

File size: 1.19Kb
<?

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="data/online.dat";
$lines0=file("$bans0");
$itogo0=count($lines0);

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


$den =date("d",$time);
$aron=@file("data/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("data/online.dat","a+");
ftruncate($fp,0);
fclose($fp);
foreach($newar as $key => $val) {
$fp=@fopen("data/online.dat","a");
flock($fp,LOCK_EX);
fputs($fp,$val);
flock($fp,LOCK_UN);
fclose($fp);}
$online=round($ton+1);

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


?>