From 35be644f6c912f6cdbe9392557ac38a9fbbc0416 Mon Sep 17 00:00:00 2001 From: Stéphane Goetz Date: Mon, 24 Oct 2011 23:10:07 +0300 Subject: Added a "break 2;", When overriding the cache file in an other folder, it would try to load all files corresponding to this name and create an error because of a double file loading --- system/libraries/Driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 8df137e74..30204d075 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -76,7 +76,7 @@ class CI_Driver_Library { if (file_exists($filepath)) { include_once $filepath; - break; + break 2; } } } -- cgit v1.2.3-24-g4f1b From 8ff2da1c7457cfd04a28776705cea64cbb96716a Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 23 Nov 2011 10:09:57 +0100 Subject: tmp_path does not exists, should be tmp_name --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 05511b5d3..fe5907ab2 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1055,7 +1055,7 @@ class CI_Upload { if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) { $output = array(); - @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code); + @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code); if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution { $this->file_type = rtrim($output[0]); -- cgit v1.2.3-24-g4f1b From 59654319d20a7ec406e7d6f15cf6804e94897d14 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Dec 2011 14:28:54 +0200 Subject: Hotfix for a file type detection bug in the Upload library --- system/libraries/Upload.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index fe5907ab2..ff3461586 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1042,14 +1042,17 @@ class CI_Upload { if (function_exists('mime_content_type')) { $this->file_type = @mime_content_type($file['tmp_name']); - return; + if (strlen($this->file_type) > 0) // Turned out it's possible ... + { + return; + } } /* This is an ugly hack, but UNIX-type systems provide a native way to detect the file type, * which is still more secure than depending on the value of $_FILES[$field]['type']. * * Notes: - * - a 'W' in the substr() expression bellow, would mean that we're using Windows + * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check */ if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) -- cgit v1.2.3-24-g4f1b From f796655d37163e7fd046395ddfe765baf752ec77 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 2 Dec 2011 15:00:36 +0200 Subject: Update a comment, just to be clearer --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index ff3461586..506d15897 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1042,7 +1042,7 @@ class CI_Upload { if (function_exists('mime_content_type')) { $this->file_type = @mime_content_type($file['tmp_name']); - if (strlen($this->file_type) > 0) // Turned out it's possible ... + if (strlen($this->file_type) > 0) // Turns out it's possible that mime_content_type() returns FALSE or an empty string { return; } -- cgit v1.2.3-24-g4f1b From a49e381fde010a7a83845910c0f772fb139f0b1e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Dec 2011 13:05:22 +0200 Subject: Improve CI_Upload::_file_mime_type() --- system/libraries/Upload.php | 102 +++++++++++++++++++++++++++++++++----------- 1 file changed, 78 insertions(+), 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 506d15897..564d6000e 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1018,50 +1018,104 @@ class CI_Upload { */ protected function _file_mime_type($file) { - // Use if the Fileinfo extension, if available (only versions above 5.3 support the FILEINFO_MIME_TYPE flag) - if ( (float) substr(phpversion(), 0, 3) >= 5.3 && function_exists('finfo_file')) + // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) + $regexp = '/^([a-z\-]+\/[a-z0-9\-]+);\s.+$/'; + + /* Fileinfo extension - most reliable method + * + * Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the + * more convenient FILEINFO_MIME_TYPE flag doesn't exist. + */ + if (function_exists('finfo_file')) { - $finfo = new finfo(FILEINFO_MIME_TYPE); - if ($finfo !== FALSE) // This is possible, if there is no magic MIME database file found on the system + $finfo = finfo_open(FILEINFO_MIME); + if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system { - $file_type = $finfo->file($file['tmp_name']); + $mime = @finfo_file($finfo, $file['tmp_name']); + finfo_close($finfo); /* According to the comments section of the PHP manual page, * it is possible that this function returns an empty string * for some files (e.g. if they don't exist in the magic MIME database) */ - if (strlen($file_type) > 1) + if (is_string($mime) && preg_match($regexp, $mime, $matches)) { - $this->file_type = $file_type; + $this->file_type = $matches[1]; return; } } } - // Fall back to the deprecated mime_content_type(), if available - if (function_exists('mime_content_type')) + /* This is an ugly hack, but UNIX-type systems provide a "native" way to detect the file type, + * which is still more secure than depending on the value of $_FILES[$field]['type'], and as it + * was reported in issue #750 (https://github.com/EllisLab/CodeIgniter/issues/750) - it's better + * than mime_content_type() as well, hence the attempts to try calling the command line with + * three different functions. + * + * Notes: + * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system + * - many system admins would disable the exec(), shell_exec(), popen() and similar functions + * due to security concerns, hence the function_exists() checks + */ + if (DIRECTORY_SEPARATOR !== '\\') { - $this->file_type = @mime_content_type($file['tmp_name']); - if (strlen($this->file_type) > 0) // Turns out it's possible that mime_content_type() returns FALSE or an empty string + $cmd = 'file --brief --mime ' . escapeshellarg($file['tmp_name']) . ' 2>&1'; + + if (function_exists('exec')) { - return; + /* This might look confusing, as $mime is being populated with all of the output when set in the second parameter. + * However, we only neeed the last line, which is the actual return value of exec(), and as such - it overwrites + * anything that could already be set for $mime previously. This effectively makes the second parameter a dummy + * value, which is only put to allow us to get the return status code. + */ + $mime = @exec($cmd, $mime, $return_status); + if ($return_status === 0 && is_string($mime) && preg_match($regexp, $mime, $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + + if ( (bool) @ini_get('safe_mode') === FALSE && function_exists('shell_exec')) + { + $mime = @shell_exec($cmd); + if (strlen($mime) > 0) + { + $mime = explode("\n", trim($mime)); + if (preg_match($regexp, $mime[(count($mime) - 1)], $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + } + + if (function_exists('popen')) + { + $proc = @popen($cmd, 'r'); + if (is_resource($proc)) + { + $mime = @fread($test, 512); + @pclose($proc); + if ($mime !== FALSE) + { + $mime = explode("\n", trim($mime)); + if (preg_match($regexp, $mime[(count($mime) - 1)], $matches)) + { + $this->file_type = $matches[1]; + return; + } + } + } } } - /* This is an ugly hack, but UNIX-type systems provide a native way to detect the file type, - * which is still more secure than depending on the value of $_FILES[$field]['type']. - * - * Notes: - * - the DIRECTORY_SEPARATOR comparison ensures that we're not on a Windows system - * - many system admins would disable the exec() function due to security concerns, hence the function_exists() check - */ - if (DIRECTORY_SEPARATOR !== '\\' && function_exists('exec')) + // Fall back to the deprecated mime_content_type(), if available (still better than $_FILES[$field]['type']) + if (function_exists('mime_content_type')) { - $output = array(); - @exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code); - if ($return_code === 0 && strlen($output[0]) > 0) // A return status code != 0 would mean failed execution + $this->file_type = @mime_content_type($file['tmp_name']); + if (strlen($this->file_type) > 0) // It's possible that mime_content_type() returns FALSE or an empty string { - $this->file_type = rtrim($output[0]); return; } } -- cgit v1.2.3-24-g4f1b From 750ffb9f6d545772c7139b5ee0c1402241c6ceb2 Mon Sep 17 00:00:00 2001 From: Andrew Mackrodt Date: Sat, 10 Dec 2011 23:42:07 +0000 Subject: Fix for Issue #538. --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 8902f524d..7f905128b 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -208,7 +208,7 @@ class CI_Image_lib { } else { - if (strpos($this->new_image, '/') === FALSE) + if (strpos($this->new_image, '/') === FALSE AND strpos($this->new_image, '\\') === FALSE) { $this->dest_folder = $this->source_folder; $this->dest_image = $this->new_image; -- cgit v1.2.3-24-g4f1b From 3b6ff4ddc5ca433ba7b68a51a617c00b93511889 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 11 Dec 2011 14:57:36 +0200 Subject: Fix regular expression for validating MIME type string --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 564d6000e..c72fa3c6d 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1019,7 +1019,7 @@ class CI_Upload { protected function _file_mime_type($file) { // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) - $regexp = '/^([a-z\-]+\/[a-z0-9\-]+);\s.+$/'; + $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+);\s.+$/'; /* Fileinfo extension - most reliable method * -- cgit v1.2.3-24-g4f1b From f7aed129051475b4baeeb549a764464560c9dd34 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 13 Dec 2011 11:01:06 +0200 Subject: Tweak MIME regular expression check again --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index c72fa3c6d..91fbf66ca 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1019,7 +1019,7 @@ class CI_Upload { protected function _file_mime_type($file) { // We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii) - $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+);\s.+$/'; + $regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/'; /* Fileinfo extension - most reliable method * -- cgit v1.2.3-24-g4f1b From 8bd8f687827454f83a5512b96bb0f632178a08a6 Mon Sep 17 00:00:00 2001 From: dixy Date: Mon, 19 Dec 2011 22:26:12 +0100 Subject: Prev link and 1 link don't have the same url with use_page_numbers=TRUE --- system/libraries/Pagination.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index eea953ae4..cc73e0d2f 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -236,13 +236,13 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page; - if (($i == 0 OR ($this->use_page_numbers && $i == 1)) AND $this->first_url != '') + if ($i == $base_page AND $this->first_url != '') { $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->first_url.'">'.$this->prev_link.''.$this->prev_tag_close; } else { - $i = ($i == 0) ? '' : $this->prefix.$i.$this->suffix; + $i = ($i == $base_page) ? '' : $this->prefix.$i.$this->suffix; $output .= $this->prev_tag_open.'anchor_class.'href="'.$this->base_url.$i.'">'.$this->prev_link.''.$this->prev_tag_close; } -- cgit v1.2.3-24-g4f1b From 8dc532d3aead6debad4c6488330735d50b369b4d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 17:57:54 +0200 Subject: Improve the Form validation library --- system/libraries/Form_validation.php | 169 +++++++++++------------------------ 1 file changed, 50 insertions(+), 119 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 918f6904c..8173c6edf 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1,4 +1,4 @@ -_field_data) == 0) + if (count($this->_field_data) === 0) { // No validation rules? We're done... - if (count($this->_config_rules) == 0) + if (count($this->_config_rules) === 0) { return FALSE; } @@ -321,7 +320,7 @@ class CI_Form_validation { } // We're we able to set the rules correctly? - if (count($this->_field_data) == 0) + if (count($this->_field_data) === 0) { log_message('debug', "Unable to find validation rules"); return FALSE; @@ -338,7 +337,7 @@ class CI_Form_validation { // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. // Depending on whether the field name is an array or a string will determine where we get it from. - if ($row['is_array'] == TRUE) + if ($row['is_array'] === TRUE) { $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); } @@ -364,14 +363,7 @@ class CI_Form_validation { // Now we need to re-set the POST data with the new, processed data $this->_reset_post_array(); - // No errors, validation passes! - if ($total_errors == 0) - { - return TRUE; - } - - // Validation fails - return FALSE; + return ($total_errors === 0); } // -------------------------------------------------------------------- @@ -379,7 +371,7 @@ class CI_Form_validation { /** * Traverse a multidimensional $_POST array index until the data is found * - * @access private + * @access protected * @param array * @param array * @param integer @@ -387,23 +379,9 @@ class CI_Form_validation { */ protected function _reduce_array($array, $keys, $i = 0) { - if (is_array($array)) + if (is_array($array) && isset($keys[$i])) { - if (isset($keys[$i])) - { - if (isset($array[$keys[$i]])) - { - $array = $this->_reduce_array($array[$keys[$i]], $keys, ($i+1)); - } - else - { - return NULL; - } - } - else - { - return $array; - } + return isset($array[$keys[$i]]) ? $this->_reduce_array($array[$keys[$i]], $keys, ($i+1)) : NULL; } return $array; @@ -414,7 +392,7 @@ class CI_Form_validation { /** * Re-populate the _POST array with our finalized and processed data * - * @access private + * @access protected * @return null */ protected function _reset_post_array() @@ -423,7 +401,7 @@ class CI_Form_validation { { if ( ! is_null($row['postdata'])) { - if ($row['is_array'] == FALSE) + if ($row['is_array'] === FALSE) { if (isset($_POST[$row['field']])) { @@ -436,7 +414,7 @@ class CI_Form_validation { $post_ref =& $_POST; // before we assign values, make a reference to the right POST key - if (count($row['keys']) == 1) + if (count($row['keys']) === 1) { $post_ref =& $post_ref[current($row['keys'])]; } @@ -472,7 +450,7 @@ class CI_Form_validation { /** * Executes the Validation routines * - * @access private + * @access protected * @param array * @param array * @param mixed @@ -514,7 +492,7 @@ class CI_Form_validation { // -------------------------------------------------------------------- // Isset Test. Typically this rule will only apply to checkboxes. - if (is_null($postdata) AND $callback == FALSE) + if (is_null($postdata) AND $callback === FALSE) { if (in_array('isset', $rules, TRUE) OR in_array('required', $rules)) { @@ -605,7 +583,7 @@ class CI_Form_validation { $result = $this->CI->$rule($postdata, $param); // Re-assign the result to the master data array - if ($_in_array == TRUE) + if ($_in_array === TRUE) { $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; } @@ -630,7 +608,7 @@ class CI_Form_validation { { $result = $rule($postdata); - if ($_in_array == TRUE) + if ($_in_array === TRUE) { $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; } @@ -649,7 +627,7 @@ class CI_Form_validation { $result = $this->$rule($postdata, $param); - if ($_in_array == TRUE) + if ($_in_array === TRUE) { $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; } @@ -676,7 +654,7 @@ class CI_Form_validation { // Is the parameter we are inserting into the error message the name // of another field? If so we need to grab its "field label" - if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label'])) + if (isset($this->_field_data[$param], $this->_field_data[$param]['label'])) { $param = $this->_translate_fieldname($this->_field_data[$param]['label']); } @@ -702,7 +680,7 @@ class CI_Form_validation { /** * Translate a field name * - * @access private + * @access protected * @param string the field name * @return string */ @@ -710,7 +688,7 @@ class CI_Form_validation { { // Do we need to translate the field name? // We look for the prefix lang: to determine this - if (substr($fieldname, 0, 5) == 'lang:') + if (substr($fieldname, 0, 5) === 'lang:') { // Grab the variable $line = substr($fieldname, 5); @@ -858,33 +836,8 @@ class CI_Form_validation { */ public function set_checkbox($field = '', $value = '', $default = FALSE) { - if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) - { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' checked="checked"'; - } - return ''; - } - - $field = $this->_field_data[$field]['postdata']; - - if (is_array($field)) - { - if ( ! in_array($value, $field)) - { - return ''; - } - } - else - { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } - } - - return ' checked="checked"'; + // Logic is exactly the same as for radio fields + return $this->set_radio($field, $value, $default); } // -------------------------------------------------------------------- @@ -898,14 +851,7 @@ class CI_Form_validation { */ public function required($str) { - if ( ! is_array($str)) - { - return (trim($str) == '') ? FALSE : TRUE; - } - else - { - return ( ! empty($str)); - } + return ( ! is_array($str)) ? (trim($str) !== '') : ( ! empty($str)); } // -------------------------------------------------------------------- @@ -920,12 +866,7 @@ class CI_Form_validation { */ public function regex_match($str, $regex) { - if ( ! preg_match($regex, $str)) - { - return FALSE; - } - - return TRUE; + return (bool) preg_match($regex, $str); } // -------------------------------------------------------------------- @@ -947,7 +888,7 @@ class CI_Form_validation { $field = $_POST[$field]; - return ($str !== $field) ? FALSE : TRUE; + return ($str === $field); } // -------------------------------------------------------------------- @@ -969,7 +910,7 @@ class CI_Form_validation { return $query->num_rows() === 0; } return FALSE; - } + } // -------------------------------------------------------------------- @@ -990,10 +931,10 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) < $val) ? FALSE : TRUE; + return ! (mb_strlen($str) < $val); } - return (strlen($str) < $val) ? FALSE : TRUE; + return ! (strlen($str) < $val); } // -------------------------------------------------------------------- @@ -1015,10 +956,10 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) > $val) ? FALSE : TRUE; + return ! (mb_strlen($str) > $val); } - return (strlen($str) > $val) ? FALSE : TRUE; + return ! (strlen($str) > $val); } // -------------------------------------------------------------------- @@ -1040,10 +981,10 @@ class CI_Form_validation { if (function_exists('mb_strlen')) { - return (mb_strlen($str) != $val) ? FALSE : TRUE; + return (mb_strlen($str) == $val); } - return (strlen($str) != $val) ? FALSE : TRUE; + return (strlen($str) == $val); } // -------------------------------------------------------------------- @@ -1057,7 +998,7 @@ class CI_Form_validation { */ public function valid_email($str) { - return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; + return (bool) preg_match('/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix', $str); } // -------------------------------------------------------------------- @@ -1078,7 +1019,7 @@ class CI_Form_validation { foreach (explode(',', $str) as $email) { - if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) + if (trim($email) !== '' && $this->valid_email(trim($email)) === FALSE) { return FALSE; } @@ -1112,7 +1053,7 @@ class CI_Form_validation { */ public function alpha($str) { - return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; + return (bool) preg_match('/^[a-z]+$/i', $str); } // -------------------------------------------------------------------- @@ -1126,7 +1067,7 @@ class CI_Form_validation { */ public function alpha_numeric($str) { - return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; + return (bool) preg_match('/^[a-z0-9]+$/i', $str); } // -------------------------------------------------------------------- @@ -1140,7 +1081,7 @@ class CI_Form_validation { */ public function alpha_dash($str) { - return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; + return (bool) preg_match('/^[a-z0-9_-]+$/i', $str); } // -------------------------------------------------------------------- @@ -1154,7 +1095,7 @@ class CI_Form_validation { */ public function numeric($str) { - return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); + return (bool) preg_match('/^[\-+]?[0-9]*\.?[0-9]+$/', $str); } @@ -1169,7 +1110,7 @@ class CI_Form_validation { */ public function is_numeric($str) { - return ( ! is_numeric($str)) ? FALSE : TRUE; + return is_numeric($str); } // -------------------------------------------------------------------- @@ -1247,7 +1188,7 @@ class CI_Form_validation { */ public function is_natural($str) { - return (bool) preg_match( '/^[0-9]+$/', $str); + return (bool) preg_match('/^[0-9]+$/', $str); } // -------------------------------------------------------------------- @@ -1261,17 +1202,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - if ( ! preg_match( '/^[0-9]+$/', $str)) - { - return FALSE; - } - - if ($str == 0) - { - return FALSE; - } - - return TRUE; + return ($str != 0 AND preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- @@ -1339,7 +1270,7 @@ class CI_Form_validation { return ''; } - if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') + if (substr($str, 0, 7) !== 'http://' && substr($str, 0, 8) !== 'https://') { $str = 'http://'.$str; } -- cgit v1.2.3-24-g4f1b From a92b903c0e6c2faa2a9480e23e2d3e4b6308878f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 19:05:58 +0200 Subject: Improve the Image manipulation library --- system/libraries/Image_lib.php | 150 ++++++++++++++++------------------------- 1 file changed, 58 insertions(+), 92 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 20ca1f055..70a127987 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1,4 +1,4 @@ -y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis; // Watermark-related Stuff... - if ($this->wm_font_color != '') + if ($this->wm_font_color != '' AND strlen($this->wm_font_color) === 6) { - if (strlen($this->wm_font_color) == 6) - { - $this->wm_font_color = '#'.$this->wm_font_color; - } + $this->wm_font_color = '#'.$this->wm_font_color; } - if ($this->wm_shadow_color != '') + if ($this->wm_shadow_color != '' AND strlen($this->wm_shadow_color) === 6) { - if (strlen($this->wm_shadow_color) == 6) - { - $this->wm_shadow_color = '#'.$this->wm_shadow_color; - } + $this->wm_shadow_color = '#'.$this->wm_shadow_color; } if ($this->wm_overlay_path != '') @@ -381,13 +375,7 @@ class CI_Image_lib { */ public function resize() { - $protocol = 'image_process_'.$this->image_library; - - if (preg_match('/gd2$/i', $protocol)) - { - $protocol = 'image_process_gd'; - } - + $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('resize'); } @@ -404,13 +392,7 @@ class CI_Image_lib { */ public function crop() { - $protocol = 'image_process_'.$this->image_library; - - if (preg_match('/gd2$/i', $protocol)) - { - $protocol = 'image_process_gd'; - } - + $protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library; return $this->$protocol('crop'); } @@ -453,7 +435,6 @@ class CI_Image_lib { if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm') { $protocol = 'image_process_'.$this->image_library; - return $this->$protocol('rotate'); } @@ -484,20 +465,14 @@ class CI_Image_lib { // If the target width/height match the source, AND if the new file name is not equal to the old file name // we'll simply make a copy of the original with the new name... assuming dynamic rendering is off. - if ($this->dynamic_output === FALSE) + if ($this->dynamic_output === FALSE AND $this->orig_width == $this->width AND $this->orig_height == $this->height) { - if ($this->orig_width == $this->width AND $this->orig_height == $this->height) + if ($this->source_image != $this->new_image AND @copy($this->full_src_path, $this->full_dst_path)) { - if ($this->source_image != $this->new_image) - { - if (@copy($this->full_src_path, $this->full_dst_path)) - { - @chmod($this->full_dst_path, FILE_WRITE_MODE); - } - } - - return TRUE; + @chmod($this->full_dst_path, FILE_WRITE_MODE); } + + return TRUE; } // Let's set up our values based on the action @@ -601,9 +576,7 @@ class CI_Image_lib { if ( ! preg_match("/convert$/i", $this->library_path)) { - $this->library_path = rtrim($this->library_path, '/').'/'; - - $this->library_path .= 'convert'; + $this->library_path = rtrim($this->library_path, '/').'/convert'; } // Execute the command @@ -808,11 +781,8 @@ class CI_Image_lib { if ($this->rotation_angle == 'hor') { - for ($i = 0; $i < $height; $i++) + for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1) { - $left = 0; - $right = $width-1; - while ($left < $right) { $cl = imagecolorat($src_img, $left, $i); @@ -828,11 +798,8 @@ class CI_Image_lib { } else { - for ($i = 0; $i < $width; $i++) + for ($i = 0; $i < $width; $i++, $top = 0, $bot = $height-1) { - $top = 0; - $bot = $height-1; - while ($top < $bot) { $ct = imagecolorat($src_img, $i, $top); @@ -993,12 +960,9 @@ class CI_Image_lib { { $this->image_display_gd($src_img); } - else + elseif ( ! $this->image_save_gd($src_img)) { - if ( ! $this->image_save_gd($src_img)) - { - return FALSE; - } + return FALSE; } imagedestroy($src_img); @@ -1065,7 +1029,9 @@ class CI_Image_lib { if ($this->wm_use_truetype == TRUE) { if ($this->wm_font_size == '') - $this->wm_font_size = '17'; + { + $this->wm_font_size = 17; + } $fontwidth = $this->wm_font_size-($this->wm_font_size/4); $fontheight = $this->wm_font_size; @@ -1090,11 +1056,11 @@ class CI_Image_lib { switch ($this->wm_vrt_alignment) { - case "T" : + case 'T': break; - case "M": $y_axis += ($this->orig_height/2)+($fontheight/2); + case 'M': $y_axis += ($this->orig_height/2)+($fontheight/2); break; - case "B": $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2)); + case 'B': $y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2)); break; } @@ -1104,32 +1070,34 @@ class CI_Image_lib { // Set horizontal alignment switch ($this->wm_hor_alignment) { - case "L": + case 'L': break; - case "R": - if ($this->wm_use_drop_shadow) - $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text)); - $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + case 'R': + if ($this->wm_use_drop_shadow) + { + $x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + $x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text)); + } break; - case "C": - if ($this->wm_use_drop_shadow) - $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); - $x_axis += floor(($this->orig_width -$fontwidth*strlen($this->wm_text))/2); + case 'C': + if ($this->wm_use_drop_shadow) + { + $x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); + $x_axis += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2); + } break; } // Add the text to the source image - if ($this->wm_use_truetype) + if ($this->wm_use_truetype AND $this->wm_use_drop_shadow) { - if ($this->wm_use_drop_shadow) - imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); - imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); + imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text); + imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text); } - else + elseif ($this->wm_use_drop_shadow) { - if ($this->wm_use_drop_shadow) - imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); - imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); + imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color); + imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color); } // Output the final image @@ -1369,26 +1337,24 @@ class CI_Image_lib { } $vals = getimagesize($path); - $types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png'); - - $mime = (isset($types[$vals['2']])) ? 'image/'.$types[$vals['2']] : 'image/jpg'; + $mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg'; if ($return == TRUE) { - $v['width'] = $vals['0']; - $v['height'] = $vals['1']; - $v['image_type'] = $vals['2']; - $v['size_str'] = $vals['3']; - $v['mime_type'] = $mime; - - return $v; + return array( + 'width' => $vals[0], + 'height' => $vals[1], + 'image_type' => $vals[2], + 'size_str' => $vals[3], + 'mime_type' => $mime + ); } - $this->orig_width = $vals['0']; - $this->orig_height = $vals['1']; - $this->image_type = $vals['2']; - $this->size_str = $vals['3']; + $this->orig_width = $vals[0]; + $this->orig_height = $vals[1]; + $this->image_type = $vals[2]; + $this->size_str = $vals[3]; $this->mime_type = $mime; return TRUE; @@ -1482,10 +1448,10 @@ class CI_Image_lib { { if ( ! extension_loaded('gd')) { - if ( ! dl('gd.so')) - { - return FALSE; - } + /* As it is stated in the PHP manual, dl() is not always available + * and even if so - it could generate an E_WARNING message on failure + */ + return (function_exists('dl') AND @dl('gd.so')); } return TRUE; -- cgit v1.2.3-24-g4f1b From 33987e6a318eaf853f626f950573601928547f8f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 24 Dec 2011 19:48:45 +0200 Subject: Improve the Pagination library --- system/libraries/Pagination.php | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index eea953ae4..008c15192 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -1,4 +1,4 @@ -total_rows / $this->per_page); // Is there only one page? Hm... nothing more to do here then. - if ($num_pages == 1) + if ($num_pages === 1) { return ''; } @@ -146,25 +146,16 @@ class CI_Pagination { { if ($CI->input->get($this->query_string_segment) != $base_page) { - $this->cur_page = $CI->input->get($this->query_string_segment); - - // Prep the current page - no funny business! - $this->cur_page = (int) $this->cur_page; + $this->cur_page = (int) $CI->input->get($this->query_string_segment); } } - else + elseif ($CI->uri->segment($this->uri_segment) != $base_page) { - if ($CI->uri->segment($this->uri_segment) != $base_page) - { - $this->cur_page = $CI->uri->segment($this->uri_segment); - - // Prep the current page - no funny business! - $this->cur_page = (int) $this->cur_page; - } + $this->cur_page = (int) $CI->uri->segment($this->uri_segment); } - // Set current page to 1 if using page numbers instead of offset - if ($this->use_page_numbers AND $this->cur_page == 0) + // Set current page to 1 if it's not valid or if using page numbers instead of offset + if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers AND $this->cur_page == 0)) { $this->cur_page = $base_page; } @@ -176,11 +167,6 @@ class CI_Pagination { show_error('Your number of links must be a positive number.'); } - if ( ! is_numeric($this->cur_page)) - { - $this->cur_page = $base_page; - } - // Is the page number beyond the result range? // If so we show the last page if ($this->use_page_numbers) @@ -310,4 +296,4 @@ class CI_Pagination { // END Pagination Class /* End of file Pagination.php */ -/* Location: ./system/libraries/Pagination.php */ \ No newline at end of file +/* Location: ./system/libraries/Pagination.php */ -- cgit v1.2.3-24-g4f1b From 195d311796072477c5808ce99688abae1512b696 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 03:59:13 +0200 Subject: Improve the Profiler library --- system/libraries/Profiler.php | 225 +++++++++++++++--------------------------- 1 file changed, 81 insertions(+), 144 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 8a2568d8e..9cbd69bb2 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -1,13 +1,13 @@ -CI->benchmark->marker[$match[1].'_end'], $this->CI->benchmark->marker[$match[1].'_start'])) { - if (isset($this->CI->benchmark->marker[$match[1].'_end']) AND isset($this->CI->benchmark->marker[$match[1].'_start'])) - { - $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); - } + $profile[$match[1]] = $this->CI->benchmark->elapsed_time($match[1].'_start', $key); } } @@ -139,12 +137,11 @@ class CI_Profiler { // Note: At some point we should turn this into a template that can // be modified. We also might want to make this data available to be logged - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_benchmarks').'  '; - $output .= "\n"; - $output .= "\n\n\n"; + $output = "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_benchmarks').'  ' + . "\n\n\n
\n"; foreach ($profile as $key => $val) { @@ -152,10 +149,7 @@ class CI_Profiler { $output .= "\n"; } - $output .= "
".$key."  ".$val."
\n"; - $output .= "
"; - - return $output; + return $output."\n"; } // -------------------------------------------------------------------- @@ -178,19 +172,16 @@ class CI_Profiler { } } - if (count($dbs) == 0) + if (count($dbs) === 0) { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_queries').'  '; - $output .= "\n"; - $output .= "\n\n\n"; - $output .="\n"; - $output .= "
".$this->CI->lang->line('profiler_no_db')."
\n"; - $output .= "
"; - - return $output; + return "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_queries').'  ' + . "\n\n\n\n" + . '\n
' + . $this->CI->lang->line('profiler_no_db') + . "
\n
"; } // Load the text helper so we can highlight the SQL @@ -205,8 +196,6 @@ class CI_Profiler { foreach ($dbs as $db) { - $count++; - $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; @@ -216,13 +205,12 @@ class CI_Profiler { $show_hide_js = '('.$this->CI->lang->line('profiler_section_show').')'; } - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_database').':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'  '.$show_hide_js.''; - $output .= "\n"; - $output .= "\n\n\n"; + $output .= '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_database').':  '.$db->database.'   '.$this->CI->lang->line('profiler_queries').': '.count($db->queries).'  '.$show_hide_js.'' + . "\n\n\n
\n"; - if (count($db->queries) == 0) + if (count($db->queries) === 0) { $output .= "\n"; } @@ -243,8 +231,7 @@ class CI_Profiler { } } - $output .= "
".$this->CI->lang->line('profiler_no_queries')."
\n"; - $output .= "
"; + $output .= "\n"; } @@ -261,13 +248,13 @@ class CI_Profiler { */ protected function _compile_get() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_get_data').'  '; - $output .= "\n"; + $output = "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_get_data').'  ' + . "\n"; - if (count($_GET) == 0) + if (count($_GET) === 0) { $output .= "
".$this->CI->lang->line('profiler_no_get')."
"; } @@ -282,23 +269,15 @@ class CI_Profiler { $key = "'".$key."'"; } - $output .= "$_GET[".$key."]   "; - if (is_array($val)) - { - $output .= "
" . htmlspecialchars(stripslashes(print_r($val, true))) . "
"; - } - else - { - $output .= htmlspecialchars(stripslashes($val)); - } - $output .= "\n"; + $output .= "$_GET[".$key."]   " + . (is_array($val) ? "
" . htmlspecialchars(stripslashes(print_r($val, true))) . "
" : htmlspecialchars(stripslashes($val))) + . "\n"; } $output .= "\n"; } - $output .= "
"; - return $output; + return $output.'
'; } // -------------------------------------------------------------------- @@ -310,11 +289,11 @@ class CI_Profiler { */ protected function _compile_post() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_post_data').'  '; - $output .= "\n"; + $output = "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_post_data').'  ' + . "\n"; if (count($_POST) == 0) { @@ -345,9 +324,8 @@ class CI_Profiler { $output .= "\n"; } - $output .= "
"; - return $output; + return $output.'
'; } // -------------------------------------------------------------------- @@ -359,24 +337,13 @@ class CI_Profiler { */ protected function _compile_uri_string() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_uri_string').'  '; - $output .= "\n"; - - if ($this->CI->uri->uri_string == '') - { - $output .= "
".$this->CI->lang->line('profiler_no_uri')."
"; - } - else - { - $output .= "
".$this->CI->uri->uri_string."
"; - } - - $output .= "
"; - - return $output; + return "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_uri_string').'  ' + . "\n
" + . ($this->CI->uri->uri_string == '' ? $this->CI->lang->line('profiler_no_uri') : $this->CI->uri->uri_string) + . '
'; } // -------------------------------------------------------------------- @@ -388,17 +355,12 @@ class CI_Profiler { */ protected function _compile_controller_info() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_controller_info').'  '; - $output .= "\n"; - - $output .= "
".$this->CI->router->fetch_class()."/".$this->CI->router->fetch_method()."
"; - - $output .= "
"; - - return $output; + return "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_controller_info').'  ' + . "\n
".$this->CI->router->fetch_class().'/'.$this->CI->router->fetch_method() + . '
'; } // -------------------------------------------------------------------- @@ -412,24 +374,13 @@ class CI_Profiler { */ protected function _compile_memory_usage() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_memory_usage').'  '; - $output .= "\n"; - - if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') - { - $output .= "
".number_format($usage).' bytes
'; - } - else - { - $output .= "
".$this->CI->lang->line('profiler_no_memory')."
"; - } - - $output .= "
"; - - return $output; + return "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_memory_usage').'  ' + . "\n
" + . ((function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') ? number_format($usage).' bytes' : $this->CI->lang->line('profiler_no_memory')) + . '
'; } // -------------------------------------------------------------------- @@ -443,13 +394,11 @@ class CI_Profiler { */ protected function _compile_http_headers() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_headers').'  ('.$this->CI->lang->line('profiler_section_show').')'; - $output .= "\n"; - - $output .= "\n\n\n"; + $output = "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_headers').'  ('.$this->CI->lang->line('profiler_section_show').')' + . "\n\n\n
\n"; foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) { @@ -457,10 +406,7 @@ class CI_Profiler { $output .= "\n"; } - $output .= "\n"; - $output .= "
"; - - return $output; + return $output."\n"; } // -------------------------------------------------------------------- @@ -474,13 +420,11 @@ class CI_Profiler { */ protected function _compile_config() { - $output = "\n\n"; - $output .= '
'; - $output .= "\n"; - $output .= '  '.$this->CI->lang->line('profiler_config').'  ('.$this->CI->lang->line('profiler_section_show').')'; - $output .= "\n"; - - $output .= "\n\n\n"; + $output = "\n\n" + . '
' + . "\n" + . '  '.$this->CI->lang->line('profiler_config').'  ('.$this->CI->lang->line('profiler_section_show').')' + . "\n\n\n
\n"; foreach ($this->CI->config->config as $config=>$val) { @@ -492,10 +436,7 @@ class CI_Profiler { $output .= "\n"; } - $output .= "\n"; - $output .= "
"; - - return $output; + return $output."\n"; } // -------------------------------------------------------------------- @@ -512,9 +453,9 @@ class CI_Profiler { return; } - $output = '
'; - $output .= '  '.$this->CI->lang->line('profiler_session_data').'  ('.$this->CI->lang->line('profiler_section_show').')'; - $output .= ""; + $output = '
' + . '  '.$this->CI->lang->line('profiler_session_data').'  ('.$this->CI->lang->line('profiler_section_show').')' + . "
"; foreach ($this->CI->session->all_userdata() as $key => $val) { @@ -526,9 +467,7 @@ class CI_Profiler { $output .= "\n"; } - $output .= ''; - $output .= "
"; - return $output; + return $output."\n"; } // -------------------------------------------------------------------- @@ -553,14 +492,12 @@ class CI_Profiler { } } - if ($fields_displayed == 0) + if ($fields_displayed === 0) { $output .= '

