您的位置:首页 > 编程语言 > PHP开发

php实现cc攻击防御和防止快速刷新页面示例

2014-02-13 10:53 513 查看
<?php//代理IP直接退出empty($_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'] < $seconds){ 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;}?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息