forum.coppermine-gallery.net
No Support => Feature requests => Topic started by: bnies on December 12, 2005, 09:50:14 am
-
Version: Coppermine 1.4.2
Problem description: If the host is set up with PHP and IPv6 support the regular expressions to match the IP address do not work because the address has the form "::ffff:192.168.1.1"
Fix: The inet_ntop() inet_pton() functions are only available with PHP 5.1 and later so one has to add a dirty regex hack to convert IPv6 into IPv4. In file include/init.inc.php find REMOTE_ADDR and replace this code:
// Record User's IP address
$raw_ip = stripslashes($_SERVER['REMOTE_ADDR']);
$raw_ip = eregi_replace('^::ffff:', '', $raw_ip);
if (isset($_SERVER['HTTP_CLIENT_IP'])) {
$hdr_ip = stripslashes($_SERVER['HTTP_CLIENT_IP']);
$hdr_ip = eregi_replace('^::ffff:', '', $hdr_ip);
} else {
if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$hdr_ip = stripslashes($_SERVER['HTTP_X_FORWARDED_FOR']);
$hdr_ip = eregi_replace('^::ffff:', '', $hdr_ip);
} else {
$hdr_ip = $raw_ip;
}
}
-
that's a commonly used "hybrid IPv4-compatible address". Besides them there's also the "IPv4 mapped addresses" which are normally used by the IP stack to represent IPv4 addresses to IPv6 applications.
This notation has a hexadecimal representation of the IPv4 address.
::ffff:c0a8:101
IPv6 doesn't make it easy for us at the moment
-
To make Coppermine ipv6 compatible would take more than just this fix. I think we should treat this as a feature request for 1.5 instead of a 1.4 bug.
-
Moved as suggested by Nibbler