View file chat/files/floodclick.php

File size: 765B
<?php 

$floodstime=1800;

function CheckIP () 
{global $floodstime;
	
$flag= false;	
$fs= filesize('data/floodclick.dat');
$f= fopen('data/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('data/floodclick.dat', 'a+');	
flock($f, LOCK_EX);
ftruncate($f, 0);
@fwrite($f, serialize($arr));
fflush($f);
flock($f, LOCK_UN);
fclose($f);
return $flag;
}
?>