Home >Backend Development >PHP Problem >How to disable page refresh in php

How to disable page refresh in php

藏色散人
藏色散人Original
2020-07-07 10:30:462927browse

How to disable refresh in php: first exit the proxy IP directly; then set the time period and number of refreshes to prevent rapid refresh; then set the monitoring variables and process the monitoring results; finally jump to the attacker's server address. Can.

How to disable page refresh in php

php page prevents refreshing code

//代理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[&#39;last_time&#39;] < $seconds){
    if($_SESSION[&#39;refresh_times&#39;] >= $refresh){
        //跳转至攻击者服务器地址
        header(sprintf(&#39;Location:%s&#39;, &#39;http://127.0.0.1&#39;));
        exit(&#39;Access Denied&#39;);
    }
}else{
    $_SESSION[&#39;refresh_times&#39;] = 0;
    $_SESSION[&#39;last_time&#39;] = $cur_time;

For more related knowledge, please visit PHP Chinese website!

The above is the detailed content of How to disable page refresh in php. For more information, please follow other related articles on the PHP Chinese website!

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