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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

WebStorm Mac version
Useful JavaScript development tools
