Jump to content

[SOLVED] getting the users ip address?


shadiadiph

Recommended Posts

That will not always be filled or it will not always contain the actually client ip. Such as when a client is using a proxy or they are using many pass thru proxies. If you want to be 100% sure, then you need to check...

 

REMOTE_ADDR (assign 2 variables [ip, op])

HTTP_CLIENT_IP (if this is set, assign op to this value)

HTTP_X_FORWARDED_FOR (else if this is set, you will have to loop each ip, removing network masked ip(s) and then assigning op this value)

HTTP_FROM (else if this is set, assign op to this value)

 

in that order

 

At the end of that, if $ip == $op, then client is using a unique ip, else if $ip != $op, client is using proxy gateway ip, (ip is shared)

 

It important to do that when you create a (BLOCKING BY IP) so you only block that client, not the proxy because it is shared by thousands of users, (AOL,NETZero,most mobile phones,...)

You could also pull all the variables on the server by using:

echo "<b>_SERVER</b><br />";
foreach($_SERVER as $clave=>$valor)
{
echo $clave." = ".$valor."<br />";
}

this also works very well for debugging, so you can see what variables are being sent by changing the variable type.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.