#1 zhgzzy
/**
* 获取用户真实IP
*/
function getIP(){
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"]))
{
if ($_SERVER["HTTP_CLIENT_IP"])
{
$proxy = $_SERVER["HTTP_CLIENT_IP"];
}
else
{
$proxy = $_SERVER["REMOTE_ADDR"];
}
$ip = $_SERVER["HTTP_X_FORWARDED_FOR"];
}
else
{
if (isset($_SERVER["HTTP_CLIENT_IP"]))
{
$ip = $_SERVER["HTTP_CLIENT_IP"];
}
else
{
$ip = $_SERVER["REMOTE_ADDR"];
}
}
return str_replace(",","",$ip);
}
问题:
1. 在获取的IP后面有时会有一个逗号如: 192.168.1.1, 我已处理
2. 现在又发现一个问题 192.168.1.101 10 又获取到这样的地址
2014-05-28 17:30:36