$_SERVER['REMOTE_ADDR'], 'proxy' => false, 'proxy_ip' => '', ); /* * This code tries to bypass a proxy and get the actual IP address of * the visitor behind the proxy. * Warning: These values might be spoofed! */ $ip_fields = array( 'HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR', ); foreach ( $ip_fields as $key ) { if ( array_key_exists( $key, $_SERVER ) === true ) { foreach ( explode( ',', $_SERVER[$key] ) as $ip ) { $ip = trim( $ip ); if ( filter_var( $ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE ) !== false ) { $forwarded = $ip; break 2; } } } } // If we found a different IP address then REMOTE_ADDR then it's a proxy! if ( $forwarded != $result->ip ) { $result->proxy = true; $result->proxy_ip = $result->ip; $result->ip = $forwarded; } return $result; } $info = ip_info(); if ( $info->proxy ) { echo 'Your IP real is ' . $info->ip; } else { echo 'Your IP real is ' . $info->ip . ' and your proxy is ' . $info->proxy_ip; } // ?>