function getip(){
if (getenv("http_client_ip") && strcasecmp(getenv("http_client_ip"), "unknown"))
$ip = getenv("http_client_ip");
else if (getenv("http_x_forwarded_for") && strcasecmp(getenv("http_x_forwarded_for"), "unknown"))
$ip = getenv("http_x_forwarded_for");
else if (getenv("remote_addr") && strcasecmp(getenv("remote_addr"), "unknown"))
$ip = getenv("remote_addr");
else if (isset($_server['remote_addr']) && $_server['remote_addr'] && strcasecmp($_server['remote_addr'], "unknown"))
$ip = $_server['remote_addr'];
else
$ip = "unknown";
return($ip);
}
即使用户通过代理服务器上网,也能查出他的ip。但是要求代理服务器的类型是transparent类型。如果代理服务器是anonymous或者是high anonymous类型,http_x_forwarded_for也无能为力了。
新闻热点
疑难解答