View file templates/counter_forum.php

File size: 1.34Kb
<?
clearstatcache();
$agent=htmlspecialchars(stripslashes($_SERVER['REMOTE_ADDR']));
$ugent=htmlspecialchars(stripslashes($_SERVER['HTTP_USER_AGENT']));
$agent=$agent.'|'.$ugent;
$time=time();
$oftime=$time-600;
$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);
#####Защита от ****** ****** ***** ** ***!!!!#####
#####Если превышает максимальное, удаляем старую запись(Made by hintoz)#####
$maxonline="100"; #сколько онлайн записей хранить
$anti_hack=@file("../data/online.dat");
$i = count($anti_hack);
$i = "$i-1";
if ($i>=$maxonline) {
$fp=@fopen("../data/online.dat","w");
flock ($fp,LOCK_EX);
unset($anti_hack[0]);
fputs($fp, implode("",$anti_hack));
flock ($fp,LOCK_UN);
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);
?>