diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-13 11:40:00 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-13 11:40:00 +0100 |
commit | 3f71628066254371904ad872ab5d16c01ee21269 (patch) | |
tree | fdbb82e4d9448f18d3ad316fd16662cd8db78c0d /system/core/Input.php | |
parent | dd389df69cd1ab74316ac7a7e227a5f47f16f95c (diff) | |
parent | d153002858256c6f206c8877f4952ed075902f9e (diff) |
Merge branch 'develop' of github.com:EllisLab/CodeIgniter into develop-helpers-sst
Diffstat (limited to 'system/core/Input.php')
-rwxr-xr-x | system/core/Input.php | 50 |
1 files changed, 19 insertions, 31 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index ee15f4013..901b4147e 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * @@ -366,36 +366,7 @@ class CI_Input { */ public function valid_ip($ip) { - // if php version >= 5.2, use filter_var to check validate ip. - if (function_exists('filter_var')) - { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); - } - - $ip_segments = explode('.', $ip); - - // Always 4 segments needed - if (count($ip_segments) !== 4) - { - return FALSE; - } - // IP can not start with 0 - if ($ip_segments[0][0] == '0') - { - return FALSE; - } - // Check each segment - foreach ($ip_segments as $segment) - { - // IP segments must be digits and can not be - // longer than 3 digits or greater then 255 - if ($segment == '' OR preg_match('/[^0-9]/', $segment) OR $segment > 255 OR strlen($segment) > 3) - { - return FALSE; - } - } - - return TRUE; + return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } // -------------------------------------------------------------------- @@ -699,6 +670,23 @@ class CI_Input { return (php_sapi_name() === 'cli' OR defined('STDIN')); } + // -------------------------------------------------------------------- + + /** + * Get Request Method + * + * Return the Request Method + * + * @param bool uppercase or lowercase + * @return bool + */ + public function method($upper = FALSE) + { + return ($upper) + ? strtoupper($this->server('REQUEST_METHOD')) + : strtolower($this->server('REQUEST_METHOD')); + } + } /* End of file Input.php */ |