Home >php教程 >php手册 >PHP防止快速刷新代码

PHP防止快速刷新代码

WBOY
WBOYOriginal
2016-06-06 19:57:38917browse

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 代码: //代理IP直接退出 empty($_SERVER['HTTP_VIA']) or exit('Access Denied'); //防止快速刷新 session_start(); $seconds = '3'; //时间段[秒] $refresh = '5'; //刷新次数 //设置监控

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  代码:

  //代理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']

  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;

  }

PHP防止快速刷新代码

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn