diff options
Diffstat (limited to 'system/libraries/Form_validation.php')
-rw-r--r-- | system/libraries/Form_validation.php | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 31d73303e..2f072343d 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -223,8 +223,6 @@ class CI_Form_validation { $indexes[] = $matches[1][$i]; } } - - $is_array = TRUE; } // Build our master array @@ -1096,19 +1094,16 @@ class CI_Form_validation { * Check if the input value doesn't already exist * in the specified database field. * - * @param string - * @param string field + * @param string $str + * @param string $field * @return bool */ public function is_unique($str, $field) { sscanf($field, '%[^.].%[^.]', $table, $field); - if (isset($this->CI->db)) - { - $query = $this->CI->db->limit(1)->get_where($table, array($field => $str)); - return $query->num_rows() === 0; - } - return FALSE; + return isset($this->CI->db) + ? ($this->CI->db->limit(1)->get_where($table, array($field => $str))->num_rows() === 0) + : FALSE; } // -------------------------------------------------------------------- @@ -1126,10 +1121,6 @@ class CI_Form_validation { { return FALSE; } - else - { - $val = (int) $val; - } return (MB_ENABLED === TRUE) ? ($val <= mb_strlen($str)) @@ -1151,10 +1142,6 @@ class CI_Form_validation { { return FALSE; } - else - { - $val = (int) $val; - } return (MB_ENABLED === TRUE) ? ($val >= mb_strlen($str)) @@ -1176,14 +1163,10 @@ class CI_Form_validation { { return FALSE; } - else - { - $val = (int) $val; - } return (MB_ENABLED === TRUE) - ? (mb_strlen($str) === $val) - : (strlen($str) === $val); + ? (mb_strlen($str) === (int) $val) + : (strlen($str) === (int) $val); } // -------------------------------------------------------------------- @@ -1219,7 +1202,7 @@ class CI_Form_validation { // There's a bug affecting PHP 5.2.13, 5.3.2 that considers the // underscore to be a valid hostname character instead of a dash. // Reference: https://bugs.php.net/bug.php?id=51192 - if (version_compare(PHP_VERSION, '5.2.13', '==') === 0 OR version_compare(PHP_VERSION, '5.3.2', '==') === 0) + if (version_compare(PHP_VERSION, '5.2.13', '==') OR version_compare(PHP_VERSION, '5.3.2', '==')) { sscanf($str, 'http://%[^/]', $host); $str = substr_replace($str, strtr($host, array('_' => '-', '-' => '_')), 7, strlen($host)); |