'.$this->CI->lang->line('profiler_no_profiles').'

'; } - $output .= ''; - - return $output; + return $output.''; } } -- cgit v1.2.3-24-g4f1b From 57ffbbb98558be7dd4639b47e637c09fffb37dcb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 04:48:47 +0200 Subject: Improve the Session library --- system/libraries/Session.php | 149 +++++++++++++++++++------------------------ 1 file changed, 66 insertions(+), 83 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 08d2ba4ba..ada97a032 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -1,13 +1,13 @@ -sess_expiration = (60*60*24*365*2); } - + // Set the cookie name $this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name; @@ -144,7 +144,7 @@ class CI_Session { * @access public * @return bool */ - function sess_read() + public function sess_read() { // Fetch the cookie $session = $this->CI->input->cookie($this->sess_cookie_name); @@ -194,14 +194,14 @@ class CI_Session { } // Does the IP Match? - if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address()) + if ($this->sess_match_ip == TRUE AND $session['ip_address'] !== $this->CI->input->ip_address()) { $this->sess_destroy(); return FALSE; } // Does the User Agent Match? - if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 120))) + if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; @@ -225,7 +225,7 @@ class CI_Session { $query = $this->CI->db->get($this->sess_table_name); // No result? Kill it! - if ($query->num_rows() == 0) + if ($query->num_rows() === 0) { $this->sess_destroy(); return FALSE; @@ -262,7 +262,7 @@ class CI_Session { * @access public * @return void */ - function sess_write() + public function sess_write() { // Are we saving custom data to the DB? If not, all we do is update the cookie if ($this->sess_use_database === FALSE) @@ -314,13 +314,14 @@ class CI_Session { * @access public * @return void */ - function sess_create() + public function sess_create() { $sessid = ''; - while (strlen($sessid) < 32) + do { $sessid .= mt_rand(0, mt_getrandmax()); } + while (strlen($sessid) < 32); // To make the session ID even more secure we'll combine it with the user's IP $sessid .= $this->CI->input->ip_address(); @@ -352,7 +353,7 @@ class CI_Session { * @access public * @return void */ - function sess_update() + public function sess_update() { // We only update the session every five minutes by default if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now) @@ -364,19 +365,17 @@ class CI_Session { // update in the database if we need it $old_sessid = $this->userdata['session_id']; $new_sessid = ''; - while (strlen($new_sessid) < 32) + do { $new_sessid .= mt_rand(0, mt_getrandmax()); } + while (strlen($new_sessid) < 32); // To make the session ID even more secure we'll combine it with the user's IP $new_sessid .= $this->CI->input->ip_address(); - // Turn it into a hash - $new_sessid = md5(uniqid($new_sessid, TRUE)); - - // Update the session data in the session data array - $this->userdata['session_id'] = $new_sessid; + // Turn it into a hash and update the session data array + $this->userdata['session_id'] = $new_sessid = md5(uniqid($new_sessid, TRUE)); $this->userdata['last_activity'] = $this->now; // _set_cookie() will handle this for us if we aren't using database sessions @@ -408,7 +407,7 @@ class CI_Session { * @access public * @return void */ - function sess_destroy() + public function sess_destroy() { // Kill the session DB row if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id'])) @@ -437,7 +436,7 @@ class CI_Session { * @param string * @return string */ - function userdata($item) + public function userdata($item) { return ( ! isset($this->userdata[$item])) ? FALSE : $this->userdata[$item]; } @@ -450,7 +449,7 @@ class CI_Session { * @access public * @return array */ - function all_userdata() + public function all_userdata() { return $this->userdata; } @@ -465,7 +464,7 @@ class CI_Session { * @param string * @return void */ - function set_userdata($newdata = array(), $newval = '') + public function set_userdata($newdata = array(), $newval = '') { if (is_string($newdata)) { @@ -491,7 +490,7 @@ class CI_Session { * @access array * @return void */ - function unset_userdata($newdata = array()) + public function unset_userdata($newdata = array()) { if (is_string($newdata)) { @@ -520,7 +519,7 @@ class CI_Session { * @param string * @return void */ - function set_flashdata($newdata = array(), $newval = '') + public function set_flashdata($newdata = array(), $newval = '') { if (is_string($newdata)) { @@ -531,8 +530,7 @@ class CI_Session { { foreach ($newdata as $key => $val) { - $flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($flashdata_key, $val); + $this->set_userdata($this->flashdata_key.':new:'.$key, $val); } } } @@ -546,17 +544,15 @@ class CI_Session { * @param string * @return void */ - function keep_flashdata($key) + public function keep_flashdata($key) { // 'old' flashdata gets removed. Here we mark all // flashdata as 'new' to preserve it from _flashdata_sweep() // Note the function will return FALSE if the $key // provided cannot be found - $old_flashdata_key = $this->flashdata_key.':old:'.$key; - $value = $this->userdata($old_flashdata_key); + $value = $this->userdata($this->flashdata_key.':old:'.$key); - $new_flashdata_key = $this->flashdata_key.':new:'.$key; - $this->set_userdata($new_flashdata_key, $value); + $this->set_userdata($this->flashdata_key.':new:'.$key, $value); } // ------------------------------------------------------------------------ @@ -568,10 +564,9 @@ class CI_Session { * @param string * @return string */ - function flashdata($key) + public function flashdata($key) { - $flashdata_key = $this->flashdata_key.':old:'.$key; - return $this->userdata($flashdata_key); + return $this->userdata($this->flashdata_key.':old:'.$key); } // ------------------------------------------------------------------------ @@ -583,7 +578,7 @@ class CI_Session { * @access private * @return void */ - function _flashdata_mark() + private function _flashdata_mark() { $userdata = $this->all_userdata(); foreach ($userdata as $name => $value) @@ -591,8 +586,7 @@ class CI_Session { $parts = explode(':new:', $name); if (is_array($parts) && count($parts) === 2) { - $new_name = $this->flashdata_key.':old:'.$parts[1]; - $this->set_userdata($new_name, $value); + $this->set_userdata($this->flashdata_key.':old:'.$parts[1], $value); $this->unset_userdata($name); } } @@ -607,7 +601,7 @@ class CI_Session { * @return void */ - function _flashdata_sweep() + private function _flashdata_sweep() { $userdata = $this->all_userdata(); foreach ($userdata as $key => $value) @@ -628,19 +622,11 @@ class CI_Session { * @access private * @return string */ - function _get_time() + private function _get_time() { - if (strtolower($this->time_reference) == 'gmt') - { - $now = time(); - $time = mktime(gmdate("H", $now), gmdate("i", $now), gmdate("s", $now), gmdate("m", $now), gmdate("d", $now), gmdate("Y", $now)); - } - else - { - $time = time(); - } - - return $time; + $now = time(); + return (strtolower($this->time_reference) === 'gmt') ? + mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), gmdate('d', $now), gmdate('Y', $now)) : $now; } // -------------------------------------------------------------------- @@ -651,7 +637,7 @@ class CI_Session { * @access public * @return void */ - function _set_cookie($cookie_data = NULL) + private function _set_cookie($cookie_data = NULL) { if (is_null($cookie_data)) { @@ -696,22 +682,19 @@ class CI_Session { * @param array * @return string */ - function _serialize($data) + private function _serialize($data) { if (is_array($data)) { array_walk_recursive($data, array(&$this, '_escape_slashes')); } - else + elseif (is_string($data)) { - if (is_string($data)) - { - $data = str_replace('\\', '{{slash}}', $data); - } + $data = str_replace('\\', '{{slash}}', $data); } return serialize($data); } - + /** * Escape slashes * @@ -739,7 +722,7 @@ class CI_Session { * @param array * @return string */ - function _unserialize($data) + private function _unserialize($data) { $data = @unserialize(strip_slashes($data)); @@ -751,7 +734,7 @@ class CI_Session { return (is_string($data)) ? str_replace('{{slash}}', '\\', $data) : $data; } - + /** * Unescape slashes * @@ -759,7 +742,7 @@ class CI_Session { * * @access private */ - function _unescape_slashes(&$val, $key) + private function _unescape_slashes(&$val, $key) { if (is_string($val)) { @@ -778,7 +761,7 @@ class CI_Session { * @access public * @return void */ - function _sess_gc() + private function _sess_gc() { if ($this->sess_use_database != TRUE) { @@ -802,4 +785,4 @@ class CI_Session { // END Session Class /* End of file Session.php */ -/* Location: ./system/libraries/Session.php */ \ No newline at end of file +/* Location: ./system/libraries/Session.php */ -- cgit v1.2.3-24-g4f1b From 5c1aa631c5f5ec2f6b75ba1158178418e50ba11a Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 25 Dec 2011 01:24:29 -0600 Subject: Abstracting the loading of files in the config directory depending on environments. --- system/libraries/Upload.php | 15 +++++---------- system/libraries/User_agent.php | 13 ++++--------- 2 files changed, 9 insertions(+), 19 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 826bcceb8..5108afa1b 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -952,17 +952,12 @@ class CI_Upload { { global $mimes; - if (count($this->mimes) == 0) + if (count($this->mimes) === 0) { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); - } - elseif (is_file(APPPATH.'config/mimes.php')) - { - include(APPPATH.'config//mimes.php'); - } - else + load_environ_config('mimes'); + + // Return FALSE if we still have no mimes after trying to load them up. + if (count($this->mimes) === 0) { return FALSE; } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a007acec8..4a29d7d94 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -96,15 +96,10 @@ class CI_User_agent { */ private function _load_agent_file() { - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); - } - elseif (is_file(APPPATH.'config/user_agents.php')) - { - include(APPPATH.'config/user_agents.php'); - } - else + load_environ_config('user_agents'); + + // Return FALSE if we still have no mimes after trying to load them up. + if (count($this->mimes) === 0) { return FALSE; } -- cgit v1.2.3-24-g4f1b From fe9b9a96b4aacc54765190c1c3fc01271d361c36 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 16:11:01 +0200 Subject: Improve the Table library --- system/libraries/Table.php | 109 +++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 63 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 8d0e11a43..fb410e9fd 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -1,13 +1,13 @@ -heading = $this->_prep_args($args); @@ -103,9 +103,9 @@ class CI_Table { * @param int * @return void */ - function make_columns($array = array(), $col_limit = 0) + public function make_columns($array = array(), $col_limit = 0) { - if ( ! is_array($array) OR count($array) == 0) + if ( ! is_array($array) OR count($array) === 0) { return FALSE; } @@ -120,7 +120,7 @@ class CI_Table { } $new = array(); - while (count($array) > 0) + do { $temp = array_splice($array, 0, $col_limit); @@ -134,6 +134,7 @@ class CI_Table { $new[] = $temp; } + while (count($array) > 0); return $new; } @@ -149,7 +150,7 @@ class CI_Table { * @param mixed * @return void */ - function set_empty($value) + public function set_empty($value) { $this->empty_cells = $value; } @@ -165,7 +166,7 @@ class CI_Table { * @param mixed * @return void */ - function add_row() + public function add_row() { $args = func_get_args(); $this->rows[] = $this->_prep_args($args); @@ -178,16 +179,16 @@ class CI_Table { * * Ensures a standard associative array format for all cell data * - * @access public + * @access private * @param type * @return type */ - function _prep_args($args) + private function _prep_args($args) { // If there is no $args[0], skip this and treat as an associative array // This can happen if there is only a single key, for example this is passed to table->generate // array(array('foo'=>'bar')) - if (isset($args[0]) AND (count($args) == 1 && is_array($args[0]))) + if (isset($args[0]) AND (count($args) === 1 && is_array($args[0]))) { // args sent as indexed array if ( ! isset($args[0]['data'])) @@ -228,7 +229,7 @@ class CI_Table { * @param string * @return void */ - function set_caption($caption) + public function set_caption($caption) { $this->caption = $caption; } @@ -242,7 +243,7 @@ class CI_Table { * @param mixed * @return string */ - function generate($table_data = NULL) + public function generate($table_data = NULL) { // The table data can optionally be passed to this function // either as a database result object or an array @@ -254,13 +255,13 @@ class CI_Table { } elseif (is_array($table_data)) { - $set_heading = (count($this->heading) == 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE; + $set_heading = (count($this->heading) === 0 AND $this->auto_heading == FALSE) ? FALSE : TRUE; $this->_set_from_array($table_data, $set_heading); } } // Is there anything to display? No? Smite them! - if (count($this->heading) == 0 AND count($this->rows) == 0) + if (count($this->heading) === 0 AND count($this->rows) === 0) { return 'Undefined table data'; } @@ -273,24 +274,18 @@ class CI_Table { // Build the table! - $out = $this->template['table_open']; - $out .= $this->newline; + $out = $this->template['table_open'].$this->newline; // Add any caption here if ($this->caption) { - $out .= $this->newline; - $out .= '' . $this->caption . ''; - $out .= $this->newline; + $out .= $this->newline.''.$this->caption.''.$this->newline; } // Is there a table heading to display? if (count($this->heading) > 0) { - $out .= $this->template['thead_open']; - $out .= $this->newline; - $out .= $this->template['heading_row_start']; - $out .= $this->newline; + $out .= $this->template['thead_open'].$this->newline.$this->template['heading_row_start'].$this->newline; foreach ($this->heading as $heading) { @@ -304,22 +299,16 @@ class CI_Table { } } - $out .= $temp; - $out .= isset($heading['data']) ? $heading['data'] : ''; - $out .= $this->template['heading_cell_end']; + $out .= $temp.(isset($heading['data']) ? $heading['data'] : '').$this->template['heading_cell_end']; } - $out .= $this->template['heading_row_end']; - $out .= $this->newline; - $out .= $this->template['thead_close']; - $out .= $this->newline; + $out .= $this->template['heading_row_end'].$this->newline.$this->template['thead_close'].$this->newline; } // Build the table rows if (count($this->rows) > 0) { - $out .= $this->template['tbody_open']; - $out .= $this->newline; + $out .= $this->template['tbody_open'].$this->newline; $i = 1; foreach ($this->rows as $row) @@ -332,8 +321,7 @@ class CI_Table { // We use modulus to alternate the row colors $name = (fmod($i++, 2)) ? '' : 'alt_'; - $out .= $this->template['row_'.$name.'start']; - $out .= $this->newline; + $out .= $this->template['row_'.$name.'start'].$this->newline; foreach ($row as $cell) { @@ -341,7 +329,7 @@ class CI_Table { foreach ($cell as $key => $val) { - if ($key != 'data') + if ($key !== 'data') { $temp = str_replace('template['cell_'.$name.'end']; } - $out .= $this->template['row_'.$name.'end']; - $out .= $this->newline; + $out .= $this->template['row_'.$name.'end'].$this->newline; } - $out .= $this->template['tbody_close']; - $out .= $this->newline; + $out .= $this->template['tbody_close'].$this->newline; } $out .= $this->template['table_close']; @@ -393,7 +379,7 @@ class CI_Table { * @access public * @return void */ - function clear() + public function clear() { $this->rows = array(); $this->heading = array(); @@ -405,11 +391,11 @@ class CI_Table { /** * Set table data from a database result object * - * @access public + * @access private * @param object * @return void */ - function _set_from_object($query) + private function _set_from_object($query) { if ( ! is_object($query)) { @@ -417,7 +403,7 @@ class CI_Table { } // First generate the headings from the table column names - if (count($this->heading) == 0) + if (count($this->heading) === 0) { if ( ! method_exists($query, 'list_fields')) { @@ -443,13 +429,13 @@ class CI_Table { /** * Set table data from an array * - * @access public + * @access private * @param array * @return void */ - function _set_from_array($data, $set_heading = TRUE) + private function _set_from_array($data, $set_heading = TRUE) { - if ( ! is_array($data) OR count($data) == 0) + if ( ! is_array($data) OR count($data) === 0) { return FALSE; } @@ -458,7 +444,7 @@ class CI_Table { foreach ($data as $row) { // If a heading hasn't already been set we'll use the first row of the array as the heading - if ($i == 0 AND count($data) > 1 AND count($this->heading) == 0 AND $set_heading == TRUE) + if ($i++ === 0 AND count($data) > 1 AND count($this->heading) === 0 AND $set_heading == TRUE) { $this->heading = $this->_prep_args($row); } @@ -466,8 +452,6 @@ class CI_Table { { $this->rows[] = $this->_prep_args($row); } - - $i++; } } @@ -479,7 +463,7 @@ class CI_Table { * @access private * @return void */ - function _compile_template() + private function _compile_template() { if ($this->template == NULL) { @@ -505,7 +489,7 @@ class CI_Table { * @access private * @return void */ - function _default_template() + private function _default_template() { return array ( 'table_open' => '', @@ -538,6 +522,5 @@ class CI_Table { } - /* End of file Table.php */ /* Location: ./system/libraries/Table.php */ -- cgit v1.2.3-24-g4f1b From d9cfa7bd39bfc88c09f88e63883fc3e8341d7f9d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 16:32:59 +0200 Subject: Improve the Trackback library --- system/libraries/Trackback.php | 49 +++++++++++++----------------------------- 1 file changed, 15 insertions(+), 34 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 1e5928314..4302634cc 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -1,4 +1,4 @@ -convert_ascii == TRUE) + if ($this->convert_ascii == TRUE && in_array($item, array('excerpt', 'title', 'blog_name'))) { - if ($item == 'excerpt') - { - $$item = $this->convert_ascii($$item); - } - elseif ($item == 'title') - { - $$item = $this->convert_ascii($$item); - } - elseif ($item == 'blog_name') - { - $$item = $this->convert_ascii($$item); - } + $$item = $this->convert_ascii($$item); } } @@ -280,15 +269,9 @@ class CI_Trackback { @fclose($fp); - if (stristr($this->response, '0') === FALSE) + if (stripos($this->response, '0') === FALSE) { - $message = 'An unknown error was encountered'; - - if (preg_match("/(.*?)<\/message>/is", $this->response, $match)) - { - $message = trim($match['1']); - } - + $message = (preg_match('/(.*?)<\/message>/is', $this->response, $match)) ? trim($match[1]) : 'An unknown error was encountered'; $this->set_error($message); return FALSE; } @@ -318,7 +301,7 @@ class CI_Trackback { $urls = str_replace(",,", ",", $urls); // Remove any comma that might be at the end - if (substr($urls, -1) == ",") + if (substr($urls, -1) === ',') { $urls = substr($urls, 0, -1); } @@ -349,9 +332,9 @@ class CI_Trackback { { $url = trim($url); - if (substr($url, 0, 4) != "http") + if (strpos($url, 'http') !== 0) { - $url = "http://".$url; + $url = 'http://'.$url; } } @@ -417,15 +400,13 @@ class CI_Trackback { { $temp = '__TEMP_AMPERSANDS__'; - $str = preg_replace("/&#(\d+);/", "$temp\\1;", $str); - $str = preg_replace("/&(\w+);/", "$temp\\1;", $str); + $str = preg_replace(array('/&#(\d+);/', '/&(\w+);/'), "$temp\\1;", $str); $str = str_replace(array("&","<",">","\"", "'", "-"), array("&", "<", ">", """, "'", "-"), $str); - $str = preg_replace("/$temp(\d+);/","&#\\1;",$str); - $str = preg_replace("/$temp(\w+);/","&\\1;", $str); + $str = preg_replace(array("/$temp(\d+);/", "/$temp(\w+);/"), array('&#\\1;', '&\\1;'), $str); return $str; } @@ -457,13 +438,13 @@ class CI_Trackback { return $str; } - $out = ""; + $out = ''; foreach (explode(' ', trim($str)) as $val) { $out .= $val.' '; if (strlen($out) >= $n) { - return trim($out).$end_char; + return rtrim($out).$end_char; } } } @@ -496,16 +477,16 @@ class CI_Trackback { } else { - if (count($temp) == 0) + if (count($temp) === 0) { $count = ($ordinal < 224) ? 2 : 3; } $temp[] = $ordinal; - if (count($temp) == $count) + if (count($temp) === $count) { - $number = ($count == 3) ? (($temp['0'] % 16) * 4096) + (($temp['1'] % 64) * 64) + ($temp['2'] % 64) : (($temp['0'] % 32) * 64) + ($temp['1'] % 64); + $number = ($count == 3) ? (($temp[0] % 16) * 4096) + (($temp[1] % 64) * 64) + ($temp[2] % 64) : (($temp[0] % 32) * 64) + ($temp[1] % 64); $out .= '&#'.$number.';'; $count = 1; -- cgit v1.2.3-24-g4f1b From 7dc8c442be1122f4fa71f7f53efe4d837b555f2f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 16:52:37 +0200 Subject: Improve the Typography library --- system/libraries/Typography.php | 99 +++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 58 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index af6ca2bf2..0f48f32ad 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -1,13 +1,13 @@ - tags - var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; + public $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; // Elements that should not have

and
tags within them. - var $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; + public $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; // Tags we want the parser to completely ignore when splitting the string. - var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; + public $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; // array of block level elements that require inner content to be within another block level element - var $inner_block_required = array('blockquote'); + public $inner_block_required = array('blockquote'); // the last block element parsed - var $last_block_element = ''; + public $last_block_element = ''; // whether or not to protect quotes within { curly braces } - var $protect_braced_quotes = FALSE; + public $protect_braced_quotes = FALSE; /** * Auto Typography @@ -72,7 +72,7 @@ class CI_Typography { * @param bool whether to reduce more then two consecutive newlines to two * @return string */ - function auto_typography($str, $reduce_linebreaks = FALSE) + public function auto_typography($str, $reduce_linebreaks = FALSE) { if ($str == '') { @@ -127,35 +127,32 @@ class CI_Typography { // adversely affected if they are split out so we'll convert the opening bracket < temporarily to: {@TAG} $str = preg_replace("#<(/*)(".$this->inline_elements.")([ >])#i", "{@TAG}\\1\\2\\3", $str); - // Split the string at every tag. This expression creates an array with this prototype: - // - // [array] - // { - // [0] = - // [1] = Content... - // [2] = - // Etc... - // } + /* Split the string at every tag. This expression creates an array with this prototype: + * + * [array] + * { + * [0] = + * [1] = Content... + * [2] = + * Etc... + * } + */ $chunks = preg_split('/(<(?:[^<>]+(?:"[^"]*"|\'[^\']*\')?)+>)/', $str, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); // Build our finalized string. We cycle through the array, skipping tags, and processing the contained text $str = ''; $process = TRUE; $paragraph = FALSE; - $current_chunk = 0; - $total_chunks = count($chunks); - foreach ($chunks as $chunk) + for ($i = 1, $c = count($chunks); $i <= $c; $i++) { - $current_chunk++; - // Are we dealing with a tag? If so, we'll skip the processing for this cycle. // Well also set the "process" flag which allows us to skip

 tags and a few other things.
-			if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunk, $match))
+			if (preg_match("#<(/*)(".$this->block_elements.").*?>#", $chunks[$i], $match))
 			{
 				if (preg_match("#".$this->skip_elements."#", $match[2]))
 				{
-					$process =  ($match[1] == '/') ? TRUE : FALSE;
+					$process = ($match[1] === '/');
 				}
 
 				if ($match[1] == '')
@@ -163,24 +160,24 @@ class CI_Typography {
 					$this->last_block_element = $match[2];
 				}
 
-				$str .= $chunk;
+				$str .= $chunks[$i];
 				continue;
 			}
 
-			if ($process == FALSE)
+			if ($process === FALSE)
 			{
-				$str .= $chunk;
+				$str .= $chunks[$i];
 				continue;
 			}
 
 			//  Force a newline to make sure end tags get processed by _format_newlines()
-			if ($current_chunk == $total_chunks)
+			if ($i === $c)
 			{
-				$chunk .= "\n";
+				$chunks[$i] .= "\n";
 			}
 
 			//  Convert Newlines into 

and
tags - $str .= $this->_format_newlines($chunk); + $str .= $this->_format_newlines($chunks[$i]); } // No opening block level tag? Add it if needed. @@ -265,7 +262,7 @@ class CI_Typography { * @param string * @return string */ - function format_characters($str) + public function format_characters($str) { static $table; @@ -325,18 +322,13 @@ class CI_Typography { * * Converts newline characters into either

