废话不多说,上代码
<?php<BR><STRONG>//查询禁止IP<BR></STRONG>$ip =$_SERVER['REMOTE_ADDR'];<BR>$fileht=".htaccess2";<BR>if(!file_exists($fileht))<BR> file_put_contents($fileht,"");<BR>$filehtarr=@file($fileht);<BR>if(in_array($ip."\r\n",$filehtarr))<BR> die("Warning:"."<br>"."Your IP address are forbided by some reason, IF you have any question Pls emill to [email protected]!");<BR><STRONG>//加入禁止IP<BR></STRONG>$time=time();<BR>$fileforbid="log/forbidchk.dat";<BR>if(file_exists($fileforbid)) { <BR> if($time-filemtime($fileforbid)>60)<BR> unlink($fileforbid);<BR> else {<BR> $fileforbidarr=@file($fileforbid);<BR> if($ip==substr($fileforbidarr[0],0,strlen($ip))) {<BR> if($time-substr($fileforbidarr[1],0,strlen($time))>600)<BR> unlink($fileforbid);<BR> elseif($fileforbidarr[2]>600) {<BR> file_put_contents($fileht,$ip."\r\n",FILE_APPEND);<BR> unlink($fileforbid);<BR> } else { <BR> $fileforbidarr[2]++;<BR> file_put_contents($fileforbid,$fileforbidarr);<BR> }<BR> }<BR> }<BR>}<BR><STRONG>//防刷新<BR></STRONG>$str="";<BR>$file="log/ipdate.dat";<BR>if(!file_exists("log")&&!is_dir("log"))<BR> mkdir("log",0777);<BR>if(!file_exists($file))<BR> file_put_contents($file,"");<BR>$allowTime = 120;//防刷新时间<BR>$allowNum=10;//防刷新次数<BR>$uri=$_SERVER['REQUEST_URI'];<BR>$checkip=md5($ip);<BR>$checkuri=md5($uri);<BR>$yesno=true;<BR>$ipdate=@file($file);<BR>foreach($ipdate as $k=>$v) { <BR> $iptem=substr($v,0,32);<BR> $uritem=substr($v,32,32);<BR> $timetem=substr($v,64,10);<BR> $numtem=substr($v,74);<BR> if($time-$timetem<$allowTime) {<BR> if($iptem!=$checkip)<BR> $str.=$v;<BR> else {<BR> $yesno=false;<BR> if($uritem!=$checkuri) <BR> $str.=$iptem.$checkuri.$time."1\r\n";<BR> elseif($numtem<$allowNum)<BR> $str.=$iptem.$uritem.$timetem.($numtem+1)."\r\n";<BR> else {<BR> if(!file_exists($fileforbid)) {<BR> $addforbidarr=array($ip."\r\n",time()."\r\n",1);<BR> file_put_contents($fileforbid,$addforbidarr);<BR> }<BR> file_put_contents("log/forbided_ip.log",$ip."--".date("Y-m-d H:i:s",ti<p style="color:transparent">。本文来源gao!%daima.com搞$代*!码网1</p><cite>搞代gaodaima码</cite>me())."--".$uri."\r\n",FILE_APPEND);<BR> $timepass=$timetem+$allowTime-$time;<BR> die("Warning:"."<br>"."Sorry,you are forbided by refreshing frequently too much, Pls wait for ".$timepass." seconds to continue!");<BR> }<BR> }<BR> }<BR>}<BR>if($yesno) $str.=$checkip.$checkuri.$time."1\r\n";<BR>file_put_contents($file,$str);<BR>?><BR>