Remove ugly IP code duplication
authorAaron Schulz <aaron@users.mediawiki.org>
Wed, 18 Jun 2008 18:10:11 +0000 (18:10 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Wed, 18 Jun 2008 18:10:11 +0000 (18:10 +0000)
includes/User.php

index ea5a49d..6d8c739 100644 (file)
@@ -431,7 +431,7 @@ class User {
         * @return bool
         */
        static function isIP( $name ) {
-               return preg_match('/^\d{1,3}\.\d{1,3}\.\d{1,3}\.(?:xxx|\d{1,3})$/',$name) || User::isIPv6($name);
+               return IP::isIPAddress($name);
                /*return preg_match("/^
                        (?:[01]?\d{1,2}|2(:?[0-4]\d|5[0-5]))\.
                        (?:[01]?\d{1,2}|2(:?[0-4]\d|5[0-5]))\.
@@ -440,27 +440,6 @@ class User {
                $/x", $name);*/
        }
 
-       /**
-        * Check if $name is an IPv6 IP.
-        */
-       static function isIPv6($name) {
-               /*
-                * if it has any non-valid characters, it can't be a valid IPv6
-                * address.
-                */
-               if (preg_match("/[^:a-fA-F0-9]/", $name))
-                       return false;
-
-               $parts = explode(":", $name);
-               if (count($parts) < 3)
-                       return false;
-               foreach ($parts as $part) {
-                       if (!preg_match("/^[0-9a-fA-F]{0,4}$/", $part))
-                               return false;
-               }
-               return true;
-       }
-
        /**
         * Is the input a valid username?
         *