added setServerAddr and isServerAddr to IPAddr.class.php to identify users connecting...
authorpk910 <philipp@zoelle1.de>
Sun, 27 May 2012 16:01:40 +0000 (18:01 +0200)
committerpk910 <philipp@zoelle1.de>
Sun, 27 May 2012 16:01:40 +0000 (18:01 +0200)
Bots/Stats.class.php
Uplink/IPAddr.class.php
Uplink/Uplink.class.php

index 4fc06a2ad84d82fc11268257993b26b10335a393..df3db8c1eaa902b3f465946c34f580b7c484aa10 100644 (file)
@@ -146,7 +146,7 @@ class {$_NAME} extends Bot {
                        if($user->isAway()) $stats['away']++;
                        else $stats['here']++;
                        if($user->getModes()->hasMode('o')) $stats['opers']++;
                        if($user->isAway()) $stats['away']++;
                        else $stats['here']++;
                        if($user->getModes()->hasMode('o')) $stats['opers']++;
-                       if($user->getIP()->isLocalAddress()) $stats['local']++;
+                       if($user->getIP()->isLocalAddress(true)) $stats['local']++;
                        if($user->getIP()->isIPv6()) $stats['ipv6']++;
                        else $stats['ipv4']++;
                }
                        if($user->getIP()->isIPv6()) $stats['ipv6']++;
                        else $stats['ipv4']++;
                }
index 2370cf66e48fab506177595eec9a74ad9edd3611..b1912e8926c3c503d395415aa0b2b46c275ba707 100644 (file)
@@ -28,6 +28,7 @@ class IPAddr {
        private static $pattern_IPv4 = '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(|\/[0-9]{1,2})$/';
        private $ip6 = array();
        private $addr_is_ipv6 = false;
        private static $pattern_IPv4 = '/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(|\/[0-9]{1,2})$/';
        private $ip6 = array();
        private $addr_is_ipv6 = false;
+       private $is_server_addr = false;
 
        public function __construct($initial_value) {
                for($i = 0; $i < 8; $i++) {
 
        public function __construct($initial_value) {
                for($i = 0; $i < 8; $i++) {
@@ -97,7 +98,15 @@ class IPAddr {
                return $this->addr_is_ipv6;
        }
        
                return $this->addr_is_ipv6;
        }
        
-       public function isLocalAddress() {
+       public function setServerAddr($serverAddr) {
+               $this->is_server_addr = $serverAddr;
+       }
+       
+       public function isServerAddr() {
+               return $this->is_server_addr;
+       }
+       
+       public function isLocalAddress($serverAddr = false) {
                /* checks if address is out of:
                * 127.0.0.1/32
                * 10.0.0.0/8
                /* checks if address is out of:
                * 127.0.0.1/32
                * 10.0.0.0/8
@@ -105,6 +114,8 @@ class IPAddr {
                * 172.16.0.0/12
                * ::1/128
                * fc00::/7
                * 172.16.0.0/12
                * ::1/128
                * fc00::/7
+               *
+               * if $serverAddr is true also return true for server IP's
                */
                if($this->addr_is_ipv6) {
                        if(
                */
                if($this->addr_is_ipv6) {
                        if(
@@ -122,6 +133,8 @@ class IPAddr {
                          )
                                return true;
                }
                          )
                                return true;
                }
+               if($serverAddr && $this->is_server_addr)
+                       return true;
                return false;
        }
 
                return false;
        }
 
index 6465a9879d2990bf2e6844e269cad24b81e152d1..bef5d05e58096ddd2d9bfd4293fdb65d61e8a316 100644 (file)
@@ -374,6 +374,8 @@ class Uplink {
                        $modes = implode(" ",array_slice($args, 5, count($args)-8));
                        $modes = new P10_UserModeSet($modes);
                        $ip = new IPAddr($args[count($args)-3]);
                        $modes = implode(" ",array_slice($args, 5, count($args)-8));
                        $modes = new P10_UserModeSet($modes);
                        $ip = new IPAddr($args[count($args)-3]);
+                       if($host == $server->getName())
+                               $ip->setServerAddr(true);
                        $realname = $args[count($args)-1];
                        $user = new P10_User($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes);
                        if($this->eventHandler)
                        $realname = $args[count($args)-1];
                        $user = new P10_User($nick, $numeric, $server, $connect_time, $ident, $host, $ip, $realname, $modes);
                        if($this->eventHandler)