1 /** 2 * 获取用户真实IP 3 * @return $onlineIp 4 */ 5 public function getOnlineIp() 6 { 7 if (getenv('HTTP_CLIENT_IP')) { 8 $onlineIp = getenv('HTTP_CLIENT_IP'); 9 } elseif (getenv('HTTP_X_FORWARDED_FOR')) { 10 $onlineIp = getenv('HTTP_X_FORWARDED_FOR'); 11 } elseif (getenv('REMOTE_ADDR')) { 12 $onlineIp = getenv('REMOTE_ADDR'); 13 } else { 14 $onlineIp = 'unknown'; 15 } 16 return $onlineIp; 17 }