im dealing with a problem ...
When i want to send the client's ip adress along with a form, and the ip adress that the form sends is this: "2a02:a456:4012:X:dcXX:56f5:XXX:555a" And it keeps changing too...
Instead of an actual ip adress that i can use to as example ban people with, example given: "85.333.222.111".
I use this code:
function get_client_ip_server() {
$ipaddress = '';
if ($_SERVER['HTTP_CLIENT_IP'])
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if($_SERVER['HTTP_X_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if($_SERVER['HTTP_X_FORWARDED'])
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if($_SERVER['HTTP_FORWARDED_FOR'])
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if($_SERVER['HTTP_FORWARDED'])
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if($_SERVER['REMOTE_ADDR'])
$ipaddress = $_SERVER['REMOTE_ADDR'];
else
$ipaddress = 'ONBEKEND';
return $ipaddress;
}
and i use this code:
function get_client_ip_env() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'ONBEKEND';
return $ipaddress;
}
both returning these ip adresses: "2a02:a456:4012:X:dcXX:56f5:XXX:555a
Also, very important: my .htaccess won't allow me when I deny all but my IP4 address. When I allow my IP6 address it allows me but that address changes from time to time.
Can somebody please point me in the right direction and tell me what im doing wrong here? Help would be really appreciated.
Kinds regards, Julian.