获取客户端IP的解决办法
1.针对Apache服务器
function getUserIp(){if(getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown')) {$user_ip = getenv('HTTP_CLIENT_IP');} elseif(getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown')) {$user_ip = getenv('HTTP_X_FORWARDED_FOR');} elseif(getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown')) {$user_ip = getenv('REMOTE_ADDR');} elseif(isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown')) {$user_ip = $_SERVER['REMOTE_ADDR'];}else{$user_ip = '0.0.0.0';}$user_ip = preg_replace("/^([\d\.]+).*/", "\\1", $user_ip);return $user_ip;}
? 2.IIS?getenv不支持IIS的isapi方式运行的php
? 3.http://www.cnblogs.com/lmule/archive/2010/10/15/1852020.html