02 |
$user_IP = ($_SERVER[ "HTTP_VIA" ]) ? $_SERVER[ "HTTP_X_FORWARDED_FOR" ] : $_SERVER[ "REMOTE_ADDR" ]; |
03 |
$user_IP = ($user_IP) ? $user_IP : $_SERVER[ "REMOTE_ADDR" ]; |
04 |
function get_real_ip(){ |
06 |
if (!emptyempty($_SERVER[ "HTTP_CLIENT_IP" ])){ |
07 |
$ip = $_SERVER[ "HTTP_CLIENT_IP" ]; |
09 |
if (!emptyempty($_SERVER[ 'HTTP_X_FORWARDED_FOR' ])) { |
10 |
$ips = explode ( ", " , $_SERVER[ 'HTTP_X_FORWARDED_FOR' ]); |
11 |
if ($ip) { array_unshift($ips, $ip); $ip = FALSE; } |
12 |
for ($i = 0; $i < count($ips); $i++) { |
13 |
if (!eregi ( "^(10│172.16│192.168)." , $ips[$i])) { |
19 |
return ($ip ? $ip : $_SERVER[ 'REMOTE_ADDR' ]); |
21 |
echo "YOUR IP " . " " . get_real_ip(); |
|