In php, we usually use $ _ SERVER [REMOTE_ADDR] to obtain the visitor's ip address. However, when a visitor uses a proxy, it can only obtain the proxy ip address. Then, use the following function to obtain the visitor's real ip address: functiongetRealIpAddr () {if (! Empty ($ _ SERVER [HTTP_CLIENT_IP]) {checkipfrom1_ I in php, we usually use $ _ SERVER ['remote _ ADDR '] to get the visitor's ip address. However, when a visitor uses a proxy, it can only obtain the proxy ip address. Then, use the following function to obtain the visitor's real ip address:
Function getRealIpAddr (){
If (! Empty ($ _ SERVER ['http _ CLIENT_IP ']) {// check ip from share internet
$ Ip = $ _ SERVER ['http _ CLIENT_IP '];
}
Elseif (! Empty ($ _ SERVER ['http _ X_FORWARDED_FOR ']) {// to check ip is pass from PRoxy
$ Ip = $ _ SERVER ['http _ X_FORWARDED_FOR '];
} Else {
$ Ip = $ _ SERVER ['remote _ ADDR '];
}
Return $ ip;
}
In fact, this function is not omnipotent. as we all know, header information can be forged. O (Partition _ partition) O