Advanced search  

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

Pages: [1]   Go Down

Author Topic: BUG: IPv6 addresses in include/init.inc.php  (Read 4139 times)

0 Members and 2 Guests are viewing this topic.

bnies

  • Coppermine newbie
  • Offline Offline
  • Gender: Male
  • Posts: 3
    • http://www.nies.ch/
BUG: IPv6 addresses in include/init.inc.php
« 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;
    }
}
« Last Edit: January 25, 2006, 08:00:45 am by GauGau »
Logged

DJMaze

  • VIP
  • Coppermine addict
  • ***
  • Offline Offline
  • Posts: 831
    • Dragonfly CMS
Re: BUG: IPv6 addresses in include/init.inc.php
« Reply #1 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
Logged
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

  • Guest
Re: BUG: IPv6 addresses in include/init.inc.php
« Reply #2 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.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: BUG: IPv6 addresses in include/init.inc.php
« Reply #3 on: January 25, 2006, 08:00:27 am »

Moved as suggested by Nibbler
Logged
Pages: [1]   Go Up
 

Page created in 0.019 seconds with 21 queries.