some fixes
authorpk910 <philipp@zoelle1.de>
Thu, 28 Jul 2011 08:15:41 +0000 (10:15 +0200)
committerpk910 <philipp@zoelle1.de>
Thu, 28 Jul 2011 08:15:41 +0000 (10:15 +0200)
Uplink/IPAddr.class.php
Uplink/Numerics.class.php
Uplink/Uplink.class.php

index e486fb0caa787509382a2721daed3eb5e29dcf26..661a8e209ac694230b790a261c92da3c60b3d2e4 100644 (file)
@@ -34,7 +34,7 @@ class IPAddr {
        
        public function __construct($initial_value) {
                for($i = 0; $i < 8; $i++) {
-                       $ip6[$i] = 0;
+                       $this->ip6[$i] = 0;
                }
                if($initial_value == null) {
                        //nothing
@@ -67,6 +67,7 @@ class IPAddr {
                                        $i += 3;
                                }
                        }
+                       $this->addr_is_ipv6 = true;
                }
        }
        
@@ -83,6 +84,7 @@ class IPAddr {
                                $this->ip6[$j++] = hexdec($block);
                        }
                }
+               $this->addr_is_ipv6 = true;
        }
        
        public function parseIPv4($ipv4) {
@@ -91,6 +93,7 @@ class IPAddr {
                $this->ip6[6] |= intval($ipv4blocks[1]);
                $this->ip6[7] = intval($ipv4blocks[2]) << 8;
                $this->ip6[7] |= intval($ipv4blocks[3]);
+               $this->addr_is_ipv6 = false;
        }
        
        public function isIPv6() {
index 01944dcb9aa6d42776c97e38593287fcc10fefb0..87cb6426f191b65bb67742ef8b96ebf434313ad5 100644 (file)
@@ -50,9 +50,6 @@ class Numerics {
        private static $base64charsLength = 64;
        
        public static function intToNum($int, $length) {
-               //fix a small "bug": normaly 0 = AAAAA but we need 1 = AAAAA
-               $int = $int - 1;
-               
                $numeric = "";
                for($pos = $length-1; $pos >= 0; $pos--) {
                        //current position represents floor($int / ($base64charsLength ^ $pos))
@@ -77,10 +74,6 @@ class Numerics {
                        $int = ($posValue * $base);
                        $base = $base * self::$base64charsLength;
                }
-               
-               //fix a small "bug": normaly 0 = AAAAA but we need 1 = AAAAA
-               $int = $int + 1;
-               
                return $int;
        }
        
index 9f3eb52c211e13eacc59fb3a8d24f29fcbffbd08..232d976619a9abba4b373fd16c960786ff463302 100644 (file)
@@ -75,7 +75,7 @@ class Uplink {
        private $settings = array();
        private $server;
        private $eventHandler = null;
-       private $last_local_numeric = 1;
+       private $last_local_numeric = 0;
        
        const FLAG_P10SESSION      = 0x0001; //connection is in P10 mode (server is connected)
        const FLAG_SECURITY_QUIT   = 0x0002; //local connection abort because of security issues
@@ -713,7 +713,7 @@ class Uplink {
                        $ident = $user->getIdent();
                        $host = $user->getHost();
                        $modes = $user->getModes()->getModeString();
-                       $ip = Numerics::numericFromIP($user->getIP());
+                       $ip = $user->getIP()->getNumeric();
                        $numeric = $user->getNumeric();
                        $realname = $user->getRealname();
                        $this->send("N", $nick, $connect_time, $ident, $host, $modes, $ip, $numeric, $realname);