php获取客户端IP
时间:2009-08-15 来源:dow
if ($HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"])
$ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
elseif ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"])
$ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"])
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"]; //this is right
elseif (getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
elseif (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
elseif (getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknown";
$ip = $HTTP_SERVER_VARS["HTTP_X_FORWARDED_FOR"];
elseif ($HTTP_SERVER_VARS["HTTP_CLIENT_IP"])
$ip = $HTTP_SERVER_VARS["HTTP_CLIENT_IP"];
elseif ($HTTP_SERVER_VARS["REMOTE_ADDR"])
$ip = $HTTP_SERVER_VARS["REMOTE_ADDR"]; //this is right
elseif (getenv("HTTP_X_FORWARDED_FOR"))
$ip = getenv("HTTP_X_FORWARDED_FOR");
elseif (getenv("HTTP_CLIENT_IP"))
$ip = getenv("HTTP_CLIENT_IP");
elseif (getenv("REMOTE_ADDR"))
$ip = getenv("REMOTE_ADDR");
else
$ip = "Unknown";
相关阅读 更多 +