首页
学习
活动
专区
工具
TVP
发布

php防cc代码

//代理IP直接退出

emptyempty($_SERVER['HTTP_VIA']) or exit('Access Denied');

//防止快速刷新

session_start();

$seconds = '3'; /段[秒]

$refresh = '5'; //刷新次数

//设置监控变量

$cur_time = time();

if(isset($_SESSION['last_time'])){

$_SESSION['refresh_times'] += 1;

}else{

$_SESSION['refresh_times'] = 1;

$_SESSION['last_time'] = $cur_time;

}

//处理监控结果

if($cur_time - $_SESSION['last_time']

if($_SESSION['refresh_times'] >= $refresh){

//跳转至攻击者服务器地址

header(sprintf('Location:%s', 'http://127.0.0.1'));

exit('Access Denied');

}

}else{

$_SESSION['refresh_times'] = 0;

$_SESSION['last_time'] = $cur_time;

}

?>

  • 发表于:
  • 原文链接https://kuaibao.qq.com/s/20180824A1W1KB00?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券