From 0e34e7a49480ad6dad4c49dac6f25955c23b11c0 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Wed, 18 Jun 2008 18:10:11 +0000 Subject: [PATCH] Remove ugly IP code duplication --- includes/User.php | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/includes/User.php b/includes/User.php index ea5a49da97..6d8c739499 100644 --- a/includes/User.php +++ b/includes/User.php @@ -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? * -- 2.20.1