get_ip not working
-
Hi,
it seems that get_ip that rely on getenv() is not working on my configuration.
I’ve set up a workaround, adding below your test also these (same as yours, but with $_SERVER variable):
if ( $_SERVER[ ‘HTTP_CF_CONNECTING_IP’ ] ) {
$ipaddress = $_SERVER[ ‘HTTP_CF_CONNECTING_IP’ ];
} elseif ( $_SERVER[ ‘HTTP_CLIENT_IP’] ) {
$ipaddress = $_SERVER[ ‘HTTP_CLIENT_IP’ ];
} elseif ( $_SERVER[ ‘HTTP_X_FORWARDED_FOR’] ) {
$ipaddress = $_SERVER[ ‘HTTP_X_FORWARDED_FOR’ ];
} elseif ( $_SERVER[ ‘HTTP_X_FORWARDED’] ) {
$ipaddress = $_SERVER[ ‘HTTP_X_FORWARDED’ ];
} elseif ( $_SERVER[ ‘HTTP_FORWARDED_FOR’] ) {
$ipaddress = $_SERVER[ ‘HTTP_FORWARDED_FOR’ ];
} elseif ( $_SERVER[ ‘HTTP_FORWARDED’ ] ) {
$ipaddress = $_SERVER[ ‘HTTP_FORWARDED’ ];
} elseif ( $_SERVER[ ‘REMOTE_ADDR’ ] ) {
$ipaddress = $_SERVER[ ‘REMOTE_ADDR’ ];
}I suggest you to add these ones to provide a better compatibility.
Simone.
- You must be logged in to reply to this topic.