您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

网站防御DDOS的PHP代码

2024/3/13 2:27:31发布14次查看
今天的主题是网站攻击与网站防护。这是我查到的资料,能够有效的拦截住我的ddos 一个php代码
60)unlink($fileforbid);  
else{  
$fileforbidarr=@file($fileforbid);  
if($ip==substr($fileforbidarr[0],0,strlen($ip)))  
{  
if($time-substr($fileforbidarr[1],0,strlen($time))>600)unlink($fileforbid);  
elseif($fileforbidarr[2]>600){file_put_contents($fileht,$ip.\r\n,file_append);unlink($fileforbid);}  
else{$fileforbidarr[2]++;file_put_contents($fileforbid,$fileforbidarr);}  
}  
}  
}  
//防刷新  
$str=;  
$file=log/ipdate.dat;  
if(!file_exists(log)&&!is_dir(log))mkdir(log,0777);  
if(!file_exists($file))file_put_contents($file,);  
$allowtime = 120;//防刷新时间  
$allownum=10;//防刷新次数  
$uri=$_server['request_uri'];  
$checkip=md5($ip);  
$checkuri=md5($uri);  
$yesno=true;  
$ipdate=@file($file);  
foreach($ipdate as $k=>$v)  
{ $iptem=substr($v,0,32);  
$uritem=substr($v,32,32);  
$timetem=substr($v,64,10);  
$numtem=substr($v,74);  
if($time-$timetem if($iptem!=$checkip)$str.=$v;  
else{  
$yesno=false;  
if($uritem!=$checkuri)$str.=$iptem.$checkuri.$time.1\r\n;  
elseif($numtem else  
{  
if(!file_exists($fileforbid)){$addforbidarr=array($ip.\r\n,time().\r\n,1);file_put_contents($fileforbid,$addforbidarr);}  
file_put_contents(log/forbided_ip.log,$ip.--.date(y-m-d h:i:s,time()).--.$uri.\r\n,file_append);  
$timepass=$timetem+$allowtime-$time;  
die(warning:.
.sorry,you are forbided by refreshing frequently too much, pls wait for .$timepass. seconds to continue!);  
}  
}  
}  
}  
if($yesno) $str.=$checkip.$checkuri.$time.1\r\n;  
file_put_contents($file,$str);  
?>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product