欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

php實現cc攻擊防御和防止快速刷新頁面示例

 更新時間:2014年02月13日 10:53:31   作者:  
這篇文章主要介紹了php實現cc攻擊防御的方法和防止快速刷新頁面示例,需要的朋友可以參考下

復制代碼 代碼如下:

<?php
//代理IP直接退出
empty($_SERVER['HTTP_VIA']) or exit('Access Denied');
//防止快速刷新
session_start();
$seconds = '3'; //時間段[秒]
$refresh = '5'; //刷新次數
//設置監(jiān)控變量
$cur_time = time();
if(isset($_SESSION['last_time'])){
 $_SESSION['refresh_times'] += 1;
}else{
 $_SESSION['refresh_times'] = 1;
 $_SESSION['last_time'] = $cur_time;
}
//處理監(jiān)控結果
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;
}
?>

相關文章

最新評論