In article <9f**************************@posting.google.com >, Johnny's
output was...
I read the documents of apache on RH9, and found that apache currently
can fully support IPv6, but how about PHP?
Searches haven't turned up much, but:
at
http://uk.php.net/gethostbyaddr
Somebody called Abe has posted this:
gethostbyaddr() doesn't seem to be able to resolve ip6.int
(ipv6) adresses, so I made a function that can, and works
just like the normal gethostbyaddr().
You need dig and ipv6calc, dig should come with most
distributions, if not, install bind from
http://www.isc.org.
ipv6calc can be found at
http://www.bieringer.de/linux/IPv6/ipv6calc/index.html.
function gethostbyaddr6($ip6) {
$ipv6calc = "/bin/ipv6calc";
$dig = "/usr/bin/dig";
$file = popen($ipv6calc." --in ipv6addr --out revnibbles.int
".escapeshellarg($ip6), r);
$ip = fread($file, 128);
pclose($file);
if ((substr($ip, 0, 5) == "Error") || (!$ip)) return "Address is not a
valid IPv6 address";
$file = popen($dig." ptr ".$ip, r);
while (!feof ($file)) {
$buffer = fgets($file, 128);
if (substr($buffer, 0, 1) == ";") continue;
$buffer = explode(" ", $buffer);
if ($buffer[3] == "PTR") {
$host = substr(trim($buffer[4]), 0, -1);
pclose($file);
return $host;
}
}
pclose($file);
return $ip6;
}
echo gethostbyaddr6($_SERVER[REMOTE_ADDR]);