源地址:[url]http://www.osphp.com.cn/read.php/323.htm#entrymore[/url]
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
<?
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
function GetIP() {
//获取IP
if ($_SERVER[
"HTTP_X_FORWARDED_FOR"])
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = $_SERVER[
"HTTP_X_FORWARDED_FOR"];
//OSPHP.COm.CN
else
if ($_SERVER[
"HTTP_CLIENT_IP"])
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = $_SERVER[
"HTTP_CLIENT_IP"];
else
if ($_SERVER[
"REMOTE_ADDR"])
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = $_SERVER[
"REMOTE_ADDR"];
//oSPHP.COM.CN
else
if (getenv(
"HTTP_X_FORWARDED_FOR"))
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = getenv(
"HTTP_X_FORWARDED_FOR");
else
if (getenv(
"HTTP_CLIENT_IP"))
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = getenv(
"HTTP_CLIENT_IP");
//OsPHP.COM.CN
else
if (getenv(
"REMOTE_ADDR"))
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip = getenv(
"REMOTE_ADDR");
else
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
$ip =
"Unknown";
return $ip;
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
}
![InBlock.gif](https://s1.51cto.com/images/editer/InBlock.gif)
?>
转载于:https://blog.51cto.com/xcf007/140967