-
-
/*
- func: get_client_ip()
- 获取客户端IP地址
- */
- function get_client_ip()
- {
- $ip=false;
- if(!empty($_SERVER["HTTP_CLIENT_IP"]))
- {
- $ip = $_SERVER["HTTP_CLIENT_IP"];
- }
- if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
- {
- $ips = explode (", ", $_SERVER['HTTP_X_FORWARDED_FOR']);
- if ($ip)
- {
- array_unshift($ips, $ip); $ip = FALSE;
- }
- for ($i = 0; $i {
- if (!eregi ("^(10|172\.16|192\.168)\.", $ips[$i]))
- {
- $ip = $ips[$i];
- break;
- }
- }
- }
- return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
- }
- ?>
复制代码
|