1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
<?php function getRealIpAddr(){ if(!empty($_SERVER['HTTP_CLIENT_IP']) && getenv('HTTP_CLIENT_IP')){ return $_SERVER['HTTP_CLIENT_IP']; } elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR']) && getenv('HTTP_X_FORWARDED_FOR')){ return $_SERVER['HTTP_X_FORWARDED_FOR']; } elseif(!empty($_SERVER['REMOTE_HOST']) && getenv('REMOTE_HOST')){ return $_SERVER['REMOTE_HOST']; } elseif(!empty($_SERVER['REMOTE_ADDR']) && getenv('REMOTE_ADDR')){ return $_SERVER['REMOTE_ADDR']; } return false; } if($ip = getRealIpAddr()){ echo $ip; } ?> |