BUG: IPv6 addresses in include/init.inc.php BUG: IPv6 addresses in include/init.inc.php
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

BUG: IPv6 addresses in include/init.inc.php

Started by bnies, December 12, 2005, 09:50:14 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

bnies

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;
    }
}


DJMaze

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
There are 2 kinds of users in this world: satisfied and complainers.
Why do we never hear something from the satisfied users?
http://coppermine-gallery.net/forum/index.php?topic=24315.0

Nibbler

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.

Joachim Müller