tags or
* - * @access public + * @access private * @param string * @return string */ - function _format_newlines($str) + private function _format_newlines($str) { - if ($str == '') - { - return $str; - } - - if (strpos($str, "\n") === FALSE && ! in_array($this->last_block_element, $this->inner_block_required)) + if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required))) { return $str; } @@ -373,11 +365,11 @@ class CI_Typography { * and we don't want double dashes converted to emdash entities, so they are marked with {@DD} * likewise double spaces are converted to {@NBS} to prevent entity conversion * - * @access public + * @access private * @param array * @return string */ - function _protect_characters($match) + private function _protect_characters($match) { return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]); } @@ -391,25 +383,16 @@ class CI_Typography { * @param string * @return string */ - function nl2br_except_pre($str) + public function nl2br_except_pre($str) { - $ex = explode("pre>",$str); - $ct = count($ex); - - $newstr = ""; - for ($i = 0; $i < $ct; $i++) + $newstr = ''; + for ($ex = explode('pre>', $str), $ct = count($ex), $i = 0; $i < $ct; $i++) { - if (($i % 2) == 0) + $newstr .= (($i % 2) === 0) ? nl2br($ex[$i]) : $ex[$i]; + if ($ct - 1 !== $i) { - $newstr .= nl2br($ex[$i]); + $newstr .= 'pre>'; } - else - { - $newstr .= $ex[$i]; - } - - if ($ct - 1 != $i) - $newstr .= "pre>"; } return $newstr; -- cgit v1.2.3-24-g4f1b From 2a27d312074598346e29bfe76bb87b81a00554d4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 17:08:24 +0200 Subject: Improve the Unit test library --- system/libraries/Unit_test.php | 90 +++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 54 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 7afe40b09..dac1a5c7e 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -1,13 +1,13 @@ -active == FALSE) { @@ -110,11 +110,7 @@ class CI_Unit_test { } else { - if ($this->strict == TRUE) - $result = ($test === $expected) ? TRUE : FALSE; - else - $result = ($test == $expected) ? TRUE : FALSE; - + $result = ($this->strict == TRUE) ? ($test === $expected) : ($test == $expected); $extype = gettype($expected); } @@ -145,9 +141,9 @@ class CI_Unit_test { * @access public * @return string */ - function report($result = array()) + public function report($result = array()) { - if (count($result) == 0) + if (count($result) === 0) { $result = $this->result(); } @@ -176,10 +172,7 @@ class CI_Unit_test { } } - $temp = $this->_template_rows; - $temp = str_replace('{item}', $key, $temp); - $temp = str_replace('{result}', $val, $temp); - $table .= $temp; + $table .= str_replace(array('{item}', '{result}'), array($key, $val), $this->_template_rows); } $r .= str_replace('{rows}', $table, $this->_template); @@ -199,9 +192,9 @@ class CI_Unit_test { * @param bool * @return null */ - function use_strict($state = TRUE) + public function use_strict($state = TRUE) { - $this->strict = ($state == FALSE) ? FALSE : TRUE; + $this->strict = (bool) $state; } // -------------------------------------------------------------------- @@ -215,9 +208,9 @@ class CI_Unit_test { * @param bool * @return null */ - function active($state = TRUE) + public function active($state = TRUE) { - $this->active = ($state == FALSE) ? FALSE : TRUE; + $this->active = (bool) $state; } // -------------------------------------------------------------------- @@ -230,12 +223,12 @@ class CI_Unit_test { * @access public * @return array */ - function result($results = array()) + public function result($results = array()) { $CI =& get_instance(); $CI->load->language('unit_test'); - if (count($results) == 0) + if (count($results) === 0) { $results = $this->results; } @@ -289,7 +282,7 @@ class CI_Unit_test { * @param string * @return void */ - function set_template($template) + public function set_template($template) { $this->_template = $template; } @@ -304,16 +297,15 @@ class CI_Unit_test { * @access private * @return array */ - function _backtrace() + private function _backtrace() { if (function_exists('debug_backtrace')) { $back = debug_backtrace(); - - $file = ( ! isset($back['1']['file'])) ? '' : $back['1']['file']; - $line = ( ! isset($back['1']['line'])) ? '' : $back['1']['line']; - - return array('file' => $file, 'line' => $line); + return array( + 'file' => (isset($back[1]['file']) ? $back[1]['file'] : ''), + 'line' => (isset($back[1]['line']) ? $back[1]['line'] : '') + ); } return array('file' => 'Unknown', 'line' => 'Unknown'); } @@ -326,16 +318,12 @@ class CI_Unit_test { * @access private * @return string */ - function _default_template() + private function _default_template() { - $this->_template = "\n".'

'; - $this->_template .= '{rows}'; - $this->_template .= "\n".'
'; - - $this->_template_rows = "\n\t".''; - $this->_template_rows .= "\n\t\t".'{item}'; - $this->_template_rows .= "\n\t\t".'{result}'; - $this->_template_rows .= "\n\t".''; + $this->_template = "\n".'{rows}'."\n".'
'; + + $this->_template_rows = "\n\t\n\t\t".'{item}' + . "\n\t\t".'{result}'."\n\t"; } // -------------------------------------------------------------------- @@ -348,27 +336,21 @@ class CI_Unit_test { * @access private * @return void */ - function _parse_template() + private function _parse_template() { if ( ! is_null($this->_template_rows)) { return; } - if (is_null($this->_template)) - { - $this->_default_template(); - return; - } - - if ( ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match)) + if (is_null($this->_template) OR ! preg_match("/\{rows\}(.*?)\{\/rows\}/si", $this->_template, $match)) { $this->_default_template(); return; } - $this->_template_rows = $match['1']; - $this->_template = str_replace($match['0'], '{rows}', $this->_template); + $this->_template_rows = $match[1]; + $this->_template = str_replace($match[0], '{rows}', $this->_template); } } -- cgit v1.2.3-24-g4f1b From e9ccf74554266bf8122359d4221a228725c54218 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 17:30:10 +0200 Subject: Improve the User agent library --- system/libraries/User_agent.php | 63 ++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 36 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index a007acec8..060de695f 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -1,13 +1,13 @@ -languages) == 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') + if ((count($this->languages) === 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { - $languages = preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE']))); - - $this->languages = explode(',', $languages); + $this->languages = explode(',', preg_replace('/(;q=[0-9\.]+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_LANGUAGE'])))); } - if (count($this->languages) == 0) + if (count($this->languages) === 0) { $this->languages = array('Undefined'); } @@ -297,14 +295,12 @@ class CI_User_agent { */ private function _set_charsets() { - if ((count($this->charsets) == 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') + if ((count($this->charsets) === 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') { - $charsets = preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET']))); - - $this->charsets = explode(',', $charsets); + $this->charsets = explode(',', preg_replace('/(;q=.+)/i', '', strtolower(trim($_SERVER['HTTP_ACCEPT_CHARSET'])))); } - if (count($this->charsets) == 0) + if (count($this->charsets) === 0) { $this->charsets = array('Undefined'); } @@ -395,11 +391,7 @@ class CI_User_agent { */ public function is_referral() { - if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') - { - return FALSE; - } - return TRUE; + return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '') ? FALSE : TRUE; } // -------------------------------------------------------------------- @@ -502,7 +494,7 @@ class CI_User_agent { */ public function languages() { - if (count($this->languages) == 0) + if (count($this->languages) === 0) { $this->_set_languages(); } @@ -520,7 +512,7 @@ class CI_User_agent { */ public function charsets() { - if (count($this->charsets) == 0) + if (count($this->charsets) === 0) { $this->_set_charsets(); } @@ -556,6 +548,5 @@ class CI_User_agent { } - /* End of file User_agent.php */ /* Location: ./system/libraries/User_agent.php */ -- cgit v1.2.3-24-g4f1b From a30faf95d1d833f716dd1e181cef5b33b02ef8b9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:15:34 +0200 Subject: Improve the Xmlrpc library --- system/libraries/Xmlrpc.php | 408 +++++++++++++++++++------------------------- 1 file changed, 180 insertions(+), 228 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php index 7b1e3fa6e..ebb04601b 100644 --- a/system/libraries/Xmlrpc.php +++ b/system/libraries/Xmlrpc.php @@ -1,13 +1,13 @@ -xmlrpcName = $this->xmlrpcName; + $this->xmlrpcName = $this->xmlrpcName; $this->xmlrpc_backslash = chr(92).chr(92); // Types for info sent back and forth @@ -101,23 +101,23 @@ class CI_Xmlrpc { // Array of Valid Parents for Various XML-RPC elements $this->valid_parents = array('BOOLEAN' => array('VALUE'), - 'I4' => array('VALUE'), - 'INT' => array('VALUE'), - 'STRING' => array('VALUE'), - 'DOUBLE' => array('VALUE'), - 'DATETIME.ISO8601' => array('VALUE'), - 'BASE64' => array('VALUE'), - 'ARRAY' => array('VALUE'), - 'STRUCT' => array('VALUE'), - 'PARAM' => array('PARAMS'), - 'METHODNAME' => array('METHODCALL'), - 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), - 'MEMBER' => array('STRUCT'), - 'NAME' => array('MEMBER'), - 'DATA' => array('ARRAY'), - 'FAULT' => array('METHODRESPONSE'), - 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') - ); + 'I4' => array('VALUE'), + 'INT' => array('VALUE'), + 'STRING' => array('VALUE'), + 'DOUBLE' => array('VALUE'), + 'DATETIME.ISO8601' => array('VALUE'), + 'BASE64' => array('VALUE'), + 'ARRAY' => array('VALUE'), + 'STRUCT' => array('VALUE'), + 'PARAM' => array('PARAMS'), + 'METHODNAME' => array('METHODCALL'), + 'PARAMS' => array('METHODCALL', 'METHODRESPONSE'), + 'MEMBER' => array('STRUCT'), + 'NAME' => array('MEMBER'), + 'DATA' => array('ARRAY'), + 'FAULT' => array('METHODRESPONSE'), + 'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT') + ); // XML-RPC Responses @@ -128,7 +128,7 @@ class CI_Xmlrpc { $this->xmlrpcerr['incorrect_params'] = '3'; $this->xmlrpcstr['incorrect_params'] = 'Incorrect parameters were passed to method'; $this->xmlrpcerr['introspect_unknown'] = '4'; - $this->xmlrpcstr['introspect_unknown'] = "Cannot inspect signature for request: method unknown"; + $this->xmlrpcstr['introspect_unknown'] = 'Cannot inspect signature for request: method unknown'; $this->xmlrpcerr['http_error'] = '5'; $this->xmlrpcstr['http_error'] = "Did not receive a '200 OK' response from remote server."; $this->xmlrpcerr['no_data'] = '6'; @@ -144,7 +144,7 @@ class CI_Xmlrpc { // Initialize Prefs //------------------------------------- - function initialize($config = array()) + public function initialize($config = array()) { if (count($config) > 0) { @@ -163,9 +163,9 @@ class CI_Xmlrpc { // Take URL and parse it //------------------------------------- - function server($url, $port=80) + public function server($url, $port=80) { - if (substr($url, 0, 4) != "http") + if (strpos($url, 'http') !== 0) { $url = "http://".$url; } @@ -187,7 +187,7 @@ class CI_Xmlrpc { // Set Timeout //------------------------------------- - function timeout($seconds=5) + public function timeout($seconds = 5) { if ( ! is_null($this->client) && is_int($seconds)) { @@ -200,7 +200,7 @@ class CI_Xmlrpc { // Set Methods //------------------------------------- - function method($function) + public function method($function) { $this->method = $function; } @@ -210,7 +210,7 @@ class CI_Xmlrpc { // Take Array of Data and Create Objects //------------------------------------- - function request($incoming) + public function request($incoming) { if ( ! is_array($incoming)) { @@ -231,42 +231,34 @@ class CI_Xmlrpc { // Set Debug //------------------------------------- - function set_debug($flag = TRUE) + public function set_debug($flag = TRUE) { - $this->debug = ($flag == TRUE) ? TRUE : FALSE; + $this->debug = ($flag == TRUE); } //------------------------------------- // Values Parsing //------------------------------------- - function values_parsing($value, $return = FALSE) + public function values_parsing($value, $return = FALSE) { if (is_array($value) && array_key_exists(0, $value)) { - if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']]))) + if ( ! isset($value[1]) OR ( ! isset($this->xmlrpcTypes[$value[1]]))) { - if (is_array($value[0])) - { - $temp = new XML_RPC_Values($value['0'], 'array'); - } - else - { - $temp = new XML_RPC_Values($value['0'], 'string'); - } + $temp = new XML_RPC_Values($value[0], (is_array($value[0]) ? 'array' : 'string')); } - elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array')) + else { - while (list($k) = each($value['0'])) + if (is_array($value[0]) && ($value[1] == 'struct' OR $value[1] == 'array')) { - $value['0'][$k] = $this->values_parsing($value['0'][$k], TRUE); + while (list($k) = each($value[0])) + { + $value[0][$k] = $this->values_parsing($value[0][$k], TRUE); + } } - $temp = new XML_RPC_Values($value['0'], $value['1']); - } - else - { - $temp = new XML_RPC_Values($value['0'], $value['1']); + $temp = new XML_RPC_Values($value[0], $value[1]); } } else @@ -283,24 +275,18 @@ class CI_Xmlrpc { // Sends XML-RPC Request //------------------------------------- - function send_request() + public function send_request() { $this->message = new XML_RPC_Message($this->method,$this->data); $this->message->debug = $this->debug; - if ( ! $this->result = $this->client->send($this->message)) - { - $this->error = $this->result->errstr; - return FALSE; - } - elseif ( ! is_object($this->result->val)) + if ( ! $this->result = $this->client->send($this->message) OR ! is_object($this->result->val)) { $this->error = $this->result->errstr; return FALSE; } $this->response = $this->result->decode(); - return TRUE; } // END @@ -309,7 +295,7 @@ class CI_Xmlrpc { // Returns Error //------------------------------------- - function display_error() + public function display_error() { return $this->error; } @@ -319,7 +305,7 @@ class CI_Xmlrpc { // Returns Remote Server Response //------------------------------------- - function display_response() + public function display_response() { return $this->response; } @@ -329,9 +315,9 @@ class CI_Xmlrpc { // Sends an Error Message for Server Request //------------------------------------- - function send_error_message($number, $message) + public function send_error_message($number, $message) { - return new XML_RPC_Response('0',$number, $message); + return new XML_RPC_Response(0, $number, $message); } // END @@ -340,14 +326,11 @@ class CI_Xmlrpc { // Send Response for Server Request //------------------------------------- - function send_response($response) + public function send_response($response) { // $response should be array of values, which will be parsed // based on their data and type into a valid group of XML-RPC values - - $response = $this->values_parsing($response); - - return new XML_RPC_Response($response); + return new XML_RPC_Response($this->values_parsing($response)); } // END @@ -364,13 +347,13 @@ class CI_Xmlrpc { */ class XML_RPC_Client extends CI_Xmlrpc { - var $path = ''; - var $server = ''; - var $port = 80; - var $errno = ''; - var $errstring = ''; - var $timeout = 5; - var $no_multicall = FALSE; + public $path = ''; + public $server = ''; + public $port = 80; + public $errno = ''; + public $errstring = ''; + public $timeout = 5; + public $no_multicall = FALSE; public function __construct($path, $server, $port=80) { @@ -381,7 +364,7 @@ class XML_RPC_Client extends CI_Xmlrpc $this->path = $path; } - function send($msg) + public function send($msg) { if (is_array($msg)) { @@ -393,7 +376,7 @@ class XML_RPC_Client extends CI_Xmlrpc return $this->sendPayload($msg); } - function sendPayload($msg) + public function sendPayload($msg) { $fp = @fsockopen($this->server, $this->port,$this->errno, $this->errstr, $this->timeout); @@ -411,12 +394,12 @@ class XML_RPC_Client extends CI_Xmlrpc } $r = "\r\n"; - $op = "POST {$this->path} HTTP/1.0$r"; - $op .= "Host: {$this->server}$r"; - $op .= "Content-Type: text/xml$r"; - $op .= "User-Agent: {$this->xmlrpcName}$r"; - $op .= "Content-Length: ".strlen($msg->payload). "$r$r"; - $op .= $msg->payload; + $op = "POST {$this->path} HTTP/1.0$r" + . "Host: {$this->server}$r" + . "Content-Type: text/xml$r" + . "User-Agent: {$this->xmlrpcName}$r" + . "Content-Length: ".strlen($msg->payload)."$r$r" + . $msg->payload; if ( ! fputs($fp, $op, strlen($op))) @@ -430,8 +413,8 @@ class XML_RPC_Client extends CI_Xmlrpc return $resp; } -} // end class XML_RPC_Client - +} +// end class XML_RPC_Client /** * XML-RPC Response class @@ -442,11 +425,11 @@ class XML_RPC_Client extends CI_Xmlrpc */ class XML_RPC_Response { - var $val = 0; - var $errno = 0; - var $errstr = ''; - var $headers = array(); - var $xss_clean = TRUE; + public $val = 0; + public $errno = 0; + public $errstr = ''; + public $headers = array(); + public $xss_clean = TRUE; public function __construct($val, $code = 0, $fstr = '') { @@ -468,27 +451,26 @@ class XML_RPC_Response } } - function faultCode() + public function faultCode() { return $this->errno; } - function faultString() + public function faultString() { return $this->errstr; } - function value() + public function value() { return $this->val; } - function prepare_response() + public function prepare_response() { - $result = "\n"; - if ($this->errno) - { - $result .= ' + return "\n" + . ($this->errno + ? ' @@ -501,23 +483,16 @@ class XML_RPC_Response -'; - } - else - { - $result .= "\n\n" . - $this->val->serialize_class() . - "\n"; - } - $result .= "\n"; - return $result; +' + : "\n\n".$this->val->serialize_class()."\n") + . "\n"; } - function decode($array=FALSE) + public function decode($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -556,7 +531,7 @@ class XML_RPC_Response // XML-RPC Object to PHP Types //------------------------------------- - function xmlrpc_decoder($xmlrpc_val) + public function xmlrpc_decoder($xmlrpc_val) { $kind = $xmlrpc_val->kindOf(); @@ -568,11 +543,9 @@ class XML_RPC_Response { reset($xmlrpc_val->me); list($a,$b) = each($xmlrpc_val->me); - $size = count($b); - $arr = array(); - for ($i = 0; $i < $size; $i++) + for ($i = 0, $size = count($b); $i < $size; $i++) { $arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]); } @@ -596,7 +569,7 @@ class XML_RPC_Response // ISO-8601 time to server or UTC time //------------------------------------- - function iso8601_decode($time, $utc=0) + public function iso8601_decode($time, $utc = 0) { // return a timet in the localtime, or UTC $t = 0; @@ -608,9 +581,8 @@ class XML_RPC_Response return $t; } -} // End Response Class - - +} +// End Response Class /** * XML-RPC Message class @@ -621,10 +593,10 @@ class XML_RPC_Response */ class XML_RPC_Message extends CI_Xmlrpc { - var $payload; - var $method_name; - var $params = array(); - var $xh = array(); + public $payload; + public $method_name; + public $params = array(); + public $xh = array(); public function __construct($method, $pars=0) { @@ -633,7 +605,7 @@ class XML_RPC_Message extends CI_Xmlrpc $this->method_name = $method; if (is_array($pars) && count($pars) > 0) { - for ($i=0; $iparams[] = $pars[$i]; @@ -645,13 +617,13 @@ class XML_RPC_Message extends CI_Xmlrpc // Create Payload to Send //------------------------------------- - function createPayload() + public function createPayload() { - $this->payload = "\r\n\r\n"; - $this->payload .= '' . $this->method_name . "\r\n"; - $this->payload .= "\r\n"; + $this->payload = "\r\n\r\n" + . ''.$this->method_name."\r\n" + . "\r\n"; - for ($i=0; $iparams); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { // $p = XML_RPC_Values $p = $this->params[$i]; @@ -665,7 +637,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parse External XML-RPC Server's Response //------------------------------------- - function parseResponse($fp) + public function parseResponse($fp) { $data = ''; @@ -680,16 +652,14 @@ class XML_RPC_Message extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
-			echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n";
-			echo "
"; + echo "
---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n
"; } //------------------------------------- // Check for data //------------------------------------- - if ($data == "") + if ($data === '') { error_log($this->xmlrpcstr['no_data']); $r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']); @@ -701,7 +671,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Check for HTTP 200 Response //------------------------------------- - if (strncmp($data, 'HTTP', 4) == 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) + if (strncmp($data, 'HTTP', 4) === 0 && ! preg_match('/^HTTP\/[0-9\.]+ 200 /', $data)) { $errstr= substr($data, 0, strpos($data, "\n")-1); $r = new XML_RPC_Response(0, $this->xmlrpcerr['http_error'], $this->xmlrpcstr['http_error']. ' (' . $errstr . ')'); @@ -714,13 +684,14 @@ class XML_RPC_Message extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); - $this->xh[$parser] = array(); - $this->xh[$parser]['isf'] = 0; - $this->xh[$parser]['ac'] = ''; - $this->xh[$parser]['headers'] = array(); - $this->xh[$parser]['stack'] = array(); - $this->xh[$parser]['valuestack'] = array(); - $this->xh[$parser]['isf_reason'] = 0; + $this->xh[$parser] = array( + 'isf' => 0, + 'ac' => '', + 'headers' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'isf_reason' => 0 + ); xml_set_object($parser, $this); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -769,9 +740,7 @@ class XML_RPC_Message extends CI_Xmlrpc { if ($this->debug === TRUE) { - echo "---Invalid Return---\n"; - echo $this->xh[$parser]['isf_reason']; - echo "---Invalid Return---\n\n"; + echo "---Invalid Return---\n".$this->xh[$parser]['isf_reason']."---Invalid Return---\n\n"; } $r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'],$this->xmlrpcstr['invalid_return'].' '.$this->xh[$parser]['isf_reason']); @@ -801,9 +770,7 @@ class XML_RPC_Message extends CI_Xmlrpc echo "---END HEADERS---\n\n"; } - echo "---DATA---\n" . htmlspecialchars($data) . "\n---END DATA---\n\n"; - - echo "---PARSED---\n" ; + echo "---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n---PARSED---\n"; var_dump($this->xh[$parser]['value']); echo "\n---END PARSED---"; } @@ -813,7 +780,6 @@ class XML_RPC_Message extends CI_Xmlrpc //------------------------------------- $v = $this->xh[$parser]['value']; - if ($this->xh[$parser]['isf']) { $errno_v = $v->me['struct']['faultCode']; @@ -855,7 +821,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Start Element Handler //------------------------------------- - function open_tag($the_parser, $name, $attrs) + public function open_tag($the_parser, $name, $attrs) { // If invalid nesting, then return if ($this->xh[$the_parser]['isf'] > 1) return; @@ -957,7 +923,7 @@ class XML_RPC_Message extends CI_Xmlrpc // End Element Handler //------------------------------------- - function closing_tag($the_parser, $name) + public function closing_tag($the_parser, $name) { if ($this->xh[$the_parser]['isf'] > 1) return; @@ -1101,7 +1067,7 @@ class XML_RPC_Message extends CI_Xmlrpc // Parses Character Data //------------------------------------- - function character_data($the_parser, $data) + public function character_data($the_parser, $data) { if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already @@ -1123,13 +1089,16 @@ class XML_RPC_Message extends CI_Xmlrpc } - function addParam($par) { $this->params[]=$par; } + public function addParam($par) + { + $this->params[] = $par; + } - function output_parameters($array=FALSE) + public function output_parameters($array = FALSE) { $CI =& get_instance(); - - if ($array !== FALSE && is_array($array)) + + if (is_array($array)) { while (list($key) = each($array)) { @@ -1151,7 +1120,7 @@ class XML_RPC_Message extends CI_Xmlrpc { $parameters = array(); - for ($i = 0; $i < count($this->params); $i++) + for ($i = 0, $c = count($this->params); $i < $c; $i++) { $a_param = $this->decode_message($this->params[$i]); @@ -1170,7 +1139,7 @@ class XML_RPC_Message extends CI_Xmlrpc } - function decode_message($param) + public function decode_message($param) { $kind = $param->kindOf(); @@ -1185,7 +1154,7 @@ class XML_RPC_Message extends CI_Xmlrpc $arr = array(); - for($i = 0; $i < count($b); $i++) + for($i = 0, $c = count($b); $i < $c; $i++) { $arr[] = $this->decode_message($param->me['array'][$i]); } @@ -1207,9 +1176,8 @@ class XML_RPC_Message extends CI_Xmlrpc } } -} // End XML_RPC_Messages class - - +} +// End XML_RPC_Messages class /** * XML-RPC Values class @@ -1220,10 +1188,10 @@ class XML_RPC_Message extends CI_Xmlrpc */ class XML_RPC_Values extends CI_Xmlrpc { - var $me = array(); - var $mytype = 0; + public $me = array(); + public $mytype = 0; - public function __construct($val=-1, $type='') + public function __construct($val = -1, $type = '') { parent::__construct(); @@ -1246,7 +1214,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function addScalar($val, $type='string') + public function addScalar($val, $type = 'string') { $typeof = $this->xmlrpcTypes[$type]; @@ -1264,14 +1232,7 @@ class XML_RPC_Values extends CI_Xmlrpc if ($type == $this->xmlrpcBoolean) { - if (strcasecmp($val,'true')==0 OR $val==1 OR ($val==true && strcasecmp($val,'false'))) - { - $val = 1; - } - else - { - $val=0; - } + $val = (strcasecmp($val,'true') === 0 OR $val == 1 OR ($val == true && strcasecmp($val, 'false'))) ? 1 : 0; } if ($this->mytype == 2) @@ -1290,7 +1251,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addArray($vals) + public function addArray($vals) { if ($this->mytype != 0) { @@ -1303,7 +1264,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function addStruct($vals) + public function addStruct($vals) { if ($this->mytype != 0) { @@ -1315,7 +1276,7 @@ class XML_RPC_Values extends CI_Xmlrpc return 1; } - function kindOf() + public function kindOf() { switch($this->mytype) { @@ -1333,7 +1294,7 @@ class XML_RPC_Values extends CI_Xmlrpc } } - function serializedata($typ, $val) + public function serializedata($typ, $val) { $rs = ''; @@ -1345,20 +1306,18 @@ class XML_RPC_Values extends CI_Xmlrpc reset($val); while (list($key2, $val2) = each($val)) { - $rs .= "\n{$key2}\n"; - $rs .= $this->serializeval($val2); - $rs .= "\n"; + $rs .= "\n{$key2}\n".$this->serializeval($val2)."\n"; } $rs .= ''; break; case 2: // array $rs .= "\n\n"; - for($i=0; $i < count($val); $i++) + for($i = 0, $c = count($val); $i < $c; $i++) { $rs .= $this->serializeval($val[$i]); } - $rs.="\n\n"; + $rs .= "\n\n"; break; case 1: // others @@ -1383,22 +1342,21 @@ class XML_RPC_Values extends CI_Xmlrpc return $rs; } - function serialize_class() + public function serialize_class() { return $this->serializeval($this); } - function serializeval($o) + public function serializeval($o) { $ar = $o->me; reset($ar); list($typ, $val) = each($ar); - $rs = "\n".$this->serializedata($typ, $val)."\n"; - return $rs; + return "\n".$this->serializedata($typ, $val)."\n"; } - function scalarval() + public function scalarval() { reset($this->me); list($a,$b) = each($this->me); @@ -1412,24 +1370,18 @@ class XML_RPC_Values extends CI_Xmlrpc // Useful for sending time in XML-RPC - function iso8601_encode($time, $utc=0) + public function iso8601_encode($time, $utc=0) { if ($utc == 1) { - $t = strftime("%Y%m%dT%H:%i:%s", $time); + return strftime("%Y%m%dT%H:%i:%s", $time); } - else - { - if (function_exists('gmstrftime')) - $t = gmstrftime("%Y%m%dT%H:%i:%s", $time); - else - $t = strftime("%Y%m%dT%H:%i:%s", $time - date('Z')); - } - return $t; + + return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z')); } } // END XML_RPC_Values Class /* End of file Xmlrpc.php */ -/* Location: ./system/libraries/Xmlrpc.php */ \ No newline at end of file +/* Location: ./system/libraries/Xmlrpc.php */ -- cgit v1.2.3-24-g4f1b From 56e3214d8e05d3b74bf728c675ce0691399b3867 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 18:36:31 +0200 Subject: Improve the Xmlrpcs library --- system/libraries/Xmlrpcs.php | 144 ++++++++++++++++++++----------------------- 1 file changed, 68 insertions(+), 76 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index 587b75040..893e51873 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -1,13 +1,13 @@ -methods = array( 'system.listMethods' => array( - 'function' => 'this.listMethods', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)), - 'docstring' => 'Returns an array of available methods on this server'), - 'system.methodHelp' => array( - 'function' => 'this.methodHelp', - 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)), - 'docstring' => 'Returns a documentation string for the specified method'), + 'function' => 'this.listMethods', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString), array($this->xmlrpcArray)), + 'docstring' => 'Returns an array of available methods on this server'), + 'system.methodHelp' => array( + 'function' => 'this.methodHelp', + 'signature' => array(array($this->xmlrpcString, $this->xmlrpcString)), + 'docstring' => 'Returns a documentation string for the specified method'), 'system.methodSignature' => array( - 'function' => 'this.methodSignature', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)), - 'docstring' => 'Returns an array describing the return type and required parameters of a method'), - 'system.multicall' => array( - 'function' => 'this.multicall', - 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)), - 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details') - ); + 'function' => 'this.methodSignature', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcString)), + 'docstring' => 'Returns an array describing the return type and required parameters of a method'), + 'system.multicall' => array( + 'function' => 'this.multicall', + 'signature' => array(array($this->xmlrpcArray, $this->xmlrpcArray)), + 'docstring' => 'Combine multiple RPC calls in one request. See http://www.xmlrpc.com/discuss/msgReader$1208 for details') + ); } // -------------------------------------------------------------------- @@ -141,12 +140,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @access public * @return void */ - function serve() + public function serve() { $r = $this->parseRequest(); - $payload = 'xmlrpc_defencoding.'"?'.'>'."\n"; - $payload .= $this->debug_msg; - $payload .= $r->prepare_response(); + $payload = 'xmlrpc_defencoding.'"?'.'>'."\n".$this->debug_msg.$r->prepare_response(); header("Content-Type: text/xml"); header("Content-Length: ".strlen($payload)); @@ -165,7 +162,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param string docstring * @return void */ - function add_to_map($methodname, $function, $sig, $doc) + public function add_to_map($methodname, $function, $sig, $doc) { $this->methods[$methodname] = array( 'function' => $function, @@ -183,7 +180,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param string data * @return object xmlrpc response */ - function parseRequest($data='') + public function parseRequest($data = '') { global $HTTP_RAW_POST_DATA; @@ -203,13 +200,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc $parser = xml_parser_create($this->xmlrpc_defencoding); $parser_object = new XML_RPC_Message("filler"); - $parser_object->xh[$parser] = array(); - $parser_object->xh[$parser]['isf'] = 0; - $parser_object->xh[$parser]['isf_reason'] = ''; - $parser_object->xh[$parser]['params'] = array(); - $parser_object->xh[$parser]['stack'] = array(); - $parser_object->xh[$parser]['valuestack'] = array(); - $parser_object->xh[$parser]['method'] = ''; + $parser_object->xh[$parser] = array( + 'isf' => 0, + 'isf_reason' => '', + 'params' => array(), + 'stack' => array(), + 'valuestack' => array(), + 'method' => '' + ); xml_set_object($parser, $parser_object); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true); @@ -243,7 +241,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $m = new XML_RPC_Message($parser_object->xh[$parser]['method']); $plist=''; - for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++) + for ($i = 0, $c = count($parser_object->xh[$parser]['params']); $i < $c; $i++) { if ($this->debug === TRUE) { @@ -255,9 +253,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($this->debug === TRUE) { - echo "
";
-				echo "---PLIST---\n" . $plist . "\n---PLIST END---\n\n";
-				echo "
"; + echo "
---PLIST---\n".$plist."\n---PLIST END---\n\n
"; } $r = $this->_execute($m); @@ -284,12 +280,12 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param object * @return mixed */ - function _execute($m) + protected function _execute($m) { $methName = $m->method_name; // Check to see if it is a system call - $system_call = (strncmp($methName, 'system', 5) == 0) ? TRUE : FALSE; + $system_call = (strncmp($methName, 'system', 5) === 0); if ($this->xss_clean == FALSE) { @@ -310,22 +306,20 @@ class CI_Xmlrpcs extends CI_Xmlrpc //------------------------------------- $method_parts = explode(".", $this->methods[$methName]['function']); - $objectCall = (isset($method_parts['1']) && $method_parts['1'] != "") ? TRUE : FALSE; + $objectCall = (isset($method_parts[1]) && $method_parts[1] != ''); if ($system_call === TRUE) { - if ( ! is_callable(array($this,$method_parts['1']))) + if ( ! is_callable(array($this,$method_parts[1]))) { return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } } else { - if ($objectCall && ! is_callable(array($method_parts['0'],$method_parts['1']))) - { - return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); - } - elseif ( ! $objectCall && ! is_callable($this->methods[$methName]['function'])) + if (($objectCall AND ! is_callable(array($method_parts[0], $method_parts[1]))) + OR ( ! $objectCall AND ! is_callable($this->methods[$methName]['function'])) + ) { return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); } @@ -338,13 +332,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc if (isset($this->methods[$methName]['signature'])) { $sig = $this->methods[$methName]['signature']; - for ($i=0; $iparams)+1) + if (count($current_sig) === count($m->params)+1) { - for ($n=0; $n < count($m->params); $n++) + for ($n = 0, $mc = count($m->params); $n < $mc; $n++) { $p = $m->params[$n]; $pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf(); @@ -370,7 +364,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($objectCall === TRUE) { - if ($method_parts[0] == "this" && $system_call == TRUE) + if ($method_parts[0] === 'this' && $system_call === TRUE) { return call_user_func(array($this, $method_parts[1]), $m); } @@ -379,11 +373,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc if ($this->object === FALSE) { $CI =& get_instance(); - return $CI->$method_parts['1']($m); + return $CI->$method_parts[1]($m); } else { - return $this->object->$method_parts['1']($m); + return $this->object->$method_parts[1]($m); //return call_user_func(array(&$method_parts['0'],$method_parts['1']), $m); } } @@ -393,7 +387,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return call_user_func($this->methods[$methName]['function'], $m); } } - + // -------------------------------------------------------------------- /** @@ -403,7 +397,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function listMethods($m) + public function listMethods($m) { $v = new XML_RPC_Values(); $output = array(); @@ -421,7 +415,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $v->addArray($output); return new XML_RPC_Response($v); } - + // -------------------------------------------------------------------- /** @@ -431,7 +425,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function methodSignature($m) + public function methodSignature($m) { $parameters = $m->output_parameters(); $method_name = $parameters[0]; @@ -443,15 +437,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc $sigs = array(); $signature = $this->methods[$method_name]['signature']; - for ($i=0; $i < count($signature); $i++) + for ($i = 0, $c = count($signature); $i < $c; $i++) { $cursig = array(); $inSig = $signature[$i]; - for ($j=0; $joutput_parameters(); $method_name = $parameters[0]; @@ -492,7 +486,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']); } } - + // -------------------------------------------------------------------- /** @@ -502,7 +496,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function multicall($m) + public function multicall($m) { // Disabled return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']); @@ -519,7 +513,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc $m = new XML_RPC_Message($value[0]); $plist=''; - for ($i=0; $i < count($value[1]); $i++) + for ($i = 0, $c = count($value[1]); $i < $c; $i++) { $m->addParam(new XML_RPC_Values($value[1][$i], 'string')); } @@ -546,7 +540,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function multicall_error($err) + public function multicall_error($err) { $str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString(); $code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode(); @@ -566,7 +560,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc * @param mixed * @return object */ - function do_multicall($call) + public function do_multicall($call) { if ($call->kindOf() != 'struct') { @@ -597,11 +591,10 @@ class CI_Xmlrpcs extends CI_Xmlrpc return $this->multicall_error('notarray'); } - list($a,$b)=each($params->me); - $numParams = count($b); + list($a,$b) = each($params->me); $msg = new XML_RPC_Message($scalar_value); - for ($i = 0; $i < $numParams; $i++) + for ($i = 0, $numParams = count($b); $i < $numParams; $i++) { $msg->params[] = $params->me['array'][$i]; } @@ -619,6 +612,5 @@ class CI_Xmlrpcs extends CI_Xmlrpc } // END XML_RPC_Server class - /* End of file Xmlrpcs.php */ -/* Location: ./system/libraries/Xmlrpcs.php */ \ No newline at end of file +/* Location: ./system/libraries/Xmlrpcs.php */ -- cgit v1.2.3-24-g4f1b From ad47f94ce5bc7652710baa65fb924e0f10540bef Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 19:13:48 +0200 Subject: Improve the Javascript & Jquery libs --- system/libraries/Javascript.php | 120 +++++---- system/libraries/javascript/Jquery.php | 436 ++++++++++++++++----------------- 2 files changed, 263 insertions(+), 293 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 15887cb95..723b10679 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -1,13 +1,13 @@ -js->_blur($element, $js); } @@ -95,7 +95,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function change($element = 'this', $js = '') + public function change($element = 'this', $js = '') { return $this->js->_change($element, $js); } @@ -113,7 +113,7 @@ class CI_Javascript { * @param boolean whether or not to return false * @return string */ - function click($element = 'this', $js = '', $ret_false = TRUE) + public function click($element = 'this', $js = '', $ret_false = TRUE) { return $this->js->_click($element, $js, $ret_false); } @@ -130,7 +130,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function dblclick($element = 'this', $js = '') + public function dblclick($element = 'this', $js = '') { return $this->js->_dblclick($element, $js); } @@ -147,7 +147,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function error($element = 'this', $js = '') + public function error($element = 'this', $js = '') { return $this->js->_error($element, $js); } @@ -164,7 +164,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function focus($element = 'this', $js = '') + public function focus($element = 'this', $js = '') { return $this->js->__add_event($focus, $js); } @@ -182,7 +182,7 @@ class CI_Javascript { * @param string - Javascript code for mouse out * @return string */ - function hover($element = 'this', $over, $out) + public function hover($element = 'this', $over, $out) { return $this->js->__hover($element, $over, $out); } @@ -199,7 +199,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function keydown($element = 'this', $js = '') + public function keydown($element = 'this', $js = '') { return $this->js->_keydown($element, $js); } @@ -216,7 +216,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function keyup($element = 'this', $js = '') + public function keyup($element = 'this', $js = '') { return $this->js->_keyup($element, $js); } @@ -233,7 +233,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function load($element = 'this', $js = '') + public function load($element = 'this', $js = '') { return $this->js->_load($element, $js); } @@ -250,7 +250,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function mousedown($element = 'this', $js = '') + public function mousedown($element = 'this', $js = '') { return $this->js->_mousedown($element, $js); } @@ -267,7 +267,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function mouseout($element = 'this', $js = '') + public function mouseout($element = 'this', $js = '') { return $this->js->_mouseout($element, $js); } @@ -284,7 +284,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function mouseover($element = 'this', $js = '') + public function mouseover($element = 'this', $js = '') { return $this->js->_mouseover($element, $js); } @@ -301,7 +301,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function mouseup($element = 'this', $js = '') + public function mouseup($element = 'this', $js = '') { return $this->js->_mouseup($element, $js); } @@ -317,7 +317,7 @@ class CI_Javascript { * @param string The code to output * @return string */ - function output($js) + public function output($js) { return $this->js->_output($js); } @@ -334,7 +334,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function ready($js) + public function ready($js) { return $this->js->_document_ready($js); } @@ -351,7 +351,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function resize($element = 'this', $js = '') + public function resize($element = 'this', $js = '') { return $this->js->_resize($element, $js); } @@ -368,7 +368,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function scroll($element = 'this', $js = '') + public function scroll($element = 'this', $js = '') { return $this->js->_scroll($element, $js); } @@ -385,7 +385,7 @@ class CI_Javascript { * @param string The code to execute * @return string */ - function unload($element = 'this', $js = '') + public function unload($element = 'this', $js = '') { return $this->js->_unload($element, $js); } @@ -405,7 +405,7 @@ class CI_Javascript { * @param string - Class to add * @return string */ - function addClass($element = 'this', $class = '') + public function addClass($element = 'this', $class = '') { return $this->js->_addClass($element, $class); } @@ -423,7 +423,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function animate($element = 'this', $params = array(), $speed = '', $extra = '') + public function animate($element = 'this', $params = array(), $speed = '', $extra = '') { return $this->js->_animate($element, $params, $speed, $extra); } @@ -441,7 +441,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function fadeIn($element = 'this', $speed = '', $callback = '') + public function fadeIn($element = 'this', $speed = '', $callback = '') { return $this->js->_fadeIn($element, $speed, $callback); } @@ -459,7 +459,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function fadeOut($element = 'this', $speed = '', $callback = '') + public function fadeOut($element = 'this', $speed = '', $callback = '') { return $this->js->_fadeOut($element, $speed, $callback); } @@ -476,7 +476,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function slideUp($element = 'this', $speed = '', $callback = '') + public function slideUp($element = 'this', $speed = '', $callback = '') { return $this->js->_slideUp($element, $speed, $callback); @@ -494,7 +494,7 @@ class CI_Javascript { * @param string - Class to add * @return string */ - function removeClass($element = 'this', $class = '') + public function removeClass($element = 'this', $class = '') { return $this->js->_removeClass($element, $class); } @@ -512,7 +512,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function slideDown($element = 'this', $speed = '', $callback = '') + public function slideDown($element = 'this', $speed = '', $callback = '') { return $this->js->_slideDown($element, $speed, $callback); } @@ -530,7 +530,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function slideToggle($element = 'this', $speed = '', $callback = '') + public function slideToggle($element = 'this', $speed = '', $callback = '') { return $this->js->_slideToggle($element, $speed, $callback); @@ -549,7 +549,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function hide($element = 'this', $speed = '', $callback = '') + public function hide($element = 'this', $speed = '', $callback = '') { return $this->js->_hide($element, $speed, $callback); } @@ -565,7 +565,7 @@ class CI_Javascript { * @param string - element * @return string */ - function toggle($element = 'this') + public function toggle($element = 'this') { return $this->js->_toggle($element); @@ -582,7 +582,7 @@ class CI_Javascript { * @param string - element * @return string */ - function toggleClass($element = 'this', $class='') + public function toggleClass($element = 'this', $class='') { return $this->js->_toggleClass($element, $class); } @@ -600,7 +600,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function show($element = 'this', $speed = '', $callback = '') + public function show($element = 'this', $speed = '', $callback = '') { return $this->js->_show($element, $speed, $callback); } @@ -617,7 +617,7 @@ class CI_Javascript { * @param string The element to attach the event to * @return string */ - function compile($view_var = 'script_foot', $script_tags = TRUE) + public function compile($view_var = 'script_foot', $script_tags = TRUE) { $this->js->_compile($view_var, $script_tags); } @@ -630,7 +630,7 @@ class CI_Javascript { * @access public * @return void */ - function clear_compile() + public function clear_compile() { $this->js->_clear_compile(); } @@ -646,7 +646,7 @@ class CI_Javascript { * @param string The element to attach the event to * @return string */ - function external($external_file = '', $relative = FALSE) + public function external($external_file = '', $relative = FALSE) { if ($external_file !== '') { @@ -660,7 +660,7 @@ class CI_Javascript { } } - if ($relative === TRUE OR strncmp($external_file, 'http://', 7) == 0 OR strncmp($external_file, 'https://', 8) == 0) + if ($relative === TRUE OR strncmp($external_file, 'http://', 7) === 0 OR strncmp($external_file, 'https://', 8) === 0) { $str = $this->_open_script($external_file); } @@ -673,8 +673,7 @@ class CI_Javascript { $str = $this->_open_script($this->CI->config->slash_item('base_url').$this->_javascript_location.$external_file); } - $str .= $this->_close_script(); - return $str; + return $str.$this->_close_script(); } // -------------------------------------------------------------------- @@ -689,15 +688,13 @@ class CI_Javascript { * @param boolean If a CDATA section should be added * @return string */ - function inline($script, $cdata = TRUE) + public function inline($script, $cdata = TRUE) { - $str = $this->_open_script(); - $str .= ($cdata) ? "\n// \n" : "\n{$script}\n"; - $str .= $this->_close_script(); - - return $str; + return $this->_open_script() + . ($cdata ? "\n// \n" : "\n{$script}\n") + . $this->_close_script(); } - + // -------------------------------------------------------------------- /** @@ -709,11 +706,10 @@ class CI_Javascript { * @param string * @return string */ - function _open_script($src = '') + private function _open_script($src = '') { - $str = '$extra"; } @@ -750,7 +746,7 @@ class CI_Javascript { * @param string - Javascript callback function * @return string */ - function update($element = 'this', $speed = '', $callback = '') + public function update($element = 'this', $speed = '', $callback = '') { return $this->js->_updater($element, $speed, $callback); } @@ -766,7 +762,7 @@ class CI_Javascript { * @param bool match array types (defaults to objects) * @return string a json formatted string */ - function generate_json($result = NULL, $match_array_type = FALSE) + public function generate_json($result = NULL, $match_array_type = FALSE) { // JSON data can optionally be passed to this function // either as a database result object or an array, or a user supplied array @@ -827,11 +823,11 @@ class CI_Javascript { * * Checks for an associative array * - * @access public + * @access protected * @param type * @return type */ - function _is_associative_array($arr) + protected function _is_associative_array($arr) { foreach (array_keys($arr) as $key => $val) { @@ -851,11 +847,11 @@ class CI_Javascript { * * Ensures a standard json value and escapes values * - * @access public + * @access protected * @param type * @return type */ - function _prep_args($result, $is_key = FALSE) + protected function _prep_args($result, $is_key = FALSE) { if (is_null($result)) { @@ -867,7 +863,7 @@ class CI_Javascript { } elseif (is_string($result) OR $is_key) { - return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"'; + return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"'; } elseif (is_scalar($result)) { @@ -880,4 +876,4 @@ class CI_Javascript { // END Javascript Class /* End of file Javascript.php */ -/* Location: ./system/libraries/Javascript.php */ \ No newline at end of file +/* Location: ./system/libraries/Javascript.php */ diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 4b8f76a10..05057bec2 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -1,13 +1,13 @@ -CI =& get_instance(); + $this->CI =& get_instance(); extract($params); if ($autoload === TRUE) { - $this->script(); + $this->script(); } - + log_message('debug', "Jquery Class Initialized"); } - - // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- // Event Code - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- /** * Blur * * Outputs a jQuery blur event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _blur($element = 'this', $js = '') + protected function _blur($element = 'this', $js = '') { return $this->_add_event($element, $js, 'blur'); } - + // -------------------------------------------------------------------- - + /** * Change * * Outputs a jQuery change event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _change($element = 'this', $js = '') + protected function _change($element = 'this', $js = '') { return $this->_add_event($element, $js, 'change'); } - + // -------------------------------------------------------------------- - + /** * Click * * Outputs a jQuery click event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @param boolean whether or not to return false * @return string */ - function _click($element = 'this', $js = '', $ret_false = TRUE) + protected function _click($element = 'this', $js = '', $ret_false = TRUE) { if ( ! is_array($js)) { @@ -125,70 +125,70 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Double Click * * Outputs a jQuery dblclick event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _dblclick($element = 'this', $js = '') + protected function _dblclick($element = 'this', $js = '') { return $this->_add_event($element, $js, 'dblclick'); } // -------------------------------------------------------------------- - + /** * Error * * Outputs a jQuery error event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _error($element = 'this', $js = '') + protected function _error($element = 'this', $js = '') { return $this->_add_event($element, $js, 'error'); } // -------------------------------------------------------------------- - + /** * Focus * * Outputs a jQuery focus event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _focus($element = 'this', $js = '') + protected function _focus($element = 'this', $js = '') { return $this->_add_event($element, $js, 'focus'); } // -------------------------------------------------------------------- - + /** * Hover * * Outputs a jQuery hover event * - * @access private + * @access protected * @param string - element * @param string - Javascript code for mouse over * @param string - Javascript code for mouse out * @return string */ - function _hover($element = 'this', $over, $out) + protected function _hover($element = 'this', $over, $out) { $event = "\n\t$(" . $this->_prep_element($element) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; @@ -198,103 +198,103 @@ class CI_Jquery extends CI_Javascript { } // -------------------------------------------------------------------- - + /** * Keydown * * Outputs a jQuery keydown event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _keydown($element = 'this', $js = '') + protected function _keydown($element = 'this', $js = '') { return $this->_add_event($element, $js, 'keydown'); } // -------------------------------------------------------------------- - + /** * Keyup * * Outputs a jQuery keydown event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _keyup($element = 'this', $js = '') + protected function _keyup($element = 'this', $js = '') { return $this->_add_event($element, $js, 'keyup'); - } + } // -------------------------------------------------------------------- - + /** * Load * * Outputs a jQuery load event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _load($element = 'this', $js = '') + protected function _load($element = 'this', $js = '') { return $this->_add_event($element, $js, 'load'); - } - + } + // -------------------------------------------------------------------- - + /** * Mousedown * * Outputs a jQuery mousedown event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _mousedown($element = 'this', $js = '') + protected function _mousedown($element = 'this', $js = '') { return $this->_add_event($element, $js, 'mousedown'); } // -------------------------------------------------------------------- - + /** * Mouse Out * * Outputs a jQuery mouseout event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _mouseout($element = 'this', $js = '') + protected function _mouseout($element = 'this', $js = '') { return $this->_add_event($element, $js, 'mouseout'); } // -------------------------------------------------------------------- - + /** * Mouse Over * * Outputs a jQuery mouseover event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _mouseover($element = 'this', $js = '') + protected function _mouseover($element = 'this', $js = '') { return $this->_add_event($element, $js, 'mouseover'); } @@ -306,12 +306,12 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery mouseup event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _mouseup($element = 'this', $js = '') + protected function _mouseup($element = 'this', $js = '') { return $this->_add_event($element, $js, 'mouseup'); } @@ -323,18 +323,18 @@ class CI_Jquery extends CI_Javascript { * * Outputs script directly * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _output($array_js = '') + protected function _output($array_js = '') { if ( ! is_array($array_js)) { $array_js = array($array_js); } - + foreach ($array_js as $js) { $this->jquery_code_for_compile[] = "\t$js\n"; @@ -348,12 +348,12 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery resize event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _resize($element = 'this', $js = '') + protected function _resize($element = 'this', $js = '') { return $this->_add_event($element, $js, 'resize'); } @@ -365,16 +365,16 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery scroll event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _scroll($element = 'this', $js = '') + protected function _scroll($element = 'this', $js = '') { return $this->_add_event($element, $js, 'scroll'); } - + // -------------------------------------------------------------------- /** @@ -382,34 +382,33 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery unload event * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string */ - function _unload($element = 'this', $js = '') + protected function _unload($element = 'this', $js = '') { return $this->_add_event($element, $js, 'unload'); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // Effects - // -------------------------------------------------------------------- - + // -------------------------------------------------------------------- + /** * Add Class * * Outputs a jQuery addClass event * - * @access private + * @access protected * @param string - element * @return string */ - function _addClass($element = 'this', $class='') + protected function _addClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).addClass(\"$class\");"; - return $str; + return "$({$element}).addClass(\"$class\");"; } // -------------------------------------------------------------------- @@ -419,19 +418,19 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery animate event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _animate($element = 'this', $params = array(), $speed = '', $extra = '') + protected function _animate($element = 'this', $params = array(), $speed = '', $extra = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + $animations = "\t\t\t"; - + foreach ($params as $param=>$value) { $animations .= $param.': \''.$value.'\', '; @@ -443,71 +442,65 @@ class CI_Jquery extends CI_Javascript { { $speed = ', '.$speed; } - + if ($extra != '') { $extra = ', '.$extra; } - - $str = "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; - - return $str; + + return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; } // -------------------------------------------------------------------- - + /** * Fade In * * Outputs a jQuery hide event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _fadeIn($element = 'this', $speed = '', $callback = '') + protected function _fadeIn($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).fadeIn({$speed}{$callback});"; - - return $str; + + return "$({$element}).fadeIn({$speed}{$callback});"; } - + // -------------------------------------------------------------------- - + /** * Fade Out * * Outputs a jQuery hide event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _fadeOut($element = 'this', $speed = '', $callback = '') + protected function _fadeOut($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).fadeOut({$speed}{$callback});"; - - return $str; + + return "$({$element}).fadeOut({$speed}{$callback});"; } // -------------------------------------------------------------------- @@ -517,27 +510,25 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery hide action * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _hide($element = 'this', $speed = '', $callback = '') + protected function _hide($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).hide({$speed}{$callback});"; - return $str; + return "$({$element}).hide({$speed}{$callback});"; } - + // -------------------------------------------------------------------- /** @@ -545,75 +536,70 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery remove class event * - * @access private + * @access protected * @param string - element * @return string */ - function _removeClass($element = 'this', $class='') + protected function _removeClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).removeClass(\"$class\");"; - return $str; + return "$({$element}).removeClass(\"$class\");"; } // -------------------------------------------------------------------- - + /** * Slide Up * * Outputs a jQuery slideUp event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _slideUp($element = 'this', $speed = '', $callback = '') + protected function _slideUp($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideUp({$speed}{$callback});"; - - return $str; + + return "$({$element}).slideUp({$speed}{$callback});"; } - + // -------------------------------------------------------------------- - + /** * Slide Down * * Outputs a jQuery slideDown event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _slideDown($element = 'this', $speed = '', $callback = '') + protected function _slideDown($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideDown({$speed}{$callback});"; - - return $str; + + return "$({$element}).slideDown({$speed}{$callback});"; } // -------------------------------------------------------------------- - + /** * Slide Toggle * @@ -625,83 +611,77 @@ class CI_Jquery extends CI_Javascript { * @param string - Javascript callback function * @return string */ - function _slideToggle($element = 'this', $speed = '', $callback = '') + protected function _slideToggle($element = 'this', $speed = '', $callback = '') { $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).slideToggle({$speed}{$callback});"; - - return $str; + + return "$({$element}).slideToggle({$speed}{$callback});"; } - + // -------------------------------------------------------------------- - + /** * Toggle * * Outputs a jQuery toggle event * - * @access private + * @access protected * @param string - element * @return string */ - function _toggle($element = 'this') + protected function _toggle($element = 'this') { $element = $this->_prep_element($element); - $str = "$({$element}).toggle();"; - return $str; + return "$({$element}).toggle();"; } - + // -------------------------------------------------------------------- - + /** * Toggle Class * * Outputs a jQuery toggle class event * - * @access private + * @access protected * @param string - element * @return string */ - function _toggleClass($element = 'this', $class='') + protected function _toggleClass($element = 'this', $class='') { $element = $this->_prep_element($element); - $str = "$({$element}).toggleClass(\"$class\");"; - return $str; + return "$({$element}).toggleClass(\"$class\");"; } - + // -------------------------------------------------------------------- - + /** * Show * * Outputs a jQuery show event * - * @access private + * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function * @return string */ - function _show($element = 'this', $speed = '', $callback = '') + protected function _show($element = 'this', $speed = '', $callback = '') { - $element = $this->_prep_element($element); + $element = $this->_prep_element($element); $speed = $this->_validate_speed($speed); - + if ($callback != '') { $callback = ", function(){\n{$callback}\n}"; } - - $str = "$({$element}).show({$speed}{$callback});"; - - return $str; + + return "$({$element}).show({$speed}{$callback});"; } // -------------------------------------------------------------------- @@ -709,22 +689,21 @@ class CI_Jquery extends CI_Javascript { /** * Updater * - * An Ajax call that populates the designated DOM node with + * An Ajax call that populates the designated DOM node with * returned content * - * @access private + * @access protected * @param string The element to attach the event to * @param string the controller to run the call against * @param string optional parameters * @return string */ - - function _updater($container = 'this', $controller, $options = '') - { + + protected function _updater($container = 'this', $controller, $options = '') + { $container = $this->_prep_element($container); - $controller = (strpos('://', $controller) === FALSE) ? $controller : $this->CI->config->site_url($controller); - + // ajaxStart and ajaxStop are better choices here... but this is a stop gap if ($this->CI->config->item('javascript_ajax_img') == '') { @@ -732,41 +711,39 @@ class CI_Jquery extends CI_Javascript { } else { - $loading_notifier = 'CI->config->slash_item('base_url') . $this->CI->config->item('javascript_ajax_img') . '\' alt=\'Loading\' />'; + $loading_notifier = 'CI->config->slash_item('base_url').$this->CI->config->item('javascript_ajax_img').'\' alt=\'Loading\' />'; } - - $updater = "$($container).empty();\n"; // anything that was in... get it out - $updater .= "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image + + $updater = "$($container).empty();\n" // anything that was in... get it out + . "\t\t$($container).prepend(\"$loading_notifier\");\n"; // to replace with an image $request_options = ''; if ($options != '') { - $request_options .= ", {"; - $request_options .= (is_array($options)) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'"; - $request_options .= "}"; + $request_options .= ', {' + . (is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(":", "':'", $options)."'") + . '}'; } - $updater .= "\t\t$($container).load('$controller'$request_options);"; - return $updater; + return $updater."\t\t$($container).load('$controller'$request_options);"; } // -------------------------------------------------------------------- // Pre-written handy stuff // -------------------------------------------------------------------- - + /** * Zebra tables * - * @access private + * @access protected * @param string table name * @param string plugin location * @return string */ - function _zebraTables($class = '', $odd = 'odd', $hover = '') + protected function _zebraTables($class = '', $odd = 'odd', $hover = '') { $class = ($class != '') ? '.'.$class : ''; - $zebra = "\t\$(\"table{$class} tbody tr:nth-child(even)\").addClass(\"{$odd}\");"; $this->jquery_code_for_compile[] = $zebra; @@ -779,12 +756,10 @@ class CI_Jquery extends CI_Javascript { return $zebra; } - - // -------------------------------------------------------------------- // Plugins // -------------------------------------------------------------------- - + /** * Corner Plugin * @@ -794,7 +769,7 @@ class CI_Jquery extends CI_Javascript { * @param string target * @return string */ - function corner($element = '', $corner_style = '') + public function corner($element = '', $corner_style = '') { // may want to make this configurable down the road $corner_location = '/plugins/jquery.corner.js'; @@ -806,7 +781,7 @@ class CI_Jquery extends CI_Javascript { return "$(" . $this->_prep_element($element) . ").corner(".$corner_style.");"; } - + // -------------------------------------------------------------------- /** @@ -817,8 +792,8 @@ class CI_Jquery extends CI_Javascript { * @access public * @return void */ - function modal($src, $relative = FALSE) - { + public function modal($src, $relative = FALSE) + { $this->jquery_code_for_load[] = $this->external($src, $relative); } @@ -832,7 +807,7 @@ class CI_Jquery extends CI_Javascript { * @access public * @return void */ - function effect($src, $relative = FALSE) + public function effect($src, $relative = FALSE) { $this->jquery_code_for_load[] = $this->external($src, $relative); } @@ -847,7 +822,7 @@ class CI_Jquery extends CI_Javascript { * @access public * @return void */ - function plugin($src, $relative = FALSE) + public function plugin($src, $relative = FALSE) { $this->jquery_code_for_load[] = $this->external($src, $relative); } @@ -862,7 +837,7 @@ class CI_Jquery extends CI_Javascript { * @access public * @return void */ - function ui($src, $relative = FALSE) + public function ui($src, $relative = FALSE) { $this->jquery_code_for_load[] = $this->external($src, $relative); } @@ -876,7 +851,7 @@ class CI_Jquery extends CI_Javascript { * @access public * @return void */ - function sortable($element, $options = array()) + public function sortable($element, $options = array()) { if (count($options) > 0) @@ -906,11 +881,11 @@ class CI_Jquery extends CI_Javascript { * @param string plugin location * @return string */ - function tablesorter($table = '', $options = '') + public function tablesorter($table = '', $options = '') { $this->jquery_code_for_compile[] = "\t$(" . $this->_prep_element($table) . ").tablesorter($options);\n"; } - + // -------------------------------------------------------------------- // Class functions // -------------------------------------------------------------------- @@ -920,13 +895,13 @@ class CI_Jquery extends CI_Javascript { * * Constructs the syntax for an event, and adds to into the array for compilation * - * @access private + * @access protected * @param string The element to attach the event to * @param string The code to execute * @param string The event to pass * @return string - */ - function _add_event($element, $js, $event) + */ + protected function _add_event($element, $js, $event) { if (is_array($js)) { @@ -947,65 +922,64 @@ class CI_Jquery extends CI_Javascript { * As events are specified, they are stored in an array * This funciton compiles them all for output on a page * - * @access private + * @access protected * @return string */ - function _compile($view_var = 'script_foot', $script_tags = TRUE) + protected function _compile($view_var = 'script_foot', $script_tags = TRUE) { // External references $external_scripts = implode('', $this->jquery_code_for_load); $this->CI->load->vars(array('library_src' => $external_scripts)); - if (count($this->jquery_code_for_compile) == 0 ) + if (count($this->jquery_code_for_compile) === 0) { // no inline references, let's just return return; } // Inline references - $script = '$(document).ready(function() {' . "\n"; - $script .= implode('', $this->jquery_code_for_compile); - $script .= '});'; - + $script = '$(document).ready(function() {'."\n" + . implode('', $this->jquery_code_for_compile) + . '});'; + $output = ($script_tags === FALSE) ? $script : $this->inline($script); $this->CI->load->vars(array($view_var => $output)); } - + // -------------------------------------------------------------------- - + /** * Clear Compile * * Clears the array of script events collected for output * - * @access public + * @access protected * @return void */ - function _clear_compile() + protected function _clear_compile() { $this->jquery_code_for_compile = array(); } // -------------------------------------------------------------------- - + /** * Document Ready * * A wrapper for writing document.ready() * - * @access private + * @access protected * @return string */ - function _document_ready($js) + protected function _document_ready($js) { if ( ! is_array($js)) { - $js = array ($js); - + $js = array($js); } - + foreach ($js as $script) { $this->jquery_code_for_compile[] = $script; @@ -1023,13 +997,13 @@ class CI_Jquery extends CI_Javascript { * @param string * @return string */ - function script($library_src = '', $relative = FALSE) + public function script($library_src = '', $relative = FALSE) { $library_src = $this->external($library_src, $relative); $this->jquery_code_for_load[] = $library_src; return $library_src; } - + // -------------------------------------------------------------------- /** @@ -1039,20 +1013,20 @@ class CI_Jquery extends CI_Javascript { * unless the supplied element is the Javascript 'this' * object, in which case no quotes are added * - * @access public + * @access protected * @param string * @return string */ - function _prep_element($element) + protected function _prep_element($element) { if ($element != 'this') { $element = '"'.$element.'"'; } - + return $element; } - + // -------------------------------------------------------------------- /** @@ -1060,25 +1034,25 @@ class CI_Jquery extends CI_Javascript { * * Ensures the speed parameter is valid for jQuery * - * @access private + * @access protected * @param string * @return string - */ - function _validate_speed($speed) + */ + protected function _validate_speed($speed) { if (in_array($speed, array('slow', 'normal', 'fast'))) { - $speed = '"'.$speed.'"'; + return '"'.$speed.'"'; } elseif (preg_match("/[^0-9]/", $speed)) { - $speed = ''; + return ''; } - + return $speed; } } /* End of file Jquery.php */ -/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file +/* Location: ./system/libraries/Jquery.php */ -- cgit v1.2.3-24-g4f1b From 7d4ea07ae5dee6abb0116e76ec9c9a876a02e610 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 25 Dec 2011 19:23:50 +0200 Subject: Improve the Cache library --- system/libraries/Cache/Cache.php | 36 +++++++------- system/libraries/Cache/drivers/Cache_apc.php | 30 ++++++------ system/libraries/Cache/drivers/Cache_dummy.php | 8 ++-- system/libraries/Cache/drivers/Cache_file.php | 55 +++++++++------------- system/libraries/Cache/drivers/Cache_memcached.php | 10 ++-- 5 files changed, 64 insertions(+), 75 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php index c296fa770..87253739c 100644 --- a/system/libraries/Cache/Cache.php +++ b/system/libraries/Cache/Cache.php @@ -1,13 +1,13 @@ -{$this->_adapter}->get($id); } @@ -124,7 +124,7 @@ class CI_Cache extends CI_Driver_Library { * Cache Info * * @param string user/filehits - * @return mixed array on success, false on failure + * @return mixed array on success, false on failure */ public function cache_info($type = 'user') { @@ -132,7 +132,7 @@ class CI_Cache extends CI_Driver_Library { } // ------------------------------------------------------------------------ - + /** * Get Cache Metadata * @@ -143,7 +143,7 @@ class CI_Cache extends CI_Driver_Library { { return $this->{$this->_adapter}->get_metadata($id); } - + // ------------------------------------------------------------------------ /** @@ -151,7 +151,7 @@ class CI_Cache extends CI_Driver_Library { * * Initialize class properties based on the configuration array. * - * @param array + * @param array * @return void */ private function _initialize($config) @@ -219,10 +219,10 @@ class CI_Cache extends CI_Driver_Library { return $obj; } - + // ------------------------------------------------------------------------ } // End Class /* End of file Cache.php */ -/* Location: ./system/libraries/Cache/Cache.php */ \ No newline at end of file +/* Location: ./system/libraries/Cache/Cache.php */ diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php index f15cf8501..90b68688d 100644 --- a/system/libraries/Cache/drivers/Cache_apc.php +++ b/system/libraries/Cache/drivers/Cache_apc.php @@ -1,13 +1,13 @@ -load->helper('file'); - $path = $CI->config->item('cache_path'); - $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path; } @@ -68,16 +66,15 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - - $data = read_file($this->_cache_path.$id); - $data = unserialize($data); - + + $data = unserialize(read_file($this->_cache_path.$id)); + if (time() > $data['time'] + $data['ttl']) { unlink($this->_cache_path.$id); return FALSE; } - + return $data['data']; } @@ -88,22 +85,22 @@ class CI_Cache_file extends CI_Driver { * * @param string unique key * @param mixed data to store - * @param int length of time (in seconds) the cache is valid + * @param int length of time (in seconds) the cache is valid * - Default is 60 seconds * @return boolean true on success/false on failure */ public function save($id, $data, $ttl = 60) - { + { $contents = array( 'time' => time(), - 'ttl' => $ttl, + 'ttl' => $ttl, 'data' => $data ); - + if (write_file($this->_cache_path.$id, serialize($contents))) { @chmod($this->_cache_path.$id, 0777); - return TRUE; + return TRUE; } return FALSE; @@ -119,14 +116,7 @@ class CI_Cache_file extends CI_Driver { */ public function delete($id) { - if (file_exists($this->_cache_path.$id)) - { - return unlink($this->_cache_path.$id); - } - else - { - return FALSE; - } + return (file_exists($this->_cache_path.$id)) ? unlink($this->_cache_path.$id) : FALSE; } // ------------------------------------------------------------------------ @@ -135,7 +125,7 @@ class CI_Cache_file extends CI_Driver { * Clean the Cache * * @return boolean false on failure/true on success - */ + */ public function clean() { return delete_files($this->_cache_path); @@ -170,10 +160,9 @@ class CI_Cache_file extends CI_Driver { { return FALSE; } - - $data = read_file($this->_cache_path.$id); - $data = unserialize($data); - + + $data = unserialize(read_file($this->_cache_path.$id)); + if (is_array($data)) { $mtime = filemtime($this->_cache_path.$id); @@ -188,7 +177,7 @@ class CI_Cache_file extends CI_Driver { 'mtime' => $mtime ); } - + return FALSE; } @@ -198,7 +187,7 @@ class CI_Cache_file extends CI_Driver { * Is supported * * In the file driver, check to see that the cache directory is indeed writable - * + * * @return boolean */ public function is_supported() diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 78cab25d4..0037e6755 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -1,13 +1,13 @@ -_memcached->set($id, array($data, time(), $ttl), 0, $ttl); } - + return FALSE; } @@ -256,4 +256,4 @@ class CI_Cache_memcached extends CI_Driver { // End Class /* End of file Cache_memcached.php */ -/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file +/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ -- cgit v1.2.3-24-g4f1b From d1af1854e3444d58907225f46f473723cdf97628 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 25 Dec 2011 21:59:30 -0600 Subject: Removing previously deprecated SHA1 library and removed SHA1 method in the Encryption Library --- system/libraries/Encrypt.php | 105 +++++------------ system/libraries/Sha1.php | 263 ------------------------------------------- 2 files changed, 27 insertions(+), 341 deletions(-) delete mode 100644 system/libraries/Sha1.php (limited to 'system/libraries') diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index c2cb808dd..92b0b3c4a 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -40,22 +40,19 @@ */ class CI_Encrypt { - var $CI; - var $encryption_key = ''; - var $_hash_type = 'sha1'; - var $_mcrypt_exists = FALSE; - var $_mcrypt_cipher; - var $_mcrypt_mode; + public $encryption_key = ''; + protected $_hash_type = 'sha1'; + protected $_mcrypt_exists = FALSE; + protected $_mcrypt_cipher; + protected $_mcrypt_mode; /** * Constructor * * Simply determines whether the mcrypt library exists. - * */ public function __construct() { - $this->CI =& get_instance(); $this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE; log_message('debug', "Encrypt Class Initialized"); } @@ -68,11 +65,10 @@ class CI_Encrypt { * Returns it as MD5 in order to have an exact-length 128 bit key. * Mcrypt is sensitive to keys that are not the correct length * - * @access public * @param string * @return string */ - function get_key($key = '') + public function get_key($key = '') { if ($key == '') { @@ -84,7 +80,7 @@ class CI_Encrypt { $CI =& get_instance(); $key = $CI->config->item('encryption_key'); - if ($key == FALSE) + if ($key === FALSE) { show_error('In order to use the encryption class requires that you set an encryption key in your config file.'); } @@ -98,13 +94,13 @@ class CI_Encrypt { /** * Set the encryption key * - * @access public * @param string * @return void */ - function set_key($key = '') + public function set_key($key = '') { $this->encryption_key = $key; + return $this; } // -------------------------------------------------------------------- @@ -120,12 +116,11 @@ class CI_Encrypt { * that is randomized with each call to this function, * even if the supplied message and key are the same. * - * @access public * @param string the string to encode * @param string the key * @return string */ - function encode($string, $key = '') + public function encode($string, $key = '') { $key = $this->get_key($key); @@ -148,12 +143,11 @@ class CI_Encrypt { * * Reverses the above process * - * @access public * @param string * @param string * @return string */ - function decode($string, $key = '') + public function decode($string, $key = '') { $key = $this->get_key($key); @@ -191,13 +185,12 @@ class CI_Encrypt { * * For more details, see http://codeigniter.com/user_guide/installation/upgrade_200.html#encryption * - * @access public * @param string * @param int (mcrypt mode constant) * @param string * @return string */ - function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '') + public function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '') { if ($this->_mcrypt_exists === FALSE) { @@ -242,12 +235,11 @@ class CI_Encrypt { * Takes a plain-text string and key as input and generates an * encoded bit-string using XOR * - * @access private * @param string * @param string * @return string */ - function _xor_encode($string, $key) + protected function _xor_encode($string, $key) { $rand = ''; while (strlen($rand) < 32) @@ -274,12 +266,11 @@ class CI_Encrypt { * Takes an encoded string and key as input and generates the * plain-text original message * - * @access private * @param string * @param string * @return string */ - function _xor_decode($string, $key) + protected function _xor_decode($string, $key) { $string = $this->_xor_merge($string, $key); @@ -299,12 +290,11 @@ class CI_Encrypt { * * Takes a string and key as input and computes the difference using XOR * - * @access private * @param string * @param string * @return string */ - function _xor_merge($string, $key) + protected function _xor_merge($string, $key) { $hash = $this->hash($key); $str = ''; @@ -321,12 +311,11 @@ class CI_Encrypt { /** * Encrypt using Mcrypt * - * @access public * @param string * @param string * @return string */ - function mcrypt_encode($data, $key) + public function mcrypt_encode($data, $key) { $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode()); $init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND); @@ -338,12 +327,11 @@ class CI_Encrypt { /** * Decrypt using Mcrypt * - * @access public * @param string * @param string * @return string */ - function mcrypt_decode($data, $key) + public function mcrypt_decode($data, $key) { $data = $this->_remove_cipher_noise($data, $key); $init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode()); @@ -365,14 +353,11 @@ class CI_Encrypt { * against Man-in-the-middle attacks on CBC mode ciphers * http://www.ciphersbyritter.com/GLOSSARY.HTM#IV * - * Function description - * - * @access private * @param string * @param string * @return string */ - function _add_cipher_noise($data, $key) + protected function _add_cipher_noise($data, $key) { $keyhash = $this->hash($key); $keylen = strlen($keyhash); @@ -399,11 +384,10 @@ class CI_Encrypt { * * Function description * - * @access public * @param type * @return type */ - function _remove_cipher_noise($data, $key) + protected function _remove_cipher_noise($data, $key) { $keyhash = $this->hash($key); $keylen = strlen($keyhash); @@ -434,13 +418,13 @@ class CI_Encrypt { /** * Set the Mcrypt Cipher * - * @access public * @param constant * @return string */ - function set_cipher($cipher) + public function set_cipher($cipher) { $this->_mcrypt_cipher = $cipher; + return $this; } // -------------------------------------------------------------------- @@ -448,13 +432,13 @@ class CI_Encrypt { /** * Set the Mcrypt Mode * - * @access public * @param constant * @return string */ function set_mode($mode) { $this->_mcrypt_mode = $mode; + return $this; } // -------------------------------------------------------------------- @@ -462,10 +446,9 @@ class CI_Encrypt { /** * Get Mcrypt cipher Value * - * @access private * @return string */ - function _get_cipher() + protected function _get_cipher() { if ($this->_mcrypt_cipher == '') { @@ -480,10 +463,9 @@ class CI_Encrypt { /** * Get Mcrypt Mode Value * - * @access private * @return string */ - function _get_mode() + protected function _get_mode() { if ($this->_mcrypt_mode == '') { @@ -498,11 +480,10 @@ class CI_Encrypt { /** * Set the Hash type * - * @access public * @param string * @return string */ - function set_hash($type = 'sha1') + public function set_hash($type = 'sha1') { $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type; } @@ -512,45 +493,13 @@ class CI_Encrypt { /** * Hash encode a string * - * @access public * @param string * @return string */ - function hash($str) + public function hash($str) { - return ($this->_hash_type == 'sha1') ? $this->sha1($str) : md5($str); + return ($this->_hash_type == 'sha1') ? sha1($str) : md5($str); } - - // -------------------------------------------------------------------- - - /** - * Generate an SHA1 Hash - * - * @access public - * @param string - * @return string - */ - function sha1($str) - { - if ( ! function_exists('sha1')) - { - if ( ! function_exists('mhash')) - { - require_once(BASEPATH.'libraries/Sha1.php'); - $SH = new CI_SHA; - return $SH->generate($str); - } - else - { - return bin2hex(mhash(MHASH_SHA1, $str)); - } - } - else - { - return sha1($str); - } - } - } // END CI_Encrypt class diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php deleted file mode 100644 index 477b92bcb..000000000 --- a/system/libraries/Sha1.php +++ /dev/null @@ -1,263 +0,0 @@ -> 6) + 1; - - for ($i = 0; $i < $n * 16; $i++) - { - $x[$i] = 0; - } - - for ($i = 0; $i < strlen($str); $i++) - { - $x[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8); - } - - $x[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); - - $x[$n * 16 - 1] = strlen($str) * 8; - - $a = 1732584193; - $b = -271733879; - $c = -1732584194; - $d = 271733878; - $e = -1009589776; - - for ($i = 0; $i < count($x); $i += 16) - { - $olda = $a; - $oldb = $b; - $oldc = $c; - $oldd = $d; - $olde = $e; - - for ($j = 0; $j < 80; $j++) - { - if ($j < 16) - { - $w[$j] = $x[$i + $j]; - } - else - { - $w[$j] = $this->_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); - } - - $t = $this->_safe_add($this->_safe_add($this->_rol($a, 5), $this->_ft($j, $b, $c, $d)), $this->_safe_add($this->_safe_add($e, $w[$j]), $this->_kt($j))); - - $e = $d; - $d = $c; - $c = $this->_rol($b, 30); - $b = $a; - $a = $t; - } - - $a = $this->_safe_add($a, $olda); - $b = $this->_safe_add($b, $oldb); - $c = $this->_safe_add($c, $oldc); - $d = $this->_safe_add($d, $oldd); - $e = $this->_safe_add($e, $olde); - } - - return $this->_hex($a).$this->_hex($b).$this->_hex($c).$this->_hex($d).$this->_hex($e); - } - - // -------------------------------------------------------------------- - - /** - * Convert a decimal to hex - * - * @access private - * @param string - * @return string - */ - function _hex($str) - { - $str = dechex($str); - - if (strlen($str) == 7) - { - $str = '0'.$str; - } - - return $str; - } - - // -------------------------------------------------------------------- - - /** - * Return result based on iteration - * - * @access private - * @return string - */ - function _ft($t, $b, $c, $d) - { - if ($t < 20) - return ($b & $c) | ((~$b) & $d); - if ($t < 40) - return $b ^ $c ^ $d; - if ($t < 60) - return ($b & $c) | ($b & $d) | ($c & $d); - - return $b ^ $c ^ $d; - } - - // -------------------------------------------------------------------- - - /** - * Determine the additive constant - * - * @access private - * @return string - */ - function _kt($t) - { - if ($t < 20) - { - return 1518500249; - } - else if ($t < 40) - { - return 1859775393; - } - else if ($t < 60) - { - return -1894007588; - } - else - { - return -899497514; - } - } - - // -------------------------------------------------------------------- - - /** - * Add integers, wrapping at 2^32 - * - * @access private - * @return string - */ - function _safe_add($x, $y) - { - $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); - $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); - - return ($msw << 16) | ($lsw & 0xFFFF); - } - - // -------------------------------------------------------------------- - - /** - * Bitwise rotate a 32-bit number - * - * @access private - * @return integer - */ - function _rol($num, $cnt) - { - return ($num << $cnt) | $this->_zero_fill($num, 32 - $cnt); - } - - // -------------------------------------------------------------------- - - /** - * Pad string with zero - * - * @access private - * @return string - */ - function _zero_fill($a, $b) - { - $bin = decbin($a); - - if (strlen($bin) < $b) - { - $bin = 0; - } - else - { - $bin = substr($bin, 0, strlen($bin) - $b); - } - - for ($i=0; $i < $b; $i++) - { - $bin = "0".$bin; - } - - return bindec($bin); - } -} -// END CI_SHA - -/* End of file Sha1.php */ -/* Location: ./system/libraries/Sha1.php */ -- cgit v1.2.3-24-g4f1b From 114586fa466e085180f8c2c5b9ec1c514b3cefb2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:27:17 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/Unit_test.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index dac1a5c7e..99c34ea61 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -43,9 +43,9 @@ class CI_Unit_test { public $active = TRUE; public $results = array(); public $strict = FALSE; - private $_template = NULL; - private $_template_rows = NULL; - private $_test_items_visible = array(); + protected $_template = NULL; + protected $_template_rows = NULL; + protected $_test_items_visible = array(); public function __construct() { @@ -294,10 +294,10 @@ class CI_Unit_test { * * This lets us show file names and line numbers * - * @access private + * @access protected * @return array */ - private function _backtrace() + protected function _backtrace() { if (function_exists('debug_backtrace')) { @@ -315,10 +315,10 @@ class CI_Unit_test { /** * Get Default Template * - * @access private + * @access protected * @return string */ - private function _default_template() + protected function _default_template() { $this->_template = "\n".'{rows}'."\n".'
'; @@ -333,10 +333,10 @@ class CI_Unit_test { * * Harvests the data within the template {pseudo-variables} * - * @access private + * @access protected * @return void */ - private function _parse_template() + protected function _parse_template() { if ( ! is_null($this->_template_rows)) { @@ -360,7 +360,7 @@ class CI_Unit_test { * Helper functions to test boolean true/false * * - * @access private + * @access protected * @return bool */ function is_true($test) -- cgit v1.2.3-24-g4f1b From 75c5efbc6abf6a789bedaf6a0cb5fa41b36a31eb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:28:40 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/User_agent.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 060de695f..d55fc3e14 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -91,10 +91,10 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access private + * @access protected * @return bool */ - private function _load_agent_file() + protected function _load_agent_file() { if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) { @@ -147,10 +147,10 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access private + * @access protected * @return bool */ - private function _compile_data() + protected function _compile_data() { $this->_set_platform(); @@ -168,10 +168,10 @@ class CI_User_agent { /** * Set the Platform * - * @access private + * @access protected * @return mixed */ - private function _set_platform() + protected function _set_platform() { if (is_array($this->platforms) AND count($this->platforms) > 0) { @@ -192,10 +192,10 @@ class CI_User_agent { /** * Set the Browser * - * @access private + * @access protected * @return bool */ - private function _set_browser() + protected function _set_browser() { if (is_array($this->browsers) AND count($this->browsers) > 0) { @@ -219,10 +219,10 @@ class CI_User_agent { /** * Set the Robot * - * @access private + * @access protected * @return bool */ - private function _set_robot() + protected function _set_robot() { if (is_array($this->robots) AND count($this->robots) > 0) { @@ -244,10 +244,10 @@ class CI_User_agent { /** * Set the Mobile Device * - * @access private + * @access protected * @return bool */ - private function _set_mobile() + protected function _set_mobile() { if (is_array($this->mobiles) AND count($this->mobiles) > 0) { @@ -269,10 +269,10 @@ class CI_User_agent { /** * Set the accepted languages * - * @access private + * @access protected * @return void */ - private function _set_languages() + protected function _set_languages() { if ((count($this->languages) === 0) AND isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) AND $_SERVER['HTTP_ACCEPT_LANGUAGE'] != '') { @@ -290,10 +290,10 @@ class CI_User_agent { /** * Set the accepted character sets * - * @access private + * @access protected * @return void */ - private function _set_charsets() + protected function _set_charsets() { if ((count($this->charsets) === 0) AND isset($_SERVER['HTTP_ACCEPT_CHARSET']) AND $_SERVER['HTTP_ACCEPT_CHARSET'] != '') { -- cgit v1.2.3-24-g4f1b From 43aa8e4f66e0a109cfb80a8ea424edb04b9feecc Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:53:18 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/Typography.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 0f48f32ad..651ba7bff 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -31,7 +31,7 @@ * Typography Class * * - * @access private + * @access protected * @category Helpers * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/typography.html @@ -322,11 +322,11 @@ class CI_Typography { * * Converts newline characters into either

tags or
* - * @access private + * @access protected * @param string * @return string */ - private function _format_newlines($str) + protected function _format_newlines($str) { if ($str == '' OR (strpos($str, "\n") === FALSE AND ! in_array($this->last_block_element, $this->inner_block_required))) { @@ -365,11 +365,11 @@ class CI_Typography { * and we don't want double dashes converted to emdash entities, so they are marked with {@DD} * likewise double spaces are converted to {@NBS} to prevent entity conversion * - * @access private + * @access protected * @param array * @return string */ - private function _protect_characters($match) + protected function _protect_characters($match) { return str_replace(array("'",'"','--',' '), array('{@SQ}', '{@DQ}', '{@DD}', '{@NBS}'), $match[0]); } -- cgit v1.2.3-24-g4f1b From 49ddaa3a65e4fcfd362bc8eb57e7fc5f9dbfa42e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:54:10 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/Table.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index fb410e9fd..9aa467b1a 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -179,11 +179,11 @@ class CI_Table { * * Ensures a standard associative array format for all cell data * - * @access private + * @access protected * @param type * @return type */ - private function _prep_args($args) + protected function _prep_args($args) { // If there is no $args[0], skip this and treat as an associative array // This can happen if there is only a single key, for example this is passed to table->generate @@ -391,11 +391,11 @@ class CI_Table { /** * Set table data from a database result object * - * @access private + * @access protected * @param object * @return void */ - private function _set_from_object($query) + protected function _set_from_object($query) { if ( ! is_object($query)) { @@ -429,11 +429,11 @@ class CI_Table { /** * Set table data from an array * - * @access private + * @access protected * @param array * @return void */ - private function _set_from_array($data, $set_heading = TRUE) + protected function _set_from_array($data, $set_heading = TRUE) { if ( ! is_array($data) OR count($data) === 0) { @@ -460,10 +460,10 @@ class CI_Table { /** * Compile Template * - * @access private + * @access protected * @return void */ - private function _compile_template() + protected function _compile_template() { if ($this->template == NULL) { @@ -486,10 +486,10 @@ class CI_Table { /** * Default Template * - * @access private + * @access protected * @return void */ - private function _default_template() + protected function _default_template() { return array ( 'table_open' => '', -- cgit v1.2.3-24-g4f1b From 2c79b76c566e96adde0ed9efc3a37e6268c64fce Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:54:44 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/Session.php | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index ada97a032..319860794 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -575,10 +575,10 @@ class CI_Session { * Identifies flashdata as 'old' for removal * when _flashdata_sweep() runs. * - * @access private + * @access protected * @return void */ - private function _flashdata_mark() + protected function _flashdata_mark() { $userdata = $this->all_userdata(); foreach ($userdata as $name => $value) @@ -597,11 +597,11 @@ class CI_Session { /** * Removes all flashdata marked as 'old' * - * @access private + * @access protected * @return void */ - private function _flashdata_sweep() + protected function _flashdata_sweep() { $userdata = $this->all_userdata(); foreach ($userdata as $key => $value) @@ -619,10 +619,10 @@ class CI_Session { /** * Get the "now" time * - * @access private + * @access protected * @return string */ - private function _get_time() + protected function _get_time() { $now = time(); return (strtolower($this->time_reference) === 'gmt') ? @@ -637,7 +637,7 @@ class CI_Session { * @access public * @return void */ - private function _set_cookie($cookie_data = NULL) + protected function _set_cookie($cookie_data = NULL) { if (is_null($cookie_data)) { @@ -678,11 +678,11 @@ class CI_Session { * This function first converts any slashes found in the array to a temporary * marker, so when it gets unserialized the slashes will be preserved * - * @access private + * @access protected * @param array * @return string */ - private function _serialize($data) + protected function _serialize($data) { if (is_array($data)) { @@ -700,7 +700,7 @@ class CI_Session { * * This function converts any slashes found into a temporary marker * - * @access private + * @access protected */ function _escape_slashes(&$val, $key) { @@ -718,11 +718,11 @@ class CI_Session { * This function unserializes a data string, then converts any * temporary slash markers back to actual slashes * - * @access private + * @access protected * @param array * @return string */ - private function _unserialize($data) + protected function _unserialize($data) { $data = @unserialize(strip_slashes($data)); @@ -740,9 +740,9 @@ class CI_Session { * * This function converts any slash markers back into actual slashes * - * @access private + * @access protected */ - private function _unescape_slashes(&$val, $key) + protected function _unescape_slashes(&$val, $key) { if (is_string($val)) { @@ -761,7 +761,7 @@ class CI_Session { * @access public * @return void */ - private function _sess_gc() + protected function _sess_gc() { if ($this->sess_use_database != TRUE) { -- cgit v1.2.3-24-g4f1b From 92ba08a1b293ba46cecd21e5857c1e40c9e68ef9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Dec 2011 16:56:00 +0200 Subject: Replace private with protected, so the class can be easily extended --- system/libraries/Javascript.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 723b10679..074af948b 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -702,11 +702,11 @@ class CI_Javascript { * * Outputs an opening * - * @access private + * @access protected * @param string * @return string */ - private function _close_script($extra = "\n") + protected function _close_script($extra = "\n") { return "$extra"; } -- cgit v1.2.3-24-g4f1b From 6aac0ba44a8d770aa4e14cb9ac0553c8c4633f81 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:34:00 +0200 Subject: Remove @access from method descriptions --- system/libraries/Javascript.php | 42 +------------------------------ system/libraries/javascript/Jquery.php | 46 ---------------------------------- 2 files changed, 1 insertion(+), 87 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 074af948b..f872d672f 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -73,7 +73,6 @@ class CI_Javascript { * * Outputs a javascript library blur event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -90,7 +89,6 @@ class CI_Javascript { * * Outputs a javascript library change event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -107,7 +105,6 @@ class CI_Javascript { * * Outputs a javascript library click event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @param boolean whether or not to return false @@ -125,7 +122,6 @@ class CI_Javascript { * * Outputs a javascript library dblclick event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -142,7 +138,6 @@ class CI_Javascript { * * Outputs a javascript library error event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -159,7 +154,6 @@ class CI_Javascript { * * Outputs a javascript library focus event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -176,7 +170,6 @@ class CI_Javascript { * * Outputs a javascript library hover event * - * @access public * @param string - element * @param string - Javascript code for mouse over * @param string - Javascript code for mouse out @@ -194,7 +187,6 @@ class CI_Javascript { * * Outputs a javascript library keydown event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -211,7 +203,6 @@ class CI_Javascript { * * Outputs a javascript library keydown event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -228,7 +219,6 @@ class CI_Javascript { * * Outputs a javascript library load event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -245,7 +235,6 @@ class CI_Javascript { * * Outputs a javascript library mousedown event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -262,7 +251,6 @@ class CI_Javascript { * * Outputs a javascript library mouseout event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -279,7 +267,6 @@ class CI_Javascript { * * Outputs a javascript library mouseover event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -296,7 +283,6 @@ class CI_Javascript { * * Outputs a javascript library mouseup event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -313,7 +299,6 @@ class CI_Javascript { * * Outputs the called javascript to the screen * - * @access public * @param string The code to output * @return string */ @@ -329,7 +314,6 @@ class CI_Javascript { * * Outputs a javascript library mouseup event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -346,7 +330,6 @@ class CI_Javascript { * * Outputs a javascript library resize event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -363,7 +346,6 @@ class CI_Javascript { * * Outputs a javascript library scroll event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -380,7 +362,6 @@ class CI_Javascript { * * Outputs a javascript library unload event * - * @access public * @param string The element to attach the event to * @param string The code to execute * @return string @@ -390,7 +371,7 @@ class CI_Javascript { return $this->js->_unload($element, $js); } - // -------------------------------------------------------------------- + // -------------------------------------------------------------------- // Effects // -------------------------------------------------------------------- @@ -400,7 +381,6 @@ class CI_Javascript { * * Outputs a javascript library addClass event * - * @access public * @param string - element * @param string - Class to add * @return string @@ -417,7 +397,6 @@ class CI_Javascript { * * Outputs a javascript library animate event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -435,7 +414,6 @@ class CI_Javascript { * * Outputs a javascript library hide event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -453,7 +431,6 @@ class CI_Javascript { * * Outputs a javascript library hide event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -470,7 +447,6 @@ class CI_Javascript { * * Outputs a javascript library slideUp event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -489,7 +465,6 @@ class CI_Javascript { * * Outputs a javascript library removeClass event * - * @access public * @param string - element * @param string - Class to add * @return string @@ -506,7 +481,6 @@ class CI_Javascript { * * Outputs a javascript library slideDown event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -524,7 +498,6 @@ class CI_Javascript { * * Outputs a javascript library slideToggle event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -543,7 +516,6 @@ class CI_Javascript { * * Outputs a javascript library hide action * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -561,7 +533,6 @@ class CI_Javascript { * * Outputs a javascript library toggle event * - * @access public * @param string - element * @return string */ @@ -578,7 +549,6 @@ class CI_Javascript { * * Outputs a javascript library toggle class event * - * @access public * @param string - element * @return string */ @@ -594,7 +564,6 @@ class CI_Javascript { * * Outputs a javascript library show event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -613,7 +582,6 @@ class CI_Javascript { * * gather together all script needing to be output * - * @access public * @param string The element to attach the event to * @return string */ @@ -627,7 +595,6 @@ class CI_Javascript { * * Clears any previous javascript collected for output * - * @access public * @return void */ public function clear_compile() @@ -642,7 +609,6 @@ class CI_Javascript { * * Outputs a * - * @access protected * @param string * @return string */ @@ -740,7 +703,6 @@ class CI_Javascript { * * Outputs a javascript library slideDown event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -823,7 +785,6 @@ class CI_Javascript { * * Checks for an associative array * - * @access protected * @param type * @return type */ @@ -847,7 +808,6 @@ class CI_Javascript { * * Ensures a standard json value and escapes values * - * @access protected * @param type * @return type */ diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php index 05057bec2..888e89b1b 100644 --- a/system/libraries/javascript/Jquery.php +++ b/system/libraries/javascript/Jquery.php @@ -69,7 +69,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery blur event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -86,7 +85,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery change event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -103,7 +101,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery click event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @param boolean whether or not to return false @@ -131,7 +128,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery dblclick event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -148,7 +144,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery error event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -165,7 +160,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery focus event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -182,7 +176,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery hover event * - * @access protected * @param string - element * @param string - Javascript code for mouse over * @param string - Javascript code for mouse out @@ -204,7 +197,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery keydown event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -221,7 +213,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery keydown event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -238,7 +229,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery load event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -255,7 +245,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery mousedown event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -272,7 +261,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery mouseout event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -289,7 +277,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery mouseover event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -306,7 +293,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery mouseup event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -323,7 +309,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs script directly * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -348,7 +333,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery resize event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -365,7 +349,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery scroll event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -382,7 +365,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery unload event * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @return string @@ -401,7 +383,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery addClass event * - * @access protected * @param string - element * @return string */ @@ -418,7 +399,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery animate event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -458,7 +438,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery hide event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -484,7 +463,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery hide event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -510,7 +488,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery hide action * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -536,7 +513,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery remove class event * - * @access protected * @param string - element * @return string */ @@ -553,7 +529,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery slideUp event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -579,7 +554,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery slideDown event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -605,7 +579,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery slideToggle event * - * @access public * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -631,7 +604,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery toggle event * - * @access protected * @param string - element * @return string */ @@ -648,7 +620,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery toggle class event * - * @access protected * @param string - element * @return string */ @@ -665,7 +636,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs a jQuery show event * - * @access protected * @param string - element * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds * @param string - Javascript callback function @@ -692,7 +662,6 @@ class CI_Jquery extends CI_Javascript { * An Ajax call that populates the designated DOM node with * returned content * - * @access protected * @param string The element to attach the event to * @param string the controller to run the call against * @param string optional parameters @@ -736,7 +705,6 @@ class CI_Jquery extends CI_Javascript { /** * Zebra tables * - * @access protected * @param string table name * @param string plugin location * @return string @@ -765,7 +733,6 @@ class CI_Jquery extends CI_Javascript { * * http://www.malsup.com/jquery/corner/ * - * @access public * @param string target * @return string */ @@ -789,7 +756,6 @@ class CI_Jquery extends CI_Javascript { * * Load a thickbox modal window * - * @access public * @return void */ public function modal($src, $relative = FALSE) @@ -804,7 +770,6 @@ class CI_Jquery extends CI_Javascript { * * Load an Effect library * - * @access public * @return void */ public function effect($src, $relative = FALSE) @@ -819,7 +784,6 @@ class CI_Jquery extends CI_Javascript { * * Load a plugin library * - * @access public * @return void */ public function plugin($src, $relative = FALSE) @@ -834,7 +798,6 @@ class CI_Jquery extends CI_Javascript { * * Load a user interface library * - * @access public * @return void */ public function ui($src, $relative = FALSE) @@ -848,7 +811,6 @@ class CI_Jquery extends CI_Javascript { * * Creates a jQuery sortable * - * @access public * @return void */ public function sortable($element, $options = array()) @@ -876,7 +838,6 @@ class CI_Jquery extends CI_Javascript { /** * Table Sorter Plugin * - * @access public * @param string table name * @param string plugin location * @return string @@ -895,7 +856,6 @@ class CI_Jquery extends CI_Javascript { * * Constructs the syntax for an event, and adds to into the array for compilation * - * @access protected * @param string The element to attach the event to * @param string The code to execute * @param string The event to pass @@ -922,7 +882,6 @@ class CI_Jquery extends CI_Javascript { * As events are specified, they are stored in an array * This funciton compiles them all for output on a page * - * @access protected * @return string */ protected function _compile($view_var = 'script_foot', $script_tags = TRUE) @@ -955,7 +914,6 @@ class CI_Jquery extends CI_Javascript { * * Clears the array of script events collected for output * - * @access protected * @return void */ protected function _clear_compile() @@ -970,7 +928,6 @@ class CI_Jquery extends CI_Javascript { * * A wrapper for writing document.ready() * - * @access protected * @return string */ protected function _document_ready($js) @@ -993,7 +950,6 @@ class CI_Jquery extends CI_Javascript { * * Outputs the script tag that loads the jquery.js file into an HTML document * - * @access public * @param string * @return string */ @@ -1013,7 +969,6 @@ class CI_Jquery extends CI_Javascript { * unless the supplied element is the Javascript 'this' * object, in which case no quotes are added * - * @access protected * @param string * @return string */ @@ -1034,7 +989,6 @@ class CI_Jquery extends CI_Javascript { * * Ensures the speed parameter is valid for jQuery * - * @access protected * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From 394ae12c0512ac5b376fd26b022c760ca8661e95 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:40:41 +0200 Subject: Remove access lines from method descriptions --- system/libraries/User_agent.php | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index d55fc3e14..c31ff2646 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -65,7 +65,6 @@ class CI_User_agent { * * Sets the User Agent and runs the compilation routine * - * @access public * @return void */ public function __construct() @@ -91,7 +90,6 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access protected * @return bool */ protected function _load_agent_file() @@ -147,7 +145,6 @@ class CI_User_agent { /** * Compile the User Agent Data * - * @access protected * @return bool */ protected function _compile_data() @@ -168,7 +165,6 @@ class CI_User_agent { /** * Set the Platform * - * @access protected * @return mixed */ protected function _set_platform() @@ -192,7 +188,6 @@ class CI_User_agent { /** * Set the Browser * - * @access protected * @return bool */ protected function _set_browser() @@ -219,7 +214,6 @@ class CI_User_agent { /** * Set the Robot * - * @access protected * @return bool */ protected function _set_robot() @@ -244,7 +238,6 @@ class CI_User_agent { /** * Set the Mobile Device * - * @access protected * @return bool */ protected function _set_mobile() @@ -269,7 +262,6 @@ class CI_User_agent { /** * Set the accepted languages * - * @access protected * @return void */ protected function _set_languages() @@ -290,7 +282,6 @@ class CI_User_agent { /** * Set the accepted character sets * - * @access protected * @return void */ protected function _set_charsets() @@ -311,7 +302,6 @@ class CI_User_agent { /** * Is Browser * - * @access public * @return bool */ public function is_browser($key = NULL) @@ -336,7 +326,6 @@ class CI_User_agent { /** * Is Robot * - * @access public * @return bool */ public function is_robot($key = NULL) @@ -361,7 +350,6 @@ class CI_User_agent { /** * Is Mobile * - * @access public * @return bool */ public function is_mobile($key = NULL) @@ -386,7 +374,6 @@ class CI_User_agent { /** * Is this a referral from another site? * - * @access public * @return bool */ public function is_referral() @@ -399,7 +386,6 @@ class CI_User_agent { /** * Agent String * - * @access public * @return string */ public function agent_string() @@ -412,7 +398,6 @@ class CI_User_agent { /** * Get Platform * - * @access public * @return string */ public function platform() @@ -425,7 +410,6 @@ class CI_User_agent { /** * Get Browser Name * - * @access public * @return string */ public function browser() @@ -438,7 +422,6 @@ class CI_User_agent { /** * Get the Browser Version * - * @access public * @return string */ public function version() @@ -451,7 +434,6 @@ class CI_User_agent { /** * Get The Robot Name * - * @access public * @return string */ public function robot() @@ -463,7 +445,6 @@ class CI_User_agent { /** * Get the Mobile Device * - * @access public * @return string */ public function mobile() @@ -476,7 +457,6 @@ class CI_User_agent { /** * Get the referrer * - * @access public * @return bool */ public function referrer() @@ -489,7 +469,6 @@ class CI_User_agent { /** * Get the accepted languages * - * @access public * @return array */ public function languages() @@ -507,7 +486,6 @@ class CI_User_agent { /** * Get the accepted Character Sets * - * @access public * @return array */ public function charsets() @@ -525,7 +503,6 @@ class CI_User_agent { /** * Test for a particular language * - * @access public * @return bool */ public function accept_lang($lang = 'en') @@ -538,7 +515,6 @@ class CI_User_agent { /** * Test for a particular character set * - * @access public * @return bool */ public function accept_charset($charset = 'utf-8') -- cgit v1.2.3-24-g4f1b From 9c0e2346e06e71d4f2c467f986dc39ff30137643 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:42:31 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Unit_test.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php index 99c34ea61..fd3880d29 100644 --- a/system/libraries/Unit_test.php +++ b/system/libraries/Unit_test.php @@ -70,7 +70,6 @@ class CI_Unit_test { * * Runs the supplied tests * - * @access public * @param array * @return void */ @@ -89,7 +88,6 @@ class CI_Unit_test { * * Runs the supplied tests * - * @access public * @param mixed * @param mixed * @param string @@ -138,7 +136,6 @@ class CI_Unit_test { * * Displays a table with the test data * - * @access public * @return string */ public function report($result = array()) @@ -188,7 +185,6 @@ class CI_Unit_test { * * Causes the evaluation to use === rather than == * - * @access public * @param bool * @return null */ @@ -204,7 +200,6 @@ class CI_Unit_test { * * Enables/disables unit testing * - * @access public * @param bool * @return null */ @@ -220,7 +215,6 @@ class CI_Unit_test { * * Returns the raw result data * - * @access public * @return array */ public function result($results = array()) @@ -278,7 +272,6 @@ class CI_Unit_test { * * This lets us set the template to be used to display results * - * @access public * @param string * @return void */ @@ -294,7 +287,6 @@ class CI_Unit_test { * * This lets us show file names and line numbers * - * @access protected * @return array */ protected function _backtrace() @@ -315,7 +307,6 @@ class CI_Unit_test { /** * Get Default Template * - * @access protected * @return string */ protected function _default_template() @@ -333,7 +324,6 @@ class CI_Unit_test { * * Harvests the data within the template {pseudo-variables} * - * @access protected * @return void */ protected function _parse_template() @@ -359,8 +349,6 @@ class CI_Unit_test { /** * Helper functions to test boolean true/false * - * - * @access protected * @return bool */ function is_true($test) -- cgit v1.2.3-24-g4f1b From cdf0c01f65f0b024fedc474a988957ed45a771e7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:44:33 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Trackback.php | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php index 4302634cc..b5e68507f 100644 --- a/system/libraries/Trackback.php +++ b/system/libraries/Trackback.php @@ -47,11 +47,6 @@ class CI_Trackback { public $response = ''; public $error_msg = array(); - /** - * Constructor - * - * @access public - */ public function __construct() { log_message('debug', "Trackback Class Initialized"); @@ -62,7 +57,6 @@ class CI_Trackback { /** * Send Trackback * - * @access public * @param array * @return bool */ @@ -133,7 +127,6 @@ class CI_Trackback { * If the data is valid it is set to the $this->data array * so that it can be inserted into a database. * - * @access public * @return bool */ public function receive() @@ -175,7 +168,6 @@ class CI_Trackback { * sends the "incomplete information" error, as that's * the most common one. * - * @access public * @param string * @return void */ @@ -193,7 +185,6 @@ class CI_Trackback { * This should be called when a trackback has been * successfully received and inserted. * - * @access public * @return void */ public function send_success() @@ -207,7 +198,6 @@ class CI_Trackback { /** * Fetch a particular item * - * @access public * @param string * @return string */ @@ -224,7 +214,6 @@ class CI_Trackback { * Opens a socket connection and passes the data to * the server. Returns TRUE on success, FALSE on failure * - * @access public * @param string * @param string * @return bool @@ -288,7 +277,6 @@ class CI_Trackback { * It takes a string of URLs (separated by comma or * space) and puts each URL into an array * - * @access public * @param string * @return string */ @@ -324,7 +312,6 @@ class CI_Trackback { * * Simply adds "http://" if missing * - * @access public * @param string * @return string */ @@ -343,7 +330,6 @@ class CI_Trackback { /** * Find the Trackback URL's ID * - * @access public * @param string * @return string */ @@ -392,7 +378,6 @@ class CI_Trackback { /** * Convert Reserved XML characters to Entities * - * @access public * @param string * @return string */ @@ -418,7 +403,6 @@ class CI_Trackback { * * Limits the string based on the character count. Will preserve complete words. * - * @access public * @param string * @param integer * @param string @@ -457,7 +441,6 @@ class CI_Trackback { * Converts Hight ascii text and MS Word special chars * to character entities * - * @access public * @param string * @return string */ @@ -503,7 +486,6 @@ class CI_Trackback { /** * Set error message * - * @access public * @param string * @return void */ @@ -518,7 +500,6 @@ class CI_Trackback { /** * Show error messages * - * @access public * @param string * @param string * @return string -- cgit v1.2.3-24-g4f1b From 0c82cf5fa2555a28c05d0b64a15f27933a4ab382 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:45:56 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Table.php | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Table.php b/system/libraries/Table.php index 9aa467b1a..1851bf3bc 100644 --- a/system/libraries/Table.php +++ b/system/libraries/Table.php @@ -59,7 +59,6 @@ class CI_Table { /** * Set the template * - * @access public * @param array * @return void */ @@ -80,7 +79,6 @@ class CI_Table { * * Can be passed as an array or discreet params * - * @access public * @param mixed * @return void */ @@ -98,7 +96,6 @@ class CI_Table { * columns. This allows a single array with many elements to be * displayed in a table that has a fixed column count. * - * @access public * @param array * @param int * @return void @@ -146,7 +143,6 @@ class CI_Table { * * Can be passed as an array or discreet params * - * @access public * @param mixed * @return void */ @@ -162,7 +158,6 @@ class CI_Table { * * Can be passed as an array or discreet params * - * @access public * @param mixed * @return void */ @@ -179,7 +174,6 @@ class CI_Table { * * Ensures a standard associative array format for all cell data * - * @access protected * @param type * @return type */ @@ -225,7 +219,6 @@ class CI_Table { /** * Add a table caption * - * @access public * @param string * @return void */ @@ -239,7 +232,6 @@ class CI_Table { /** * Generate the table * - * @access public * @param mixed * @return string */ @@ -376,7 +368,6 @@ class CI_Table { /** * Clears the table arrays. Useful if multiple tables are being generated * - * @access public * @return void */ public function clear() @@ -391,7 +382,6 @@ class CI_Table { /** * Set table data from a database result object * - * @access protected * @param object * @return void */ @@ -429,7 +419,6 @@ class CI_Table { /** * Set table data from an array * - * @access protected * @param array * @return void */ @@ -460,7 +449,6 @@ class CI_Table { /** * Compile Template * - * @access protected * @return void */ protected function _compile_template() @@ -486,7 +474,6 @@ class CI_Table { /** * Default Template * - * @access protected * @return void */ protected function _default_template() -- cgit v1.2.3-24-g4f1b From 85f018f7cfd7596f06c600e83f0fc9bb2e6efdbf Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:52:36 +0200 Subject: Remove access lines from method descriptions and rollback a previous change --- system/libraries/Session.php | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 319860794..137b037b8 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -141,7 +141,6 @@ class CI_Session { /** * Fetch the current session data if it exists * - * @access public * @return bool */ public function sess_read() @@ -259,7 +258,6 @@ class CI_Session { /** * Write the session data * - * @access public * @return void */ public function sess_write() @@ -311,7 +309,6 @@ class CI_Session { /** * Create a new session * - * @access public * @return void */ public function sess_create() @@ -350,7 +347,6 @@ class CI_Session { /** * Update an existing session * - * @access public * @return void */ public function sess_update() @@ -404,7 +400,6 @@ class CI_Session { /** * Destroy the current session * - * @access public * @return void */ public function sess_destroy() @@ -432,7 +427,6 @@ class CI_Session { /** * Fetch a specific item from the session array * - * @access public * @param string * @return string */ @@ -446,7 +440,6 @@ class CI_Session { /** * Fetch all session data * - * @access public * @return array */ public function all_userdata() @@ -459,7 +452,6 @@ class CI_Session { /** * Add or change data in the "userdata" array * - * @access public * @param mixed * @param string * @return void @@ -487,7 +479,6 @@ class CI_Session { /** * Delete a session variable from the "userdata" array * - * @access array * @return void */ public function unset_userdata($newdata = array()) @@ -514,7 +505,6 @@ class CI_Session { * Add or change flashdata, only available * until the next request * - * @access public * @param mixed * @param string * @return void @@ -540,7 +530,6 @@ class CI_Session { /** * Keeps existing flashdata available to next request. * - * @access public * @param string * @return void */ @@ -560,7 +549,6 @@ class CI_Session { /** * Fetch a specific flashdata item from the session array * - * @access public * @param string * @return string */ @@ -575,7 +563,6 @@ class CI_Session { * Identifies flashdata as 'old' for removal * when _flashdata_sweep() runs. * - * @access protected * @return void */ protected function _flashdata_mark() @@ -597,7 +584,6 @@ class CI_Session { /** * Removes all flashdata marked as 'old' * - * @access protected * @return void */ @@ -619,14 +605,17 @@ class CI_Session { /** * Get the "now" time * - * @access protected * @return string */ protected function _get_time() { - $now = time(); - return (strtolower($this->time_reference) === 'gmt') ? - mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), gmdate('d', $now), gmdate('Y', $now)) : $now; + if (strtolower($this->time_reference) === 'gmt') + { + $now = time(); + return mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), gmdate('d', $now), gmdate('Y', $now)); + } + + return time(); } // -------------------------------------------------------------------- @@ -634,7 +623,6 @@ class CI_Session { /** * Write the session cookie * - * @access public * @return void */ protected function _set_cookie($cookie_data = NULL) @@ -678,7 +666,6 @@ class CI_Session { * This function first converts any slashes found in the array to a temporary * marker, so when it gets unserialized the slashes will be preserved * - * @access protected * @param array * @return string */ @@ -700,7 +687,6 @@ class CI_Session { * * This function converts any slashes found into a temporary marker * - * @access protected */ function _escape_slashes(&$val, $key) { @@ -718,7 +704,6 @@ class CI_Session { * This function unserializes a data string, then converts any * temporary slash markers back to actual slashes * - * @access protected * @param array * @return string */ @@ -740,7 +725,6 @@ class CI_Session { * * This function converts any slash markers back into actual slashes * - * @access protected */ protected function _unescape_slashes(&$val, $key) { @@ -758,7 +742,6 @@ class CI_Session { * This deletes expired session rows from database * if the probability percentage is met * - * @access public * @return void */ protected function _sess_gc() -- cgit v1.2.3-24-g4f1b From 5342e8b0d8e4c0b585a4757d60f0fd7127704755 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 02:57:52 +0200 Subject: Remove access lines from method descriptions --- system/libraries/Image_lib.php | 24 ------------------------ 1 file changed, 24 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 70a127987..2737503a8 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -111,7 +111,6 @@ class CI_Image_lib { * * Resets values in case this class is used in a loop * - * @access public * @return void */ public function clear() @@ -154,7 +153,6 @@ class CI_Image_lib { /** * initialize image preferences * - * @access public * @param array * @return bool */ @@ -370,7 +368,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * resize function based on the protocol specified * - * @access public * @return bool */ public function resize() @@ -387,7 +384,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * cropping function based on the protocol specified * - * @access public * @return bool */ public function crop() @@ -404,7 +400,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the proper * rotation function based on the protocol specified * - * @access public * @return bool */ public function rotate() @@ -455,7 +450,6 @@ class CI_Image_lib { * * This function will resize or crop * - * @access public * @param string * @return bool */ @@ -561,7 +555,6 @@ class CI_Image_lib { * * This function will resize, crop or rotate * - * @access public * @param string * @return bool */ @@ -629,7 +622,6 @@ class CI_Image_lib { * * This function will resize, crop or rotate * - * @access public * @param string * @return bool */ @@ -713,7 +705,6 @@ class CI_Image_lib { /** * Image Rotate Using GD * - * @access public * @return bool */ public function image_rotate_gd() @@ -766,7 +757,6 @@ class CI_Image_lib { * * This function will flip horizontal or vertical * - * @access public * @return bool */ public function image_mirror_gd() @@ -845,7 +835,6 @@ class CI_Image_lib { * This is a wrapper function that chooses the type * of watermarking based on the specified preference. * - * @access public * @param string * @return bool */ @@ -866,7 +855,6 @@ class CI_Image_lib { /** * Watermark - Graphic Version * - * @access public * @return bool */ public function overlay_watermark() @@ -976,7 +964,6 @@ class CI_Image_lib { /** * Watermark - Text Version * - * @access public * @return bool */ public function text_watermark() @@ -1123,7 +1110,6 @@ class CI_Image_lib { * This simply creates an image resource handle * based on the type of image being processed * - * @access public * @param string * @return resource */ @@ -1180,7 +1166,6 @@ class CI_Image_lib { * Takes an image resource as input and writes the file * to the specified destination * - * @access public * @param resource * @return bool */ @@ -1241,7 +1226,6 @@ class CI_Image_lib { /** * Dynamically outputs an image * - * @access public * @param resource * @return void */ @@ -1277,7 +1261,6 @@ class CI_Image_lib { * This function lets us re-proportion the width/height * if users choose to maintain the aspect ratio when resizing. * - * @access public * @return void */ public function image_reproportion() @@ -1318,7 +1301,6 @@ class CI_Image_lib { * * A helper function that gets info about the file * - * @access public * @param string * @return mixed */ @@ -1376,7 +1358,6 @@ class CI_Image_lib { * 'new_height' => '' * ); * - * @access public * @param array * @return array */ @@ -1424,7 +1405,6 @@ class CI_Image_lib { * $array['ext'] = '.jpg'; * $array['name'] = 'my.cool'; * - * @access public * @param array * @return array */ @@ -1441,7 +1421,6 @@ class CI_Image_lib { /** * Is GD Installed? * - * @access public * @return bool */ public function gd_loaded() @@ -1462,7 +1441,6 @@ class CI_Image_lib { /** * Get GD version * - * @access public * @return mixed */ public function gd_version() @@ -1483,7 +1461,6 @@ class CI_Image_lib { /** * Set error message * - * @access public * @param string * @return void */ @@ -1515,7 +1492,6 @@ class CI_Image_lib { /** * Show error messages * - * @access public * @param string * @return string */ -- cgit v1.2.3-24-g4f1b From 7c251b38b690183b590adeb31d5155d043b6f74b Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 27 Dec 2011 16:37:23 +0200 Subject: Improve the Encryption library --- system/libraries/Encrypt.php | 92 +++++++++++++++----------------------------- 1 file changed, 32 insertions(+), 60 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 92b0b3c4a..d9f40b0d5 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -1,13 +1,13 @@ -get_key($key); - - if ($this->_mcrypt_exists === TRUE) - { - $enc = $this->mcrypt_encode($string, $key); - } - else - { - $enc = $this->_xor_encode($string, $key); - } - - return base64_encode($enc); + $method = ($this->_mcrypt_exists === TRUE) ? 'mcrypt_encode' : '_xor_encode'; + return base64_encode($this->$method($string, $this->get_key($key))); } // -------------------------------------------------------------------- @@ -149,28 +139,13 @@ class CI_Encrypt { */ public function decode($string, $key = '') { - $key = $this->get_key($key); - if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) { return FALSE; } - $dec = base64_decode($string); - - if ($this->_mcrypt_exists === TRUE) - { - if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE) - { - return FALSE; - } - } - else - { - $dec = $this->_xor_decode($dec, $key); - } - - return $dec; + $method = ($this->_mcrypt_exists === TRUE) ? 'mcrypt_decode' : '_xor_decode'; + return $this->$method(base64_decode($string), $this->get_key($key)); } // -------------------------------------------------------------------- @@ -197,6 +172,10 @@ class CI_Encrypt { log_message('error', 'Encoding from legacy is available only when Mcrypt is in use.'); return FALSE; } + elseif (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) + { + return FALSE; + } // decode it first // set mode temporarily to what it was when string was encoded with the legacy @@ -205,12 +184,6 @@ class CI_Encrypt { $this->set_mode($legacy_mode); $key = $this->get_key($key); - - if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string)) - { - return FALSE; - } - $dec = base64_decode($string); if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE) @@ -242,17 +215,18 @@ class CI_Encrypt { protected function _xor_encode($string, $key) { $rand = ''; - while (strlen($rand) < 32) + do { $rand .= mt_rand(0, mt_getrandmax()); } + while (strlen($rand) < 32); $rand = $this->hash($rand); $enc = ''; - for ($i = 0; $i < strlen($string); $i++) + for ($i = 0, $ls = strlen($string), $lr = strlen($rand); $i < $ls; $i++) { - $enc .= substr($rand, ($i % strlen($rand)), 1).(substr($rand, ($i % strlen($rand)), 1) ^ substr($string, $i, 1)); + $enc .= $rand[($i % $lr)].($rand[($i % $lr)] ^ $string[$i]); } return $this->_xor_merge($enc, $key); @@ -275,9 +249,9 @@ class CI_Encrypt { $string = $this->_xor_merge($string, $key); $dec = ''; - for ($i = 0; $i < strlen($string); $i++) + for ($i = 0, $l = strlen($string); $i < $l; $i++) { - $dec .= (substr($string, $i++, 1) ^ substr($string, $i, 1)); + $dec .= ($string[$i++] ^ $string[$i]); } return $dec; @@ -298,9 +272,9 @@ class CI_Encrypt { { $hash = $this->hash($key); $str = ''; - for ($i = 0; $i < strlen($string); $i++) + for ($i = 0, $ls = strlen($string), $lh = strlen($hash); $i < $ls; $i++) { - $str .= substr($string, $i, 1) ^ substr($hash, ($i % strlen($hash)), 1); + $str .= $string[$i] ^ $hash[($i % $lh)]; } return $str; @@ -359,18 +333,17 @@ class CI_Encrypt { */ protected function _add_cipher_noise($data, $key) { - $keyhash = $this->hash($key); - $keylen = strlen($keyhash); + $key = $this->hash($key); $str = ''; - for ($i = 0, $j = 0, $len = strlen($data); $i < $len; ++$i, ++$j) + for ($i = 0, $j = 0, $ld = strlen($data), $lk = strlen($key); $i < $ld; ++$i, ++$j) { - if ($j >= $keylen) + if ($j >= $lk) { $j = 0; } - $str .= chr((ord($data[$i]) + ord($keyhash[$j])) % 256); + $str .= chr((ord($data[$i]) + ord($key[$j])) % 256); } return $str; @@ -389,22 +362,21 @@ class CI_Encrypt { */ protected function _remove_cipher_noise($data, $key) { - $keyhash = $this->hash($key); - $keylen = strlen($keyhash); + $key = $this->hash($key); $str = ''; - for ($i = 0, $j = 0, $len = strlen($data); $i < $len; ++$i, ++$j) + for ($i = 0, $j = 0, $ld = strlen($data), $lk = strlen($key); $i < $ld; ++$i, ++$j) { - if ($j >= $keylen) + if ($j >= $lk) { $j = 0; } - $temp = ord($data[$i]) - ord($keyhash[$j]); + $temp = ord($data[$i]) - ord($key[$j]); if ($temp < 0) { - $temp = $temp + 256; + $temp += 256; } $str .= chr($temp); @@ -435,7 +407,7 @@ class CI_Encrypt { * @param constant * @return string */ - function set_mode($mode) + public function set_mode($mode) { $this->_mcrypt_mode = $mode; return $this; @@ -485,7 +457,7 @@ class CI_Encrypt { */ public function set_hash($type = 'sha1') { - $this->_hash_type = ($type != 'sha1' AND $type != 'md5') ? 'sha1' : $type; + $this->_hash_type = ($type !== 'sha1' AND $type !== 'md5') ? 'sha1' : $type; } // -------------------------------------------------------------------- @@ -498,11 +470,11 @@ class CI_Encrypt { */ public function hash($str) { - return ($this->_hash_type == 'sha1') ? sha1($str) : md5($str); + return ($this->_hash_type === 'sha1') ? sha1($str) : md5($str); } } // END CI_Encrypt class /* End of file Encrypt.php */ -/* Location: ./system/libraries/Encrypt.php */ \ No newline at end of file +/* Location: ./system/libraries/Encrypt.php */ -- cgit v1.2.3-24-g4f1b From d96f88277c1e9a4c069c2e2ee3d779385549f31a Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Tue, 27 Dec 2011 16:23:47 -0600 Subject: Revert "Abstracting the loading of files in the config directory depending on environments." This reverts commit 5c1aa631c5f5ec2f6b75ba1158178418e50ba11a. --- system/libraries/Upload.php | 15 ++++++++++----- system/libraries/User_agent.php | 13 +++++++++---- 2 files changed, 19 insertions(+), 9 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 5108afa1b..826bcceb8 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -952,12 +952,17 @@ class CI_Upload { { global $mimes; - if (count($this->mimes) === 0) + if (count($this->mimes) == 0) { - load_environ_config('mimes'); - - // Return FALSE if we still have no mimes after trying to load them up. - if (count($this->mimes) === 0) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); + } + elseif (is_file(APPPATH.'config/mimes.php')) + { + include(APPPATH.'config//mimes.php'); + } + else { return FALSE; } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 5288525cb..c31ff2646 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -94,10 +94,15 @@ class CI_User_agent { */ protected function _load_agent_file() { - load_environ_config('user_agents'); - - // Return FALSE if we still have no mimes after trying to load them up. - if (count($this->mimes) === 0) + if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); + } + elseif (is_file(APPPATH.'config/user_agents.php')) + { + include(APPPATH.'config/user_agents.php'); + } + else { return FALSE; } -- cgit v1.2.3-24-g4f1b From 345e7ee1c655c53b8022c3e725a4266e15bd2542 Mon Sep 17 00:00:00 2001 From: Ronald Beilsma Date: Wed, 28 Dec 2011 12:59:04 +0100 Subject: fixed bug in pagination library return value of ceil is of type float --- system/libraries/Pagination.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 008c15192..d10bef3e5 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -131,7 +131,7 @@ class CI_Pagination { $num_pages = ceil($this->total_rows / $this->per_page); // Is there only one page? Hm... nothing more to do here then. - if ($num_pages === 1) + if ($num_pages == 1) { return ''; } -- cgit v1.2.3-24-g4f1b From 64b013611f65006197fdf465186ca36adf12847d Mon Sep 17 00:00:00 2001 From: Ronald Beilsma Date: Wed, 28 Dec 2011 12:59:45 +0100 Subject: fixed bug in typography library array index starts at 0, not 1 --- system/libraries/Typography.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php index 651ba7bff..ac9486a6b 100644 --- a/system/libraries/Typography.php +++ b/system/libraries/Typography.php @@ -144,7 +144,7 @@ class CI_Typography { $process = TRUE; $paragraph = FALSE; - for ($i = 1, $c = count($chunks); $i <= $c; $i++) + for ($i = 0, $c = count($chunks) - 1; $i <= $c; $i++) { // Are we dealing with a tag? If so, we'll skip the processing for this cycle. // Well also set the "process" flag which allows us to skip
 tags and a few other things.
-- 
cgit v1.2.3-24-g4f1b


From cfb7021e9f53fa089bfd676978b448b27e4bd996 Mon Sep 17 00:00:00 2001
From: Ronald Beilsma 
Date: Thu, 29 Dec 2011 09:57:49 +0100
Subject: ceil returned float (line 131), so if statement in line 134 was bound
 to return false (===, float vs integer)

---
 system/libraries/Pagination.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index d10bef3e5..63b750bdb 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -128,10 +128,10 @@ class CI_Pagination {
 		}
 
 		// Calculate the total number of pages
-		$num_pages = ceil($this->total_rows / $this->per_page);
+		$num_pages = (int) ceil($this->total_rows / $this->per_page);
 
 		// Is there only one page? Hm... nothing more to do here then.
-		if ($num_pages == 1)
+		if ($num_pages === 1)
 		{
 			return '';
 		}
-- 
cgit v1.2.3-24-g4f1b


From 6209015edde25e8ca82a8e8f5eb5a5eda2750e7b Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 12:49:27 +0200
Subject: Some more optimizations

---
 system/libraries/Xmlrpc.php | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index ebb04601b..2804e6685 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -542,7 +542,7 @@ class XML_RPC_Response
 		elseif ($kind == 'array')
 		{
 			reset($xmlrpc_val->me);
-			list($a,$b) = each($xmlrpc_val->me);
+			list(, $b) = each($xmlrpc_val->me);
 			$arr = array();
 
 			for ($i = 0, $size = count($b); $i < $size; $i++)
@@ -1150,7 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 		elseif ($kind == 'array')
 		{
 			reset($param->me);
-			list($a,$b) = each($param->me);
+			list(, $b) = each($param->me);
 
 			$arr = array();
 
@@ -1359,7 +1359,7 @@ class XML_RPC_Values extends CI_Xmlrpc
 	public function scalarval()
 	{
 		reset($this->me);
-		list($a,$b) = each($this->me);
+		list(, $b) = each($this->me);
 		return $b;
 	}
 
@@ -1370,14 +1370,9 @@ class XML_RPC_Values extends CI_Xmlrpc
 
 	// Useful for sending time in XML-RPC
 
-	public function iso8601_encode($time, $utc=0)
+	public function iso8601_encode($time, $utc = 0)
 	{
-		if ($utc == 1)
-		{
-			return strftime("%Y%m%dT%H:%i:%s", $time);
-		}
-
-		return (function_exists('gmstrftime')) ? gmstrftime('%Y%m%dT%H:%i:%s', $time) : strftime('%Y%m%dT%H:%i:%s', $time - date('Z'));
+		return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time);
 	}
 
 }
-- 
cgit v1.2.3-24-g4f1b


From 64dbdfb60e0556177061db2eecdf899111ae4ac9 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 14:14:07 +0200
Subject: Added support for 3-length hex color values format and a number of
 validation improvements

---
 system/libraries/Image_lib.php | 87 ++++++++++++++++++++++++------------------
 1 file changed, 49 insertions(+), 38 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 2737503a8..d4fb51923 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -67,8 +67,8 @@ class CI_Image_lib {
 	public $wm_padding			= 0;			// Padding around text
 	public $wm_hor_offset		= 0;			// Lets you push text to the right
 	public $wm_vrt_offset		= 0;			// Lets you push  text down
-	public $wm_font_color		= '#ffffff';	// Text color
-	public $wm_shadow_color	= '';			// Dropshadow color
+	protected $wm_font_color		= '#ffffff';	// Text color
+	protected $wm_shadow_color		= '';	// Dropshadow color
 	public $wm_shadow_distance	= 2;			// Dropshadow distance
 	public $wm_opacity			= 50;			// Image opacity: 1 - 100  Only works with image
 
@@ -85,7 +85,7 @@ class CI_Image_lib {
 	public $create_fnc			= 'imagecreatetruecolor';
 	public $copy_fnc			= 'imagecopyresampled';
 	public $error_msg			= array();
-	public $wm_use_drop_shadow	= FALSE;
+	protected $wm_use_drop_shadow	= FALSE;
 	public $wm_use_truetype	= FALSE;
 
 	/**
@@ -165,7 +165,30 @@ class CI_Image_lib {
 		{
 			foreach ($props as $key => $val)
 			{
-				$this->$key = $val;
+				if (property_exists($this, $key))
+				{
+					if (in_array($key, array('wm_font_color', 'wm_shadow_color')))
+					{
+						if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
+						{
+							if (strlen($matches[1]) === 6)
+							{
+								$val = '#'.$val;
+							}
+							else
+							{
+								$val = str_split($val, 1);
+								$val = '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2];
+							}
+						}
+						else
+						{
+							continue;
+						}
+					}
+
+					$this->$key = $val;
+				}
 			}
 		}
 
@@ -332,16 +355,6 @@ class CI_Image_lib {
 		$this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis;
 
 		// Watermark-related Stuff...
-		if ($this->wm_font_color != '' AND strlen($this->wm_font_color) === 6)
-		{
-			$this->wm_font_color = '#'.$this->wm_font_color;
-		}
-
-		if ($this->wm_shadow_color != '' AND strlen($this->wm_shadow_color) === 6)
-		{
-			$this->wm_shadow_color = '#'.$this->wm_shadow_color;
-		}
-
 		if ($this->wm_overlay_path != '')
 		{
 			$this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path));
@@ -351,6 +364,10 @@ class CI_Image_lib {
 		{
 			$this->wm_use_drop_shadow = TRUE;
 		}
+		elseif ($this->wm_use_drop_shadow == TRUE AND $this->wm_shadow_color == '')
+		{
+			$this->wm_use_drop_shadow = FALSE;
+		}
 
 		if ($this->wm_font_path != '')
 		{
@@ -982,21 +999,6 @@ class CI_Image_lib {
 		//  Fetch source image properties
 		$this->get_image_properties();
 
-		// Set RGB values for text and shadow
-		$this->wm_font_color	= str_replace('#', '', $this->wm_font_color);
-		$this->wm_shadow_color	= str_replace('#', '', $this->wm_shadow_color);
-
-		$R1 = hexdec(substr($this->wm_font_color, 0, 2));
-		$G1 = hexdec(substr($this->wm_font_color, 2, 2));
-		$B1 = hexdec(substr($this->wm_font_color, 4, 2));
-
-		$R2 = hexdec(substr($this->wm_shadow_color, 0, 2));
-		$G2 = hexdec(substr($this->wm_shadow_color, 2, 2));
-		$B2 = hexdec(substr($this->wm_shadow_color, 4, 2));
-
-		$txt_color	= imagecolorclosest($src_img, $R1, $G1, $B1);
-		$drp_color	= imagecolorclosest($src_img, $R2, $G2, $B2);
-
 		// Reverse the vertical offset
 		// When the image is positioned at the bottom
 		// we don't want the vertical offset to push it
@@ -1075,16 +1077,25 @@ class CI_Image_lib {
 				break;
 		}
 
-		//  Add the text to the source image
-		if ($this->wm_use_truetype AND $this->wm_use_drop_shadow)
-		{
-			imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
-			imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
-		}
-		elseif ($this->wm_use_drop_shadow)
+		if ($this->wm_use_drop_shadow)
 		{
-			imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
-			imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
+			// Set RGB values for text and shadow
+			$txt_color = str_split(substr($this->wm_font_color, 1, 6));
+			$txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2]));
+			$drp_color = str_split(substr($this->wm_shadow_color, 1, 6));
+			$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3]));
+
+			//  Add the text to the source image
+			if ($this->wm_use_truetype)
+			{
+				imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
+				imagettftext($src_img, $this->wm_font_size, 0, $x_axis, $y_axis, $txt_color, $this->wm_font_path, $this->wm_text);
+			}
+			else
+			{
+				imagestring($src_img, $this->wm_font_size, $x_shad, $y_shad, $this->wm_text, $drp_color);
+				imagestring($src_img, $this->wm_font_size, $x_axis, $y_axis, $this->wm_text, $txt_color);
+			}
 		}
 
 		//  Output the final image
-- 
cgit v1.2.3-24-g4f1b


From a948f07bde83e149d9fc75e9aaf7260efba39b55 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 14:22:50 +0200
Subject: Remove a str_split() from the previous commit - we can access string
 characters like we do in an indexed array anyways

---
 system/libraries/Image_lib.php | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index d4fb51923..72621c9b4 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -171,15 +171,7 @@ class CI_Image_lib {
 					{
 						if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
 						{
-							if (strlen($matches[1]) === 6)
-							{
-								$val = '#'.$val;
-							}
-							else
-							{
-								$val = str_split($val, 1);
-								$val = '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2];
-							}
+							$val = (strlen($matches[1]) === 6) ? '#'.$val : '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2];
 						}
 						else
 						{
-- 
cgit v1.2.3-24-g4f1b


From 1d97f291fa1988794b0e6ac2b90a0b1f8c83df25 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 14:24:59 +0200
Subject: Another fix on a previous commit from this request

---
 system/libraries/Image_lib.php | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 72621c9b4..609cb7f98 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -171,7 +171,8 @@ class CI_Image_lib {
 					{
 						if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
 						{
-							$val = (strlen($matches[1]) === 6) ? '#'.$val : '#'.$val[0].$val[0].$val[1].$val[1].$val[2].$val[2];
+							$val = (strlen($matches[1]) === 6) ?
+								'#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2];
 						}
 						else
 						{
-- 
cgit v1.2.3-24-g4f1b


From 665af0cbb98372f8521298aafcde9e0c9023123e Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 14:39:29 +0200
Subject: Some alignment for readability

---
 system/libraries/Image_lib.php | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 609cb7f98..7beac0ba0 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -171,8 +171,9 @@ class CI_Image_lib {
 					{
 						if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
 						{
-							$val = (strlen($matches[1]) === 6) ?
-								'#'.$matches[1] : '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2];
+							$val = (strlen($matches[1]) === 6)
+								? '#'.$matches[1]
+								: '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2];
 						}
 						else
 						{
-- 
cgit v1.2.3-24-g4f1b


From adc1175f7af1a5fa3a833f72b6f24a82b59e69c1 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Fri, 30 Dec 2011 14:46:08 +0200
Subject: Replace some list(...) = each(...) expressions with current(), where
 only values are needed

---
 system/libraries/Xmlrpc.php | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 2804e6685..bb95ca145 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -542,7 +542,7 @@ class XML_RPC_Response
 		elseif ($kind == 'array')
 		{
 			reset($xmlrpc_val->me);
-			list(, $b) = each($xmlrpc_val->me);
+			$b = current($xmlrpc_val->me);
 			$arr = array();
 
 			for ($i = 0, $size = count($b); $i < $size; $i++)
@@ -1150,8 +1150,7 @@ class XML_RPC_Message extends CI_Xmlrpc
 		elseif ($kind == 'array')
 		{
 			reset($param->me);
-			list(, $b) = each($param->me);
-
+			$b = current($param->me);
 			$arr = array();
 
 			for($i = 0, $c = count($b); $i < $c; $i++)
@@ -1164,7 +1163,6 @@ class XML_RPC_Message extends CI_Xmlrpc
 		elseif ($kind == 'struct')
 		{
 			reset($param->me['struct']);
-
 			$arr = array();
 
 			while (list($key,$value) = each($param->me['struct']))
@@ -1359,8 +1357,7 @@ class XML_RPC_Values extends CI_Xmlrpc
 	public function scalarval()
 	{
 		reset($this->me);
-		list(, $b) = each($this->me);
-		return $b;
+		return current($this->me);
 	}
 
 
-- 
cgit v1.2.3-24-g4f1b


From d268eda6c2b502cc7fa352072482d1924e36127e Mon Sep 17 00:00:00 2001
From: Phil Sturgeon 
Date: Sat, 31 Dec 2011 16:20:11 +0000
Subject: Added SELECT version to migrations to make the query a billionth
 faster.

---
 system/libraries/Migration.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index eb5161d76..f89391c0d 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -322,7 +322,7 @@ class CI_Migration {
 	 */
 	protected function _get_version()
 	{
-		$row = $this->db->get($this->_migration_table)->row();
+		$row = $this->db->select('version')->get($this->_migration_table)->row();
 		return $row ? $row->version : 0;
 	}
 
-- 
cgit v1.2.3-24-g4f1b


From 8323ae6cebde490bc29141d8dadbdbc07a1c6a4a Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 31 Dec 2011 18:39:10 +0200
Subject: Fix a bug and put some comments describing changes from pull #818

---
 system/libraries/Image_lib.php | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 7beac0ba0..c175c6740 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -169,8 +169,21 @@ class CI_Image_lib {
 				{
 					if (in_array($key, array('wm_font_color', 'wm_shadow_color')))
 					{
-						if ($val != '' AND preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
+						if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
 						{
+							/* This particular line has caused a lengthy discussion
+							 * (https://github.com/EllisLab/CodeIgniter/pull/818), so
+							 * just to clarify:
+							 *
+							 * $matches[1] contains our hex color value, but it might be
+							 * both in the full 6-length format or the shortened 3-length
+							 * value.
+							 * We'll later need the full version, so if we keep it if it's
+							 * already there and if not - we'll convert to it. We can
+							 * access string characters by their index as in an array,
+							 * so we'll do that and use concatenation to form the final
+							 * value:
+							 */
 							$val = (strlen($matches[1]) === 6)
 								? '#'.$matches[1]
 								: '#'.$matches[1][0].$matches[1][0].$matches[1][1].$matches[1][1].$matches[1][2].$matches[1][2];
@@ -1073,10 +1086,15 @@ class CI_Image_lib {
 
 		if ($this->wm_use_drop_shadow)
 		{
-			// Set RGB values for text and shadow
-			$txt_color = str_split(substr($this->wm_font_color, 1, 6));
+			/* Set RGB values for text and shadow
+			 *
+			 * First character is #, so we don't really need it.
+			 * Get the rest of the string and split it into 2-length
+			 * hex values:
+			 */
+			$txt_color = str_split(substr($this->wm_font_color, 1, 6), 2);
 			$txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2]));
-			$drp_color = str_split(substr($this->wm_shadow_color, 1, 6));
+			$drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2);
 			$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3]));
 
 			//  Add the text to the source image
-- 
cgit v1.2.3-24-g4f1b


From bb96c8b466cb618c5fd6f004234a137011a7e374 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 31 Dec 2011 18:48:39 +0200
Subject: Fix a comment typo

---
 system/libraries/Image_lib.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index c175c6740..5f5b5f9d5 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -178,7 +178,7 @@ class CI_Image_lib {
 							 * $matches[1] contains our hex color value, but it might be
 							 * both in the full 6-length format or the shortened 3-length
 							 * value.
-							 * We'll later need the full version, so if we keep it if it's
+							 * We'll later need the full version, so we keep it if it's
 							 * already there and if not - we'll convert to it. We can
 							 * access string characters by their index as in an array,
 							 * so we'll do that and use concatenation to form the final
-- 
cgit v1.2.3-24-g4f1b


From cf2ba9ee5fc50b8411eba46ddd73c59b66524fea Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sun, 1 Jan 2012 21:57:13 +0200
Subject: Cut some comments

---
 system/libraries/Image_lib.php | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 5f5b5f9d5..fe9b8dc79 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -171,11 +171,7 @@ class CI_Image_lib {
 					{
 						if (preg_match('/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i', $val, $matches))
 						{
-							/* This particular line has caused a lengthy discussion
-							 * (https://github.com/EllisLab/CodeIgniter/pull/818), so
-							 * just to clarify:
-							 *
-							 * $matches[1] contains our hex color value, but it might be
+							/* $matches[1] contains our hex color value, but it might be
 							 * both in the full 6-length format or the shortened 3-length
 							 * value.
 							 * We'll later need the full version, so we keep it if it's
-- 
cgit v1.2.3-24-g4f1b


From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001
From: Greg Aker 
Date: Sun, 1 Jan 2012 18:46:41 -0600
Subject: Updating copyright date to 2012

---
 system/libraries/Cache/Cache.php                   | 2 +-
 system/libraries/Cache/drivers/Cache_apc.php       | 2 +-
 system/libraries/Cache/drivers/Cache_dummy.php     | 2 +-
 system/libraries/Cache/drivers/Cache_file.php      | 2 +-
 system/libraries/Cache/drivers/Cache_memcached.php | 2 +-
 system/libraries/Calendar.php                      | 2 +-
 system/libraries/Cart.php                          | 2 +-
 system/libraries/Driver.php                        | 2 +-
 system/libraries/Email.php                         | 2 +-
 system/libraries/Encrypt.php                       | 2 +-
 system/libraries/Form_validation.php               | 2 +-
 system/libraries/Ftp.php                           | 2 +-
 system/libraries/Image_lib.php                     | 2 +-
 system/libraries/Javascript.php                    | 2 +-
 system/libraries/Log.php                           | 2 +-
 system/libraries/Migration.php                     | 2 +-
 system/libraries/Pagination.php                    | 2 +-
 system/libraries/Parser.php                        | 2 +-
 system/libraries/Profiler.php                      | 2 +-
 system/libraries/Session.php                       | 2 +-
 system/libraries/Table.php                         | 2 +-
 system/libraries/Trackback.php                     | 2 +-
 system/libraries/Typography.php                    | 2 +-
 system/libraries/Unit_test.php                     | 2 +-
 system/libraries/Upload.php                        | 2 +-
 system/libraries/User_agent.php                    | 2 +-
 system/libraries/Xmlrpc.php                        | 2 +-
 system/libraries/Xmlrpcs.php                       | 2 +-
 system/libraries/Zip.php                           | 2 +-
 system/libraries/javascript/Jquery.php             | 2 +-
 30 files changed, 30 insertions(+), 30 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index 87253739c..2e78a6660 100644
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @copyright	Copyright (c) 2006 - 2012 EllisLab, Inc.
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index 90b68688d..93993d07a 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @copyright	Copyright (c) 2006 - 2012 EllisLab, Inc.
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index ff787e90b..fcd55da39 100644
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @copyright	Copyright (c) 2006 - 2012 EllisLab, Inc.
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index 194279726..4a81b0422 100644
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @copyright	Copyright (c) 2006 - 2012 EllisLab, Inc.
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 0037e6755..ffe6f2ff7 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011 EllisLab, Inc.
+ * @copyright	Copyright (c) 2006 - 2012 EllisLab, Inc.
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 2.0
diff --git a/system/libraries/Calendar.php b/system/libraries/Calendar.php
index 605765bf6..a05a7babf 100644
--- a/system/libraries/Calendar.php
+++ b/system/libraries/Calendar.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php
index 01a0cb8ce..ba8d69be2 100644
--- a/system/libraries/Cart.php
+++ b/system/libraries/Cart.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 183a95985..2112a7ee6 100644
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index 1066535c7..922107e9f 100644
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 92b0b3c4a..e297576e6 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index d83afdd25..2761d060b 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Ftp.php b/system/libraries/Ftp.php
index 99850a9e5..ab395b0a0 100644
--- a/system/libraries/Ftp.php
+++ b/system/libraries/Ftp.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index fe9b8dc79..c86224ffb 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index f872d672f..33df6007a 100644
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Log.php b/system/libraries/Log.php
index 7f3a307f3..944173fdd 100644
--- a/system/libraries/Log.php
+++ b/system/libraries/Log.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php
index f89391c0d..d07097223 100644
--- a/system/libraries/Migration.php
+++ b/system/libraries/Migration.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2006 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2006 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 3.0
diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 008c15192..23ca549e2 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Parser.php b/system/libraries/Parser.php
index 39aa61e45..321248277 100644
--- a/system/libraries/Parser.php
+++ b/system/libraries/Parser.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 9cbd69bb2..89c616543 100644
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 137b037b8..04103a4d9 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 1851bf3bc..fb154e50f 100644
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.3.1
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index b5e68507f..79a009133 100644
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 651ba7bff..76f0d4fc5 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Unit_test.php b/system/libraries/Unit_test.php
index fd3880d29..38d767c69 100644
--- a/system/libraries/Unit_test.php
+++ b/system/libraries/Unit_test.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.3.1
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 826bcceb8..0c63886e7 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index c31ff2646..cd644c00d 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 7b1e3fa6e..1bdc27512 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 893e51873..355d43f29 100644
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 52f1bc3d0..50e84920e 100644
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php
index 888e89b1b..03574c66e 100644
--- a/system/libraries/javascript/Jquery.php
+++ b/system/libraries/javascript/Jquery.php
@@ -18,7 +18,7 @@
  *
  * @package		CodeIgniter
  * @author		EllisLab Dev Team
- * @copyright	Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright	Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
  * @license		http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
  * @link		http://codeigniter.com
  * @since		Version 1.0
-- 
cgit v1.2.3-24-g4f1b


From d09d650acf612652627d77efda3616e5bbc3871c Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Tue, 3 Jan 2012 06:38:33 +0200
Subject: Fix a comment and remove access description lines

---
 system/libraries/Form_validation.php | 46 ++++--------------------------------
 1 file changed, 4 insertions(+), 42 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index 2761d060b..0a6a2af0d 100644
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -78,7 +78,6 @@ class CI_Form_validation {
 	 * This function takes an array of field names and validation
 	 * rules as input, validates the info, and stores it
 	 *
-	 * @access	public
 	 * @param	mixed
 	 * @param	string
 	 * @return	void
@@ -168,7 +167,6 @@ class CI_Form_validation {
 	 * Lets users set their own error messages on the fly.  Note:  The key
 	 * name has to match the  function name that it corresponds to.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -192,7 +190,6 @@ class CI_Form_validation {
 	 *
 	 * Permits a prefix/suffix to be added to each error message
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	void
@@ -212,7 +209,6 @@ class CI_Form_validation {
 	 *
 	 * Gets the error message associated with a particular field
 	 *
-	 * @access	public
 	 * @param	string	the field name
 	 * @return	void
 	 */
@@ -243,7 +239,6 @@ class CI_Form_validation {
 	 *
 	 * Returns the error messages as a string, wrapped in the error delimiters
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	str
@@ -286,7 +281,6 @@ class CI_Form_validation {
 	 *
 	 * This function does all the work.
 	 *
-	 * @access	public
 	 * @return	bool
 	 */
 	public function run($group = '')
@@ -371,7 +365,6 @@ class CI_Form_validation {
 	/**
 	 * Traverse a multidimensional $_POST array index until the data is found
 	 *
-	 * @access	protected
 	 * @param	array
 	 * @param	array
 	 * @param	integer
@@ -392,7 +385,6 @@ class CI_Form_validation {
 	/**
 	 * Re-populate the _POST array with our finalized and processed data
 	 *
-	 * @access	protected
 	 * @return	null
 	 */
 	protected function _reset_post_array()
@@ -450,7 +442,6 @@ class CI_Form_validation {
 	/**
 	 * Executes the Validation routines
 	 *
-	 * @access	protected
 	 * @param	array
 	 * @param	array
 	 * @param	mixed
@@ -680,7 +671,6 @@ class CI_Form_validation {
 	/**
 	 * Translate a field name
 	 *
-	 * @access	protected
 	 * @param	string	the field name
 	 * @return	string
 	 */
@@ -711,7 +701,6 @@ class CI_Form_validation {
 	 * Permits you to repopulate a form field with the value it was submitted
 	 * with, or, if that value doesn't exist, with the default
 	 *
-	 * @access	public
 	 * @param	string	the field name
 	 * @param	string
 	 * @return	void
@@ -741,7 +730,6 @@ class CI_Form_validation {
 	 * Enables pull-down lists to be set to the value the user
 	 * selected in the event of an error
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -785,7 +773,6 @@ class CI_Form_validation {
 	 * Enables radio buttons to be set to the value the user
 	 * selected in the event of an error
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -829,7 +816,6 @@ class CI_Form_validation {
 	 * Enables checkboxes to be set to the value the user
 	 * selected in the event of an error
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	string
 	 * @return	string
@@ -845,7 +831,6 @@ class CI_Form_validation {
 	/**
 	 * Required
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -859,7 +844,6 @@ class CI_Form_validation {
 	/**
 	 * Performs a Regular Expression match test.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	regex
 	 * @return	bool
@@ -874,7 +858,6 @@ class CI_Form_validation {
 	/**
 	 * Match one field to another
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	field
 	 * @return	bool
@@ -894,9 +877,11 @@ class CI_Form_validation {
 	// --------------------------------------------------------------------
 
 	/**
-	 * Match one field to another
+	 * Is Unique
+	 *
+	 * Check if the input value doesn't already exist
+	 * in the specified database field.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	field
 	 * @return	bool
@@ -917,7 +902,6 @@ class CI_Form_validation {
 	/**
 	 * Minimum Length
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	value
 	 * @return	bool
@@ -942,7 +926,6 @@ class CI_Form_validation {
 	/**
 	 * Max Length
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	value
 	 * @return	bool
@@ -967,7 +950,6 @@ class CI_Form_validation {
 	/**
 	 * Exact Length
 	 *
-	 * @access	public
 	 * @param	string
 	 * @param	value
 	 * @return	bool
@@ -992,7 +974,6 @@ class CI_Form_validation {
 	/**
 	 * Valid Email
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1006,7 +987,6 @@ class CI_Form_validation {
 	/**
 	 * Valid Emails
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1033,7 +1013,6 @@ class CI_Form_validation {
 	/**
 	 * Validate IP Address
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1047,7 +1026,6 @@ class CI_Form_validation {
 	/**
 	 * Alpha
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1061,7 +1039,6 @@ class CI_Form_validation {
 	/**
 	 * Alpha-numeric
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1075,7 +1052,6 @@ class CI_Form_validation {
 	/**
 	 * Alpha-numeric with underscores and dashes
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1089,7 +1065,6 @@ class CI_Form_validation {
 	/**
 	 * Numeric
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1104,7 +1079,6 @@ class CI_Form_validation {
 	/**
 	 * Is Numeric
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1118,7 +1092,6 @@ class CI_Form_validation {
 	/**
 	 * Integer
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1132,7 +1105,6 @@ class CI_Form_validation {
 	/**
 	 * Decimal number
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1146,7 +1118,6 @@ class CI_Form_validation {
 	/**
 	 * Greather than
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1164,7 +1135,6 @@ class CI_Form_validation {
 	/**
 	 * Less than
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1182,7 +1152,6 @@ class CI_Form_validation {
 	/**
 	 * Is a Natural number  (0,1,2,3, etc.)
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1196,7 +1165,6 @@ class CI_Form_validation {
 	/**
 	 * Is a Natural number, but not a zero  (1,2,3, etc.)
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1213,7 +1181,6 @@ class CI_Form_validation {
 	 * Tests a string for characters outside of the Base64 alphabet
 	 * as defined by RFC 2045 http://www.faqs.org/rfcs/rfc2045
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	bool
 	 */
@@ -1230,7 +1197,6 @@ class CI_Form_validation {
 	 * This function allows HTML to be safely shown in a form.
 	 * Special characters are converted.
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -1259,7 +1225,6 @@ class CI_Form_validation {
 	/**
 	 * Prep URL
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -1283,7 +1248,6 @@ class CI_Form_validation {
 	/**
 	 * Strip Image Tags
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -1297,7 +1261,6 @@ class CI_Form_validation {
 	/**
 	 * XSS Clean
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
@@ -1311,7 +1274,6 @@ class CI_Form_validation {
 	/**
 	 * Convert PHP tags to entities
 	 *
-	 * @access	public
 	 * @param	string
 	 * @return	string
 	 */
-- 
cgit v1.2.3-24-g4f1b


From b195637240bbbc7c3dc7ee0585f0e4cd39cb9d81 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Tue, 3 Jan 2012 11:01:48 +0200
Subject: Replace htmlentities() with htmlspecialchars() to fix issue #561

---
 system/libraries/Xmlrpc.php | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index bb95ca145..a9f8d9c38 100644
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -437,7 +437,14 @@ class XML_RPC_Response
 		{
 			// error
 			$this->errno = $code;
-			$this->errstr = htmlentities($fstr);
+			if ( ! is_php('5.4'))
+			{
+				$this->errstr = htmlspecialchars($fstr, ENT_NOQUOTES, 'UTF-8');
+			}
+			else
+			{
+				$this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8');
+			}
 		}
 		else if ( ! is_object($val))
 		{
-- 
cgit v1.2.3-24-g4f1b


From 8d727f14446f31d919e808e3833d252ef12cf1ae Mon Sep 17 00:00:00 2001
From: Eric Barnes 
Date: Wed, 4 Jan 2012 00:06:36 -0500
Subject: Fixed prefix and suffix in pagination. Fixes #677

---
 system/libraries/Pagination.php | 5 +++++
 1 file changed, 5 insertions(+)

(limited to 'system/libraries')

diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 23ca549e2..2fe4cf31b 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -142,6 +142,11 @@ class CI_Pagination {
 		// Determine the current page number.
 		$CI =& get_instance();
 
+		if ($this->prefix != '' OR $this->suffix != '')
+		{
+			$this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment));
+		}
+
 		if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
 		{
 			if ($CI->input->get($this->query_string_segment) != $base_page)
-- 
cgit v1.2.3-24-g4f1b


From 3b376595183e0e0db5559ccbfc368c442408dca9 Mon Sep 17 00:00:00 2001
From: Eric Barnes 
Date: Wed, 4 Jan 2012 00:28:27 -0500
Subject: Fixed paging with prefix and suffix for real page numbers. Refs #677
 Fixes #52

---
 system/libraries/Pagination.php | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php
index 2fe4cf31b..e0cab2128 100644
--- a/system/libraries/Pagination.php
+++ b/system/libraries/Pagination.php
@@ -142,9 +142,10 @@ class CI_Pagination {
 		// Determine the current page number.
 		$CI =& get_instance();
 
+		// See if we are using a prefix or suffix on links
 		if ($this->prefix != '' OR $this->suffix != '')
 		{
-			$this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment));
+			$this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->segment($this->uri_segment));
 		}
 
 		if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE)
@@ -154,7 +155,7 @@ class CI_Pagination {
 				$this->cur_page = (int) $CI->input->get($this->query_string_segment);
 			}
 		}
-		elseif ($CI->uri->segment($this->uri_segment) != $base_page)
+		elseif ( ! $this->cur_page AND $CI->uri->segment($this->uri_segment) != $base_page)
 		{
 			$this->cur_page = (int) $CI->uri->segment($this->uri_segment);
 		}
@@ -165,7 +166,7 @@ class CI_Pagination {
 			$this->cur_page = $base_page;
 		}
 
-		$this->num_links = (int)$this->num_links;
+		$this->num_links = (int) $this->num_links;
 
 		if ($this->num_links < 1)
 		{
-- 
cgit v1.2.3-24-g4f1b


From 1a9f52c8ec021f6169b977ee936bb8cf2b972230 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 7 Jan 2012 01:06:34 +0200
Subject: Fixed a bug in CI_Image_lib::resize()

---
 system/libraries/Image_lib.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index c86224ffb..39f9887f1 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -392,7 +392,7 @@ class CI_Image_lib {
 	 */
 	public function resize()
 	{
-		$protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
+		$protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
 		return $this->$protocol('resize');
 	}
 
-- 
cgit v1.2.3-24-g4f1b


From 5a67e3d09fe934af6f1bd75bb4e3dac87eb1361f Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sat, 7 Jan 2012 01:21:09 +0200
Subject: Fix the same expression in crop()

---
 system/libraries/Image_lib.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 39f9887f1..dc7d362ce 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -408,7 +408,7 @@ class CI_Image_lib {
 	 */
 	public function crop()
 	{
-		$protocol = (strtolower(substr($this->image_library, 0, -3)) === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
+		$protocol = ($this->image_library === 'gd2') ? 'image_process_gd' : 'image_process_'.$this->image_library;
 		return $this->$protocol('crop');
 	}
 
-- 
cgit v1.2.3-24-g4f1b


From cc6dbda62c1c04d4e247308f980e64d5d13c932d Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Sun, 8 Jan 2012 06:35:17 +0200
Subject: Some more misc. stuff

---
 system/libraries/Encrypt.php | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index d9f40b0d5..63e3bb55e 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -46,15 +46,10 @@ class CI_Encrypt {
 	protected $_mcrypt_cipher;
 	protected $_mcrypt_mode;
 
-	/**
-	 * Constructor
-	 *
-	 * Simply determines whether the mcrypt library exists.
-	 */
 	public function __construct()
 	{
 		$this->_mcrypt_exists = ( ! function_exists('mcrypt_encrypt')) ? FALSE : TRUE;
-		log_message('debug', "Encrypt Class Initialized");
+		log_message('debug', 'Encrypt Class Initialized');
 	}
 
 	// --------------------------------------------------------------------
@@ -95,7 +90,7 @@ class CI_Encrypt {
 	 * Set the encryption key
 	 *
 	 * @param	string
-	 * @return	void
+	 * @return	object
 	 */
 	public function set_key($key = '')
 	{
@@ -457,7 +452,7 @@ class CI_Encrypt {
 	 */
 	public function set_hash($type = 'sha1')
 	{
-		$this->_hash_type = ($type !== 'sha1' AND $type !== 'md5') ? 'sha1' : $type;
+		$this->_hash_type = ($type !== 'sha1' && $type !== 'md5') ? 'sha1' : $type;
 	}
 
 	// --------------------------------------------------------------------
@@ -474,7 +469,5 @@ class CI_Encrypt {
 	}
 }
 
-// END CI_Encrypt class
-
 /* End of file Encrypt.php */
 /* Location: ./system/libraries/Encrypt.php */
-- 
cgit v1.2.3-24-g4f1b


From d655a997f7b98da29ea932084e2fb50956188141 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Tue, 10 Jan 2012 22:31:29 +0200
Subject: Two returns

---
 system/libraries/Encrypt.php | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 63e3bb55e..8cb4b1b19 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -180,7 +180,6 @@ class CI_Encrypt {
 
 		$key = $this->get_key($key);
 		$dec = base64_decode($string);
-
 		if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
 		{
 			return FALSE;
@@ -419,7 +418,7 @@ class CI_Encrypt {
 	{
 		if ($this->_mcrypt_cipher == '')
 		{
-			$this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
+			return $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
 		}
 
 		return $this->_mcrypt_cipher;
@@ -436,7 +435,7 @@ class CI_Encrypt {
 	{
 		if ($this->_mcrypt_mode == '')
 		{
-			$this->_mcrypt_mode = MCRYPT_MODE_CBC;
+			return $this->_mcrypt_mode = MCRYPT_MODE_CBC;
 		}
 
 		return $this->_mcrypt_mode;
-- 
cgit v1.2.3-24-g4f1b


From 8f80bc4f855f78efbcb6344ea29cf67647b6772b Mon Sep 17 00:00:00 2001
From: Ronald Beilsma 
Date: Thu, 12 Jan 2012 16:41:49 +0100
Subject: array keys should be 0, 1, and 2. key 3 results in error (invalid
 offset)

---
 system/libraries/Image_lib.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index dc7d362ce..a226ae8f8 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -1091,7 +1091,7 @@ class CI_Image_lib {
 			$txt_color = str_split(substr($this->wm_font_color, 1, 6), 2);
 			$txt_color = imagecolorclosest($src_img, hexdec($txt_color[0]), hexdec($txt_color[1]), hexdec($txt_color[2]));
 			$drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2);
-			$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[2]), hexdec($drp_color[3]));
+			$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2]));
 
 			//  Add the text to the source image
 			if ($this->wm_use_truetype)
-- 
cgit v1.2.3-24-g4f1b


From 8e70b7935181ff56a340a3388080bf4ac6f3428f Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 12 Jan 2012 20:19:24 +0200
Subject: CI_Image_lib::image_reproportion() to work if only one of either
 width or height are set

---
 system/libraries/Image_lib.php | 195 +++++++++++++++++++----------------------
 1 file changed, 88 insertions(+), 107 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index a226ae8f8..8430d60df 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -88,12 +88,6 @@ class CI_Image_lib {
 	protected $wm_use_drop_shadow	= FALSE;
 	public $wm_use_truetype	= FALSE;
 
-	/**
-	 * Constructor
-	 *
-	 * @param	string
-	 * @return	void
-	 */
 	public function __construct($props = array())
 	{
 		if (count($props) > 0)
@@ -101,7 +95,7 @@ class CI_Image_lib {
 			$this->initialize($props);
 		}
 
-		log_message('debug', "Image Lib Class Initialized");
+		log_message('debug', 'Image Lib Class Initialized');
 	}
 
 	// --------------------------------------------------------------------
@@ -158,9 +152,7 @@ class CI_Image_lib {
 	 */
 	public function initialize($props = array())
 	{
-		/*
-		 * Convert array elements into class variables
-		 */
+		// Convert array elements into class variables
 		if (count($props) > 0)
 		{
 			foreach ($props as $key => $val)
@@ -199,7 +191,6 @@ class CI_Image_lib {
 		 * Is there a source image?
 		 *
 		 * If not, there's no reason to continue
-		 *
 		 */
 		if ($this->source_image == '')
 		{
@@ -213,7 +204,6 @@ class CI_Image_lib {
 		 * We use it to determine the image properties (width/height).
 		 * Note:  We need to figure out how to determine image
 		 * properties using ImageMagick and NetPBM
-		 *
 		 */
 		if ( ! function_exists('getimagesize'))
 		{
@@ -229,11 +219,10 @@ class CI_Image_lib {
 		 * The source image may or may not contain a path.
 		 * Either way, we'll try use realpath to generate the
 		 * full server path in order to more reliably read it.
-		 *
 		 */
-		if (function_exists('realpath') AND @realpath($this->source_image) !== FALSE)
+		if (function_exists('realpath') && @realpath($this->source_image) !== FALSE)
 		{
-			$full_source_path = str_replace("\\", "/", realpath($this->source_image));
+			$full_source_path = str_replace('\\', '/', realpath($this->source_image));
 		}
 		else
 		{
@@ -257,7 +246,6 @@ class CI_Image_lib {
 		 * we are making a copy of the source image. If not
 		 * it means we are altering the original.  We'll
 		 * set the destination filename and path accordingly.
-		 *
 		 */
 		if ($this->new_image == '')
 		{
@@ -273,9 +261,9 @@ class CI_Image_lib {
 			}
 			else
 			{
-				if (function_exists('realpath') AND @realpath($this->new_image) !== FALSE)
+				if (function_exists('realpath') && @realpath($this->new_image) !== FALSE)
 				{
-					$full_dest_path = str_replace("\\", "/", realpath($this->new_image));
+					$full_dest_path = str_replace('\\', '/', realpath($this->new_image));
 				}
 				else
 				{
@@ -283,7 +271,7 @@ class CI_Image_lib {
 				}
 
 				// Is there a file name?
-				if ( ! preg_match("#\.(jpg|jpeg|gif|png)$#i", $full_dest_path))
+				if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path))
 				{
 					$this->dest_folder = $full_dest_path.'/';
 					$this->dest_image = $this->source_image;
@@ -305,7 +293,6 @@ class CI_Image_lib {
 		 * full server path to the destination image.
 		 * We'll also split the destination image name
 		 * so we can insert the thumbnail marker if needed.
-		 *
 		 */
 		if ($this->create_thumb === FALSE OR $this->thumb_marker == '')
 		{
@@ -325,10 +312,9 @@ class CI_Image_lib {
 		 *
 		 * When creating thumbs or copies, the target width/height
 		 * might not be in correct proportion with the source
-		 * image's width/height.  We'll recalculate it here.
-		 *
+		 * image's width/height. We'll recalculate it here.
 		 */
-		if ($this->maintain_ratio === TRUE && ($this->width != '' AND $this->height != ''))
+		if ($this->maintain_ratio === TRUE && ($this->width != 0 OR $this->height != 0))
 		{
 			$this->image_reproportion();
 		}
@@ -339,35 +325,40 @@ class CI_Image_lib {
 		 * If the destination width/height was
 		 * not submitted we will use the values
 		 * from the actual file
-		 *
 		 */
 		if ($this->width == '')
+		{
 			$this->width = $this->orig_width;
+		}
 
 		if ($this->height == '')
+		{
 			$this->height = $this->orig_height;
+		}
 
 		// Set the quality
-		$this->quality = trim(str_replace("%", "", $this->quality));
+		$this->quality = trim(str_replace('%', '', $this->quality));
 
-		if ($this->quality == '' OR $this->quality == 0 OR ! is_numeric($this->quality))
+		if ($this->quality == '' OR $this->quality == 0 OR ! preg_match('/^[0-9]+$/', $this->quality))
+		{
 			$this->quality = 90;
+		}
 
 		// Set the x/y coordinates
-		$this->x_axis = ($this->x_axis == '' OR ! is_numeric($this->x_axis)) ? 0 : $this->x_axis;
-		$this->y_axis = ($this->y_axis == '' OR ! is_numeric($this->y_axis)) ? 0 : $this->y_axis;
+		$this->x_axis = ($this->x_axis == '' OR ! preg_match('/^[0-9]+$/', $this->x_axis)) ? 0 : $this->x_axis;
+		$this->y_axis = ($this->y_axis == '' OR ! preg_match('/^[0-9]+$/', $this->y_axis)) ? 0 : $this->y_axis;
 
 		// Watermark-related Stuff...
 		if ($this->wm_overlay_path != '')
 		{
-			$this->wm_overlay_path = str_replace("\\", "/", realpath($this->wm_overlay_path));
+			$this->wm_overlay_path = str_replace('\\', '/', realpath($this->wm_overlay_path));
 		}
 
 		if ($this->wm_shadow_color != '')
 		{
 			$this->wm_use_drop_shadow = TRUE;
 		}
-		elseif ($this->wm_use_drop_shadow == TRUE AND $this->wm_shadow_color == '')
+		elseif ($this->wm_use_drop_shadow == TRUE && $this->wm_shadow_color == '')
 		{
 			$this->wm_use_drop_shadow = FALSE;
 		}
@@ -445,7 +436,6 @@ class CI_Image_lib {
 			$this->height	= $this->orig_height;
 		}
 
-
 		// Choose resizing function
 		if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm')
 		{
@@ -479,9 +469,9 @@ class CI_Image_lib {
 
 		// If the target width/height match the source, AND if the new file name is not equal to the old file name
 		// we'll simply make a copy of the original with the new name... assuming dynamic rendering is off.
-		if ($this->dynamic_output === FALSE AND $this->orig_width == $this->width AND $this->orig_height == $this->height)
+		if ($this->dynamic_output === FALSE && $this->orig_width == $this->width && $this->orig_height == $this->height)
 		{
-			if ($this->source_image != $this->new_image AND @copy($this->full_src_path, $this->full_dst_path))
+			if ($this->source_image != $this->new_image && @copy($this->full_src_path, $this->full_dst_path))
 			{
 				@chmod($this->full_dst_path, FILE_WRITE_MODE);
 			}
@@ -523,7 +513,7 @@ class CI_Image_lib {
 		//  below should that ever prove inaccurate.
 		//
 		//  if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
-		if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor'))
+		if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor'))
 		{
 			$create	= 'imagecreatetruecolor';
 			$copy	= 'imagecopyresampled';
@@ -587,7 +577,7 @@ class CI_Image_lib {
 			return FALSE;
 		}
 
-		if ( ! preg_match("/convert$/i", $this->library_path))
+		if ( ! preg_match('/convert$/i', $this->library_path))
 		{
 			$this->library_path = rtrim($this->library_path, '/').'/convert';
 		}
@@ -597,7 +587,7 @@ class CI_Image_lib {
 
 		if ($action == 'crop')
 		{
-			$cmd .= " -crop ".$this->width."x".$this->height."+".$this->x_axis."+".$this->y_axis." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+			$cmd .= ' -crop '.$this->width.'x'.$this->height.'+'.$this->x_axis.'+'.$this->y_axis.' "'.$this->full_src_path.'" "'.$this->full_dst_path .'" 2>&1';
 		}
 		elseif ($action == 'rotate')
 		{
@@ -611,18 +601,17 @@ class CI_Image_lib {
 					break;
 			}
 
-			$cmd .= " ".$angle." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+			$cmd .= ' '.$angle.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1';
 		}
-		else  // Resize
+		else // Resize
 		{
-			$cmd .= " -resize ".$this->width."x".$this->height." \"$this->full_src_path\" \"$this->full_dst_path\" 2>&1";
+			$cmd .= ' -resize '.$this->width.'x'.$this->height.'" "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1';
 		}
 
 		$retval = 1;
-
 		@exec($cmd, $output, $retval);
 
-		//	Did it work?
+		// Did it work?
 		if ($retval > 0)
 		{
 			$this->set_error('imglib_image_process_failed');
@@ -700,10 +689,9 @@ class CI_Image_lib {
 		$cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
 
 		$retval = 1;
-
 		@exec($cmd, $output, $retval);
 
-		//  Did it work?
+		// Did it work?
 		if ($retval > 0)
 		{
 			$this->set_error('imglib_image_process_failed');
@@ -742,29 +730,24 @@ class CI_Image_lib {
 
 		$white	= imagecolorallocate($src_img, 255, 255, 255);
 
-		//  Rotate it!
+		// Rotate it!
 		$dst_img = imagerotate($src_img, $this->rotation_angle, $white);
 
-		//  Save the Image
+		// Show the image
 		if ($this->dynamic_output == TRUE)
 		{
 			$this->image_display_gd($dst_img);
 		}
-		else
+		elseif ( ! $this->image_save_gd($dst_img)) // ... or save it
 		{
-			// Or save it
-			if ( ! $this->image_save_gd($dst_img))
-			{
-				return FALSE;
-			}
+			return FALSE;
 		}
 
-		//  Kill the file handles
+		// Kill the file handles
 		imagedestroy($dst_img);
 		imagedestroy($src_img);
 
 		// Set the file to 777
-
 		@chmod($this->full_dst_path, FILE_WRITE_MODE);
 
 		return TRUE;
@@ -824,21 +807,17 @@ class CI_Image_lib {
 			}
 		}
 
-		//  Show the image
+		// Show the image
 		if ($this->dynamic_output == TRUE)
 		{
 			$this->image_display_gd($src_img);
 		}
-		else
+		elseif ( ! $this->image_save_gd($src_img)) // ... or save it
 		{
-			// Or save it
-			if ( ! $this->image_save_gd($src_img))
-			{
-				return FALSE;
-			}
+			return FALSE;
 		}
 
-		//  Kill the file handles
+		// Kill the file handles
 		imagedestroy($src_img);
 
 		// Set the file to 777
@@ -860,14 +839,7 @@ class CI_Image_lib {
 	 */
 	public function watermark()
 	{
-		if ($this->wm_type == 'overlay')
-		{
-			return $this->overlay_watermark();
-		}
-		else
-		{
-			return $this->text_watermark();
-		}
+		return ($this->wm_type == 'overlay') ? $this->overlay_watermark() : $this->text_watermark();
 	}
 
 	// --------------------------------------------------------------------
@@ -885,28 +857,28 @@ class CI_Image_lib {
 			return FALSE;
 		}
 
-		//  Fetch source image properties
+		// Fetch source image properties
 		$this->get_image_properties();
 
-		//  Fetch watermark image properties
+		// Fetch watermark image properties
 		$props			= $this->get_image_properties($this->wm_overlay_path, TRUE);
 		$wm_img_type	= $props['image_type'];
 		$wm_width		= $props['width'];
 		$wm_height		= $props['height'];
 
-		//  Create two image resources
+		// Create two image resources
 		$wm_img  = $this->image_create_gd($this->wm_overlay_path, $wm_img_type);
 		$src_img = $this->image_create_gd($this->full_src_path);
 
 		// Reverse the offset if necessary
 		// When the image is positioned at the bottom
 		// we don't want the vertical offset to push it
-		// further down.  We want the reverse, so we'll
-		// invert the offset.  Same with the horizontal
+		// further down. We want the reverse, so we'll
+		// invert the offset. Same with the horizontal
 		// offset when the image is at the right
 
-		$this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
-		$this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
+		$this->wm_vrt_alignment = strtoupper($this->wm_vrt_alignment[0]);
+		$this->wm_hor_alignment = strtoupper($this->wm_hor_alignment[0]);
 
 		if ($this->wm_vrt_alignment == 'B')
 			$this->wm_vrt_offset = $this->wm_vrt_offset * -1;
@@ -914,11 +886,11 @@ class CI_Image_lib {
 		if ($this->wm_hor_alignment == 'R')
 			$this->wm_hor_offset = $this->wm_hor_offset * -1;
 
-		//  Set the base x and y axis values
+		// Set the base x and y axis values
 		$x_axis = $this->wm_hor_offset + $this->wm_padding;
 		$y_axis = $this->wm_vrt_offset + $this->wm_padding;
 
-		//  Set the vertical position
+		// Set the vertical position
 		switch ($this->wm_vrt_alignment)
 		{
 			case 'T':
@@ -929,7 +901,7 @@ class CI_Image_lib {
 				break;
 		}
 
-		//  Set the horizontal position
+		// Set the horizontal position
 		switch ($this->wm_hor_alignment)
 		{
 			case 'L':
@@ -941,7 +913,7 @@ class CI_Image_lib {
 		}
 
 		//  Build the finalized image
-		if ($wm_img_type == 3 AND function_exists('imagealphablending'))
+		if ($wm_img_type == 3 && function_exists('imagealphablending'))
 		{
 			@imagealphablending($src_img, TRUE);
 		}
@@ -993,20 +965,20 @@ class CI_Image_lib {
 			return FALSE;
 		}
 
-		if ($this->wm_use_truetype == TRUE AND ! file_exists($this->wm_font_path))
+		if ($this->wm_use_truetype == TRUE && ! file_exists($this->wm_font_path))
 		{
 			$this->set_error('imglib_missing_font');
 			return FALSE;
 		}
 
-		//  Fetch source image properties
+		// Fetch source image properties
 		$this->get_image_properties();
 
 		// Reverse the vertical offset
 		// When the image is positioned at the bottom
 		// we don't want the vertical offset to push it
 		// further down.  We want the reverse, so we'll
-		// invert the offset.  Note: The horizontal
+		// invert the offset. Note: The horizontal
 		// offset flips itself automatically
 
 		if ($this->wm_vrt_alignment == 'B')
@@ -1093,7 +1065,7 @@ class CI_Image_lib {
 			$drp_color = str_split(substr($this->wm_shadow_color, 1, 6), 2);
 			$drp_color = imagecolorclosest($src_img, hexdec($drp_color[0]), hexdec($drp_color[1]), hexdec($drp_color[2]));
 
-			//  Add the text to the source image
+			// Add the text to the source image
 			if ($this->wm_use_truetype)
 			{
 				imagettftext($src_img, $this->wm_font_size, 0, $x_shad, $y_shad, $drp_color, $this->wm_font_path, $this->wm_text);
@@ -1106,7 +1078,7 @@ class CI_Image_lib {
 			}
 		}
 
-		//  Output the final image
+		// Output the final image
 		if ($this->dynamic_output == TRUE)
 		{
 			$this->image_display_gd($src_img);
@@ -1284,33 +1256,43 @@ class CI_Image_lib {
 	 */
 	public function image_reproportion()
 	{
-		if ( ! is_numeric($this->width) OR ! is_numeric($this->height) OR $this->width == 0 OR $this->height == 0)
-			return;
-
-		if ( ! is_numeric($this->orig_width) OR ! is_numeric($this->orig_height) OR $this->orig_width == 0 OR $this->orig_height == 0)
-			return;
-
-		$new_width	= ceil($this->orig_width*$this->height/$this->orig_height);
-		$new_height	= ceil($this->width*$this->orig_height/$this->orig_width);
-
-		$ratio = (($this->orig_height/$this->orig_width) - ($this->height/$this->width));
-
-		if ($this->master_dim != 'width' AND $this->master_dim != 'height')
+		if (($this->width == 0 && $this->height == 0) OR $this->orig_width == 0 OR $this->orig_height == 0
+			OR ( ! preg_match('/^[0-9]+$/', $this->width) && ! preg_match('/^[0-9]+$/', $this->height))
+			OR ! preg_match('/^[0-9]+$/', $this->orig_width) OR ! preg_match('/^[0-9]+$/', $this->orig_height))
 		{
-			$this->master_dim = ($ratio < 0) ? 'width' : 'height';
+			return;
 		}
 
-		if (($this->width != $new_width) AND ($this->height != $new_height))
+		// Sanitize so we don't call preg_match() anymore
+		$this->width = (int) $this->width;
+		$this->height = (int) $this->height;
+
+		if ($this->master_dim !== 'width' && $this->master_dim !== 'height')
 		{
-			if ($this->master_dim == 'height')
+			if ($this->width > 0 && $this->height > 0)
 			{
-				$this->width = $new_width;
+				$this->master_dim = ((($this->orig_height/$this->orig_width) - ($this->height/$this->width)) < 0)
+							? 'width' : 'height';
 			}
 			else
 			{
-				$this->height = $new_height;
+				$this->master_dim = ($this->height === 0) ? 'width' : 'height';
 			}
 		}
+		elseif (($this->master_dim === 'width' && $this->width === 0)
+			OR ($this->master_dim === 'height' && $this->height === 0))
+		{
+			return;
+		}
+
+		if ($this->master_dim === 'width')
+		{
+			$this->height = (int) ceil($this->width*$this->orig_height/$this->orig_width);
+		}
+		else
+		{
+			$this->width = (int) ceil($this->orig_width*$this->height/$this->orig_height);
+		}
 	}
 
 	// --------------------------------------------------------------------
@@ -1329,7 +1311,9 @@ class CI_Image_lib {
 		// find a way to determine this using IM or NetPBM
 
 		if ($path == '')
+		{
 			$path = $this->full_src_path;
+		}
 
 		if ( ! file_exists($path))
 		{
@@ -1449,7 +1433,7 @@ class CI_Image_lib {
 			/* As it is stated in the PHP manual, dl() is not always available
 			 * and even if so - it could generate an E_WARNING message on failure
 			 */
-			return (function_exists('dl') AND @dl('gd.so'));
+			return (function_exists('dl') && @dl('gd.so'));
 		}
 
 		return TRUE;
@@ -1467,9 +1451,7 @@ class CI_Image_lib {
 		if (function_exists('gd_info'))
 		{
 			$gd_version = @gd_info();
-			$gd_version = preg_replace("/\D/", "", $gd_version['GD Version']);
-
-			return $gd_version;
+			return preg_replace('/\D/', '', $gd_version['GD Version']);
 		}
 
 		return FALSE;
@@ -1520,7 +1502,6 @@ class CI_Image_lib {
 	}
 
 }
-// END Image_lib Class
 
 /* End of file Image_lib.php */
 /* Location: ./system/libraries/Image_lib.php */
-- 
cgit v1.2.3-24-g4f1b


From e46363083ad18c93c73a200c9a97934608bb5bab Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 12 Jan 2012 20:23:27 +0200
Subject: Remove a quote

---
 system/libraries/Image_lib.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 8430d60df..fd3cd0edb 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -605,7 +605,7 @@ class CI_Image_lib {
 		}
 		else // Resize
 		{
-			$cmd .= ' -resize '.$this->width.'x'.$this->height.'" "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1';
+			$cmd .= ' -resize '.$this->width.'x'.$this->height.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1';
 		}
 
 		$retval = 1;
-- 
cgit v1.2.3-24-g4f1b


From 7bb95dff569f465ad8887404c2f9d5304a2ff5b3 Mon Sep 17 00:00:00 2001
From: Sean Fisher 
Date: Mon, 16 Jan 2012 09:23:14 -0500
Subject: APC throws "apc_store() expects parameter 3 to be long, string
 given". Validates the TTL to an integer.

---
 system/libraries/Cache/drivers/Cache_apc.php | 1 +
 1 file changed, 1 insertion(+)

(limited to 'system/libraries')

diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index 93993d07a..a3dd46978 100644
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -68,6 +68,7 @@ class CI_Cache_apc extends CI_Driver {
 	 */
 	public function save($id, $data, $ttl = 60)
 	{
+		$ttl = (int) $ttl;
 		return apc_store($id, array($data, time(), $ttl), $ttl);
 	}
 
-- 
cgit v1.2.3-24-g4f1b


From eea2ff56657dc5f690523cfcd372b760569ef649 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 19 Jan 2012 13:21:53 +0200
Subject: Fix issue #154

---
 system/libraries/Session.php | 118 ++++++++++++++++++-------------------------
 1 file changed, 50 insertions(+), 68 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 04103a4d9..c4f97e965 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -9,7 +9,7 @@
  * Licensed under the Open Software License version 3.0
  *
  * This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst.  It is
+ * bundled with this package in the files license.txt / license.rst. It is
  * also available through the world wide web at this URL:
  * http://opensource.org/licenses/OSL-3.0
  * If you did not receive a copy of the license and are unable to obtain it
@@ -67,7 +67,7 @@ class CI_Session {
 	 */
 	public function __construct($params = array())
 	{
-		log_message('debug', "Session Class Initialized");
+		log_message('debug', 'Session Class Initialized');
 
 		// Set the super object to a local variable for use throughout the class
 		$this->CI =& get_instance();
@@ -93,14 +93,14 @@ class CI_Session {
 			$this->CI->load->library('encrypt');
 		}
 
-		// Are we using a database?  If so, load it
+		// Are we using a database? If so, load it
 		if ($this->sess_use_database === TRUE AND $this->sess_table_name != '')
 		{
 			$this->CI->load->database();
 		}
 
-		// Set the "now" time.  Can either be GMT or server time, based on the
-		// config prefs.  We use this to set the "last activity" time
+		// Set the "now" time. Can either be GMT or server time, based on the
+		// config prefs. We use this to set the "last activity" time
 		$this->now = $this->_get_time();
 
 		// Set the session length. If the session expiration is
@@ -114,7 +114,7 @@ class CI_Session {
 		$this->sess_cookie_name = $this->cookie_prefix.$this->sess_cookie_name;
 
 		// Run the Session routine. If a session doesn't exist we'll
-		// create a new one.  If it does, we'll update it.
+		// create a new one. If it does, we'll update it.
 		if ( ! $this->sess_read())
 		{
 			$this->sess_create();
@@ -133,7 +133,7 @@ class CI_Session {
 		// Delete expired sessions if necessary
 		$this->_sess_gc();
 
-		log_message('debug', "Session routines successfully run");
+		log_message('debug', 'Session routines successfully run');
 	}
 
 	// --------------------------------------------------------------------
@@ -166,7 +166,7 @@ class CI_Session {
 			$hash	 = substr($session, strlen($session)-32); // get last 32 chars
 			$session = substr($session, 0, strlen($session)-32);
 
-			// Does the md5 hash match?  This is to prevent manipulation of session data in userspace
+			// Does the md5 hash match? This is to prevent manipulation of session data in userspace
 			if ($hash !==  md5($session.$this->encryption_key))
 			{
 				log_message('error', 'The session cookie data did not match what was expected. This could be a possible hacking attempt.');
@@ -179,28 +179,11 @@ class CI_Session {
 		$session = $this->_unserialize($session);
 
 		// Is the session data we unserialized an array with the correct format?
-		if ( ! is_array($session) OR ! isset($session['session_id']) OR ! isset($session['ip_address']) OR ! isset($session['user_agent']) OR ! isset($session['last_activity']))
-		{
-			$this->sess_destroy();
-			return FALSE;
-		}
-
-		// Is the session current?
-		if (($session['last_activity'] + $this->sess_expiration) < $this->now)
-		{
-			$this->sess_destroy();
-			return FALSE;
-		}
-
-		// Does the IP Match?
-		if ($this->sess_match_ip == TRUE AND $session['ip_address'] !== $this->CI->input->ip_address())
-		{
-			$this->sess_destroy();
-			return FALSE;
-		}
-
-		// Does the User Agent Match?
-		if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120)))
+		if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity'])
+			OR ($session['last_activity'] + $this->sess_expiration) < $this->now // Is the session current?
+			OR ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) // Does the IP match?
+			OR ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) // Does the User Agent Match?
+			)
 		{
 			$this->sess_destroy();
 			return FALSE;
@@ -223,7 +206,7 @@ class CI_Session {
 
 			$query = $this->CI->db->get($this->sess_table_name);
 
-			// No result?  Kill it!
+			// No result? Kill it!
 			if ($query->num_rows() === 0)
 			{
 				$this->sess_destroy();
@@ -282,7 +265,7 @@ class CI_Session {
 			$cookie_userdata[$val] = $this->userdata[$val];
 		}
 
-		// Did we find any custom data?  If not, we turn the empty array into a string
+		// Did we find any custom data? If not, we turn the empty array into a string
 		// since there's no reason to serialize and store an empty array in the DB
 		if (count($custom_userdata) === 0)
 		{
@@ -298,7 +281,7 @@ class CI_Session {
 		$this->CI->db->where('session_id', $this->userdata['session_id']);
 		$this->CI->db->update($this->sess_table_name, array('last_activity' => $this->userdata['last_activity'], 'user_data' => $custom_userdata));
 
-		// Write the cookie.  Notice that we manually pass the cookie data array to the
+		// Write the cookie. Notice that we manually pass the cookie data array to the
 		// _set_cookie() function. Normally that function will store $this->userdata, but
 		// in this case that array contains custom data, which we do not want in the cookie.
 		$this->_set_cookie($cookie_userdata);
@@ -324,13 +307,12 @@ class CI_Session {
 		$sessid .= $this->CI->input->ip_address();
 
 		$this->userdata = array(
-							'session_id'	=> md5(uniqid($sessid, TRUE)),
-							'ip_address'	=> $this->CI->input->ip_address(),
-							'user_agent'	=> substr($this->CI->input->user_agent(), 0, 120),
-							'last_activity'	=> $this->now,
-							'user_data'		=> ''
-							);
-
+					'session_id'	=> md5(uniqid($sessid, TRUE)),
+					'ip_address'	=> $this->CI->input->ip_address(),
+					'user_agent'	=> substr($this->CI->input->user_agent(), 0, 120),
+					'last_activity'	=> $this->now,
+					'user_data'	=> ''
+				);
 
 		// Save the data to the DB if needed
 		if ($this->sess_use_database === TRUE)
@@ -352,7 +334,8 @@ class CI_Session {
 	public function sess_update()
 	{
 		// We only update the session every five minutes by default
-		if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
+		if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now
+			OR $this->CI->input->is_ajax_request()) // Changing the session ID during an AJAX call causes problems
 		{
 			return;
 		}
@@ -405,7 +388,7 @@ class CI_Session {
 	public function sess_destroy()
 	{
 		// Kill the session DB row
-		if ($this->sess_use_database === TRUE AND isset($this->userdata['session_id']))
+		if ($this->sess_use_database === TRUE && isset($this->userdata['session_id']))
 		{
 			$this->CI->db->where('session_id', $this->userdata['session_id']);
 			$this->CI->db->delete($this->sess_table_name);
@@ -413,13 +396,13 @@ class CI_Session {
 
 		// Kill the cookie
 		setcookie(
-					$this->sess_cookie_name,
-					addslashes(serialize(array())),
-					($this->now - 31500000),
-					$this->cookie_path,
-					$this->cookie_domain,
-					0
-				);
+				$this->sess_cookie_name,
+				addslashes(serialize(array())),
+				($this->now - 31500000),
+				$this->cookie_path,
+				$this->cookie_domain,
+				0
+			);
 	}
 
 	// --------------------------------------------------------------------
@@ -535,7 +518,7 @@ class CI_Session {
 	 */
 	public function keep_flashdata($key)
 	{
-		// 'old' flashdata gets removed.  Here we mark all
+		// 'old' flashdata gets removed. Here we mark all
 		// flashdata as 'new' to preserve it from _flashdata_sweep()
 		// Note the function will return FALSE if the $key
 		// provided cannot be found
@@ -586,7 +569,6 @@ class CI_Session {
 	 *
 	 * @return	void
 	 */
-
 	protected function _flashdata_sweep()
 	{
 		$userdata = $this->all_userdata();
@@ -609,13 +591,9 @@ class CI_Session {
 	 */
 	protected function _get_time()
 	{
-		if (strtolower($this->time_reference) === 'gmt')
-		{
-			$now = time();
-			return mktime(gmdate('H', $now), gmdate('i', $now), gmdate('s', $now), gmdate('m', $now), gmdate('d', $now), gmdate('Y', $now));
-		}
-
-		return time();
+		return (strtolower($this->time_reference) === 'gmt')
+			? mktime(gmdate('H'), gmdate('i'), gmdate('s'), gmdate('m'), gmdate('d'), gmdate('Y'))
+			: time();
 	}
 
 	// --------------------------------------------------------------------
@@ -649,13 +627,13 @@ class CI_Session {
 
 		// Set the cookie
 		setcookie(
-					$this->sess_cookie_name,
-					$cookie_data,
-					$expire,
-					$this->cookie_path,
-					$this->cookie_domain,
-					$this->cookie_secure
-				);
+				$this->sess_cookie_name,
+				$cookie_data,
+				$expire,
+				$this->cookie_path,
+				$this->cookie_domain,
+				$this->cookie_secure
+			);
 	}
 
 	// --------------------------------------------------------------------
@@ -687,8 +665,11 @@ class CI_Session {
 	 *
 	 * This function converts any slashes found into a temporary marker
 	 *
+	 * @param	string
+	 * @param	string
+	 * @return	void
 	 */
-	function _escape_slashes(&$val, $key)
+	protected function _escape_slashes(&$val, $key)
 	{
 		if (is_string($val))
 		{
@@ -725,6 +706,9 @@ class CI_Session {
 	 *
 	 * This function converts any slash markers back into actual slashes
 	 *
+	 * @param	string
+	 * @param	string
+	 * @return	void
 	 */
 	protected function _unescape_slashes(&$val, $key)
 	{
@@ -763,9 +747,7 @@ class CI_Session {
 		}
 	}
 
-
 }
-// END Session Class
 
 /* End of file Session.php */
 /* Location: ./system/libraries/Session.php */
-- 
cgit v1.2.3-24-g4f1b


From 9c622f373046a0a626799f4ed5a0f944628b0b43 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 19 Jan 2012 14:12:54 +0200
Subject: Still update the session on AJAX calls, just don't regenerate the
 session ID

---
 system/libraries/Session.php | 36 ++++++++++++++++++++++++++++++------
 1 file changed, 30 insertions(+), 6 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index c4f97e965..784bb62b2 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -334,12 +334,40 @@ class CI_Session {
 	public function sess_update()
 	{
 		// We only update the session every five minutes by default
-		if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now
-			OR $this->CI->input->is_ajax_request()) // Changing the session ID during an AJAX call causes problems
+		if (($this->userdata['last_activity'] + $this->sess_time_to_update) >= $this->now)
 		{
 			return;
 		}
 
+		// _set_cookie() will handle this for us if we aren't using database sessions
+		// by pushing all userdata to the cookie.
+		$cookie_data = NULL;
+
+		/* Changing the session ID during an AJAX call causes problems,
+		 * so we'll only update our last_activity
+		 */
+		if ($this->CI->input->is_ajax_request())
+		{
+			$this->userdata['last_activity'] = $this->now;
+
+			// Update the session ID and last_activity field in the DB if needed
+			if ($this->sess_use_database === TRUE)
+			{
+				// set cookie explicitly to only have our session data
+				$cookie_data = array();
+				foreach (array('session_id','ip_address','user_agent','last_activity') as $val)
+				{
+					$cookie_data[$val] = $this->userdata[$val];
+				}
+
+				$this->CI->db->query($this->CI->db->update_string($this->sess_table_name,
+											array('last_activity' => $this->userdata['last_activity']),
+											array('session_id' => $this->userdata['session_id'])));
+			}
+
+			return $this->_set_cookie($cookie_data);
+		}
+
 		// Save the old session id so we know which record to
 		// update in the database if we need it
 		$old_sessid = $this->userdata['session_id'];
@@ -357,10 +385,6 @@ class CI_Session {
 		$this->userdata['session_id'] = $new_sessid = md5(uniqid($new_sessid, TRUE));
 		$this->userdata['last_activity'] = $this->now;
 
-		// _set_cookie() will handle this for us if we aren't using database sessions
-		// by pushing all userdata to the cookie.
-		$cookie_data = NULL;
-
 		// Update the session ID and last_activity field in the DB if needed
 		if ($this->sess_use_database === TRUE)
 		{
-- 
cgit v1.2.3-24-g4f1b


From f4cb94ef0fdc81f6d9d908a4a2d2efda62add379 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 19 Jan 2012 15:16:55 +0200
Subject: Some more cleaning

---
 system/libraries/Encrypt.php | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php
index 8cb4b1b19..7c8720fd6 100644
--- a/system/libraries/Encrypt.php
+++ b/system/libraries/Encrypt.php
@@ -9,7 +9,7 @@
  * Licensed under the Open Software License version 3.0
  *
  * This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst.  It is
+ * bundled with this package in the files license.txt / license.rst. It is
  * also available through the world wide web at this URL:
  * http://opensource.org/licenses/OSL-3.0
  * If you did not receive a copy of the license and are unable to obtain it
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * CodeIgniter Encryption Class
  *
@@ -447,7 +445,7 @@ class CI_Encrypt {
 	 * Set the Hash type
 	 *
 	 * @param	string
-	 * @return	string
+	 * @return	void
 	 */
 	public function set_hash($type = 'sha1')
 	{
-- 
cgit v1.2.3-24-g4f1b


From 2c8baeb0ecdd3f5db299dc8d66edc2f157b64f23 Mon Sep 17 00:00:00 2001
From: Andrey Andreev 
Date: Thu, 19 Jan 2012 15:45:28 +0200
Subject: Some more cleaning

---
 system/libraries/Image_lib.php | 250 +++++++++++++++++------------------------
 1 file changed, 104 insertions(+), 146 deletions(-)

(limited to 'system/libraries')

diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index fd3cd0edb..065f479e8 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -9,7 +9,7 @@
  * Licensed under the Open Software License version 3.0
  *
  * This source file is subject to the Open Software License (OSL 3.0) that is
- * bundled with this package in the files license.txt / license.rst.  It is
+ * bundled with this package in the files license.txt / license.rst. It is
  * also available through the world wide web at this URL:
  * http://opensource.org/licenses/OSL-3.0
  * If you did not receive a copy of the license and are unable to obtain it
@@ -25,8 +25,6 @@
  * @filesource
  */
 
-// ------------------------------------------------------------------------
-
 /**
  * Image Manipulation class
  *
@@ -187,22 +185,17 @@ class CI_Image_lib {
 			}
 		}
 
-		/*
-		 * Is there a source image?
-		 *
-		 * If not, there's no reason to continue
-		 */
+		// Is there a source image? If not, there's no reason to continue
 		if ($this->source_image == '')
 		{
 			$this->set_error('imglib_source_image_required');
 			return FALSE;
 		}
 
-		/*
-		 * Is getimagesize() Available?
+		/* Is getimagesize() available?
 		 *
 		 * We use it to determine the image properties (width/height).
-		 * Note:  We need to figure out how to determine image
+		 * Note: We need to figure out how to determine image
 		 * properties using ImageMagick and NetPBM
 		 */
 		if ( ! function_exists('getimagesize'))
@@ -213,8 +206,7 @@ class CI_Image_lib {
 
 		$this->image_library = strtolower($this->image_library);
 
-		/*
-		 * Set the full server path
+		/* Set the full server path
 		 *
 		 * The source image may or may not contain a path.
 		 * Either way, we'll try use realpath to generate the
@@ -244,7 +236,7 @@ class CI_Image_lib {
 		 *
 		 * If the user has set a "new_image" name it means
 		 * we are making a copy of the source image. If not
-		 * it means we are altering the original.  We'll
+		 * it means we are altering the original. We'll
 		 * set the destination filename and path accordingly.
 		 */
 		if ($this->new_image == '')
@@ -252,41 +244,37 @@ class CI_Image_lib {
 			$this->dest_image = $this->source_image;
 			$this->dest_folder = $this->source_folder;
 		}
+		elseif (strpos($this->new_image, '/') === FALSE)
+		{
+			$this->dest_folder = $this->source_folder;
+			$this->dest_image = $this->new_image;
+		}
 		else
 		{
-			if (strpos($this->new_image, '/') === FALSE)
+			if (function_exists('realpath') && @realpath($this->new_image) !== FALSE)
 			{
-				$this->dest_folder = $this->source_folder;
-				$this->dest_image = $this->new_image;
+				$full_dest_path = str_replace('\\', '/', realpath($this->new_image));
 			}
 			else
 			{
-				if (function_exists('realpath') && @realpath($this->new_image) !== FALSE)
-				{
-					$full_dest_path = str_replace('\\', '/', realpath($this->new_image));
-				}
-				else
-				{
-					$full_dest_path = $this->new_image;
-				}
+				$full_dest_path = $this->new_image;
+			}
 
-				// Is there a file name?
-				if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path))
-				{
-					$this->dest_folder = $full_dest_path.'/';
-					$this->dest_image = $this->source_image;
-				}
-				else
-				{
-					$x = explode('/', $full_dest_path);
-					$this->dest_image = end($x);
-					$this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
-				}
+			// Is there a file name?
+			if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path))
+			{
+				$this->dest_folder = $full_dest_path.'/';
+				$this->dest_image = $this->source_image;
+			}
+			else
+			{
+				$x = explode('/', $full_dest_path);
+				$this->dest_image = end($x);
+				$this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
 			}
 		}
 
-		/*
-		 * Compile the finalized filenames/paths
+		/* Compile the finalized filenames/paths
 		 *
 		 * We'll create two master strings containing the
 		 * full server path to the source image and the
@@ -299,7 +287,7 @@ class CI_Image_lib {
 			$this->thumb_marker = '';
 		}
 
-		$xp	= $this->explode_name($this->dest_image);
+		$xp = $this->explode_name($this->dest_image);
 
 		$filename = $xp['name'];
 		$file_ext = $xp['ext'];
@@ -307,8 +295,7 @@ class CI_Image_lib {
 		$this->full_src_path = $this->source_folder.$this->source_image;
 		$this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
 
-		/*
-		 * Should we maintain image proportions?
+		/* Should we maintain image proportions?
 		 *
 		 * When creating thumbs or copies, the target width/height
 		 * might not be in correct proportion with the source
@@ -319,12 +306,10 @@ class CI_Image_lib {
 			$this->image_reproportion();
 		}
 
-		/*
-		 * Was a width and height specified?
+		/* Was a width and height specified?
 		 *
-		 * If the destination width/height was
-		 * not submitted we will use the values
-		 * from the actual file
+		 * If the destination width/height was not submitted we
+		 * will use the values from the actual file
 		 */
 		if ($this->width == '')
 		{
@@ -437,20 +422,15 @@ class CI_Image_lib {
 		}
 
 		// Choose resizing function
-		if ($this->image_library == 'imagemagick' OR $this->image_library == 'netpbm')
+		if ($this->image_library === 'imagemagick' OR $this->image_library === 'netpbm')
 		{
 			$protocol = 'image_process_'.$this->image_library;
 			return $this->$protocol('rotate');
 		}
 
-		if ($this->rotation_angle == 'hor' OR $this->rotation_angle == 'vrt')
-		{
-			return $this->image_mirror_gd();
-		}
-		else
-		{
-			return $this->image_rotate_gd();
-		}
+		return ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt')
+			? $this->image_mirror_gd()
+			: $this->image_rotate_gd();
 	}
 
 	// --------------------------------------------------------------------
@@ -482,7 +462,7 @@ class CI_Image_lib {
 		// Let's set up our values based on the action
 		if ($action == 'crop')
 		{
-			//  Reassign the source width/height if cropping
+			// Reassign the source width/height if cropping
 			$this->orig_width  = $this->width;
 			$this->orig_height = $this->height;
 
@@ -506,13 +486,14 @@ class CI_Image_lib {
 			return FALSE;
 		}
 
-		//  Create The Image
-		//
-		//  old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
-		//  it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
-		//  below should that ever prove inaccurate.
-		//
-		//  if ($this->image_library == 'gd2' AND function_exists('imagecreatetruecolor') AND $v2_override == FALSE)
+		/* Create the image
+		 *
+		 * Old conditional which users report cause problems with shared GD libs who report themselves as "2.0 or greater"
+		 * it appears that this is no longer the issue that it was in 2004, so we've removed it, retaining it in the comment
+		 * below should that ever prove inaccurate.
+		 *
+		 * if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor') && $v2_override == FALSE)
+		 */
 		if ($this->image_library === 'gd2' && function_exists('imagecreatetruecolor'))
 		{
 			$create	= 'imagecreatetruecolor';
@@ -534,21 +515,17 @@ class CI_Image_lib {
 
 		$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);
 
-		//  Show the image
+		// Show the image
 		if ($this->dynamic_output == TRUE)
 		{
 			$this->image_display_gd($dst_img);
 		}
-		else
+		elseif ( ! $this->image_save_gd($dst_img)) // Or save it
 		{
-			// Or save it
-			if ( ! $this->image_save_gd($dst_img))
-			{
-				return FALSE;
-			}
+			return FALSE;
 		}
 
-		//  Kill the file handles
+		// Kill the file handles
 		imagedestroy($dst_img);
 		imagedestroy($src_img);
 
@@ -583,7 +560,7 @@ class CI_Image_lib {
 		}
 
 		// Execute the command
-		$cmd = $this->library_path." -quality ".$this->quality;
+		$cmd = $this->library_path.' -quality '.$this->quality;
 
 		if ($action == 'crop')
 		{
@@ -591,15 +568,8 @@ class CI_Image_lib {
 		}
 		elseif ($action == 'rotate')
 		{
-			switch ($this->rotation_angle)
-			{
-				case 'hor'	: $angle = '-flop';
-					break;
-				case 'vrt'	: $angle = '-flip';
-					break;
-				default		: $angle = '-rotate '.$this->rotation_angle;
-					break;
-			}
+			$angle = ($this->rotation_angle === 'hor' OR $this->rotation_angle === 'vrt')
+					? '-flop' : '-rotate '.$this->rotation_angle;
 
 			$cmd .= ' '.$angle.' "'.$this->full_src_path.'" "'.$this->full_dst_path.'" 2>&1';
 		}
@@ -642,7 +612,7 @@ class CI_Image_lib {
 			return FALSE;
 		}
 
-		//  Build the resizing command
+		// Build the resizing command
 		switch ($this->image_type)
 		{
 			case 1 :
@@ -702,7 +672,7 @@ class CI_Image_lib {
 		// If you try manipulating the original it fails so
 		// we have to rename the temp file.
 		copy ($this->dest_folder.'netpbm.tmp', $this->full_dst_path);
-		unlink ($this->dest_folder.'netpbm.tmp');
+		unlink($this->dest_folder.'netpbm.tmp');
 		@chmod($this->full_dst_path, FILE_WRITE_MODE);
 
 		return TRUE;
@@ -717,7 +687,7 @@ class CI_Image_lib {
 	 */
 	public function image_rotate_gd()
 	{
-		//  Create the image handle
+		// Create the image handle
 		if ( ! ($src_img = $this->image_create_gd()))
 		{
 			return FALSE;
@@ -772,7 +742,7 @@ class CI_Image_lib {
 		$width  = $this->orig_width;
 		$height = $this->orig_height;
 
-		if ($this->rotation_angle == 'hor')
+		if ($this->rotation_angle === 'hor')
 		{
 			for ($i = 0; $i < $height; $i++, $left = 0, $right = $width-1)
 			{
@@ -839,7 +809,7 @@ class CI_Image_lib {
 	 */
 	public function watermark()
 	{
-		return ($this->wm_type == 'overlay') ? $this->overlay_watermark() : $this->text_watermark();
+		return ($this->wm_type === 'overlay') ? $this->overlay_watermark() : $this->text_watermark();
 	}
 
 	// --------------------------------------------------------------------
@@ -861,10 +831,10 @@ class CI_Image_lib {
 		$this->get_image_properties();
 
 		// Fetch watermark image properties
-		$props			= $this->get_image_properties($this->wm_overlay_path, TRUE);
+		$props		= $this->get_image_properties($this->wm_overlay_path, TRUE);
 		$wm_img_type	= $props['image_type'];
-		$wm_width		= $props['width'];
-		$wm_height		= $props['height'];
+		$wm_width	= $props['width'];
+		$wm_height	= $props['height'];
 
 		// Create two image resources
 		$wm_img  = $this->image_create_gd($this->wm_overlay_path, $wm_img_type);
@@ -891,25 +861,23 @@ class CI_Image_lib {
 		$y_axis = $this->wm_vrt_offset + $this->wm_padding;
 
 		// Set the vertical position
-		switch ($this->wm_vrt_alignment)
+		if ($this->wm_vrt_alignment === 'M')
 		{
-			case 'T':
-				break;
-			case 'M':	$y_axis += ($this->orig_height / 2) - ($wm_height / 2);
-				break;
-			case 'B':	$y_axis += $this->orig_height - $wm_height;
-				break;
+			$y_axis += ($this->orig_height / 2) - ($wm_height / 2);
+		}
+		elseif ($this->wm_vrt_alignment === 'B')
+		{
+			$y_axis += $this->orig_height - $wm_height;
 		}
 
 		// Set the horizontal position
-		switch ($this->wm_hor_alignment)
+		if ($this->wm_hor_alignment === 'C')
 		{
-			case 'L':
-				break;
-			case 'C':	$x_axis += ($this->orig_width / 2) - ($wm_width / 2);
-				break;
-			case 'R':	$x_axis += $this->orig_width - $wm_width;
-				break;
+			$x_axis += ($this->orig_width / 2) - ($wm_width / 2);
+		}
+		elseif ($this->wm_hor_alignment === 'R')
+		{
+			$x_axis += $this->orig_width - $wm_width;
 		}
 
 		//  Build the finalized image
@@ -935,12 +903,12 @@ class CI_Image_lib {
 			imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
 		}
 
-		//  Output the image
+		// Output the image
 		if ($this->dynamic_output == TRUE)
 		{
 			$this->image_display_gd($src_img);
 		}
-		elseif ( ! $this->image_save_gd($src_img))
+		elseif ( ! $this->image_save_gd($src_img)) // ... or save it
 		{
 			return FALSE;
 		}
@@ -977,7 +945,7 @@ class CI_Image_lib {
 		// Reverse the vertical offset
 		// When the image is positioned at the bottom
 		// we don't want the vertical offset to push it
-		// further down.  We want the reverse, so we'll
+		// further down. We want the reverse, so we'll
 		// invert the offset. Note: The horizontal
 		// offset flips itself automatically
 
@@ -1011,49 +979,39 @@ class CI_Image_lib {
 		$x_axis = $this->wm_hor_offset + $this->wm_padding;
 		$y_axis = $this->wm_vrt_offset + $this->wm_padding;
 
-		// Set verticle alignment
 		if ($this->wm_use_drop_shadow == FALSE)
 			$this->wm_shadow_distance = 0;
 
 		$this->wm_vrt_alignment = strtoupper(substr($this->wm_vrt_alignment, 0, 1));
 		$this->wm_hor_alignment = strtoupper(substr($this->wm_hor_alignment, 0, 1));
 
-		switch ($this->wm_vrt_alignment)
+		// Set verticle alignment
+		if ($this->wm_vrt_alignment === 'M')
 		{
-			case 'T':
-				break;
-			case 'M':	$y_axis += ($this->orig_height/2)+($fontheight/2);
-				break;
-			case 'B':	$y_axis += ($this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight/2));
-				break;
+			$y_axis += ($this->orig_height / 2) + ($fontheight / 2);
+		}
+		elseif ($this->wm_vrt_alignment === 'B')
+		{
+			$y_axis += $this->orig_height - $fontheight - $this->wm_shadow_distance - ($fontheight / 2);
 		}
 
 		$x_shad = $x_axis + $this->wm_shadow_distance;
 		$y_shad = $y_axis + $this->wm_shadow_distance;
 
-		// Set horizontal alignment
-		switch ($this->wm_hor_alignment)
-		{
-			case 'L':
-				break;
-			case 'R':
-				if ($this->wm_use_drop_shadow)
-				{
-					$x_shad += ($this->orig_width - $fontwidth*strlen($this->wm_text));
-					$x_axis += ($this->orig_width - $fontwidth*strlen($this->wm_text));
-				}
-				break;
-			case 'C':
-				if ($this->wm_use_drop_shadow)
-				{
-					$x_shad += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2);
-					$x_axis += floor(($this->orig_width - $fontwidth*strlen($this->wm_text))/2);
-				}
-				break;
-		}
-
 		if ($this->wm_use_drop_shadow)
 		{
+			// Set horizontal alignment
+			if ($this->wm_hor_alignment === 'R')
+			{
+				$x_shad += $this->orig_width - ($fontwidth * strlen($this->wm_text));
+				$x_axis += $this->orig_width - ($fontwidth * strlen($this->wm_text));
+			}
+			elseif ($this->wm_hor_alignment === 'C')
+			{
+				$x_shad += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2);
+				$x_axis += floor(($this->orig_width - ($fontwidth * strlen($this->wm_text))) / 2);
+			}
+
 			/* Set RGB values for text and shadow
 			 *
 			 * First character is #, so we don't really need it.
@@ -1222,8 +1180,8 @@ class CI_Image_lib {
 	 */
 	public function image_display_gd($resource)
 	{
-		header("Content-Disposition: filename={$this->source_image};");
-		header("Content-Type: {$this->mime_type}");
+		header('Content-Disposition: filename='.$this->source_image.';');
+		header('Content-Type: '.$this->mime_type);
 		header('Content-Transfer-Encoding: binary');
 		header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
 
@@ -1351,15 +1309,15 @@ class CI_Image_lib {
 	 * Size calculator
 	 *
 	 * This function takes a known width x height and
-	 * recalculates it to a new size.  Only one
+	 * recalculates it to a new size. Only one
 	 * new variable needs to be known
 	 *
 	 *	$props = array(
-	 *					'width'			=> $width,
-	 *					'height'		=> $height,
-	 *					'new_width'		=> 40,
-	 *					'new_height'	=> ''
-	 *				  );
+	 *			'width'		=> $width,
+	 *			'height'	=> $height,
+	 *			'new_width'	=> 40,
+	 *			'new_height'	=> ''
+	 *		);
 	 *
 	 * @param	array
 	 * @return	array
@@ -1403,7 +1361,7 @@ class CI_Image_lib {
 	 *
 	 * This is a helper function that extracts the extension
 	 * from the source_image.  This function lets us deal with
-	 * source_images with multiple periods, like:  my.cool.jpg
+	 * source_images with multiple periods, like: my.cool.jpg
 	 * It returns an associative array with two elements:
 	 * $array['ext']  = '.jpg';
 	 * $array['name'] = 'my.cool';
@@ -1498,7 +1456,7 @@ class CI_Image_lib {
 	 */
 	public function display_errors($open = '

', $close = '

') { - return (count($this->error_msg) > 0) ? $open . implode($close . $open, $this->error_msg) . $close : ''; + return (count($this->error_msg) > 0) ? $open.implode($close.$open, $this->error_msg).$close : ''; } } -- cgit v1.2.3-24-g4f1b From 7e087f5e07c4630092a1d6ecdd103dc15f48e573 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 11:46:27 +0200 Subject: Revert if() merge, for readability --- system/libraries/Session.php | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index 784bb62b2..b8c623584 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -179,11 +179,28 @@ class CI_Session { $session = $this->_unserialize($session); // Is the session data we unserialized an array with the correct format? - if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity']) - OR ($session['last_activity'] + $this->sess_expiration) < $this->now // Is the session current? - OR ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) // Does the IP match? - OR ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) // Does the User Agent Match? - ) + if ( ! is_array($session) OR ! isset($session['session_id'], $session['ip_address'], $session['user_agent'], $session['last_activity'])) + { + $this->sess_destroy(); + return FALSE; + } + + // Is the session current? + if (($session['last_activity'] + $this->sess_expiration) < $this->now) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the IP match? + if ($this->sess_match_ip == TRUE && $session['ip_address'] !== $this->CI->input->ip_address()) + { + $this->sess_destroy(); + return FALSE; + } + + // Does the User Agent Match? + if ($this->sess_match_useragent == TRUE && trim($session['user_agent']) !== trim(substr($this->CI->input->user_agent(), 0, 120))) { $this->sess_destroy(); return FALSE; -- cgit v1.2.3-24-g4f1b From f88681873b8b556d58f22a3e99c916eadbcb6171 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Jan 2012 13:14:53 +0200 Subject: Replace AND with && --- system/libraries/Session.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index b8c623584..c331d99f7 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Session Class * @@ -94,7 +92,7 @@ class CI_Session { } // Are we using a database? If so, load it - if ($this->sess_use_database === TRUE AND $this->sess_table_name != '') + if ($this->sess_use_database === TRUE && $this->sess_table_name != '') { $this->CI->load->database(); } @@ -232,7 +230,7 @@ class CI_Session { // Is there custom data? If so, add it to the main session array $row = $query->row(); - if (isset($row->user_data) AND $row->user_data != '') + if (isset($row->user_data) && $row->user_data != '') { $custom_data = $this->_unserialize($row->user_data); -- cgit v1.2.3-24-g4f1b From ed6531362e9eb98eeb477c63e3c365f79333e724 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:26:42 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Encrypt.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Encrypt.php b/system/libraries/Encrypt.php index 7c8720fd6..f6eea3b7e 100644 --- a/system/libraries/Encrypt.php +++ b/system/libraries/Encrypt.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From a3d19c4ac63c4af1c2b823b0962e6be79e89d186 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:29:29 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 065f479e8..5ea830fb1 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From f863a02e314813753662106459e93f6675b1566e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 24 Jan 2012 15:31:54 +0200 Subject: Revert a space in the license agreement :) --- system/libraries/Session.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Session.php b/system/libraries/Session.php index c331d99f7..66b39a6a2 100644 --- a/system/libraries/Session.php +++ b/system/libraries/Session.php @@ -9,7 +9,7 @@ * Licensed under the Open Software License version 3.0 * * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is + * bundled with this package in the files license.txt / license.rst. It is * also available through the world wide web at this URL: * http://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to obtain it -- cgit v1.2.3-24-g4f1b From 6e09f238acfa8f3d1180ff3f640c65aeffbc4379 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 15 Feb 2012 18:23:08 +0100 Subject: Lowered the file permissions for file caches. See #1045 for more information. Signed-off-by: Yorick Peterse --- system/libraries/Cache/drivers/Cache_file.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index 4a81b0422..a960730d7 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -99,7 +99,7 @@ class CI_Cache_file extends CI_Driver { if (write_file($this->_cache_path.$id, serialize($contents))) { - @chmod($this->_cache_path.$id, 0777); + @chmod($this->_cache_path.$id, 0660); return TRUE; } -- cgit v1.2.3-24-g4f1b From 287dd450911251c3dc4d744c2e03fcd5d8a5b173 Mon Sep 17 00:00:00 2001 From: Marcos Garcia Date: Fri, 17 Feb 2012 02:26:22 +0100 Subject: Fixed issue #960 --- system/libraries/Cart.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index ba8d69be2..10b5362a5 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -329,13 +329,6 @@ class CI_Cart { return FALSE; } - // Is the new quantity different than what is already saved in the cart? - // If it's the same there's nothing to do - if ($this->_cart_contents[$items['rowid']]['qty'] == $items['qty']) - { - return FALSE; - } - // Is the quantity zero? If so we will remove the item from the cart. // If the quantity is greater than zero we are updating if ($items['qty'] == 0) -- cgit v1.2.3-24-g4f1b From 46ac881006b1215e136a875491efb020c59246fb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Feb 2012 14:32:54 +0200 Subject: Fix issue #177 --- system/libraries/Form_validation.php | 42 ++++++++++++------------------------ 1 file changed, 14 insertions(+), 28 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 0a6a2af0d..4c393c1d5 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -703,11 +703,11 @@ class CI_Form_validation { * * @param string the field name * @param string - * @return void + * @return string */ public function set_value($field = '', $default = '') { - if ( ! isset($this->_field_data[$field])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { return $default; } @@ -736,13 +736,9 @@ class CI_Form_validation { */ public function set_select($field = '', $value = '', $default = FALSE) { - if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' selected="selected"'; - } - return ''; + return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -754,12 +750,9 @@ class CI_Form_validation { return ''; } } - else + elseif (($field == '' OR $value == '') OR ($field != $value)) { - if (($field == '' OR $value == '') OR ($field != $value)) - { - return ''; - } + return ''; } return ' selected="selected"'; @@ -779,13 +772,9 @@ class CI_Form_validation { */ public function set_radio($field = '', $value = '', $default = FALSE) { - if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) + if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - if ($default === TRUE AND count($this->_field_data) === 0) - { - return ' checked="checked"'; - } - return ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' checked="checked"' : ''; } $field = $this->_field_data[$field]['postdata']; @@ -869,9 +858,7 @@ class CI_Form_validation { return FALSE; } - $field = $_POST[$field]; - - return ($str === $field); + return ($str === $_POST[$field]); } // -------------------------------------------------------------------- @@ -908,7 +895,7 @@ class CI_Form_validation { */ public function min_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -932,7 +919,7 @@ class CI_Form_validation { */ public function max_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -956,7 +943,7 @@ class CI_Form_validation { */ public function exact_length($str, $val) { - if (preg_match("/[^0-9]/", $val)) + if (preg_match('/[^0-9]/', $val)) { return FALSE; } @@ -1170,7 +1157,7 @@ class CI_Form_validation { */ public function is_natural_no_zero($str) { - return ($str != 0 AND preg_match('/^[0-9]+$/', $str)); + return ($str != 0 && preg_match('/^[0-9]+$/', $str)); } // -------------------------------------------------------------------- @@ -1217,7 +1204,7 @@ class CI_Form_validation { return $data; } - return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); + return str_replace(array("'", '"', '<', '>'), array(''', '"', '<', '>'), stripslashes($data)); } // -------------------------------------------------------------------- @@ -1283,7 +1270,6 @@ class CI_Form_validation { } } -// END Form Validation Class /* End of file Form_validation.php */ /* Location: ./system/libraries/Form_validation.php */ -- cgit v1.2.3-24-g4f1b From 0adff1bac0617e5d02c7f8028c7fae8fedda9370 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Feb 2012 14:36:40 +0200 Subject: Replace AND with && --- system/libraries/Form_validation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 4c393c1d5..2ee734ae6 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -738,7 +738,7 @@ class CI_Form_validation { { if ( ! isset($this->_field_data[$field], $this->_field_data[$field]['postdata'])) { - return ($default === TRUE AND count($this->_field_data) === 0) ? ' selected="selected"' : ''; + return ($default === TRUE && count($this->_field_data) === 0) ? ' selected="selected"' : ''; } $field = $this->_field_data[$field]['postdata']; -- cgit v1.2.3-24-g4f1b From b57832690574b913c3224b4407427db00dfe7fed Mon Sep 17 00:00:00 2001 From: Michiel Vugteveen Date: Wed, 29 Feb 2012 15:40:28 +0100 Subject: removed double slash --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 82383f658..0b853233d 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -960,7 +960,7 @@ class CI_Upload { } elseif (is_file(APPPATH.'config/mimes.php')) { - include(APPPATH.'config//mimes.php'); + include(APPPATH.'config/mimes.php'); } else { -- cgit v1.2.3-24-g4f1b