PHP example sharing to determine whether the client uses a proxy server and its anonymity level_PHP tutorial

WBOY
Release: 2016-07-13 10:29:00
Original
712 people have browsed it

To determine whether the client uses a proxy server, you can judge from the environment variable information sent by the client.

Specifically, look at the HTTP_VIA field. If this field is set, it means that the client uses a proxy server.

The level of anonymity can be determined by referring to the table below.

Given an application example, you can hang up a proxy and try the effect: http://ip.mixsec.org/

1. When not using a proxy server:
REMOTE_ADDR = Your IP
HTTP_VIA = No value or not displayed
HTTP_X_FORWARDED_FOR = No value or not displayed

2. The use of transparent proxy servers: Transparent Proxies

REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Your real IP
This type of proxy server is still Forwarding your information to the person you visit cannot achieve the purpose of hiding your true identity.

3. The situation of using ordinary anonymous proxy servers: Anonymous Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Proxy server IP
Hide your real IP, but reveal to the visitors that you use a proxy server to access them.

4. The use of deceptive proxy servers: Distorting Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = Proxy server IP (Supplement: This field is filled in by the proxy server, and sometimes gateway information, etc.)
HTTP_X_FORWARDED_FOR = Random IP
Tell the visitor that you are using a proxy server, but make up a fake random IP to replace your real IP to deceive it.

5. Situation of using high anonymity proxy server: High Anonymity Proxies
REMOTE_ADDR = Proxy server IP
HTTP_VIA = No value or no display
HTTP_X_FORWARDED_FOR = No value or no display
Use proxy completely The server's information replaces all your information, as if you were using that proxy server to directly access the object.

In addition, proxy judges can be used to summarize some other reference judgment information and use it in practice.

Finally write a php example for your reference only:

Copy code The code is as follows:

if(!empty($_SERVER['HTTP_VIA'])) //Used Proxy
{
if(!isset($_SERVER['HTTP_X_FORWARDED_FOR']))
{
//Anonymous Proxies Ordinary anonymous proxy server
//The proxy IP address is $_SERVER[' REMOTE_ADDR']
}
else
{
$_SERVER['HTTP_X_FORWARDED_FOR']
}
}
else //No proxy or high-anonymity proxy
{
//The real ip address is $_SERVER['REMOTE_ADDR']
}


http://www.bkjia.com/PHPjc/779567.html

truehttp: //www.bkjia.com/PHPjc/779567.htmlTechArticleTo determine whether the client uses a proxy server, you can judge from the environment variable information sent by the client. Specifically, it looks at the HTTP_VIA field. If this field is set, it says...
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!