<?php
##################### Класс борьбы с SQL атаками ################
include_once("inclydings/sql.php");
$stop_injection = new InitVars();
$stop_injection->checkVars();
#########################################################
$floodstime=5;
function CheckIP ()
{global $floodstime;
$flag= false;
$fs= filesize('L2dbnam/esql2db/flood.dat');
$f= fopen('L2dbnam/esql2db/flood.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('L2dbnam/esql2db/flood.dat', 'a+');
flock($f, LOCK_EX);
ftruncate($f, 0);
@fwrite($f, serialize($arr));
fflush($f);
flock($f, LOCK_UN);
fclose($f);
return $flag;
}
?>
