summaryrefslogtreecommitdiffstats
path: root/system/core
diff options
context:
space:
mode:
Diffstat (limited to 'system/core')
-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..36ff96d03 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 int
+ */
+ public function ip_version($ip)
+ {
+ return strpos($ip, ":") === false ? 4 : 6;
}
// --------------------------------------------------------------------