Using PHP v4.4.4 on Apache 2.2, I'm trying to get the IP address of each visitor. To do it, I use $_REMOTE_ADDR, but I get this info: 1295:b508:4161:b4bf:316f:ab00:a00:0
How can I show remoteAddress in '200.12.55.20' format?
(sorry, I wrote $_REMOTE_ADDR by mistake in the first post)
Scally_Ally
4:15 pm on Jun 7, 2007 (gmt 0)
does this output any different?
$ret = apache_getenv("REMOTE_ADDR"); echo $ret;
doubt it will but maybe worth a go..
[edited by: Scally_Ally at 4:15 pm (utc) on June 7, 2007]
Philosopher
4:32 pm on Jun 7, 2007 (gmt 0)
I'm no expert, but that sure looks like an IPv6 address, in which case, you won't get it into the IPv4 structure as they are quite different.
coopster
11:32 pm on Jun 7, 2007 (gmt 0)
You could write your own class based on RFC2373 (well originally, but it's been updated by RFC4291 [rfc-editor.org]) or you might want to check into a PEAR class. You could use the whole class or peel out the parts you need, such as splitv64 [pear.php.net].
guarriman
2:55 pm on Jun 8, 2007 (gmt 0)
apache_getenv("REMOTE_ADDR") doesn't work for me :(