I was wondering if anyone could tell me how to capture a person's ip address who visits my site.
I've seen $_SERVER['REMOTE_ADDR'] and was wondering if this was the best way of doing so.
Also, lets say the user's ip address is: 203.279.16.123 OR 203.279.16.55
How can I have it displayed as 203.279.16.xxx OR 203.279.16.xx
Thanks.
IP Address: Capture and Format
Moderator: General Moderators
If the user comes through a non-anonymising proxy, that field will have the ip of the proxy. The real ip will be supplied in a http header ($_SERVER['HTTP_something']), for example HTTP_VIA, HTTP_X_FORWARDED_FOR, HTTP_FORWARDED_FOR etc.
About display - explode() the ip dotted quad into an array, change the last item to 'xx', and then join() it again
About display - explode() the ip dotted quad into an array, change the last item to 'xx', and then join() it again