forum.coppermine-gallery.net

No Support => Feature requests => Topic started by: bnies on December 12, 2005, 09:50:14 am

Title: BUG: IPv6 addresses in include/init.inc.php
Post 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:

Code: [Select]
// 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;
    }
}
Title: Re: BUG: IPv6 addresses in include/init.inc.php
Post by: DJMaze on December 14, 2005, 07:35:37 am
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
Title: Re: BUG: IPv6 addresses in include/init.inc.php
Post by: Nibbler on December 20, 2005, 03:59:29 pm
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.
Title: Re: BUG: IPv6 addresses in include/init.inc.php
Post by: Joachim Müller on January 25, 2006, 08:00:27 am
Moved as suggested by Nibbler