<?php

$floodstime=1800;

function CheckIP ()
{global $floodstime;
$flag= false;
$fs= filesize('MySql/base123/floodclick.dat');
$f= fopen('MySql/base123/floodclick.dat', 'r');
flock($f, LOCK_SH);
$arr= @unserialize(fread($f, $fs));
flock($f, LOCK_UN);
fclose($f);
$IP= $_SERVER['REMOTE_ADDR'];
$IP=htmlspecialchars(stripslashes($IP));
$t= time();
if (isset($arr)) {
foreach ($arr as $k=>$v)
if ($v<$t) unset($arr[$k]);
} else $arr= array ();
if (!isset($arr[$IP])) {
$arr[$IP]= $t + $floodstime;
$flag= false;
} else {
$arr[$IP]= $t + $floodstime;
$flag= true;
}
$f= fopen('MySql/base123/floodclick.dat', 'a+');
flock($f, LOCK_EX);
ftruncate($f, 0);
@fwrite($f, serialize($arr));
fflush($f);
flock($f, LOCK_UN);
fclose($f);
return $flag;
}
?>
