diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-06-10 05:18:14 +0200 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-06-10 05:18:14 +0200 |
commit | 5a257187c4ca09ea61c19999bf061cec3f224cc2 (patch) | |
tree | 56f5208bac5394f37c16e62625a149b3746d8e23 /system/core/Input.php | |
parent | 92aa67cf67292b20cfb8f18fc9e24b7408620355 (diff) |
Merge branch 2.1-stable into develop
Diffstat (limited to 'system/core/Input.php')
-rwxr-xr-x | system/core/Input.php | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index b986c4973..162e40c85 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -376,14 +376,26 @@ class CI_Input { /** * Validate IP Address * - * Updated version suggested by Geert De Deckere - * * @param string + * @param string 'ipv4' or 'ipv6' * @return bool */ - public function valid_ip($ip) + public function valid_ip($ip, $which = '') { - return (bool) filter_var($ip, FILTER_VALIDATE_IP); + switch (strtolower($which)) + { + case 'ipv4': + $which = FILTER_FLAG_IPV4; + break; + case 'ipv6': + $which = FILTER_FLAG_IPV6; + break; + default: + $which = NULL; + break; + } + + return (bool) filter_var($ip, FILTER_VALIDATE_IP, $which); } // -------------------------------------------------------------------- |