summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorJoffrey Jaffeux <j.jaffeux@gmail.com>2012-06-06 14:26:04 +0200
committerJoffrey Jaffeux <j.jaffeux@gmail.com>2012-06-06 14:26:04 +0200
commitc28b651b91367e86f1bd6ab7f0cd6c45e58811ab (patch)
treee09e4e0ac955a7081af200bb47244fee04527f29 /system
parent6683c3c872952ae16d98c89ef474e5522897592a (diff)
Add support for ipv6
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/Input.php22
1 files changed, 21 insertions, 1 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index 73f46ba6a..6a5a9d8f0 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -383,7 +383,27 @@ class CI_Input {
*/
public function valid_ip($ip)
{
- return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
+ if($this->ip_version($ip) === '4')
+ {
+ return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4);
+ }
+ else
+ {
+ return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6);
+ }
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Return ip version
+ *
+ * @param string
+ * @return string
+ */
+ public function ip_version($ip)
+ {
+ return strpos($ip, ":") === false ? '4' : '6';
}
// --------------------------------------------------------------------