| @@ -16,11 +16,11 @@ | ||
| 16 | 16 | $ip = $_SERVER['REMOTE_ADDR']; |
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | $ip = trim($ip); |
| 20 | - if (WPRHelper::safePregMatch('/^\[([0-9a-fA-F:]+)\](:[0-9]+)$/', $ip, $matches)) { | |
| 20 | + if (preg_match('/^\[([0-9a-fA-F:]+)\](:[0-9]+)$/', $ip, $matches)) { | |
| 21 | 21 | $ip = $matches[1]; |
| 22 | - } elseif (WPRHelper::safePregMatch('/^([0-9.]+)(:[0-9]+)$/', $ip, $matches)) { | |
| 22 | + } elseif (preg_match('/^([0-9.]+)(:[0-9]+)$/', $ip, $matches)) { | |
| 23 | 23 | $ip = $matches[1]; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | return $ip; |
| @@ -25,12 +25,8 @@ | ||
| 25 | 25 | |
| 26 | 26 | return $ip; |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - public static function isIPv6($ip) { | |
| 30 | - return (false === filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) ? false : true; | |
| 31 | - } | |
| 32 | - | |
| 33 | 29 | public static function hasIPv6Support() { |
| 34 | 30 | return defined('AF_INET6'); |
| 35 | 31 | } |
| 36 | 32 | |
| @@ -43,15 +39,15 @@ | ||
| 43 | 39 | return $pton; |
| 44 | 40 | } |
| 45 | 41 | |
| 46 | 42 | public static function _bvInetPton($ip) { |
| 47 | - if (WPRHelper::safePregMatch('/^(?:\d{1,3}(?:\.|$)){4}/', $ip)) { | |
| 43 | + if (preg_match('/^(?:\d{1,3}(?:\.|$)){4}/', $ip)) { | |
| 48 | 44 | $octets = explode('.', $ip); |
| 49 | 45 | $bin = chr($octets[0]) . chr($octets[1]) . chr($octets[2]) . chr($octets[3]); |
| 50 | 46 | return $bin; |
| 51 | 47 | } |
| 52 | 48 | |
| 53 | - if (WPRHelper::safePregMatch('/^((?:[\da-f]{1,4}(?::|)){0,8})(::)?((?:[\da-f]{1,4}(?::|)){0,8})$/i', $ip)) { | |
| 49 | + if (preg_match('/^((?:[\da-f]{1,4}(?::|)){0,8})(::)?((?:[\da-f]{1,4}(?::|)){0,8})$/i', $ip)) { | |
| 54 | 50 | if ($ip === '::') { |
| 55 | 51 | return "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"; |
| 56 | 52 | } |
| 57 | 53 | $colon_count = substr_count($ip, ':'); |
| @@ -70,9 +66,9 @@ | ||
| 70 | 66 | |
| 71 | 67 | return strlen($ipv6_bin) === 16 ? $ipv6_bin : false; |
| 72 | 68 | } |
| 73 | 69 | |
| 74 | - if (WPRHelper::safePregMatch('/^(?:\:(?:\:0{1,4}){0,4}\:|(?:0{1,4}\:){5})ffff\:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i', $ip, $matches)) { | |
| 70 | + if (preg_match('/^(?:\:(?:\:0{1,4}){0,4}\:|(?:0{1,4}\:){5})ffff\:(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/i', $ip, $matches)) { | |
| 75 | 71 | $octets = explode('.', $matches[1]); |
| 76 | 72 | return chr($octets[0]) . chr($octets[1]) . chr($octets[2]) . chr($octets[3]); |
| 77 | 73 | } |
| 78 | 74 | |