Activity Stream
48,167 MEMBERS
6777 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Results 1 to 4 of 4
  1.     
    #1
    Moderator
    NewEraCracker's Avatar

    Default Making IPB IPv6 capable

    PHP Code: 
                //-----------------------------------------
                // IP Address
                //-----------------------------------------

                
    if ( ipsRegistry::$settings['xforward_matching'] )
                {
                    foreach( 
    array_reverseexplode','my_getenv('HTTP_X_FORWARDED_FOR') ) ) as $x_f )
                    {
                        
    $x_f trim($x_f);

                        if ( 
    preg_match'/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/'$x_f ) )
                        {
                            
    $addrs[] = $x_f;
                        }
                        
                    }

                    
    $addrs[] = my_getenv('HTTP_CLIENT_IP');
                    
    $addrs[] = my_getenv('HTTP_X_CLUSTER_CLIENT_IP');
                    
    $addrs[] = my_getenv('HTTP_PROXY_USER');
                }

                
    $addrs[] = my_getenv('REMOTE_ADDR');

                
    //-----------------------------------------
                // Do we have one yet?
                //-----------------------------------------

                
    foreach ( $addrs as $ip )
                {
                    if ( 
    $ip )
                    {
                        
    preg_match"/^([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})\.([0-9]{1,3})$/"$ip$match );

                        
    self::instance()->ip_address $match[1].'.'.$match[2].'.'.$match[3].'.'.$match[4];

                        if ( 
    self::instance()->ip_address AND self::instance()->ip_address != '...' )
                        {
                            break;
                        }
                    }
                }

                
    //-----------------------------------------
                // Make sure we take a valid IP address
                //-----------------------------------------

                
    if ( ( ! self::instance()->ip_address OR self::instance()->ip_address == '...' ) AND ! isset( $_SERVER['SHELL'] ) AND $_SERVER['SESSIONNAME'] != 'Console' )
                {
                    print 
    "Could not determine your IP address";
                    exit();
                } 
    This code works well for IPv4 but for IPv6 is no go.

    Also I've noticed that IPB stores ip adresses in mysql with type varchar(32) meaning even if that piece of code gets ipv6 capable there are other problems :/
    NewEraCracker Reviewed by NewEraCracker on . Making IPB IPv6 capable //----------------------------------------- // IP Address //----------------------------------------- if ( ipsRegistry::$settings ) { foreach( array_reverse( explode( ',', my_getenv('HTTP_X_FORWARDED_FOR') ) ) as $x_f ) { $x_f = trim($x_f); Rating: 5
    Trusted: Dom, l0calh0st, 0ccul7, robert420
    Find all threads started by NewEraCracker

  2.   Sponsored Links

  3.     
    #2
    Moderator
    NewEraCracker's Avatar
    Trusted: Dom, l0calh0st, 0ccul7, robert420
    Find all threads started by NewEraCracker

  4.     
    #3
    Member
    Website's:
    gudz.org
    thanks NEC

  5.     
    #4
    Moderator
    NewEraCracker's Avatar
    I investigated this a bit and did this "mod":
    -----------------------------------------

    Upload a file with this contents named ipv6.php
    PHP Code: 
    <?php
    /* IPv6 to IPv4, a dirty hack
     *
     * This will create fake IPv4 for IPv6 users based on the 64 first bits of their IP.
     * As most currently existing IPv6 providers are assigning /64 classes to their customers,
     * banning the generated IPv4 effectively bans the whole IPv6.
     *
     * Also this script generates a 32bits IPv4 from 64bits of IPv6 using XOR.
     * While this means people using IPv6 might share the same generated IPv4 (quite unlikely),
     * it is usually impossible for someone to obtain a different generated IPv4 without access
     * to more than a /64 (I believe only system administrators have this kind of thing).
     *
     * Author: NewEraCracker
     * License: Public Domain
     */

    //@link: http://php.net/manual/en/function.inet-pton.php
    if ( !function_exists('inet_pton')) {
        function 
    inet_pton($ip){
            
    //ipv4
            
    if (strpos($ip'.') !== FALSE) {
                
    $ip trim($ip,':f');
                
    $ip pack('N',ip2long($ip));
            }
            
    //ipv6
            
    elseif (strpos($ip':') !== FALSE) {

                
    //Short ipv6 fix by NewEraCracker
                
    $_count count(explode(':'$ip));
                while(
    $_count<8)
                {
                    
    $ip str_replace('::',':0::',$ip);
                    
    $_count++;
                }
                unset(
    $_count);
                
    //Newfags can't triforce!

                
    $ip explode(':'$ip);
                
    $res str_pad('', (4*(8-count($ip))), '0000'STR_PAD_LEFT);
                foreach (
    $ip as $seg) {
                    
    $res .= str_pad($seg4'0'STR_PAD_LEFT);
                }
                
    $ip pack('H'.strlen($res), $res);
            }
            return 
    $ip;
        }
    }

    //@link: http://php.net/manual/en/function.inet-ntop.php
    if ( !function_exists('inet_ntop')){
        function 
    inet_ntop($ip){
            if (
    strlen($ip)==4){
                
    //ipv4
                
    list(,$ip)=unpack('N',$ip);
                
    $ip=long2ip($ip);
            }
            elseif(
    strlen($ip)==16){
                
    //ipv6
                
    $ip=bin2hex($ip);
                
    $ip=substr(chunk_split($ip,4,':'),0,-1);
                
    $ip=explode(':',$ip);
                
    $res='';
                foreach(
    $ip as $seg) {
                    while(
    $seg{0}=='0'$seg=substr($seg,1);
                    if (
    $seg!='') {
                        
    $res.=($res==''?'':':').$seg;
                    } else {
                        if (
    strpos($res,'::')===false) {
                            if (
    substr($res,-1)==':') continue;
                            
    $res.=':';
                            continue;
                        }
                        
    $res.=($res==''?'':':').'0';
                    }
                }
                
    $ip=$res;
            }
            return 
    $ip;
        }
    }

    //@link: http://blog.magicaltux.net/2010/02/18/invision-power-board-and-ipv6-a-dirty-hack/
    $encoded_ip inet_pton($_SERVER['REMOTE_ADDR']);
    if (
    strlen($encoded_ip) == 16) {
        
    $ipv4 '';
        for(
    $i 0$i 8$i += 2$ipv4 .= chr(ord($encoded_ip[$i]) ^ ord($encoded_ip[$i+1]));
        
    $_SERVER['REMOTE_ADDR'] = inet_ntop($ipv4);
    }

    ?>
    conf_global.php
    Look for:
    PHP Code: 
    define('IN_DEV'0); 
    Add AFTER:
    PHP Code: 
    include_once('ipv6.php'); 
    Trusted: Dom, l0calh0st, 0ccul7, robert420
    Find all threads started by NewEraCracker

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Gamerz.WS - Capable Moderators and Super Mods Recruitment!
    By immu in forum Community Cooperative
    Replies: 4
    Last Post: 3rd Mar 2012, 09:32 AM
  2. IPv6-Only Is Becoming Viable
    By Daniel in forum News & Current Events
    Replies: 0
    Last Post: 14th Jan 2012, 04:07 AM
  3. Partner for making a stream / money making site.
    By S?nic in forum Community Cooperative
    Replies: 21
    Last Post: 6th Jan 2012, 10:39 PM
  4. How capable is shared hosting?
    By Webcs-Peter in forum Hosting Discussion
    Replies: 6
    Last Post: 21st Dec 2011, 04:55 PM
  5. Want to Hire a Capable Graphics Designer
    By jayfella in forum Completed Transactions
    Replies: 12
    Last Post: 31st Oct 2009, 10:28 AM

Tags for this Thread

BE SOCIAL