function GetIP() {
if (getenv("HTTP_CLIENT_IP")){
echo "getenvHTTP_CLIENT_IP";
$ip = getenv("HTTP_CLIENT_IP");
}else if (getenv("HTTP_X_FORWARDED_FOR"))
{
$ip = getenv("HTTP_X_FORWARDED_FOR");
echo "getenvHTTP_X_FORWARDED_FOR";
echo "<br>you are right";
}else if (getenv("REMOTE_ADDR")){
echo "getenvREMOTE_ADDR";
$ip = getenv("REMOTE_ADDR");
}else{
echo "unknow";
$ip = "Unknown";
}
return $ip;
}
echo GetIp();
?>
GET /1.php HTTP/1.1
Accept: */*
Referer: http://localhost/
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; MAXTHON 2.0)
Host: localhost
Connection: Keep-Alive
Cache-Control: no-cache
X-Forwarded-For: 127.0.0.2
Cookie: rtime=0; ltime=1269249140109; cnzz_eid=64110124-1269242429-; language=zh-cn; PHPSESSID=ae9b14609808b4ff4c5811ad1943c529