How to disable proxy IP access in php: first determine the proxy IP through "empty($_SERVER['HTTP_VIA']) or exit('Access Denied');"; then set the monitoring variables; then process the monitoring Result; finally jump to the attacker's server address.
Recommendation: "PHP Video Tutorial"
PHP prevents quick page refresh proxy ip access
The website received some CC attacks a few days ago, which was quite depressing. . . Let me share here, the method to prevent the automatic refresh of the web page and the method to prevent the proxy IP from accessing the website. The codes are separate. The two functions are used. You can use which one. You can customize the time interval. This code can not only prevent CC attacks, but also prevent All kinds of things can be used as long as they are added to the header. It is very useful. No more nonsense. Just go to the code:
<?php /** * @无作为 * www.wuzuowei.com */ //代理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; } ?>
The above is the detailed content of How to ban proxy ip access in php. For more information, please follow other related articles on the PHP Chinese website!