diff options
author | Andrey Andreev <narf@devilix.net> | 2014-04-09 14:10:27 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-04-09 14:10:27 +0200 |
commit | 9a0e0c76b64d2a401d7ae32d1e53aaca30c7d959 (patch) | |
tree | 51a5ed00a7f155640e8b8197fd20d0145eea3643 /system | |
parent | b8bec1bf7407ebaee1c2b8bc1bddebe340e0346d (diff) |
Minor changes in FV, Trackback
Diffstat (limited to 'system')
-rw-r--r-- | system/core/Common.php | 3 | ||||
-rw-r--r-- | system/libraries/Form_validation.php | 33 | ||||
-rw-r--r-- | system/libraries/Trackback.php | 43 |
3 files changed, 32 insertions, 47 deletions
diff --git a/system/core/Common.php b/system/core/Common.php index fda747b05..677ceaf97 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -45,9 +45,6 @@ if ( ! function_exists('is_php')) /** * Determines if the current version of PHP is greater then the supplied value * - * Since there are a few places where we conditionally test for PHP > 5.3 - * we'll set a static variable. - * * @param string * @return bool TRUE if the current version is $version or higher */ 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)); diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 9fa4a8edb..e22361e1f 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -44,14 +44,20 @@ class CI_Trackback { * * @var string */ - public $charset = 'UTF-8'; + public $charset = 'UTF-8'; /** * Trackback data * * @var array */ - public $data = array('url' => '', 'title' => '', 'excerpt' => '', 'blog_name' => '', 'charset' => ''); + public $data = array( + 'url' => '', + 'title' => '', + 'excerpt' => '', + 'blog_name' => '', + 'charset' => '' + ); /** * Convert ASCII flag @@ -61,21 +67,21 @@ class CI_Trackback { * * @var bool */ - public $convert_ascii = TRUE; + public $convert_ascii = TRUE; /** * Response * * @var string */ - public $response = ''; + public $response = ''; /** * Error messages list * * @var string[] */ - public $error_msg = array(); + public $error_msg = array(); // -------------------------------------------------------------------- @@ -116,18 +122,22 @@ class CI_Trackback { switch ($item) { - case 'ping_url' : $$item = $this->extract_urls($tb_data[$item]); + case 'ping_url': + $$item = $this->extract_urls($tb_data[$item]); break; - case 'excerpt' : $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); + case 'excerpt': + $$item = $this->limit_characters($this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); break; - case 'url' : $$item = str_replace('-', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); + case 'url': + $$item = str_replace('-', '-', $this->convert_xml(strip_tags(stripslashes($tb_data[$item])))); break; - default : $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))); + default: + $$item = $this->convert_xml(strip_tags(stripslashes($tb_data[$item]))); break; } // Convert High ASCII Characters - if ($this->convert_ascii === TRUE && in_array($item, array('excerpt', 'title', 'blog_name'))) + if ($this->convert_ascii === TRUE && in_array($item, array('excerpt', 'title', 'blog_name'), TRUE)) { $$item = $this->convert_ascii($$item); } @@ -301,7 +311,9 @@ class CI_Trackback { if (stripos($this->response, '<error>0</error>') === FALSE) { - $message = preg_match('/<message>(.*?)<\/message>/is', $this->response, $match) ? trim($match[1]) : 'An unknown error was encountered'; + $message = preg_match('/<message>(.*?)<\/message>/is', $this->response, $match) + ? trim($match[1]) + : 'An unknown error was encountered'; $this->set_error($message); return FALSE; } @@ -326,17 +338,10 @@ class CI_Trackback { // Remove the pesky white space and replace with a comma, then replace doubles. $urls = str_replace(',,', ',', preg_replace('/\s*(\S+)\s*/', '\\1,', $urls)); - // Remove any comma that might be at the end - if (substr($urls, -1) === ',') - { - $urls = substr($urls, 0, -1); - } - // Break into an array via commas and remove duplicates - $urls = array_unique(preg_split('/[,]/', $urls)); + $urls = array_unique(preg_split('/[,]/', rtrim($urls, ','))); array_walk($urls, array($this, 'validate_url')); - return $urls; } |