From edc9afa09b01f67089f121ed7054fe3a5a3b8ec2 Mon Sep 17 00:00:00 2001 From: Edwin Aw Date: Fri, 25 Jan 2013 16:12:20 +0800 Subject: Fix issue #2191. Signed-off-by: Edwin Aw --- system/libraries/Cart.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index 8734d7774..d64f6f042 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -95,7 +95,7 @@ class CI_Cart { $config = is_array($params) ? $params : array(); // Load the Sessions class - $this->CI->load->library('session', $config); + $this->CI->load->driver('session', $config); // Grab the shopping cart array from the session table $this->_cart_contents = $this->CI->session->userdata('cart_contents'); -- cgit v1.2.3-24-g4f1b From 16c6d7e8ab6b161d11c0e8dbca7dbbef58b49138 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sat, 26 Jan 2013 17:21:29 +0100 Subject: Fix a code comment in Image_lib constant FILE_WRITE_MODE contains octal 0666 --- system/libraries/Image_lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 6d5493696..0cec43fc4 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -810,7 +810,7 @@ class CI_Image_lib { imagedestroy($dst_img); imagedestroy($src_img); - // Set the file to 777 + // Set the file to 666 @chmod($this->full_dst_path, FILE_WRITE_MODE); return TRUE; -- cgit v1.2.3-24-g4f1b From cabead10ac1e9d2aee0cc8bd5270061e75aec179 Mon Sep 17 00:00:00 2001 From: rebornishard Date: Sun, 27 Jan 2013 01:58:55 +0700 Subject: Add webm mime type http://www.webmproject.org/about/faq/ --- application/config/mimes.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 124e4a436..d9e81bf77 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -154,6 +154,7 @@ return array( 'mp4' => 'video/mp4', 'm4a' => 'audio/x-m4a', 'f4v' => 'video/mp4', + 'webm' => 'video/webm' 'aac' => 'audio/x-acc', 'm4u' => 'application/vnd.mpegurl', 'm3u' => 'text/plain', @@ -175,4 +176,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ \ No newline at end of file +/* Location: ./application/config/mimes.php */ -- cgit v1.2.3-24-g4f1b From 14c8defb73fb29282ba55d3aa444e2ce6d59fd1c Mon Sep 17 00:00:00 2001 From: dontforget Date: Sun, 27 Jan 2013 10:42:56 -0800 Subject: Fixing issue with comma --- application/config/mimes.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index d9e81bf77..ac7bfaf34 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -154,7 +154,7 @@ return array( 'mp4' => 'video/mp4', 'm4a' => 'audio/x-m4a', 'f4v' => 'video/mp4', - 'webm' => 'video/webm' + 'webm' => 'video/webm', 'aac' => 'audio/x-acc', 'm4u' => 'application/vnd.mpegurl', 'm3u' => 'text/plain', -- cgit v1.2.3-24-g4f1b From b75e13df03dcf898cc85e144b941e1b1f6c332be Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Sun, 27 Jan 2013 20:10:09 -0600 Subject: Fix newline standardization. Signed-off-by: Eric Roberts --- system/core/Input.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Input.php b/system/core/Input.php index 82e22dd49..68a8fe03f 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -720,9 +720,9 @@ class CI_Input { } // Standardize newlines if needed - if ($this->_standardize_newlines === TRUE && strpos($str, "\r") !== FALSE) + if ($this->_standardize_newlines === TRUE) { - return str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); + return preg_replace('/(?:\r\n|[\r\n])/', PHP_EOL, $str); } return $str; -- cgit v1.2.3-24-g4f1b From db529ca1e13e9f9e1c73be20c3b92a7adc3c6aa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 11:00:02 +0200 Subject: Remove unnecessary defined('ENVIRONMENT') checks As suggested in issue #2134 & PR #2149 --- application/config/mimes.php | 2 +- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 4 ++-- system/core/Config.php | 6 +----- system/core/Hooks.php | 2 +- system/core/Loader.php | 6 +++--- system/core/Router.php | 2 +- system/database/DB.php | 2 +- system/helpers/html_helper.php | 2 +- system/helpers/smiley_helper.php | 2 +- system/helpers/text_helper.php | 2 +- system/libraries/User_agent.php | 2 +- 12 files changed, 15 insertions(+), 19 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index ac7bfaf34..dfa9f24e4 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -176,4 +176,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ +/* Location: ./application/config/mimes.php */ \ No newline at end of file diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 8affde64d..cb4b735d5 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -58,7 +58,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * Load the framework constants * ------------------------------------------------------ */ - if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php')) { require(APPPATH.'config/'.ENVIRONMENT.'/constants.php'); } diff --git a/system/core/Common.php b/system/core/Common.php index d494caf80..90cc5b3a4 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -241,7 +241,7 @@ if ( ! function_exists('get_config')) } // Is the config file in the environment folder? - if (defined('ENVIRONMENT') && file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) + if (file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config.php')) { require($file_path); } @@ -316,7 +316,7 @@ if ( ! function_exists('get_mimes')) { static $_mimes = array(); - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { $_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } diff --git a/system/core/Config.php b/system/core/Config.php index 0160d1a15..7e64444bc 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -106,13 +106,9 @@ class CI_Config { $file = ($file === '') ? 'config' : str_replace('.php', '', $file); $found = $loaded = FALSE; - $check_locations = defined('ENVIRONMENT') - ? array(ENVIRONMENT.'/'.$file, $file) - : array($file); - foreach ($this->_config_paths as $path) { - foreach ($check_locations as $location) + foreach (array(ENVIRONMENT.'/'.$file, $file) as $location) { $file_path = $path.'config/'.$location.'.php'; diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 2cb416c0c..59759e02e 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -81,7 +81,7 @@ class CI_Hooks { } // Grab the "hooks" definition file. - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); } diff --git a/system/core/Loader.php b/system/core/Loader.php index 1ad07f1fa..bbd7a84b6 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1089,12 +1089,12 @@ class CI_Loader { // We test for both uppercase and lowercase, for servers that // are case-sensitive with regard to file names. Check for environment // first, global next - if (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + if (file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) { include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); break; } - elseif (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) + elseif (file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) { include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); break; @@ -1180,7 +1180,7 @@ class CI_Loader { */ protected function _ci_autoloader() { - if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); } diff --git a/system/core/Router.php b/system/core/Router.php index f284e29cc..4755b3712 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -133,7 +133,7 @@ class CI_Router { } // Load the routes.php file. - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); } diff --git a/system/database/DB.php b/system/database/DB.php index f94685c51..d9104747f 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -43,7 +43,7 @@ function &DB($params = '', $query_builder_override = NULL) if (is_string($params) && strpos($params, '://') === FALSE) { // Is the config file in the environment folder? - if (( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')) + if ( ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php') && ! file_exists($file_path = APPPATH.'config/database.php')) { show_error('The configuration file database.php does not exist.'); diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 2d474169b..7a71eb82b 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -242,7 +242,7 @@ if ( ! function_exists('doctype')) if ( ! is_array($_doctypes)) { - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 186b24ce9..c2f50ec73 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -213,7 +213,7 @@ if ( ! function_exists('_get_smiley_array')) */ function _get_smiley_array() { - if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 1c7eeaf5f..c255c15a8 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -367,7 +367,7 @@ if ( ! function_exists('convert_accented_characters')) if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) { - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 1f4b2fa52..3fe2e0519 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -175,7 +175,7 @@ class CI_User_agent { */ protected function _load_agent_file() { - if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); } -- cgit v1.2.3-24-g4f1b From 763847931d421753f503608018b0da2bbaa9bfd6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 11:22:05 +0200 Subject: Add ENVIRONMENT constant to unit tests --- tests/Bootstrap.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index 8ce80b3fd..c98d88531 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -32,6 +32,7 @@ if ( ! class_exists('vfsStream') && file_exists(PROJECT_BASE.'vendor/autoload.ph defined('BASEPATH') OR define('BASEPATH', vfsStream::url('system/')); defined('APPPATH') OR define('APPPATH', vfsStream::url('application/')); defined('VIEWPATH') OR define('VIEWPATH', APPPATH.'views/'); +defined('ENVIRONMENT') OR define('ENVIRONMENT', 'development'); // Set localhost "remote" IP isset($_SERVER['REMOTE_ADDR']) OR $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; -- cgit v1.2.3-24-g4f1b From 9f3a590751da2003698546c205a93fcc9c3325f8 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Mon, 28 Jan 2013 04:29:06 -0600 Subject: Multiple pagination bug fixes & optimizations. Signed-off-by: Eric Roberts --- system/libraries/Pagination.php | 190 ++++++++++++++++++++++------------------ 1 file changed, 107 insertions(+), 83 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index d139980d8..3a513a7c1 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -133,7 +133,7 @@ class CI_Pagination { * * @var int */ - protected $uri_segment = 3; + protected $uri_segment = 0; /** * Full tag open @@ -318,11 +318,9 @@ class CI_Pagination { */ public function initialize($params = array()) { - $attributes = array(); - if (isset($params['attributes']) && is_array($params['attributes'])) { - $attributes = $params['attributes']; + $this->_parse_attributes($params['attributes']); unset($params['attributes']); } @@ -334,8 +332,6 @@ class CI_Pagination { unset($params['anchor_class']); } - $this->_parse_attributes($attributes); - if (count($params) > 0) { foreach ($params as $key => $val) @@ -372,45 +368,111 @@ class CI_Pagination { return ''; } - // Set the base page index for starting page number - $base_page = ($this->use_page_numbers) ? 1 : 0; + // Check the user defined number of links. + $this->num_links = (int) $this->num_links; + + if ($this->num_links < 1) + { + show_error('Your number of links must be a positive number.'); + } - // 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 !== '') + // Keep any existing query string items. + // Note: Has nothing to do with any other query string option. + $get = array(); + + if ($this->reuse_query_string === TRUE) { - $this->cur_page = (int) str_replace(array($this->prefix, $this->suffix), '', $CI->uri->rsegment($this->uri_segment)); + $get = $CI->input->get(); + + // Unset the controll, method, old-school routing options + unset($get['c'], $get['m'], $get[$this->query_string_segment]); } + // Put together our base and first URLs. + $this->base_url = trim($this->base_url); + + $query_string = ''; + $query_string_sep = (strpos($this->base_url, '?') === FALSE) ? '?' : '&'; + + // Are we using query strings? if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - if ($CI->input->get($this->query_string_segment) != $base_page) + // If a custom first_url hasn't been specified, we'll create one from + // the base_url, but without the page item. + if ($this->first_url === '') { - $this->cur_page = (int) $CI->input->get($this->query_string_segment); + $this->first_url = $this->base_url; + + // If we saved any GET items earlier, make sure they're appended. + if ( ! empty($get)) + { + $this->first_url .= $query_string_sep . http_build_query($get); + } } + + // Add the page segment to the end of the query string, where the + // page number will be appended. + $this->base_url .= $query_string_sep . http_build_query(array_merge($get, array($this->query_string_segment => ''))); } - elseif ( ! $this->cur_page && $CI->uri->segment($this->uri_segment) !== $base_page) + else { - $this->cur_page = (int) $CI->uri->rsegment($this->uri_segment); + // Standard segment mode. + // Generate our saved query string to append later after the page number. + if ( ! empty($get)) + { + $query_string = $query_string_sep . http_build_query($get); + $this->suffix .= $query_string; + } + + // Does the base_url have the query string in it? + // If we're supposed to save it, remove it so we can append it later. + if ($this->reuse_query_string === TRUE && ($base_query_pos = strpos($this->base_url, '?')) !== FALSE) + { + $this->base_url = substr($this->base_url, 0, $base_query_pos); + } + + if ($this->first_url === '') + { + $this->first_url = $this->base_url . $query_string; + } + + $this->base_url = rtrim($this->base_url, '/') . '/'; } - // 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 && $this->cur_page === 0)) + // Determine the current page number. + $base_page = ($this->use_page_numbers) ? 1 : 0; + + // Are we using query strings? + if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - $this->cur_page = $base_page; + $this->cur_page = (int) $CI->input->get($this->query_string_segment); } + else + { + // Default to the last segment number if one hasn't been defined. + if ($this->uri_segment === 0) + { + $this->uri_segment = count($CI->uri->segment_array()); + } - $this->num_links = (int) $this->num_links; + $this->cur_page = $CI->uri->segment($this->uri_segment); - if ($this->num_links < 1) + // Remove any specified prefix/suffix from the segment. + $this->cur_page = ($this->prefix !== '' OR $this->suffix !== '') + ? (int) str_replace(array($this->prefix, $this->suffix), '', $this->cur_page) + : (int) $this->cur_page; + } + + // If something isn't quite right, back to the default base page. + if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page === 0)) { - show_error('Your number of links must be a positive number.'); + $this->cur_page = $base_page; } // Is the page number beyond the result range? - // If so we show the last page + // If so, we show the last page. if ($this->use_page_numbers) { if ($this->cur_page > $num_pages) @@ -425,80 +487,47 @@ class CI_Pagination { $uri_page_number = $this->cur_page; + // If we're using offset instead of page numbers, convert it + // to a page number, so we can generate the surrounding number links. if ( ! $this->use_page_numbers) { $this->cur_page = (int) floor(($this->cur_page/$this->per_page) + 1); } // Calculate the start and end numbers. These determine - // which number to start and end the digit links with + // which number to start and end the digit links with. $start = (($this->cur_page - $this->num_links) > 0) ? $this->cur_page - ($this->num_links - 1) : 1; $end = (($this->cur_page + $this->num_links) < $num_pages) ? $this->cur_page + $this->num_links : $num_pages; - // Is pagination being used over GET or POST? If get, add a per_page query - // string. If post, add a trailing slash to the base URL if needed - if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) - { - $segment = (strpos($this->base_url, '?')) ? '&' : '?'; - $this->base_url = rtrim($this->base_url).$segment.$this->query_string_segment.'='; - } - else - { - $this->base_url = rtrim($this->base_url, '/') .'/'; - } - // And here we go... $output = ''; - $query_string = ''; - - // Add anything in the query string back to the links - // Note: Nothing to do with query_string_segment or any other query string options - if ($this->reuse_query_string === TRUE) - { - $get = $CI->input->get(); - // Unset the controll, method, old-school routing options - unset($get['c'], $get['m'], $get[$this->query_string_segment]); - - if ( ! empty($get)) - { - // Put everything else onto the end - $query_string = (strpos($this->base_url, '?') !== FALSE ? '&' : '?') - .http_build_query($get, '', '&'); - - // Add this after the suffix to put it into more links easily - $this->suffix .= $query_string; - } - } - - // Render the "First" link + // Render the "First" link. if ($this->first_link !== FALSE && $this->cur_page > ($this->num_links + 1)) { - $first_url = ($this->first_url === '') ? $this->base_url : $this->first_url; - - // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's + // Take the general parameters, and squeeze this pagination-page attr in for JS frameworks. $attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, 1); - $output .= $this->first_tag_open.'_attr_rel('start').'>' + $output .= $this->first_tag_open.'_attr_rel('start').'>' .$this->first_link.''.$this->first_tag_close; } - // Render the "previous" link + // Render the "Previous" link. if ($this->prev_link !== FALSE && $this->cur_page !== 1) { $i = ($this->use_page_numbers) ? $uri_page_number - 1 : $uri_page_number - $this->per_page; - // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's $attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i); - if ($i === $base_page && $this->first_url !== '') + if ($i === $base_page) { - $output .= $this->prev_tag_open.'_attr_rel('prev').'>' + // First page + $output .= $this->prev_tag_open.'_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } else { - $append = ($i === $base_page) ? $query_string : $this->prefix.$i.$this->suffix; + $append = $this->prefix.$i.$this->suffix; $output .= $this->prev_tag_open.'_attr_rel('prev').'>' .$this->prev_link.''.$this->prev_tag_close; } @@ -513,29 +542,26 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $loop : ($loop * $this->per_page) - $this->per_page; - // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's $attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i); if ($i >= $base_page) { if ($this->cur_page === $loop) { - $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; // Current page + // Current page + $output .= $this->cur_tag_open.$loop.$this->cur_tag_close; + } + elseif ($i === $base_page) + { + // First page + $output .= $this->num_tag_open.'_attr_rel('start').'>' + .$loop.''.$this->num_tag_close; } else { - $n = ($i === $base_page) ? '' : $i; - if ($n === '' && ! empty($this->first_url)) - { - $output .= $this->num_tag_open.'_attr_rel('start').'>' - .$loop.''.$this->num_tag_close; - } - else - { - $append = ($n === '') ? $query_string : $this->prefix.$n.$this->suffix; - $output .= $this->num_tag_open.'_attr_rel('start').'>' - .$loop.''.$this->num_tag_close; - } + $append = $this->prefix.$i.$this->suffix; + $output .= $this->num_tag_open.'_attr_rel('start').'>' + .$loop.''.$this->num_tag_close; } } } @@ -546,7 +572,6 @@ class CI_Pagination { { $i = ($this->use_page_numbers) ? $this->cur_page + 1 : $this->cur_page * $this->per_page; - // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's $attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i); $output .= $this->next_tag_open.'use_page_numbers) ? $num_pages : ($num_pages * $this->per_page) - $this->per_page; - // Take the general parameters, and squeeze this pagination-page attr in there for JS fw's $attributes = sprintf('%s %s="%d"', $this->_attributes, $this->data_page_attr, (int) $i); $output .= $this->last_tag_open.'' -- cgit v1.2.3-24-g4f1b From 606fee0e2e0aa6a906db82e77090e91f133d7378 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 12:57:13 +0200 Subject: Fix auto_link() for the Nth time - anchor() is for local links and breaks ones that don't have a protocol prefix - Allow :// links (no actual protocol specified) - Further simplified the URL regular expression --- system/helpers/url_helper.php | 19 ++++++++++--------- tests/codeigniter/helpers/url_helper_test.php | 11 ++++++----- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/system/helpers/url_helper.php b/system/helpers/url_helper.php index a6536cf81..d0fab3fe0 100644 --- a/system/helpers/url_helper.php +++ b/system/helpers/url_helper.php @@ -384,22 +384,23 @@ if ( ! function_exists('auto_link')) function auto_link($str, $type = 'both', $popup = FALSE) { // Find and replace any URLs. - if ($type !== 'email' && preg_match_all('#\b(([\w-]+://?|www\.)[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))#', $str, $matches, PREG_OFFSET_CAPTURE)) + if ($type !== 'email' && preg_match_all('#(\w*://|www\.)[^\s()<>;]+\w#i', $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { // Set our target HTML if using popup links. - $target = ($popup) ? 'target="_blank"' : ''; + $target = ($popup) ? ' target="_blank"' : ''; // We process the links in reverse order (last -> first) so that // the returned string offsets from preg_match_all() are not // moved as we add more HTML. - foreach (array_reverse($matches[0]) as $match) + foreach (array_reverse($matches) as $match) { - // $match is an array generated by the PREG_OFFSET_CAPTURE flag. - // $match[0] is the matched string, $match[1] is the string offset. - - $anchor = anchor($match[0], '', $target); - - $str = substr_replace($str, $anchor, $match[1], strlen($match[0])); + // $match[0] is the matched string/link + // $match[1] is either a protocol prefix or 'www.' + // + // With PREG_OFFSET_CAPTURE, both of the above is an array, + // where the actual value is held in [0] and its offset at the [1] index. + $a = ''.$match[0][0].''; + $str = substr_replace($str, $a, $match[0][1], strlen($match[0][0])); } } diff --git a/tests/codeigniter/helpers/url_helper_test.php b/tests/codeigniter/helpers/url_helper_test.php index 5fc364238..24823a634 100644 --- a/tests/codeigniter/helpers/url_helper_test.php +++ b/tests/codeigniter/helpers/url_helper_test.php @@ -48,11 +48,12 @@ class Url_helper_test extends CI_TestCase { public function test_auto_link_url() { $strings = array( - 'www.codeigniter.com test' => 'http://www.codeigniter.com test', + 'www.codeigniter.com test' => 'www.codeigniter.com test', 'This is my noreply@codeigniter.com test' => 'This is my noreply@codeigniter.com test', - '
www.google.com' => '
http://www.google.com', - 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at http://www.codeigniter.com. Period test.', - 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at http://www.codeigniter.com, comma test' + '
www.google.com' => '
www.google.com', + 'Download CodeIgniter at www.codeigniter.com. Period test.' => 'Download CodeIgniter at www.codeigniter.com. Period test.', + 'Download CodeIgniter at www.codeigniter.com, comma test' => 'Download CodeIgniter at www.codeigniter.com, comma test', + 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' => 'This one: ://codeigniter.com must not break this one: http://codeigniter.com' ); foreach ($strings as $in => $out) @@ -66,7 +67,7 @@ class Url_helper_test extends CI_TestCase { public function test_pull_675() { $strings = array( - '
www.google.com' => '
http://www.google.com', + '
www.google.com' => '
www.google.com', ); foreach ($strings as $in => $out) -- cgit v1.2.3-24-g4f1b From 009c8f09fbe767b01453f32b28f8a8a8dd4ef7c5 Mon Sep 17 00:00:00 2001 From: gommarah Date: Mon, 28 Jan 2013 13:45:50 +0200 Subject: Upload library, clean_file_name function: Fix xss bug. For example: If you clear this string "%%3f3f" according to the $bad array will fail. The result will be "%3f" Because str_replace() replaces left to right. Signed-off-by: xeptor --- system/libraries/Upload.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 96bb17edc..86c93411e 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1005,6 +1005,13 @@ class CI_Upload { '%3d' // = ); + do + { + $old_filename = $filename; + $filename = str_replace($bad, '', $filename); + } + while ($old_filename !== $filename); + return stripslashes(str_replace($bad, '', $filename)); } -- cgit v1.2.3-24-g4f1b From 9be4cd74db158d805e0bc04c48c52a6453337c1d Mon Sep 17 00:00:00 2001 From: gommarah Date: Mon, 28 Jan 2013 13:58:35 +0200 Subject: Remove str_replace in return --- system/libraries/Upload.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 86c93411e..1f0bd6a6e 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1012,7 +1012,7 @@ class CI_Upload { } while ($old_filename !== $filename); - return stripslashes(str_replace($bad, '', $filename)); + return stripslashes($filename); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3608e1a094945631c5b65e1f66460e4486c5b541 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 16:27:30 +0200 Subject: Libraries' filenames must be named in a ucfirst-like manner --- system/core/Loader.php | 144 ++- system/libraries/Javascript.php | 2 +- system/libraries/Javascript/Jquery.php | 1069 ++++++++++++++++++++ system/libraries/Javascript/index.html | 10 + system/libraries/javascript/Jquery.php | 1069 -------------------- system/libraries/javascript/index.html | 10 - user_guide_src/source/installation/upgrade_300.rst | 34 +- 7 files changed, 1169 insertions(+), 1169 deletions(-) create mode 100644 system/libraries/Javascript/Jquery.php create mode 100644 system/libraries/Javascript/index.html delete mode 100644 system/libraries/javascript/Jquery.php delete mode 100644 system/libraries/javascript/index.html diff --git a/system/core/Loader.php b/system/core/Loader.php index bbd7a84b6..3ecce1676 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -96,13 +96,6 @@ class CI_Loader { */ protected $_ci_classes = array(); - /** - * List of loaded files - * - * @var array - */ - protected $_ci_loaded_files = array(); - /** * List of loaded models * @@ -943,117 +936,100 @@ class CI_Loader { // Was the path included with the class name? // We look for a slash to determine this - $subdir = ''; if (($last_slash = strrpos($class, '/')) !== FALSE) { // Extract the path - $subdir = substr($class, 0, ++$last_slash); + $subdir = ucfirst(substr($class, 0, ++$last_slash)); // Get the filename from the path $class = substr($class, $last_slash); } + else + { + $subdir = ''; + } + + $class = ucfirst($class); + $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; - // We'll test for both lowercase and capitalized versions of the file name - foreach (array(ucfirst($class), strtolower($class)) as $class) + // Is this a class extension request? + if (file_exists($subclass)) { - $subclass = APPPATH.'libraries/'.$subdir.config_item('subclass_prefix').$class.'.php'; + $baseclass = BASEPATH.'libraries/'.$class.'.php'; - // Is this a class extension request? - if (file_exists($subclass)) + if ( ! file_exists($baseclass)) { - $baseclass = BASEPATH.'libraries/'.ucfirst($class).'.php'; - - if ( ! file_exists($baseclass)) - { - log_message('error', 'Unable to load the requested class: '.$class); - show_error('Unable to load the requested class: '.$class); - } + log_message('error', 'Unable to load the requested class: '.$class); + show_error('Unable to load the requested class: '.$class); + } - // Safety: Was the class already loaded by a previous call? - if (in_array($subclass, $this->_ci_loaded_files)) + // Safety: Was the class already loaded by a previous call? + if (class_exists(config_item('subclass_prefix').$class, FALSE)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ($object_name !== NULL) { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); - } + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } - - $is_duplicate = TRUE; - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; } - include_once($baseclass); - include_once($subclass); - $this->_ci_loaded_files[] = $subclass; - - return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; } - // Lets search for the requested library file and load it. - $is_duplicate = FALSE; - foreach ($this->_ci_library_paths as $path) - { - $filepath = $path.'libraries/'.$subdir.$class.'.php'; + include_once($baseclass); + include_once($subclass); - // Does the file exist? No? Bummer... - if ( ! file_exists($filepath)) - { - continue; - } + return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); + } + + // Lets search for the requested library file and load it. + foreach ($this->_ci_library_paths as $path) + { + $filepath = $path.'libraries/'.$subdir.$class.'.php'; - // Safety: Was the class already loaded by a previous call? - if (in_array($filepath, $this->_ci_loaded_files)) + // Safety: Was the class already loaded by a previous call? + if (class_exists($class, FALSE)) + { + // Before we deem this to be a duplicate request, let's see + // if a custom object name is being supplied. If so, we'll + // return a new instance of the object + if ($object_name !== NULL) { - // Before we deem this to be a duplicate request, let's see - // if a custom object name is being supplied. If so, we'll - // return a new instance of the object - if ($object_name !== NULL) + $CI =& get_instance(); + if ( ! isset($CI->$object_name)) { - $CI =& get_instance(); - if ( ! isset($CI->$object_name)) - { - return $this->_ci_init_class($class, '', $params, $object_name); - } + return $this->_ci_init_class($class, '', $params, $object_name); } - - $is_duplicate = TRUE; - log_message('debug', $class.' class already loaded. Second attempt ignored.'); - return; } - include_once($filepath); - $this->_ci_loaded_files[] = $filepath; - return $this->_ci_init_class($class, '', $params, $object_name); + log_message('debug', $class.' class already loaded. Second attempt ignored.'); + return; + } + // Does the file exist? No? Bummer... + elseif ( ! file_exists($filepath)) + { + continue; } - } // END FOREACH + + include_once($filepath); + return $this->_ci_init_class($class, '', $params, $object_name); + } // One last attempt. Maybe the library is in a subdirectory, but it wasn't specified? if ($subdir === '') { - $path = strtolower($class).'/'.$class; - return $this->_ci_load_class($path, $params, $object_name); - } - elseif (ucfirst($subdir) != $subdir) - { - // Lowercase subdir failed - retry capitalized - $path = ucfirst($subdir).$class; - return $this->_ci_load_class($path, $params, $object_name); + return $this->_ci_load_class($class.'/'.$class, $params, $object_name); } // If we got this far we were unable to find the requested class. - // We do not issue errors if the load call failed due to a duplicate request - if ($is_duplicate === FALSE) - { - log_message('error', 'Unable to load the requested class: '.$class); - show_error('Unable to load the requested class: '.$class); - } + log_message('error', 'Unable to load the requested class: '.$class); + show_error('Unable to load the requested class: '.$class); } // -------------------------------------------------------------------- diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php index 7f1d85511..773a58384 100644 --- a/system/libraries/Javascript.php +++ b/system/libraries/Javascript.php @@ -69,7 +69,7 @@ class CI_Javascript { $this->CI =& get_instance(); // load the requested js library - $this->CI->load->library('javascript/'.$js_library_driver, array('autoload' => $autoload)); + $this->CI->load->library('Javascript/'.$js_library_driver, array('autoload' => $autoload)); // make js to refer to current library $this->js =& $this->CI->$js_library_driver; diff --git a/system/libraries/Javascript/Jquery.php b/system/libraries/Javascript/Jquery.php new file mode 100644 index 000000000..b6e0434b2 --- /dev/null +++ b/system/libraries/Javascript/Jquery.php @@ -0,0 +1,1069 @@ +CI =& get_instance(); + extract($params); + + if ($autoload === TRUE) + { + $this->script(); + } + + log_message('debug', 'Jquery Class Initialized'); + } + + // -------------------------------------------------------------------- + // Event Code + // -------------------------------------------------------------------- + + /** + * Blur + * + * Outputs a jQuery blur event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _blur($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'blur'); + } + + // -------------------------------------------------------------------- + + /** + * Change + * + * Outputs a jQuery change event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _change($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'change'); + } + + // -------------------------------------------------------------------- + + /** + * Click + * + * Outputs a jQuery click event + * + * @param string The element to attach the event to + * @param string The code to execute + * @param bool whether or not to return false + * @return string + */ + protected function _click($element = 'this', $js = '', $ret_false = TRUE) + { + is_array($js) OR $js = array($js); + + if ($ret_false) + { + $js[] = 'return false;'; + } + + return $this->_add_event($element, $js, 'click'); + } + + // -------------------------------------------------------------------- + + /** + * Double Click + * + * Outputs a jQuery dblclick event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _dblclick($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'dblclick'); + } + + // -------------------------------------------------------------------- + + /** + * Error + * + * Outputs a jQuery error event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _error($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'error'); + } + + // -------------------------------------------------------------------- + + /** + * Focus + * + * Outputs a jQuery focus event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _focus($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'focus'); + } + + // -------------------------------------------------------------------- + + /** + * Hover + * + * Outputs a jQuery hover event + * + * @param string - element + * @param string - Javascript code for mouse over + * @param string - Javascript code for mouse out + * @return string + */ + 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"; + + $this->jquery_code_for_compile[] = $event; + + return $event; + } + + // -------------------------------------------------------------------- + + /** + * Keydown + * + * Outputs a jQuery keydown event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _keydown($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'keydown'); + } + + // -------------------------------------------------------------------- + + /** + * Keyup + * + * Outputs a jQuery keydown event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _keyup($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'keyup'); + } + + // -------------------------------------------------------------------- + + /** + * Load + * + * Outputs a jQuery load event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _load($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'load'); + } + + // -------------------------------------------------------------------- + + /** + * Mousedown + * + * Outputs a jQuery mousedown event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _mousedown($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mousedown'); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Out + * + * Outputs a jQuery mouseout event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _mouseout($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseout'); + } + + // -------------------------------------------------------------------- + + /** + * Mouse Over + * + * Outputs a jQuery mouseover event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _mouseover($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseover'); + } + + // -------------------------------------------------------------------- + + /** + * Mouseup + * + * Outputs a jQuery mouseup event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _mouseup($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'mouseup'); + } + + // -------------------------------------------------------------------- + + /** + * Output + * + * Outputs script directly + * + * @param array $array_js = array() + * @return void + */ + protected function _output($array_js = array()) + { + if ( ! is_array($array_js)) + { + $array_js = array($array_js); + } + + foreach ($array_js as $js) + { + $this->jquery_code_for_compile[] = "\t".$js."\n"; + } + } + + // -------------------------------------------------------------------- + + /** + * Resize + * + * Outputs a jQuery resize event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _resize($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'resize'); + } + + // -------------------------------------------------------------------- + + /** + * Scroll + * + * Outputs a jQuery scroll event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _scroll($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'scroll'); + } + + // -------------------------------------------------------------------- + + /** + * Unload + * + * Outputs a jQuery unload event + * + * @param string The element to attach the event to + * @param string The code to execute + * @return string + */ + protected function _unload($element = 'this', $js = '') + { + return $this->_add_event($element, $js, 'unload'); + } + + // -------------------------------------------------------------------- + // Effects + // -------------------------------------------------------------------- + + /** + * Add Class + * + * Outputs a jQuery addClass event + * + * @param string $element + * @param string $class + * @return string + */ + protected function _addClass($element = 'this', $class = '') + { + $element = $this->_prep_element($element); + return '$('.$element.').addClass("'.$class.'");'; + } + + // -------------------------------------------------------------------- + + /** + * Animate + * + * Outputs a jQuery animate event + * + * @param string $element + * @param array $params + * @param string $speed 'slow', 'normal', 'fast', or time in milliseconds + * @param string $extra + * @return string + */ + 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."', "; + } + + $animations = substr($animations, 0, -2); // remove the last ", " + + if ($speed !== '') + { + $speed = ', '.$speed; + } + + if ($extra !== '') + { + $extra = ', '.$extra; + } + + return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');'; + } + + // -------------------------------------------------------------------- + + /** + * Fade In + * + * Outputs a jQuery hide event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _fadeIn($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return "$({$element}).fadeIn({$speed}{$callback});"; + } + + // -------------------------------------------------------------------- + + /** + * Fade Out + * + * Outputs a jQuery hide event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _fadeOut($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return '$('.$element.').fadeOut('.$speed.$callback.');'; + } + + // -------------------------------------------------------------------- + + /** + * Hide + * + * Outputs a jQuery hide action + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _hide($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return "$({$element}).hide({$speed}{$callback});"; + } + + // -------------------------------------------------------------------- + + /** + * Remove Class + * + * Outputs a jQuery remove class event + * + * @param string $element + * @param string $class + * @return string + */ + protected function _removeClass($element = 'this', $class = '') + { + $element = $this->_prep_element($element); + return '$('.$element.').removeClass("'.$class.'");'; + } + + // -------------------------------------------------------------------- + + /** + * Slide Up + * + * Outputs a jQuery slideUp event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _slideUp($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return '$('.$element.').slideUp('.$speed.$callback.');'; + } + + // -------------------------------------------------------------------- + + /** + * Slide Down + * + * Outputs a jQuery slideDown event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _slideDown($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return '$('.$element.').slideDown('.$speed.$callback.');'; + } + + // -------------------------------------------------------------------- + + /** + * Slide Toggle + * + * Outputs a jQuery slideToggle event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _slideToggle($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return '$('.$element.').slideToggle('.$speed.$callback.');'; + } + + // -------------------------------------------------------------------- + + /** + * Toggle + * + * Outputs a jQuery toggle event + * + * @param string - element + * @return string + */ + protected function _toggle($element = 'this') + { + $element = $this->_prep_element($element); + return '$('.$element.').toggle();'; + } + + // -------------------------------------------------------------------- + + /** + * Toggle Class + * + * Outputs a jQuery toggle class event + * + * @param string $element + * @param string $class + * @return string + */ + protected function _toggleClass($element = 'this', $class = '') + { + $element = $this->_prep_element($element); + return '$('.$element.').toggleClass("'.$class.'");'; + } + + // -------------------------------------------------------------------- + + /** + * Show + * + * Outputs a jQuery show event + * + * @param string - element + * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds + * @param string - Javascript callback function + * @return string + */ + protected function _show($element = 'this', $speed = '', $callback = '') + { + $element = $this->_prep_element($element); + $speed = $this->_validate_speed($speed); + + if ($callback !== '') + { + $callback = ", function(){\n{$callback}\n}"; + } + + return '$('.$element.').show('.$speed.$callback.');'; + } + + // -------------------------------------------------------------------- + + /** + * Updater + * + * An Ajax call that populates the designated DOM node with + * returned content + * + * @param string The element to attach the event to + * @param string the controller to run the call against + * @param string optional parameters + * @return string + */ + + 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') === '') + { + $loading_notifier = 'Loading...'; + } + else + { + $loading_notifier = 'Loading'; + } + + $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 .= ', {' + .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") + .'}'; + } + + return $updater."\t\t$($container).load('$controller'$request_options);"; + } + + // -------------------------------------------------------------------- + // Pre-written handy stuff + // -------------------------------------------------------------------- + + /** + * Zebra tables + * + * @param string $class + * @param string $odd + * @param string $hover + * @return string + */ + 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; + + if ($hover !== '') + { + $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');"); + } + + return $zebra; + } + + // -------------------------------------------------------------------- + // Plugins + // -------------------------------------------------------------------- + + /** + * Corner Plugin + * + * @link http://www.malsup.com/jquery/corner/ + * @param string $element + * @param string $corner_style + * @return string + */ + public function corner($element = '', $corner_style = '') + { + // may want to make this configurable down the road + $corner_location = '/plugins/jquery.corner.js'; + + if ($corner_style !== '') + { + $corner_style = '"'.$corner_style.'"'; + } + + return '$('.$this->_prep_element($element).').corner('.$corner_style.');'; + } + + // -------------------------------------------------------------------- + + /** + * Modal window + * + * Load a thickbox modal window + * + * @param string $src + * @param bool $relative + * @return void + */ + public function modal($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * Effect + * + * Load an Effect library + * + * @param string $src + * @param bool $relative + * @return void + */ + public function effect($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * Plugin + * + * Load a plugin library + * + * @param string $src + * @param bool $relative + * @return void + */ + public function plugin($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * UI + * + * Load a user interface library + * + * @param string $src + * @param bool $relative + * @return void + */ + public function ui($src, $relative = FALSE) + { + $this->jquery_code_for_load[] = $this->external($src, $relative); + } + + // -------------------------------------------------------------------- + + /** + * Sortable + * + * Creates a jQuery sortable + * + * @param string $element + * @param array $options + * @return string + */ + public function sortable($element, $options = array()) + { + if (count($options) > 0) + { + $sort_options = array(); + foreach ($options as $k=>$v) + { + $sort_options[] = "\n\t\t".$k.': '.$v; + } + $sort_options = implode(',', $sort_options); + } + else + { + $sort_options = ''; + } + + return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});"; + } + + // -------------------------------------------------------------------- + + /** + * Table Sorter Plugin + * + * @param string table name + * @param string plugin location + * @return string + */ + public function tablesorter($table = '', $options = '') + { + $this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n"; + } + + // -------------------------------------------------------------------- + // Class functions + // -------------------------------------------------------------------- + + /** + * Add Event + * + * Constructs the syntax for an event, and adds to into the array for compilation + * + * @param string The element to attach the event to + * @param string The code to execute + * @param string The event to pass + * @return string + */ + protected function _add_event($element, $js, $event) + { + if (is_array($js)) + { + $js = implode("\n\t\t", $js); + + } + + $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; + $this->jquery_code_for_compile[] = $event; + return $event; + } + + // -------------------------------------------------------------------- + + /** + * Compile + * + * As events are specified, they are stored in an array + * This funciton compiles them all for output on a page + * + * @param string $view_var + * @param bool $script_tags + * @return void + */ + 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) + { + // no inline references, let's just return + return; + } + + // Inline references + $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 + * + * @return void + */ + protected function _clear_compile() + { + $this->jquery_code_for_compile = array(); + } + + // -------------------------------------------------------------------- + + /** + * Document Ready + * + * A wrapper for writing document.ready() + * + * @param array $js + * @return void + */ + protected function _document_ready($js) + { + is_array($js) OR $js = array($js); + + foreach ($js as $script) + { + $this->jquery_code_for_compile[] = $script; + } + } + + // -------------------------------------------------------------------- + + /** + * Script Tag + * + * Outputs the script tag that loads the jquery.js file into an HTML document + * + * @param string $library_src + * @param bool $relative + * @return string + */ + public function script($library_src = '', $relative = FALSE) + { + $library_src = $this->external($library_src, $relative); + $this->jquery_code_for_load[] = $library_src; + return $library_src; + } + + // -------------------------------------------------------------------- + + /** + * Prep Element + * + * Puts HTML element in quotes for use in jQuery code + * unless the supplied element is the Javascript 'this' + * object, in which case no quotes are added + * + * @param string + * @return string + */ + protected function _prep_element($element) + { + if ($element !== 'this') + { + $element = '"'.$element.'"'; + } + + return $element; + } + + // -------------------------------------------------------------------- + + /** + * Validate Speed + * + * Ensures the speed parameter is valid for jQuery + * + * @param string + * @return string + */ + protected function _validate_speed($speed) + { + if (in_array($speed, array('slow', 'normal', 'fast'))) + { + return '"'.$speed.'"'; + } + elseif (preg_match('/[^0-9]/', $speed)) + { + return ''; + } + + return $speed; + } + +} + +/* End of file Jquery.php */ +/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file diff --git a/system/libraries/Javascript/index.html b/system/libraries/Javascript/index.html new file mode 100644 index 000000000..c942a79ce --- /dev/null +++ b/system/libraries/Javascript/index.html @@ -0,0 +1,10 @@ + + + 403 Forbidden + + + +

Directory access is forbidden.

+ + + \ No newline at end of file diff --git a/system/libraries/javascript/Jquery.php b/system/libraries/javascript/Jquery.php deleted file mode 100644 index b6e0434b2..000000000 --- a/system/libraries/javascript/Jquery.php +++ /dev/null @@ -1,1069 +0,0 @@ -CI =& get_instance(); - extract($params); - - if ($autoload === TRUE) - { - $this->script(); - } - - log_message('debug', 'Jquery Class Initialized'); - } - - // -------------------------------------------------------------------- - // Event Code - // -------------------------------------------------------------------- - - /** - * Blur - * - * Outputs a jQuery blur event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _blur($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'blur'); - } - - // -------------------------------------------------------------------- - - /** - * Change - * - * Outputs a jQuery change event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _change($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'change'); - } - - // -------------------------------------------------------------------- - - /** - * Click - * - * Outputs a jQuery click event - * - * @param string The element to attach the event to - * @param string The code to execute - * @param bool whether or not to return false - * @return string - */ - protected function _click($element = 'this', $js = '', $ret_false = TRUE) - { - is_array($js) OR $js = array($js); - - if ($ret_false) - { - $js[] = 'return false;'; - } - - return $this->_add_event($element, $js, 'click'); - } - - // -------------------------------------------------------------------- - - /** - * Double Click - * - * Outputs a jQuery dblclick event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _dblclick($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'dblclick'); - } - - // -------------------------------------------------------------------- - - /** - * Error - * - * Outputs a jQuery error event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _error($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'error'); - } - - // -------------------------------------------------------------------- - - /** - * Focus - * - * Outputs a jQuery focus event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _focus($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'focus'); - } - - // -------------------------------------------------------------------- - - /** - * Hover - * - * Outputs a jQuery hover event - * - * @param string - element - * @param string - Javascript code for mouse over - * @param string - Javascript code for mouse out - * @return string - */ - 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"; - - $this->jquery_code_for_compile[] = $event; - - return $event; - } - - // -------------------------------------------------------------------- - - /** - * Keydown - * - * Outputs a jQuery keydown event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _keydown($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'keydown'); - } - - // -------------------------------------------------------------------- - - /** - * Keyup - * - * Outputs a jQuery keydown event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _keyup($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'keyup'); - } - - // -------------------------------------------------------------------- - - /** - * Load - * - * Outputs a jQuery load event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _load($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'load'); - } - - // -------------------------------------------------------------------- - - /** - * Mousedown - * - * Outputs a jQuery mousedown event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _mousedown($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'mousedown'); - } - - // -------------------------------------------------------------------- - - /** - * Mouse Out - * - * Outputs a jQuery mouseout event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _mouseout($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'mouseout'); - } - - // -------------------------------------------------------------------- - - /** - * Mouse Over - * - * Outputs a jQuery mouseover event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _mouseover($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'mouseover'); - } - - // -------------------------------------------------------------------- - - /** - * Mouseup - * - * Outputs a jQuery mouseup event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _mouseup($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'mouseup'); - } - - // -------------------------------------------------------------------- - - /** - * Output - * - * Outputs script directly - * - * @param array $array_js = array() - * @return void - */ - protected function _output($array_js = array()) - { - if ( ! is_array($array_js)) - { - $array_js = array($array_js); - } - - foreach ($array_js as $js) - { - $this->jquery_code_for_compile[] = "\t".$js."\n"; - } - } - - // -------------------------------------------------------------------- - - /** - * Resize - * - * Outputs a jQuery resize event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _resize($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'resize'); - } - - // -------------------------------------------------------------------- - - /** - * Scroll - * - * Outputs a jQuery scroll event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _scroll($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'scroll'); - } - - // -------------------------------------------------------------------- - - /** - * Unload - * - * Outputs a jQuery unload event - * - * @param string The element to attach the event to - * @param string The code to execute - * @return string - */ - protected function _unload($element = 'this', $js = '') - { - return $this->_add_event($element, $js, 'unload'); - } - - // -------------------------------------------------------------------- - // Effects - // -------------------------------------------------------------------- - - /** - * Add Class - * - * Outputs a jQuery addClass event - * - * @param string $element - * @param string $class - * @return string - */ - protected function _addClass($element = 'this', $class = '') - { - $element = $this->_prep_element($element); - return '$('.$element.').addClass("'.$class.'");'; - } - - // -------------------------------------------------------------------- - - /** - * Animate - * - * Outputs a jQuery animate event - * - * @param string $element - * @param array $params - * @param string $speed 'slow', 'normal', 'fast', or time in milliseconds - * @param string $extra - * @return string - */ - 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."', "; - } - - $animations = substr($animations, 0, -2); // remove the last ", " - - if ($speed !== '') - { - $speed = ', '.$speed; - } - - if ($extra !== '') - { - $extra = ', '.$extra; - } - - return "$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.');'; - } - - // -------------------------------------------------------------------- - - /** - * Fade In - * - * Outputs a jQuery hide event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _fadeIn($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return "$({$element}).fadeIn({$speed}{$callback});"; - } - - // -------------------------------------------------------------------- - - /** - * Fade Out - * - * Outputs a jQuery hide event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _fadeOut($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return '$('.$element.').fadeOut('.$speed.$callback.');'; - } - - // -------------------------------------------------------------------- - - /** - * Hide - * - * Outputs a jQuery hide action - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _hide($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return "$({$element}).hide({$speed}{$callback});"; - } - - // -------------------------------------------------------------------- - - /** - * Remove Class - * - * Outputs a jQuery remove class event - * - * @param string $element - * @param string $class - * @return string - */ - protected function _removeClass($element = 'this', $class = '') - { - $element = $this->_prep_element($element); - return '$('.$element.').removeClass("'.$class.'");'; - } - - // -------------------------------------------------------------------- - - /** - * Slide Up - * - * Outputs a jQuery slideUp event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _slideUp($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return '$('.$element.').slideUp('.$speed.$callback.');'; - } - - // -------------------------------------------------------------------- - - /** - * Slide Down - * - * Outputs a jQuery slideDown event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _slideDown($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return '$('.$element.').slideDown('.$speed.$callback.');'; - } - - // -------------------------------------------------------------------- - - /** - * Slide Toggle - * - * Outputs a jQuery slideToggle event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _slideToggle($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return '$('.$element.').slideToggle('.$speed.$callback.');'; - } - - // -------------------------------------------------------------------- - - /** - * Toggle - * - * Outputs a jQuery toggle event - * - * @param string - element - * @return string - */ - protected function _toggle($element = 'this') - { - $element = $this->_prep_element($element); - return '$('.$element.').toggle();'; - } - - // -------------------------------------------------------------------- - - /** - * Toggle Class - * - * Outputs a jQuery toggle class event - * - * @param string $element - * @param string $class - * @return string - */ - protected function _toggleClass($element = 'this', $class = '') - { - $element = $this->_prep_element($element); - return '$('.$element.').toggleClass("'.$class.'");'; - } - - // -------------------------------------------------------------------- - - /** - * Show - * - * Outputs a jQuery show event - * - * @param string - element - * @param string - One of 'slow', 'normal', 'fast', or time in milliseconds - * @param string - Javascript callback function - * @return string - */ - protected function _show($element = 'this', $speed = '', $callback = '') - { - $element = $this->_prep_element($element); - $speed = $this->_validate_speed($speed); - - if ($callback !== '') - { - $callback = ", function(){\n{$callback}\n}"; - } - - return '$('.$element.').show('.$speed.$callback.');'; - } - - // -------------------------------------------------------------------- - - /** - * Updater - * - * An Ajax call that populates the designated DOM node with - * returned content - * - * @param string The element to attach the event to - * @param string the controller to run the call against - * @param string optional parameters - * @return string - */ - - 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') === '') - { - $loading_notifier = 'Loading...'; - } - else - { - $loading_notifier = 'Loading'; - } - - $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 .= ', {' - .(is_array($options) ? "'".implode("', '", $options)."'" : "'".str_replace(':', "':'", $options)."'") - .'}'; - } - - return $updater."\t\t$($container).load('$controller'$request_options);"; - } - - // -------------------------------------------------------------------- - // Pre-written handy stuff - // -------------------------------------------------------------------- - - /** - * Zebra tables - * - * @param string $class - * @param string $odd - * @param string $hover - * @return string - */ - 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; - - if ($hover !== '') - { - $hover = $this->hover("table{$class} tbody tr", "$(this).addClass('hover');", "$(this).removeClass('hover');"); - } - - return $zebra; - } - - // -------------------------------------------------------------------- - // Plugins - // -------------------------------------------------------------------- - - /** - * Corner Plugin - * - * @link http://www.malsup.com/jquery/corner/ - * @param string $element - * @param string $corner_style - * @return string - */ - public function corner($element = '', $corner_style = '') - { - // may want to make this configurable down the road - $corner_location = '/plugins/jquery.corner.js'; - - if ($corner_style !== '') - { - $corner_style = '"'.$corner_style.'"'; - } - - return '$('.$this->_prep_element($element).').corner('.$corner_style.');'; - } - - // -------------------------------------------------------------------- - - /** - * Modal window - * - * Load a thickbox modal window - * - * @param string $src - * @param bool $relative - * @return void - */ - public function modal($src, $relative = FALSE) - { - $this->jquery_code_for_load[] = $this->external($src, $relative); - } - - // -------------------------------------------------------------------- - - /** - * Effect - * - * Load an Effect library - * - * @param string $src - * @param bool $relative - * @return void - */ - public function effect($src, $relative = FALSE) - { - $this->jquery_code_for_load[] = $this->external($src, $relative); - } - - // -------------------------------------------------------------------- - - /** - * Plugin - * - * Load a plugin library - * - * @param string $src - * @param bool $relative - * @return void - */ - public function plugin($src, $relative = FALSE) - { - $this->jquery_code_for_load[] = $this->external($src, $relative); - } - - // -------------------------------------------------------------------- - - /** - * UI - * - * Load a user interface library - * - * @param string $src - * @param bool $relative - * @return void - */ - public function ui($src, $relative = FALSE) - { - $this->jquery_code_for_load[] = $this->external($src, $relative); - } - - // -------------------------------------------------------------------- - - /** - * Sortable - * - * Creates a jQuery sortable - * - * @param string $element - * @param array $options - * @return string - */ - public function sortable($element, $options = array()) - { - if (count($options) > 0) - { - $sort_options = array(); - foreach ($options as $k=>$v) - { - $sort_options[] = "\n\t\t".$k.': '.$v; - } - $sort_options = implode(',', $sort_options); - } - else - { - $sort_options = ''; - } - - return '$('.$this->_prep_element($element).').sortable({'.$sort_options."\n\t});"; - } - - // -------------------------------------------------------------------- - - /** - * Table Sorter Plugin - * - * @param string table name - * @param string plugin location - * @return string - */ - public function tablesorter($table = '', $options = '') - { - $this->jquery_code_for_compile[] = "\t$(".$this->_prep_element($table).').tablesorter('.$options.");\n"; - } - - // -------------------------------------------------------------------- - // Class functions - // -------------------------------------------------------------------- - - /** - * Add Event - * - * Constructs the syntax for an event, and adds to into the array for compilation - * - * @param string The element to attach the event to - * @param string The code to execute - * @param string The event to pass - * @return string - */ - protected function _add_event($element, $js, $event) - { - if (is_array($js)) - { - $js = implode("\n\t\t", $js); - - } - - $event = "\n\t$(".$this->_prep_element($element).').'.$event."(function(){\n\t\t{$js}\n\t});\n"; - $this->jquery_code_for_compile[] = $event; - return $event; - } - - // -------------------------------------------------------------------- - - /** - * Compile - * - * As events are specified, they are stored in an array - * This funciton compiles them all for output on a page - * - * @param string $view_var - * @param bool $script_tags - * @return void - */ - 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) - { - // no inline references, let's just return - return; - } - - // Inline references - $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 - * - * @return void - */ - protected function _clear_compile() - { - $this->jquery_code_for_compile = array(); - } - - // -------------------------------------------------------------------- - - /** - * Document Ready - * - * A wrapper for writing document.ready() - * - * @param array $js - * @return void - */ - protected function _document_ready($js) - { - is_array($js) OR $js = array($js); - - foreach ($js as $script) - { - $this->jquery_code_for_compile[] = $script; - } - } - - // -------------------------------------------------------------------- - - /** - * Script Tag - * - * Outputs the script tag that loads the jquery.js file into an HTML document - * - * @param string $library_src - * @param bool $relative - * @return string - */ - public function script($library_src = '', $relative = FALSE) - { - $library_src = $this->external($library_src, $relative); - $this->jquery_code_for_load[] = $library_src; - return $library_src; - } - - // -------------------------------------------------------------------- - - /** - * Prep Element - * - * Puts HTML element in quotes for use in jQuery code - * unless the supplied element is the Javascript 'this' - * object, in which case no quotes are added - * - * @param string - * @return string - */ - protected function _prep_element($element) - { - if ($element !== 'this') - { - $element = '"'.$element.'"'; - } - - return $element; - } - - // -------------------------------------------------------------------- - - /** - * Validate Speed - * - * Ensures the speed parameter is valid for jQuery - * - * @param string - * @return string - */ - protected function _validate_speed($speed) - { - if (in_array($speed, array('slow', 'normal', 'fast'))) - { - return '"'.$speed.'"'; - } - elseif (preg_match('/[^0-9]/', $speed)) - { - return ''; - } - - return $speed; - } - -} - -/* End of file Jquery.php */ -/* Location: ./system/libraries/Jquery.php */ \ No newline at end of file diff --git a/system/libraries/javascript/index.html b/system/libraries/javascript/index.html deleted file mode 100644 index c942a79ce..000000000 --- a/system/libraries/javascript/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - 403 Forbidden - - - -

Directory access is forbidden.

- - - \ No newline at end of file diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 94f6321be..2d125a71a 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -104,16 +104,40 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' +******************************************* +Step 9: Update your librararies' file names +******************************************* + +CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner +(meaning that the first letter of the class name must be a capital). For example, +if you have the following library file: + + application/libraries/mylibrary.php + +... then you'll have to rename it to: + + application/libraries/Mylibrary.php + +The same goes for driver libraries and extensions and/or overrides of CodeIgniter's +own libraries and core classes. + + application/libraries/MY_email.php + application/core/MY_log.php + +The above files should respectively be renamed to the following: + + application/libraries/MY_Email.php + application/core/MY_Log.php **************************************************************************** -Step 9: Check the calls to Array Helper's element() and elements() functions +Step 10: Check the calls to Array Helper's element() and elements() functions **************************************************************************** The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. ************************************************************* -Step 10: Update usage of Database Forge's drop_table() method +Step 11: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -135,7 +159,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 11: Change usage of Email library with multiple emails +Step 12: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -150,7 +174,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 12: Update your Form_validation language lines +Step 13: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -181,7 +205,7 @@ files and error messages format: later. **************************************************************** -Step 13: Remove usage of (previously) deprecated functionalities +Step 14: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a -- cgit v1.2.3-24-g4f1b From bc92262992b606847eb1e764a0ab1cdef0aa12e3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 16:47:41 +0200 Subject: Update unit tests with the ucfirst-library-filename requirement --- tests/codeigniter/core/Loader_test.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/codeigniter/core/Loader_test.php b/tests/codeigniter/core/Loader_test.php index ecc5ca933..dea01a555 100644 --- a/tests/codeigniter/core/Loader_test.php +++ b/tests/codeigniter/core/Loader_test.php @@ -25,7 +25,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'unit_test_lib'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), 'ci_base_root, 'libraries'); // Test is_loaded fail $this->assertFalse($this->load->is_loaded($lib)); @@ -48,7 +48,7 @@ class Loader_test extends CI_TestCase { // Test non-existent class $this->setExpectedException( 'RuntimeException', - 'CI Error: Non-existent class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->assertNull($this->load->library($lib)); } @@ -105,7 +105,7 @@ class Loader_test extends CI_TestCase { $lib = 'unit_test_config_lib'; $class = 'CI_'.ucfirst($lib); $content = 'config = $params; } }'; - $this->ci_vfs_create($lib, $content, $this->ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), $content, $this->ci_base_root, 'libraries'); // Create config file $cfg = array( @@ -133,7 +133,7 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'super_test_library'; $class = ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_app_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), 'ci_app_root, 'libraries'); // Load library $this->assertNull($this->load->library($lib)); @@ -152,7 +152,7 @@ class Loader_test extends CI_TestCase { $dir = ucfirst($driver); $class = 'CI_'.$dir; $content = 'ci_vfs_create($driver, $content, $this->ci_base_root, 'libraries/'.$dir); + $this->ci_vfs_create(ucfirst($driver), $content, $this->ci_base_root, 'libraries/'.$dir); // Test loading as an array. $this->assertNull($this->load->driver(array($driver))); @@ -410,7 +410,7 @@ class Loader_test extends CI_TestCase { $dir = 'third-party'; $lib = 'unit_test_package'; $class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_app_root, array($dir, 'libraries')); + $this->ci_vfs_create(ucfirst($lib), 'ci_app_root, array($dir, 'libraries')); // Get paths $paths = $this->load->get_package_paths(TRUE); @@ -440,7 +440,7 @@ class Loader_test extends CI_TestCase { // Test failed load without path $this->setExpectedException( 'RuntimeException', - 'CI Error: Unable to load the requested class: '.$lib + 'CI Error: Unable to load the requested class: '.ucfirst($lib) ); $this->load->library($lib); } @@ -467,13 +467,13 @@ class Loader_test extends CI_TestCase { // Create library in VFS $lib = 'autolib'; $lib_class = 'CI_'.ucfirst($lib); - $this->ci_vfs_create($lib, 'ci_base_root, 'libraries'); + $this->ci_vfs_create(ucfirst($lib), 'ci_base_root, 'libraries'); // Create driver in VFS $drv = 'autodrv'; $subdir = ucfirst($drv); $drv_class = 'CI_'.$subdir; - $this->ci_vfs_create($drv, 'ci_base_root, array('libraries', $subdir)); + $this->ci_vfs_create(ucfirst($drv), 'ci_base_root, array('libraries', $subdir)); // Create model in VFS package path $dir = 'testdir'; -- cgit v1.2.3-24-g4f1b From 55bbd7207d5276a7546e60f28c4c31325bab2b5e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 19:02:13 +0200 Subject: Fix issue #2179 --- system/database/DB_query_builder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index ac377d996..c7bc4a699 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -937,7 +937,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->qb_where[] = array('condition' => $like_statement, 'escape' => $escape); if ($this->qb_caching === TRUE) { - $this->qb_cache_where[] = $like_statement; + $this->qb_cache_where[] = array('condition' => $like_statement, 'escape' => $escape); $this->qb_cache_exists[] = 'where'; } } -- cgit v1.2.3-24-g4f1b From 662e34291a2d5d8997ea9835701fb9a8a7ec244c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 21:19:13 +0200 Subject: Some micro-optimization to the Driver library loader --- system/libraries/Driver.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php index 4b35dce73..382420db0 100644 --- a/system/libraries/Driver.php +++ b/system/libraries/Driver.php @@ -80,8 +80,7 @@ class CI_Driver_Library { public function load_driver($child) { // Get CodeIgniter instance and subclass prefix - $CI = get_instance(); - $prefix = (string) $CI->config->item('subclass_prefix'); + $prefix = config_item('subclass_prefix'); if ( ! isset($this->lib_name)) { @@ -102,11 +101,12 @@ class CI_Driver_Library { } // Get package paths and filename case variations to search + $CI = get_instance(); $paths = $CI->load->get_package_paths(TRUE); // Is there an extension? $class_name = $prefix.$child_name; - $found = class_exists($class_name); + $found = class_exists($class_name, FALSE); if ( ! $found) { // Check for subclass file @@ -126,8 +126,8 @@ class CI_Driver_Library { } // Include both sources and mark found - include($basepath); - include($file); + include_once($basepath); + include_once($file); $found = TRUE; break; } @@ -139,8 +139,7 @@ class CI_Driver_Library { { // Use standard class name $class_name = 'CI_'.$child_name; - $found = class_exists($class_name); - if ( ! $found) + if ( ! class_exists($class_name, FALSE)) { // Check package paths foreach ($paths as $path) @@ -150,7 +149,7 @@ class CI_Driver_Library { if (file_exists($file)) { // Include source - include($file); + include_once($file); break; } } @@ -158,9 +157,9 @@ class CI_Driver_Library { } // Did we finally find the class? - if ( ! class_exists($class_name)) + if ( ! class_exists($class_name, FALSE)) { - if (class_exists($child_name)) + if (class_exists($child_name, FALSE)) { $class_name = $child_name; } -- cgit v1.2.3-24-g4f1b From c26d34ff12458760eb843454d3224e1dad1fb2e0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 28 Jan 2013 21:46:08 +0200 Subject: Fix issue #2202 and alter Loader Class docs --- system/core/Loader.php | 2 +- user_guide_src/source/libraries/loader.rst | 146 ++++++++++++++--------------- 2 files changed, 73 insertions(+), 75 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 3ecce1676..00ca35199 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -939,7 +939,7 @@ class CI_Loader { if (($last_slash = strrpos($class, '/')) !== FALSE) { // Extract the path - $subdir = ucfirst(substr($class, 0, ++$last_slash)); + $subdir = substr($class, 0, ++$last_slash); // Get the filename from the path $class = substr($class, $last_slash); diff --git a/user_guide_src/source/libraries/loader.rst b/user_guide_src/source/libraries/loader.rst index 615aba1c2..b048f4881 100644 --- a/user_guide_src/source/libraries/loader.rst +++ b/user_guide_src/source/libraries/loader.rst @@ -11,14 +11,15 @@ can be libraries (classes) :doc:`View files <../general/views>`, .. note:: This class is initialized automatically by the system so there is no need to do it manually. -The following functions are available in this class: +The following methods are available in this class: $this->load->library('class_name', $config, 'object name') -=========================================================== +========================================================== -This function is used to load core classes. Where class_name is the -name of the class you want to load. Note: We use the terms "class" and -"library" interchangeably. +This method is used to load core classes. Where class_name is the +name of the class you want to load. + +.. note:: We use the terms "class" and "library" interchangeably. For example, if you would like to send email with CodeIgniter, the first step is to load the email class within your controller:: @@ -26,15 +27,15 @@ step is to load the email class within your controller:: $this->load->library('email'); Once loaded, the library will be ready for use, using -$this->email->*some_function*(). +$this->email->*some_method*(). Library files can be stored in subdirectories within the main -"libraries" folder, or within your personal application/libraries -folder. To load a file located in a subdirectory, simply include the -path, relative to the "libraries" folder. For example, if you have file -located at:: +"libraries" directory, or within your personal application/libraries +directory. To load a file located in a subdirectory, simply include the +path, relative to the "libraries" directory. For example, if you have +file located at:: - libraries/flavors/chocolate.php + libraries/flavors/Chocolate.php You will load it using:: @@ -43,7 +44,7 @@ You will load it using:: You may nest the file in as many subdirectories as you want. Additionally, multiple libraries can be loaded at the same time by -passing an array of libraries to the load function. +passing an array of libraries to the load method. :: @@ -56,10 +57,10 @@ The second (optional) parameter allows you to optionally pass configuration setting. You will typically pass these as an array:: $config = array ( - 'mailtype' => 'html', - 'charset' => 'utf-8, - 'priority' => '1' - ); + 'mailtype' => 'html', + 'charset' => 'utf-8, + 'priority' => '1' + ); $this->load->library('email', $config); @@ -84,16 +85,15 @@ third parameter:: $this->load->library('calendar', '', 'my_calendar'); // Calendar class is now accessed using: - $this->my_calendar Please take note, when multiple libraries are supplied in an array for the first parameter, this parameter is discarded. $this->load->driver('parent_name', $config, 'object name') -=========================================================== +========================================================== -This function is used to load driver libraries. Where parent_name is the +This method is used to load driver libraries. Where parent_name is the name of the parent class you want to load. As an example, if you would like to use sessions with CodeIgniter, the first @@ -102,15 +102,15 @@ step is to load the session driver within your controller:: $this->load->driver('session'); Once loaded, the library will be ready for use, using -$this->session->*some_function*(). +$this->session->*some_method*(). Driver files must be stored in a subdirectory within the main -"libraries" folder, or within your personal application/libraries -folder. The subdirectory must match the parent class name. Read the +"libraries" directory, or within your personal application/libraries +directory. The subdirectory must match the parent class name. Read the :doc:`Drivers <../general/drivers>` description for details. Additionally, multiple driver libraries can be loaded at the same time by -passing an array of drivers to the load function. +passing an array of drivers to the load method. :: @@ -122,11 +122,11 @@ Setting options The second (optional) parameter allows you to optionally pass configuration settings. You will typically pass these as an array:: - $config = array ( - 'sess_driver' => 'cookie', - 'sess_encrypt_cookie' => true, - 'encryption_key' => 'mysecretkey' - ); + $config = array( + 'sess_driver' => 'cookie', + 'sess_encrypt_cookie' => true, + 'encryption_key' => 'mysecretkey' + ); $this->load->driver('session', $config); @@ -135,12 +135,12 @@ is explained in detail in its own page, so please read the information regarding each one you would like to use. Assigning a Driver to a different object name ----------------------------------------------- +--------------------------------------------- If the third (optional) parameter is blank, the library will be assigned to an object with the same name as the parent class. For example, if the library is named Session, it will be assigned to a variable named -$this->session. +``$this->session``. If you prefer to set your own class names you can pass its value to the third parameter:: @@ -148,32 +148,33 @@ third parameter:: $this->load->library('session', '', 'my_session'); // Session class is now accessed using: - $this->my_session -.. note:: Driver libraries may also be loaded with the library() method, - but it is faster to use driver() +.. note:: Driver libraries may also be loaded with the ``library()`` method, + but it is faster to use ``driver()``. -$this->load->view('file_name', $data, true/false) -================================================== +$this->load->view('file_name', $data, TRUE/FALSE) +================================================= -This function is used to load your View files. If you haven't read the +This method is used to load your View files. If you haven't read the :doc:`Views <../general/views>` section of the user guide it is -recommended that you do since it shows you how this function is +recommended that you do since it shows you how this method is typically used. The first parameter is required. It is the name of the view file you -would like to load. Note: The .php file extension does not need to be -specified unless you use something other than .php. +would like to load. + +.. note:: The .php file extension does not need to be specified unless + you use something other than .php. The second **optional** parameter can take an associative array or an object as input, which it runs through the PHP -`extract `_ function to convert to variables +`extract() `_ function to convert to variables that can be used in your view files. Again, read the :doc:`Views <../general/views>` page to learn how this might be useful. The third **optional** parameter lets you change the behavior of the -function so that it returns data as a string rather than sending it to +method so that it returns data as a string rather than sending it to your browser. This can be useful if you want to process the data in some way. If you set the parameter to true (boolean) it will return data. The default behavior is false, which sends it to your browser. Remember to @@ -189,79 +190,76 @@ $this->load->model('model_name'); $this->load->model('model_name'); -If your model is located in a sub-folder, include the relative path from -your models folder. For example, if you have a model located at +If your model is located in a subdirectory, include the relative path +from your models directory. For example, if you have a model located at application/models/blog/queries.php you'll load it using:: $this->load->model('blog/queries'); - If you would like your model assigned to a different object name you can -specify it via the second parameter of the loading function:: +specify it via the second parameter of the loading method:: $this->load->model('model_name', 'fubar'); + $this->fubar->method(); - $this->fubar->function(); - -$this->load->database('options', true/false) +$this->load->database('options', TRUE/FALSE) ============================================ -This function lets you load the database class. The two parameters are +This method lets you load the database class. The two parameters are **optional**. Please see the :doc:`database <../database/index>` section for more info. $this->load->vars($array) ========================= -This function takes an associative array as input and generates +This method takes an associative array as input and generates variables using the PHP `extract `_ -function. This function produces the same result as using the second -parameter of the $this->load->view() function above. The reason you -might want to use this function independently is if you would like to +method. This method produces the same result as using the second +parameter of the ``$this->load->view()`` method above. The reason you +might want to use this method independently is if you would like to set some global variables in the constructor of your controller and have -them become available in any view file loaded from any function. You can -have multiple calls to this function. The data get cached and merged +them become available in any view file loaded from any method. You can +have multiple calls to this method. The data get cached and merged into one array for conversion to variables. $this->load->get_var($key) -=========================== +========================== -This function checks the associative array of variables available to +This method checks the associative array of variables available to your views. This is useful if for any reason a var is set in a library -or another controller method using $this->load->vars(). +or another controller method using ``$this->load->vars()``. $this->load->get_vars() -=========================== +======================= -This function retrieves all variables available to -your views. +This method retrieves all variables available to your views. $this->load->helper('file_name') -================================= +================================ -This function loads helper files, where file_name is the name of the +This method loads helper files, where file_name is the name of the file, without the _helper.php extension. -$this->load->file('filepath/filename', true/false) +$this->load->file('filepath/filename', TRUE/FALSE) ================================================== -This is a generic file loading function. Supply the filepath and name in +This is a generic file loading method. Supply the filepath and name in the first parameter and it will open and read the file. By default the data is sent to your browser, just like a View file, but if you set the second parameter to true (boolean) it will instead return the data as a string. $this->load->language('file_name') -=================================== +================================== -This function is an alias of the :doc:`language loading -function `: $this->lang->load() +This method is an alias of the :doc:`language loading +method `: ``$this->lang->load()`` $this->load->config('file_name') -================================= +================================ -This function is an alias of the :doc:`config file loading -function `: $this->config->load() +This method is an alias of the :doc:`config file loading +method `: ``$this->config->load()`` Application "Packages" ====================== @@ -269,7 +267,7 @@ Application "Packages" An application package allows for the easy distribution of complete sets of resources in a single directory, complete with its own libraries, models, helpers, config, and language files. It is recommended that -these packages be placed in the application/third_party folder. Below +these packages be placed in the application/third_party directory. Below is a sample map of an package directory Sample Package "Foo Bar" Directory Map @@ -311,7 +309,7 @@ $this->load->remove_package_path() When your controller is finished using resources from an application package, and particularly if you have other application packages you want to work with, you may wish to remove the package path so the Loader -no longer looks in that folder for resources. To remove the last path +no longer looks in that directory for resources. To remove the last path added, simply call the method with no parameters. $this->load->remove_package_path() @@ -346,4 +344,4 @@ calling add_package_path(). // Again without the second parameter: $this->load->add_package_path(APPPATH.'my_app'); $this->load->view('my_app_index'); // Loads - $this->load->view('welcome_message'); // Loads + $this->load->view('welcome_message'); // Loads \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0c1e163057308abb7324e44081b47dc9937dde17 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 28 Jan 2013 21:24:36 +0100 Subject: Adjustments in routing documentation * fixed syntax error for "note" banner * more useful example, in previous one there was no need for strtolower, nor for a callback --- user_guide_src/source/general/routing.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index 2a0332088..ed21a6109 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -129,7 +129,7 @@ For those of you who don't know regular expressions and want to learn more about them, `regular-expressions.info ` might be a good starting point. -..note:: You can also mix and match wildcards with regular expressions. +.. note:: You can also mix and match wildcards with regular expressions. Callbacks ========= @@ -137,7 +137,7 @@ Callbacks If you are using PHP >= 5.3 you can use callbacks in place of the normal routing rules to process the back-references. Example:: - $route['products/([a-z]+)/edit/(\d+)'] = function ($product_type, $id) + $route['products/([a-zA-Z]+)/edit/(\d+)'] = function ($product_type, $id) { return 'catalog/product_edit/' . strtolower($product_type) . '/' . $id; }; -- cgit v1.2.3-24-g4f1b From 9668d1d56d39187aa26f058495ca666e3544cbe2 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Mon, 28 Jan 2013 17:45:34 -0600 Subject: Remove spaces from concats. Signed-off-by: Eric Roberts --- system/libraries/Pagination.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 3a513a7c1..76754046b 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -408,13 +408,13 @@ class CI_Pagination { // If we saved any GET items earlier, make sure they're appended. if ( ! empty($get)) { - $this->first_url .= $query_string_sep . http_build_query($get); + $this->first_url .= $query_string_sep.http_build_query($get); } } // Add the page segment to the end of the query string, where the // page number will be appended. - $this->base_url .= $query_string_sep . http_build_query(array_merge($get, array($this->query_string_segment => ''))); + $this->base_url .= $query_string_sep.http_build_query(array_merge($get, array($this->query_string_segment => ''))); } else { @@ -422,7 +422,7 @@ class CI_Pagination { // Generate our saved query string to append later after the page number. if ( ! empty($get)) { - $query_string = $query_string_sep . http_build_query($get); + $query_string = $query_string_sep.http_build_query($get); $this->suffix .= $query_string; } @@ -435,10 +435,10 @@ class CI_Pagination { if ($this->first_url === '') { - $this->first_url = $this->base_url . $query_string; + $this->first_url = $this->base_url.$query_string; } - $this->base_url = rtrim($this->base_url, '/') . '/'; + $this->base_url = rtrim($this->base_url, '/').'/'; } // Determine the current page number. -- cgit v1.2.3-24-g4f1b From b835a4f3b3f8fccd7ce457d4ab13344d3dcb91a9 Mon Sep 17 00:00:00 2001 From: Chris Buckley Date: Mon, 28 Jan 2013 23:35:13 +0000 Subject: Fix list_fields seek bug On the first list_fields call, the field pointer is moved to the end of the list of fields. This change ensures that the pointer is positioned at the start of the field list before grabbing the names. Signed-off-by: Chris Buckley --- system/database/drivers/mssql/mssql_result.php | 1 + system/database/drivers/mysql/mysql_result.php | 1 + system/database/drivers/mysqli/mysqli_result.php | 1 + 3 files changed, 3 insertions(+) diff --git a/system/database/drivers/mssql/mssql_result.php b/system/database/drivers/mssql/mssql_result.php index ea3f8e4d1..b6e5f2b17 100644 --- a/system/database/drivers/mssql/mssql_result.php +++ b/system/database/drivers/mssql/mssql_result.php @@ -74,6 +74,7 @@ class CI_DB_mssql_result extends CI_DB_result { public function list_fields() { $field_names = array(); + mssql_field_seek($this->result_id, 0); while ($field = mssql_fetch_field($this->result_id)) { $field_names[] = $field->name; diff --git a/system/database/drivers/mysql/mysql_result.php b/system/database/drivers/mysql/mysql_result.php index 1ed2759b6..a2affcb58 100644 --- a/system/database/drivers/mysql/mysql_result.php +++ b/system/database/drivers/mysql/mysql_result.php @@ -89,6 +89,7 @@ class CI_DB_mysql_result extends CI_DB_result { public function list_fields() { $field_names = array(); + mysql_field_seek($this->result_id, 0); while ($field = mysql_fetch_field($this->result_id)) { $field_names[] = $field->name; diff --git a/system/database/drivers/mysqli/mysqli_result.php b/system/database/drivers/mysqli/mysqli_result.php index 4105f99f6..3fe05f9c5 100644 --- a/system/database/drivers/mysqli/mysqli_result.php +++ b/system/database/drivers/mysqli/mysqli_result.php @@ -74,6 +74,7 @@ class CI_DB_mysqli_result extends CI_DB_result { public function list_fields() { $field_names = array(); + $this->result_id->field_seek(0); while ($field = $this->result_id->fetch_field()) { $field_names[] = $field->name; -- cgit v1.2.3-24-g4f1b From ba67f3bb595817115a15f6c3249e41e7c85f2ce4 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Mon, 28 Jan 2013 18:01:01 -0600 Subject: Move $get assignment to if/else. Signed-off-by: Eric Roberts --- system/libraries/Pagination.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 76754046b..562a2d3eb 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -380,8 +380,6 @@ class CI_Pagination { // Keep any existing query string items. // Note: Has nothing to do with any other query string option. - $get = array(); - if ($this->reuse_query_string === TRUE) { $get = $CI->input->get(); @@ -389,6 +387,10 @@ class CI_Pagination { // Unset the controll, method, old-school routing options unset($get['c'], $get['m'], $get[$this->query_string_segment]); } + else + { + $get = array(); + } // Put together our base and first URLs. $this->base_url = trim($this->base_url); -- cgit v1.2.3-24-g4f1b From 032af98ab94482cc7c5b10013ec033acfdc34c74 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Mon, 28 Jan 2013 23:25:52 -0600 Subject: Replace is_numeric() with ctype_digit() Signed-off-by: Eric Roberts --- system/libraries/Pagination.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 562a2d3eb..438d6c477 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -449,7 +449,8 @@ class CI_Pagination { // Are we using query strings? if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - $this->cur_page = (int) $CI->input->get($this->query_string_segment); + // Cast as string for use in ctype_digit() later. + $this->cur_page = (string) $CI->input->get($this->query_string_segment); } else { @@ -459,19 +460,25 @@ class CI_Pagination { $this->uri_segment = count($CI->uri->segment_array()); } - $this->cur_page = $CI->uri->segment($this->uri_segment); + $this->cur_page = (string) $CI->uri->segment($this->uri_segment); // Remove any specified prefix/suffix from the segment. - $this->cur_page = ($this->prefix !== '' OR $this->suffix !== '') - ? (int) str_replace(array($this->prefix, $this->suffix), '', $this->cur_page) - : (int) $this->cur_page; + if ($this->prefix !== '' OR $this->suffix !== '') + { + $this->cur_page = str_replace(array($this->prefix, $this->suffix), '', $this->cur_page); + } } // If something isn't quite right, back to the default base page. - if ( ! is_numeric($this->cur_page) OR ($this->use_page_numbers && $this->cur_page === 0)) + if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) { $this->cur_page = $base_page; } + else + { + // Make sure we're using integers for comparisons later. + $this->cur_page = (int) $this->cur_page; + } // Is the page number beyond the result range? // If so, we show the last page. -- cgit v1.2.3-24-g4f1b From 0687911229be13e100724dbf8b15b95146b591a9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Jan 2013 15:05:02 +0200 Subject: Replace is_file() with the faster file_exists() (where it makes sense) Also: - Implemented caching of configuration arrays for smileys, foreign characters and doctypes. - Implemented cascading-style loading of configuration files (except for library configs, DB and constants.php). --- system/core/Common.php | 4 ++-- system/core/Hooks.php | 5 +++-- system/core/Router.php | 9 +++++---- system/helpers/download_helper.php | 2 +- system/helpers/html_helper.php | 20 ++++++++++++-------- system/helpers/smiley_helper.php | 28 +++++++++++++++++++++------- system/helpers/text_helper.php | 22 +++++++++++++--------- system/libraries/User_agent.php | 13 ++++++++----- 8 files changed, 65 insertions(+), 38 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 90cc5b3a4..258cd4967 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -316,11 +316,11 @@ if ( ! function_exists('get_mimes')) { static $_mimes = array(); - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { $_mimes = include(APPPATH.'config/'.ENVIRONMENT.'/mimes.php'); } - elseif (is_file(APPPATH.'config/mimes.php')) + elseif (file_exists(APPPATH.'config/mimes.php')) { $_mimes = include(APPPATH.'config/mimes.php'); } diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 59759e02e..17f6a027e 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -81,11 +81,12 @@ class CI_Hooks { } // Grab the "hooks" definition file. - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); } - elseif (is_file(APPPATH.'config/hooks.php')) + + if (file_exists(APPPATH.'config/hooks.php')) { include(APPPATH.'config/hooks.php'); } diff --git a/system/core/Router.php b/system/core/Router.php index 4755b3712..bb0ce16bd 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -133,13 +133,14 @@ class CI_Router { } // Load the routes.php file. - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) + if (file_exists(APPPATH.'config/routes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); + include(APPPATH.'config/routes.php'); } - elseif (is_file(APPPATH.'config/routes.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) { - include(APPPATH.'config/routes.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); } $this->routes = (empty($route) OR ! is_array($route)) ? array() : $route; diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php index 7294d50c5..4fe6a0e88 100644 --- a/system/helpers/download_helper.php +++ b/system/helpers/download_helper.php @@ -58,7 +58,7 @@ if ( ! function_exists('force_download')) } elseif ($data === NULL) { - if (@is_file($filename) && @file_exists($filename) && ($filesize = @filesize($filename)) !== FALSE) + if (@is_file($filename) && ($filesize = @filesize($filename)) !== FALSE) { $filepath = $filename; $filename = explode('/', str_replace(DIRECTORY_SEPARATOR, '/', $filename)); diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php index 7a71eb82b..80a27876f 100644 --- a/system/helpers/html_helper.php +++ b/system/helpers/html_helper.php @@ -238,26 +238,30 @@ if ( ! function_exists('doctype')) */ function doctype($type = 'xhtml1-strict') { - global $_doctypes; + static $doctypes; - if ( ! is_array($_doctypes)) + if ( ! is_array($doctypes)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) + if (file_exists(APPPATH.'config/doctypes.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); + include(APPPATH.'config/doctypes.php'); } - elseif (is_file(APPPATH.'config/doctypes.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php')) { - include(APPPATH.'config/doctypes.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/doctypes.php'); } - if ( ! is_array($_doctypes)) + if (empty($_doctypes) OR ! is_array($_doctypes)) { + $doctypes = array(); return FALSE; } + + $doctypes = $_doctypes; } - return isset($_doctypes[$type]) ? $_doctypes[$type] : FALSE; + return isset($doctypes[$type]) ? $doctypes[$type] : FALSE; } } diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index c2f50ec73..d9a693493 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -213,16 +213,30 @@ if ( ! function_exists('_get_smiley_array')) */ function _get_smiley_array() { - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) - { - include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); - } - elseif (file_exists(APPPATH.'config/smileys.php')) + static $_smileys; + + if ( ! is_array($smileys)) { - include(APPPATH.'config/smileys.php'); + if (file_exists(APPPATH.'config/smileys.php')) + { + include(APPPATH.'config/smileys.php'); + } + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys.php')) + { + include(APPPATH.'config/'.ENVIRONMENT.'/smileys.php'); + } + + if (empty($smileys) OR ! is_array($smileys)) + { + $_smileys = array(); + return FALSE; + } + + $_smileys = $smileys; } - return (isset($smileys) && is_array($smileys)) ? $smileys : FALSE; + return $_smileys; } } diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index c255c15a8..54db14f94 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -358,31 +358,35 @@ if ( ! function_exists('convert_accented_characters')) /** * Convert Accented Foreign Characters to ASCII * - * @param string the text string + * @param string $str Input string * @return string */ function convert_accented_characters($str) { - global $foreign_characters; + static $_foreign_characters; - if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) + if ( ! is_array($_foreign_characters)) { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) + if (file_exists(APPPATH.'config/foreign_chars.php')) { - include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); + include(APPPATH.'config/foreign_chars.php'); } - elseif (is_file(APPPATH.'config/foreign_chars.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php')) { - include(APPPATH.'config/foreign_chars.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars.php'); } - if ( ! isset($foreign_characters) OR ! is_array($foreign_characters)) + if (empty($foreign_characters) OR ! is_array($foreign_characters)) { + $_foreign_characters = array(); return $str; } + + $_foreign_characters = $foreign_characters; } - return preg_replace(array_keys($foreign_characters), array_values($foreign_characters), $str); + return preg_replace(array_keys($_foreign_characters), array_values($_foreign_characters), $str); } } diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php index 3fe2e0519..2f6f81909 100644 --- a/system/libraries/User_agent.php +++ b/system/libraries/User_agent.php @@ -175,15 +175,18 @@ class CI_User_agent { */ protected function _load_agent_file() { - if (is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) + if (($found = file_exists(APPPATH.'config/user_agents.php'))) { - include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); + include(APPPATH.'config/user_agents.php'); } - elseif (is_file(APPPATH.'config/user_agents.php')) + + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php')) { - include(APPPATH.'config/user_agents.php'); + include(APPPATH.'config/'.ENVIRONMENT.'/user_agents.php'); + $found = TRUE; } - else + + if ($found !== TRUE) { return FALSE; } -- cgit v1.2.3-24-g4f1b From d911fccb3198ffb0629d9956115ae08244ce3e66 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Jan 2013 15:14:13 +0200 Subject: [ci skip] Add some changelog entries --- user_guide_src/source/changelog.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8b9ec2539..982ae22f4 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -38,7 +38,6 @@ Release Date: Not Released - Updated support for php files in mimes.php. - Updated support for zip files in mimes.php. - Updated support for csv files in mimes.php. - - Added some more doctypes. - Added Romanian, Greek, Vietnamese and Cyrilic characters in *application/config/foreign_characters.php*. - Changed logger to only chmod when file is first created. - Removed previously deprecated SHA1 Library. @@ -74,7 +73,10 @@ Release Date: Not Released - Added support (auto-detection) for HTTP/1.1 response code 303 in :php:func:`redirect()`. - Changed :php:func:`redirect()` to only choose the **refresh** method only on IIS servers, instead of all servers on Windows (when **auto** is used). - Changed :php:func:`anchor()`, :php:func:`anchor_popup()`, and :php:func:`redirect()` to support protocol-relative URLs (e.g. *//ellislab.com/codeigniter*). - - Added XHTML Basic 1.1 doctype to :doc:`HTML Helper `. + - :doc:`HTML Helper ` changes include: + - Added more doctypes. + - Changed application and environment config files to be loaded in a cascade-like manner. + - The doctypes array is now cached and loaded only once. - :doc:`Inflector Helper ` changes include: - Changed :php:func:`humanize()` to allow passing an input separator as its second parameter. - Refactored :php:func:`plural()` and :php:func:`singular()` to avoid double pluralization and support more words. @@ -88,7 +90,10 @@ Release Date: Not Released - :doc:`Security Helper ` changes include: - :php:func:`do_hash()` now uses PHP's native ``hash()`` function (supporting more algorithms) and is deprecated. - :php:func:`strip_image_tags()` is now an alias for the same method in the :doc:`Security Library `. - - Removed previously deprecated helper function ``js_insert_smiley()`` from :doc:`Smiley Helper `. + - :doc:`Smiley Helper ` changes include: + - Removed previously deprecated function ``js_insert_smiley()``. + - Changed application and environment config files to be loaded in a cascade-like manner. + - The smileys array is now cached and loaded only once. - :doc:`File Helper ` changes include: - :php:func:`set_realpath()` can now also handle file paths as opposed to just directories. - Added an optional paramater to :php:func:`delete_files()` to enable it to skip deleting files such as *.htaccess* and *index.html*. @@ -472,6 +477,7 @@ Bug fixes for 3.0 - Fixed a bug (#113) - :doc:`Form Validation Library ` didn't properly handle empty fields that were specified as an array. - Fixed a bug (#2061) - :doc:`Routing Class ` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE. - Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values. +- Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 7e5597782a589e4171ca08abdd9ce1a185542ff4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 29 Jan 2013 15:38:33 +0200 Subject: Replace CI_Upload::clean_file_name() usage with CI_Security::sanitize_filename() Also applied @xeptor's fix (a big thanks) to the sanitize_filename() method and added a changelog entry for it - fixes issue #73. --- system/core/Security.php | 10 +++++++- system/libraries/Upload.php | 50 ++----------------------------------- user_guide_src/source/changelog.rst | 2 ++ 3 files changed, 13 insertions(+), 49 deletions(-) diff --git a/system/core/Security.php b/system/core/Security.php index a6cd14a5f..7aae54efc 100644 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -576,7 +576,15 @@ class CI_Security { } $str = remove_invisible_characters($str, FALSE); - return stripslashes(str_replace($bad, '', $str)); + + do + { + $old = $str; + $str = str_replace($bad, '', $str); + } + while ($old !== $str); + + return stripslashes($str); } // ---------------------------------------------------------------- diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 1f0bd6a6e..814ea68a4 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -463,7 +463,8 @@ class CI_Upload { } // Sanitize the file name for security - $this->file_name = $this->clean_file_name($this->file_name); + $CI =& get_instance(); + $this->file_name = $CI->security->sanitize_filename($this->file_name); // Truncate the file name if it's too long if ($this->max_filename > 0) @@ -970,53 +971,6 @@ class CI_Upload { // -------------------------------------------------------------------- - /** - * Clean the file name for security - * - * @param string $filename - * @return string - */ - public function clean_file_name($filename) - { - $bad = array( - '', - "'", '"', - '<', '>', - '&', '$', - '=', - ';', - '?', - '/', - '!', - '#', - '%20', - '%22', - '%3c', // < - '%253c', // < - '%3e', // > - '%0e', // > - '%28', // ( - '%29', // ) - '%2528', // ( - '%26', // & - '%24', // $ - '%3f', // ? - '%3b', // ; - '%3d' // = - ); - - do - { - $old_filename = $filename; - $filename = str_replace($bad, '', $filename); - } - while ($old_filename !== $filename); - - return stripslashes($filename); - } - - // -------------------------------------------------------------------- - /** * Limit the File Name Length * diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 982ae22f4..daa1cfc7a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -215,6 +215,7 @@ Release Date: Not Released - Added **max_filename_increment** config setting. - Added an **index** parameter to the ``data()`` method. - Added the **min_width** and **min_height** options for images. + - Removed method ``clean_file_name()`` and its usage in favor of :doc:`Security Library `'s ``sanitize_filename()``. - :doc:`Cart library ` changes include: - ``insert()`` now auto-increments quantity for an item when inserted twice instead of resetting it, this is the default behaviour of large e-commerce sites. - *Product Name* strictness can be disabled by switching the ``$product_name_safe`` property to FALSE. @@ -478,6 +479,7 @@ Bug fixes for 3.0 - Fixed a bug (#2061) - :doc:`Routing Class ` didn't properly sanitize directory, controller and function triggers with **enable_query_strings** set to TRUE. - Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values. - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. +- Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 4421ad07d7abf3d1f7e3ccc79a0e7f694ba0d30c Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Tue, 29 Jan 2013 22:51:01 +0800 Subject: fixed #2207 user guide error Signed-off-by: Bo-Yi Wu --- user_guide_src/source/tutorial/news_section.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst index b64ea2aae..833e34ead 100644 --- a/user_guide_src/source/tutorial/news_section.rst +++ b/user_guide_src/source/tutorial/news_section.rst @@ -68,7 +68,7 @@ following code to your model. $query = $this->db->get('news'); return $query->result_array(); } - + $query = $this->db->get_where('news', array('slug' => $slug)); return $query->row_array(); } @@ -146,7 +146,7 @@ and add the next piece of code.

-
+

View article

-- cgit v1.2.3-24-g4f1b From 8151cbb586edf565a57e33287b01222d9c4a85b6 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 30 Jan 2013 13:57:56 +0200 Subject: Fix/improve #2211 --- system/libraries/Migration.php | 4 ++-- user_guide_src/source/changelog.rst | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index fd915c382..b673e9cb7 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -104,8 +104,8 @@ class CI_Migration { */ public function __construct($config = array()) { - # Only run this constructor on main library load - if (get_parent_class($this) !== FALSE) + // Only run this constructor on main library load + if ( ! in_array(get_class($this), array('CI_Migration', config_item('subclass_prefix').'Migration'), TRUE)) { return; } diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index daa1cfc7a..de88dcf28 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -480,6 +480,7 @@ Bug fixes for 3.0 - Fixed a bug - SQLSRV didn't support ``escape_like_str()`` or escaping an array of values. - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. +- Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From ed92580e028b17230723807c51503e42f07cdb8e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 30 Jan 2013 13:59:19 +0200 Subject: Remove tests for now non-existent method CI_Upload::clean_file_name() See 7e5597782a589e4171ca08abdd9ce1a185542ff4 --- tests/codeigniter/libraries/Upload_test.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/codeigniter/libraries/Upload_test.php b/tests/codeigniter/libraries/Upload_test.php index 1bd8f1430..4d9e4a46e 100644 --- a/tests/codeigniter/libraries/Upload_test.php +++ b/tests/codeigniter/libraries/Upload_test.php @@ -208,12 +208,6 @@ class Upload_test extends CI_TestCase { $this->assertEquals('', $this->upload->get_extension('hello')); } - function test_clean_file_name() - { - $this->assertEquals('hello.txt', $this->upload->clean_file_name('hello.txt')); - $this->assertEquals('hello.txt', $this->upload->clean_file_name('%253chell>o.txt')); - } - function test_limit_filename_length() { $this->assertEquals('hello.txt', $this->upload->limit_filename_length('hello.txt', 10)); -- cgit v1.2.3-24-g4f1b From 3683723212c1de682c4e026df28fe3b03b4ea404 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Wed, 30 Jan 2013 23:18:50 +0800 Subject: core comment error. Signed-off-by: Bo-Yi Wu --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Log.php b/system/core/Log.php index cd3c17e1e..f5d091e14 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -179,4 +179,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/libraries/Log.php */ \ No newline at end of file +/* Location: ./system/core/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From d5c711cce17bbe2b24785e91a5ecc829e1ad5bf6 Mon Sep 17 00:00:00 2001 From: kaoz70 Date: Thu, 31 Jan 2013 20:54:09 -0500 Subject: Added some mime types, for newer or older files. --- application/config/mimes.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index dfa9f24e4..ac1479c0a 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -44,13 +44,13 @@ return array( 'lzh' => 'application/octet-stream', 'exe' => array('application/octet-stream', 'application/x-msdownload'), 'class' => 'application/octet-stream', - 'psd' => 'application/x-photoshop', + 'psd' => array('application/x-photoshop', 'image/vnd.adobe.photoshop'), 'so' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => array('application/pdf', 'application/x-download', 'binary/octet-stream'), - 'ai' => 'application/postscript', + 'ai' => array('application/pdf', 'application/postscript'), 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', @@ -160,7 +160,7 @@ return array( 'm3u' => 'text/plain', 'xspf' => 'application/xspf+xml', 'vlc' => 'application/videolan', - 'wmv' => 'video/x-ms-wmv', + 'wmv' => array('video/x-ms-wmv', 'video/x-ms-asf'), 'au' => 'audio/x-au', 'ac3' => 'audio/ac3', 'flac' => 'audio/x-flac', -- cgit v1.2.3-24-g4f1b From 2d1608a6325d55ab31c55c27c31052c2daa76e46 Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Sat, 2 Feb 2013 08:00:39 -0600 Subject: Added Form Validation rule for alphanum + spaces. Signed-off-by: Sajan Parikh --- system/libraries/Form_validation.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index bbd0b523e..7b9215c04 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1229,6 +1229,21 @@ class CI_Form_validation { return ctype_alnum((string) $str); } + // -------------------------------------------------------------------- + + // -------------------------------------------------------------------- + + /** + * Alpha-numeric w/ spaces + * + * @param string + * @return bool + */ + public function alpha_numeric_spaces($str) + { + return (bool) preg_match('#^[A-Z0-9 ]+$#i', $str); + } + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 7c162887a8146622e8fe126f21d9b8b615f91753 Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Sat, 2 Feb 2013 08:05:38 -0600 Subject: Fixed documentation. Signed-off-by: Sajan Parikh --- user_guide_src/source/libraries/form_validation.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index ae7859aa3..51205afa4 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -877,8 +877,10 @@ Rule Parameter Description **less_than_equal_to** Yes Returns FALSE if the form element is greater than the parameter value, less_than_equal_to[8] or not numeric. **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. -**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. -**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, +**alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. +**alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters + or spaces. Should be used after trim to avoid spaces at the beginning or end. +**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes. **numeric** No Returns FALSE if the form element contains anything other than numeric characters. **integer** No Returns FALSE if the form element contains anything other than an integer. -- cgit v1.2.3-24-g4f1b From 9c0b890bb15394d8d6d976df65a9aa7c19c1c33d Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Sat, 2 Feb 2013 08:56:35 -0600 Subject: Added error message in lang file. Signed-off-by: Sajan Parikh --- system/language/english/form_validation_lang.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 3fb007dd2..476123b06 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -28,20 +28,21 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $lang['form_validation_required'] = 'The {field} field is required.'; $lang['form_validation_isset'] = 'The {field} field must have a value.'; -$lang['form_validation_valid_email'] = 'The {field} field must contain a valid email address.'; -$lang['form_validation_valid_emails'] = 'The {field} field must contain all valid email addresses.'; +$lang['form_validation_valid_email'] = 'The {field} field must contain a valid email address.'; +$lang['form_validation_valid_emails'] = 'The {field} field must contain all valid email addresses.'; $lang['form_validation_valid_url'] = 'The {field} field must contain a valid URL.'; $lang['form_validation_valid_ip'] = 'The {field} field must contain a valid IP.'; $lang['form_validation_min_length'] = 'The {field} field must be at least {param} characters in length.'; $lang['form_validation_max_length'] = 'The {field} field cannot exceed {param} characters in length.'; -$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.'; +$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.'; $lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.'; -$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.'; +$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.'; +$lang['form_validation_alpha_numeric_spaces'] = 'The {field} field may only contain alpha-numeric characters and spaces.'; $lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.'; $lang['form_validation_numeric'] = 'The {field} field must contain only numbers.'; $lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.'; $lang['form_validation_integer'] = 'The {field} field must contain an integer.'; -$lang['form_validation_regex_match'] = 'The {field} field is not in the correct format.'; +$lang['form_validation_regex_match'] = 'The {field} field is not in the correct format.'; $lang['form_validation_matches'] = 'The {field} field does not match the {param} field.'; $lang['form_validation_differs'] = 'The {field} field must differ from the {param} field.'; $lang['form_validation_is_unique'] = 'The {field} field must contain a unique value.'; -- cgit v1.2.3-24-g4f1b From df3bfed9c19fe22d6449e2ee78ca5bd2fe9c6476 Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Mon, 4 Feb 2013 12:25:49 -0600 Subject: Cleaned up for pull request. Signed-off-by: Sajan Parikh --- system/language/english/form_validation_lang.php | 10 +++++----- system/libraries/Form_validation.php | 4 +--- user_guide_src/source/libraries/form_validation.rst | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php index 476123b06..7c0277c25 100644 --- a/system/language/english/form_validation_lang.php +++ b/system/language/english/form_validation_lang.php @@ -28,21 +28,21 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $lang['form_validation_required'] = 'The {field} field is required.'; $lang['form_validation_isset'] = 'The {field} field must have a value.'; -$lang['form_validation_valid_email'] = 'The {field} field must contain a valid email address.'; -$lang['form_validation_valid_emails'] = 'The {field} field must contain all valid email addresses.'; +$lang['form_validation_valid_email'] = 'The {field} field must contain a valid email address.'; +$lang['form_validation_valid_emails'] = 'The {field} field must contain all valid email addresses.'; $lang['form_validation_valid_url'] = 'The {field} field must contain a valid URL.'; $lang['form_validation_valid_ip'] = 'The {field} field must contain a valid IP.'; $lang['form_validation_min_length'] = 'The {field} field must be at least {param} characters in length.'; $lang['form_validation_max_length'] = 'The {field} field cannot exceed {param} characters in length.'; -$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.'; +$lang['form_validation_exact_length'] = 'The {field} field must be exactly {param} characters in length.'; $lang['form_validation_alpha'] = 'The {field} field may only contain alphabetical characters.'; -$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.'; +$lang['form_validation_alpha_numeric'] = 'The {field} field may only contain alpha-numeric characters.'; $lang['form_validation_alpha_numeric_spaces'] = 'The {field} field may only contain alpha-numeric characters and spaces.'; $lang['form_validation_alpha_dash'] = 'The {field} field may only contain alpha-numeric characters, underscores, and dashes.'; $lang['form_validation_numeric'] = 'The {field} field must contain only numbers.'; $lang['form_validation_is_numeric'] = 'The {field} field must contain only numeric characters.'; $lang['form_validation_integer'] = 'The {field} field must contain an integer.'; -$lang['form_validation_regex_match'] = 'The {field} field is not in the correct format.'; +$lang['form_validation_regex_match'] = 'The {field} field is not in the correct format.'; $lang['form_validation_matches'] = 'The {field} field does not match the {param} field.'; $lang['form_validation_differs'] = 'The {field} field must differ from the {param} field.'; $lang['form_validation_is_unique'] = 'The {field} field must contain a unique value.'; diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 7b9215c04..1511d9add 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -1229,8 +1229,6 @@ class CI_Form_validation { return ctype_alnum((string) $str); } - // -------------------------------------------------------------------- - // -------------------------------------------------------------------- /** @@ -1241,7 +1239,7 @@ class CI_Form_validation { */ public function alpha_numeric_spaces($str) { - return (bool) preg_match('#^[A-Z0-9 ]+$#i', $str); + return (bool) preg_match('/^[A-Z0-9 ]+$/i', $str); } // -------------------------------------------------------------------- diff --git a/user_guide_src/source/libraries/form_validation.rst b/user_guide_src/source/libraries/form_validation.rst index 51205afa4..8b35fdc75 100644 --- a/user_guide_src/source/libraries/form_validation.rst +++ b/user_guide_src/source/libraries/form_validation.rst @@ -879,8 +879,8 @@ Rule Parameter Description **alpha** No Returns FALSE if the form element contains anything other than alphabetical characters. **alpha_numeric** No Returns FALSE if the form element contains anything other than alpha-numeric characters. **alpha_numeric_spaces** No Returns FALSE if the form element contains anything other than alpha-numeric characters - or spaces. Should be used after trim to avoid spaces at the beginning or end. -**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, + or spaces. Should be used after trim to avoid spaces at the beginning or end. +**alpha_dash** No Returns FALSE if the form element contains anything other than alpha-numeric characters, underscores or dashes. **numeric** No Returns FALSE if the form element contains anything other than numeric characters. **integer** No Returns FALSE if the form element contains anything other than an integer. -- cgit v1.2.3-24-g4f1b From f9866509fbe79186976a9e4b0ca1aaa7fe0bdc7b Mon Sep 17 00:00:00 2001 From: Sajan Parikh Date: Mon, 4 Feb 2013 12:31:19 -0600 Subject: Add entry in user guide changelog. Signed-off-by: Sajan Parikh --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index de88dcf28..893c3db61 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -242,6 +242,7 @@ Release Date: Not Released - Added rule **valid_url**. - Added support for named parameters in error messages. - :doc:`Language ` line keys must now be prefixed with **form_validation_**. + - Added rule **alpha_numeric_spaces**. - Added support for setting :doc:`Table ` class defaults in a config file. - :doc:`Caching Library ` changes include: - Added Wincache driver. -- cgit v1.2.3-24-g4f1b From baad7617b432708ef438a3b421e8b61b0d509b9d Mon Sep 17 00:00:00 2001 From: Lasha Krikheli Date: Tue, 5 Feb 2013 02:48:21 -0500 Subject: Added 'application/x-zip' mimetype for docx --- application/config/mimes.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index ac1479c0a..0129c3ca1 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -123,7 +123,7 @@ return array( 'avi' => array('video/x-msvideo', 'video/msvideo', 'video/avi', 'application/x-troff-msvideo'), 'movie' => 'video/x-sgi-movie', 'doc' => array('application/msword', 'application/vnd.ms-office'), - 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'), + 'docx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword', 'application/x-zip'), 'dot' => array('application/msword', 'application/vnd.ms-office'), 'dotx' => array('application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/zip', 'application/msword'), 'xlsx' => array('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/zip', 'application/vnd.ms-excel', 'application/msword'), @@ -176,4 +176,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ \ No newline at end of file +/* Location: ./application/config/mimes.php */ -- cgit v1.2.3-24-g4f1b From 9708855b4c2e5f6c75403da5aa0c07247518ab64 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Feb 2013 21:53:20 +0200 Subject: Allow non-string values to be used as captcha words (issue #2215) --- system/helpers/captcha_helper.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 83783324b..78e255a15 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -93,7 +93,7 @@ if ( ! function_exists('create_captcha')) // Do we have a "word" yet? // ----------------------------------- - if ($word === '') + if (empty($word)) { $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $word = ''; @@ -102,6 +102,10 @@ if ( ! function_exists('create_captcha')) $word .= $pool[mt_rand(0, $mt_rand_max)]; } } + elseif ( ! is_string($word)) + { + $word = (string) $word; + } // ----------------------------------- // Determine angle and position -- cgit v1.2.3-24-g4f1b From cc221dc434e0d31138e81a940d38b81e994d48fe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Feb 2013 21:57:42 +0200 Subject: [ci skip] Add a missing space --- system/libraries/Session/drivers/Session_cookie.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index 474641642..11bb32fe0 100644 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -805,7 +805,7 @@ class CI_Session_cookie extends CI_Session_driver { { if (is_string($val)) { - $val= str_replace('{{slash}}', '\\', $val); + $val = str_replace('{{slash}}', '\\', $val); } } -- cgit v1.2.3-24-g4f1b From 870f11351b6e7a916bf30aa22b4a8c3dd49bf33f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Feb 2013 22:06:00 +0200 Subject: [ci skip] Remove unnecessary string casts in Pagination --- application/config/mimes.php | 2 +- system/libraries/Pagination.php | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/application/config/mimes.php b/application/config/mimes.php index 0129c3ca1..5b8ceff2e 100644 --- a/application/config/mimes.php +++ b/application/config/mimes.php @@ -176,4 +176,4 @@ return array( ); /* End of file mimes.php */ -/* Location: ./application/config/mimes.php */ +/* Location: ./application/config/mimes.php */ \ No newline at end of file diff --git a/system/libraries/Pagination.php b/system/libraries/Pagination.php index 438d6c477..10fb29dbd 100644 --- a/system/libraries/Pagination.php +++ b/system/libraries/Pagination.php @@ -449,8 +449,7 @@ class CI_Pagination { // Are we using query strings? if ($CI->config->item('enable_query_strings') === TRUE OR $this->page_query_string === TRUE) { - // Cast as string for use in ctype_digit() later. - $this->cur_page = (string) $CI->input->get($this->query_string_segment); + $this->cur_page = $CI->input->get($this->query_string_segment); } else { @@ -460,7 +459,7 @@ class CI_Pagination { $this->uri_segment = count($CI->uri->segment_array()); } - $this->cur_page = (string) $CI->uri->segment($this->uri_segment); + $this->cur_page = $CI->uri->segment($this->uri_segment); // Remove any specified prefix/suffix from the segment. if ($this->prefix !== '' OR $this->suffix !== '') -- cgit v1.2.3-24-g4f1b From c2268711a27809575f82b21e64fde6cd953ef7f9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 8 Feb 2013 22:10:23 +0200 Subject: Fix issue #2230 --- system/libraries/Form_validation.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 1511d9add..4cf4ecae0 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -517,7 +517,7 @@ class CI_Form_validation { { if (isset($_POST[$row['field']])) { - $_POST[$row['field']] = $this->prep_for_form($row['postdata']); + $_POST[$row['field']] = $row['postdata']; } } else @@ -543,14 +543,14 @@ class CI_Form_validation { $array = array(); foreach ($row['postdata'] as $k => $v) { - $array[$k] = $this->prep_for_form($v); + $array[$k] = $v; } $post_ref = $array; } else { - $post_ref = $this->prep_for_form($row['postdata']); + $post_ref = $row['postdata']; } } } -- cgit v1.2.3-24-g4f1b From 0b607252b1f3bcabfb8150120e683795ec3a0890 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 13 Feb 2013 10:34:16 +0200 Subject: Added small feature to profiler: total execution time count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit adds additional information to profiler like: DATABASE:  test   QUERIES: 3 (0.0016s)  (Hide) --- system/libraries/Profiler.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index e93239901..67922d51c 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,6 +238,8 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; + + $total_time = number_format(array_sum($db->query_times), 4) . 's'; $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; @@ -250,7 +252,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_database') .':  '.$db->database.' ('.$name.')   '.$this->CI->lang->line('profiler_queries') - .': '.count($db->queries).'  '.$show_hide_js."\n\n\n" + .': '.count($db->queries).'('.$total_time.')'.'  '.$show_hide_js."\n\n\n" .'\n"; if (count($db->queries) === 0) @@ -553,4 +555,4 @@ class CI_Profiler { } /* End of file Profiler.php */ -/* Location: ./system/libraries/Profiler.php */ \ No newline at end of file +/* Location: ./system/libraries/Profiler.php */ -- cgit v1.2.3-24-g4f1b From aae91a45e27cb11e09b22bf9be04a7da9f6ff20b Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 11:51:30 -0500 Subject: Update system/core/Log.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated Log.php so that a developer can extend it and change the log file extension. It makes sense to default to .php when logs are in the public web folder.  It would be nice if a developer moves the log file path we have the option to use a standard extension like .log --- system/core/Log.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/system/core/Log.php b/system/core/Log.php index f5d091e14..3b0a9213d 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -71,6 +71,13 @@ class CI_Log { * @var string */ protected $_date_fmt = 'Y-m-d H:i:s'; + + /** + * Log file extension + * + * @var string + */ + protected $_log_ext = 'php'; /** * Whether or not the logger can write to the log files @@ -147,7 +154,7 @@ class CI_Log { return FALSE; } - $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_log_ext; $message = ''; if ( ! file_exists($filepath)) @@ -179,4 +186,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ \ No newline at end of file +/* Location: ./system/core/Log.php */ -- cgit v1.2.3-24-g4f1b From 0bd6b28045c9b9a820e580b3f651f474b60348a3 Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 14:16:18 -0500 Subject: Added support for changing the default log file extension from .php to whatever is preferred. example (.log) This is a follow up to this pull request. https://github.com/EllisLab/CodeIgniter/pull/2243 --- application/config/config.php | 11 +++++++++++ system/core/Log.php | 2 ++ user_guide_src/source/changelog.rst | 1 + 3 files changed, 14 insertions(+) diff --git a/application/config/config.php b/application/config/config.php index 415474e06..6f597b1e2 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -224,6 +224,17 @@ $config['log_threshold'] = 0; */ $config['log_path'] = ''; +/* +|-------------------------------------------------------------------------- +| Log File Extension +|-------------------------------------------------------------------------- +| +| Leave this BLANK unless you would like to set something other than the default +| 'php'. For example you could change it to 'log'. +| +*/ +$config['log_file_extension'] = ''; + /* |-------------------------------------------------------------------------- | Date Format for Logs diff --git a/system/core/Log.php b/system/core/Log.php index 3b0a9213d..7572d2ac6 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -104,6 +104,8 @@ class CI_Log { $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; + $this->_log_ext = ($config['log_file_extension'] !== '') ? $config['log_file_extension'] : $this->_log_ext; + file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); if ( ! is_dir($this->_log_path) OR ! is_really_writable($this->_log_path)) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 893c3db61..7f12ca8a1 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -55,6 +55,7 @@ Release Date: Not Released - Updated *ip_address* database field lengths from 16 to 45 for supporting IPv6 address on :doc:`Trackback Library ` and :doc:`Captcha Helper `. - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. + - Added support for changing the file extension of CodeIgniter log files using $config['log_file_extension']. - Helpers -- cgit v1.2.3-24-g4f1b From 554d5dc6c1b9c6880a2fba150018c21ded8675c6 Mon Sep 17 00:00:00 2001 From: Tim Date: Wed, 13 Feb 2013 22:37:31 +0200 Subject: changes according to narfbg's request --- system/language/english/profiler_lang.php | 1 + system/libraries/Profiler.php | 6 +++--- user_guide_src/source/changelog.rst | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php index dfe034e79..68e794e79 100644 --- a/system/language/english/profiler_lang.php +++ b/system/language/english/profiler_lang.php @@ -46,6 +46,7 @@ $lang['profiler_no_memory'] = 'Memory Usage Unavailable'; $lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.'; $lang['profiler_section_hide'] = 'Hide'; $lang['profiler_section_show'] = 'Show'; +$lang['profiler_seconds'] = 'seconds'; /* End of file profiler_lang.php */ /* Location: ./system/language/english/profiler_lang.php */ \ No newline at end of file diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 67922d51c..a3fa61c7c 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,8 +238,8 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; - - $total_time = number_format(array_sum($db->query_times), 4) . 's'; + + $total_time = number_format(array_sum($db->query_times), 4).$this->CI->lang->line('profiler_seconds'); $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; @@ -555,4 +555,4 @@ class CI_Profiler { } /* End of file Profiler.php */ -/* Location: ./system/libraries/Profiler.php */ +/* Location: ./system/libraries/Profiler.php */ \ No newline at end of file diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 893c3db61..3969943f6 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -271,7 +271,9 @@ Release Date: Not Released - :doc:`Encryption Library ` changes include: - Added support for hashing algorithms other than SHA1 and MD5. - Removed previously deprecated ``sha1()`` method. - - :doc:`Profiler Library ` now also displays database object names. + - :doc:`Profiler Library ` changes include: + - Database object names displayed. + - The sum of all queries running times in seconds displayed. - :doc:`Migration Library ` changes include: - Added support for timestamp-based migrations (enabled by default). - Added ``$config['migration_type']`` to allow switching between *sequential* and *timestamp* migrations. -- cgit v1.2.3-24-g4f1b From 3224f077c37a054ea1995c07fe54bbe8b00e058a Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 14 Feb 2013 09:26:24 +0200 Subject: changes according to narfbg's request --- system/language/english/profiler_lang.php | 2 +- system/libraries/Profiler.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/system/language/english/profiler_lang.php b/system/language/english/profiler_lang.php index 68e794e79..0ed5f4cb0 100644 --- a/system/language/english/profiler_lang.php +++ b/system/language/english/profiler_lang.php @@ -46,7 +46,7 @@ $lang['profiler_no_memory'] = 'Memory Usage Unavailable'; $lang['profiler_no_profiles'] = 'No Profile data - all Profiler sections have been disabled.'; $lang['profiler_section_hide'] = 'Hide'; $lang['profiler_section_show'] = 'Show'; -$lang['profiler_seconds'] = 'seconds'; +$lang['profiler_seconds'] = 'seconds'; /* End of file profiler_lang.php */ /* Location: ./system/language/english/profiler_lang.php */ \ No newline at end of file diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index a3fa61c7c..ac8f6ba71 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,8 +238,8 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; - - $total_time = number_format(array_sum($db->query_times), 4).$this->CI->lang->line('profiler_seconds'); + + $total_time = number_format(array_sum($db->query_times), 4).' '.$this->CI->lang->line('profiler_seconds'); $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; -- cgit v1.2.3-24-g4f1b From 7219232771ee28f6f18248cfffd4fdffa570dfb7 Mon Sep 17 00:00:00 2001 From: maltzurra Date: Thu, 14 Feb 2013 11:12:37 +0100 Subject: Update system/core/Common.php Updated is_https() to avoid "NULL" or "0" values to set HTTPS. --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 258cd4967..136dd521c 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -343,7 +343,7 @@ if ( ! function_exists('is_https')) */ function is_https() { - return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); + return (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) === 'on'); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ \ No newline at end of file +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 2718f6c8a5bbae38b7a7f875c6eef40739ce8ee4 Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Thu, 14 Feb 2013 08:57:49 -0500 Subject: Update system/core/Log.php Added ltrim() as requested to strip '.' incase it's added by mistake. --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Log.php b/system/core/Log.php index 7572d2ac6..abc7b2494 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -104,7 +104,7 @@ class CI_Log { $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; - $this->_log_ext = ($config['log_file_extension'] !== '') ? $config['log_file_extension'] : $this->_log_ext; + $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'],'.') : $this->_log_ext; file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); -- cgit v1.2.3-24-g4f1b From fb8de247990189721bc7b2e48fe57ceb2db039f5 Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Thu, 14 Feb 2013 09:01:24 -0500 Subject: Update system/core/Log.php Don't print no script access code into log file if log file is not .php anymore. --- system/core/Log.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/system/core/Log.php b/system/core/Log.php index abc7b2494..7b2082a6c 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -162,7 +162,10 @@ class CI_Log { if ( ! file_exists($filepath)) { $newfile = TRUE; - $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; + if($this->_log_ext === 'php') + { + $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; + } } if ( ! $fp = @fopen($filepath, FOPEN_WRITE_CREATE)) -- cgit v1.2.3-24-g4f1b From de8766f0a538ef9c4d39dcd88efc9422b5170360 Mon Sep 17 00:00:00 2001 From: maltzurra Date: Thu, 14 Feb 2013 15:38:58 +0100 Subject: Update system/core/Common.php --- system/core/Common.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/system/core/Common.php b/system/core/Common.php index 136dd521c..0386ff37a 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -713,4 +713,5 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php +*/ -- cgit v1.2.3-24-g4f1b From beafe2fffbe5407f735caf2c286540d896d113f3 Mon Sep 17 00:00:00 2001 From: maltzurra Date: Thu, 14 Feb 2013 15:39:17 +0100 Subject: Update system/core/Common.php --- system/core/Common.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 0386ff37a..136dd521c 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -713,5 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php -*/ +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 3567246091195e035ea4c8d3b2915eb6b45ad5e2 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 15 Feb 2013 01:36:04 +0100 Subject: Various cosmetic fixes --- system/core/Loader.php | 2 +- system/core/URI.php | 2 +- system/libraries/Cart.php | 2 +- system/libraries/Form_validation.php | 2 +- system/libraries/Profiler.php | 2 +- system/libraries/Upload.php | 4 ++-- tests/codeigniter/core/URI_test.php | 2 +- user_guide_src/source/database/call_function.rst | 2 +- user_guide_src/source/general/controllers.rst | 4 ++-- user_guide_src/source/general/routing.rst | 2 +- user_guide_src/source/installation/upgrade_300.rst | 4 ++-- 11 files changed, 14 insertions(+), 14 deletions(-) diff --git a/system/core/Loader.php b/system/core/Loader.php index 00ca35199..9306a09ef 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -988,7 +988,7 @@ class CI_Loader { return $this->_ci_init_class($class, config_item('subclass_prefix'), $params, $object_name); } - // Lets search for the requested library file and load it. + // Let's search for the requested library file and load it. foreach ($this->_ci_library_paths as $path) { $filepath = $path.'libraries/'.$subdir.$class.'.php'; diff --git a/system/core/URI.php b/system/core/URI.php index 9b31a646b..b2286f032 100644 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -126,7 +126,7 @@ class CI_URI { return; } - // As a last ditch effort lets try using the $_GET array + // As a last ditch effort let's try using the $_GET array if (is_array($_GET) && count($_GET) === 1 && trim(key($_GET), '/') !== '') { $this->_set_uri_string(key($_GET)); diff --git a/system/libraries/Cart.php b/system/libraries/Cart.php index d64f6f042..b7b0697fb 100644 --- a/system/libraries/Cart.php +++ b/system/libraries/Cart.php @@ -365,7 +365,7 @@ class CI_Cart { */ protected function _save_cart() { - // Lets add up the individual prices and set the cart sub-total + // Let's add up the individual prices and set the cart sub-total $this->_cart_contents['total_items'] = $this->_cart_contents['cart_total'] = 0; foreach ($this->_cart_contents as $key => $val) { diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php index 4cf4ecae0..172e799f6 100644 --- a/system/libraries/Form_validation.php +++ b/system/libraries/Form_validation.php @@ -356,7 +356,7 @@ class CI_Form_validation { */ public function error_string($prefix = '', $suffix = '') { - // No errrors, validation passes! + // No errors, validation passes! if (count($this->_error_array) === 0) { return ''; diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index ac8f6ba71..36e0431b2 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,7 +238,7 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; - + $total_time = number_format(array_sum($db->query_times), 4).' '.$this->CI->lang->line('profiler_seconds'); $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 814ea68a4..acd76b03b 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -430,7 +430,7 @@ class CI_Upload { } else { - // An extension was provided, lets have it! + // An extension was provided, let's have it! $this->file_ext = $this->get_extension($this->_file_name_override); } @@ -1050,7 +1050,7 @@ class CI_Upload { // ]/i', $opening_bytes); } diff --git a/tests/codeigniter/core/URI_test.php b/tests/codeigniter/core/URI_test.php index e2deabe51..7fa0e6265 100644 --- a/tests/codeigniter/core/URI_test.php +++ b/tests/codeigniter/core/URI_test.php @@ -91,7 +91,7 @@ class URI_test extends CI_TestCase { public function test_explode_segments() { - // Lets test the function's ability to clean up this mess + // Let's test the function's ability to clean up this mess $uris = array( 'test/uri' => array('test', 'uri'), '/test2/uri2' => array('test2', 'uri2'), diff --git a/user_guide_src/source/database/call_function.rst b/user_guide_src/source/database/call_function.rst index 9890fc453..83fc870d0 100644 --- a/user_guide_src/source/database/call_function.rst +++ b/user_guide_src/source/database/call_function.rst @@ -7,7 +7,7 @@ $this->db->call_function(); This function enables you to call PHP database functions that are not natively included in CodeIgniter, in a platform independent manner. For -example, lets say you want to call the mysql_get_client_info() +example, let's say you want to call the mysql_get_client_info() function, which is **not** natively supported by CodeIgniter. You could do so like this:: diff --git a/user_guide_src/source/general/controllers.rst b/user_guide_src/source/general/controllers.rst index 729b08417..8cfb012a0 100644 --- a/user_guide_src/source/general/controllers.rst +++ b/user_guide_src/source/general/controllers.rst @@ -108,7 +108,7 @@ Passing URI Segments to your methods If your URI contains more then two segments they will be passed to your method as parameters. -For example, lets say you have a URI like this:: +For example, let's say you have a URI like this:: example.com/index.php/products/shoes/sandals/123 @@ -267,7 +267,7 @@ Simply create folders within your *application/controllers/* directory and place your controller classes within them. .. note:: When using this feature the first segment of your URI must - specify the folder. For example, lets say you have a controller located + specify the folder. For example, let's say you have a controller located here:: application/controllers/products/shoes.php diff --git a/user_guide_src/source/general/routing.rst b/user_guide_src/source/general/routing.rst index ed21a6109..0c6dfe888 100644 --- a/user_guide_src/source/general/routing.rst +++ b/user_guide_src/source/general/routing.rst @@ -12,7 +12,7 @@ In some instances, however, you may want to remap this relationship so that a different class/method can be called instead of the one corresponding to the URL. -For example, lets say you want your URLs to have this prototype:: +For example, let's say you want your URLs to have this prototype:: example.com/product/1/ example.com/product/2/ diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 2d125a71a..a3ea01d02 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -129,9 +129,9 @@ The above files should respectively be renamed to the following: application/libraries/MY_Email.php application/core/MY_Log.php -**************************************************************************** +***************************************************************************** Step 10: Check the calls to Array Helper's element() and elements() functions -**************************************************************************** +***************************************************************************** The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. -- cgit v1.2.3-24-g4f1b From 8d8636778ac600176772c4d54321a1e0842e5b07 Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Fri, 15 Feb 2013 09:06:11 -0500 Subject: Update system/core/Log.php Added a space after the comma on the ltrim(). --- system/core/Log.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/core/Log.php b/system/core/Log.php index 7b2082a6c..2a4728dc4 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -104,7 +104,7 @@ class CI_Log { $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; - $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'],'.') : $this->_log_ext; + $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'], '.') : $this->_log_ext; file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); -- cgit v1.2.3-24-g4f1b From ce6f43b7120a184aa0cff0bdb90fa3d7f032e14b Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Tue, 12 Feb 2013 16:58:38 -0500 Subject: Update system/core/Common.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If using nginx instead of apache by default nginx will not populate the $_SERVER['HTTPS'] value.  This change allows falling back to checking the port number of the request to determine if your on SSL or not. The other option is adding the following to your nginx config. fastcgi_param HTTPS on; #some php apps require this to detent https --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 258cd4967..b9c872748 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -343,7 +343,7 @@ if ( ! function_exists('is_https')) */ function is_https() { - return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); + return ( ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ) || ($_SERVER["SERVER_PORT"] === '443') ); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ \ No newline at end of file +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 614cc1c384b84801428f9823007586584af00653 Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 11:45:20 -0500 Subject: Revert "Update system/core/Common.php" This reverts commit 8af05ac97513764cc539919e179794df87352c30. --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index b9c872748..258cd4967 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -343,7 +343,7 @@ if ( ! function_exists('is_https')) */ function is_https() { - return ( ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ) || ($_SERVER["SERVER_PORT"] === '443') ); + return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b0607703b32ec790cc300e9f77a18ea17ab6d7dd Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 11:47:02 -0500 Subject: Revert "Revert "Update system/core/Common.php"" This reverts commit 3de57eaea8510ea9cfd70f063565c24904669c4c. --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index 258cd4967..b9c872748 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -343,7 +343,7 @@ if ( ! function_exists('is_https')) */ function is_https() { - return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); + return ( ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ) || ($_SERVER["SERVER_PORT"] === '443') ); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ \ No newline at end of file +/* Location: ./system/core/Common.php */ -- cgit v1.2.3-24-g4f1b From 6f19fd770b67804797c55d47c1c5f5fcb3a37b2e Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 11:47:02 -0500 Subject: Revert "Update system/core/Log.php" This reverts commit bbc6ab4736a896be83e3e3d5f8856374ffa2984c. --- system/core/Log.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/system/core/Log.php b/system/core/Log.php index 2a4728dc4..0749de8ba 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -71,13 +71,6 @@ class CI_Log { * @var string */ protected $_date_fmt = 'Y-m-d H:i:s'; - - /** - * Log file extension - * - * @var string - */ - protected $_log_ext = 'php'; /** * Whether or not the logger can write to the log files @@ -156,7 +149,7 @@ class CI_Log { return FALSE; } - $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_log_ext; + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; $message = ''; if ( ! file_exists($filepath)) @@ -191,4 +184,4 @@ class CI_Log { } /* End of file Log.php */ -/* Location: ./system/core/Log.php */ +/* Location: ./system/core/Log.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 62f7cdf3a6f5d701430267ef9ba9bfd92650deab Mon Sep 17 00:00:00 2001 From: Chris Passas Date: Wed, 13 Feb 2013 11:47:45 -0500 Subject: Revert "Update system/core/Common.php" This reverts commit 8af05ac97513764cc539919e179794df87352c30. --- system/core/Common.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/core/Common.php b/system/core/Common.php index b9c872748..258cd4967 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -343,7 +343,7 @@ if ( ! function_exists('is_https')) */ function is_https() { - return ( ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ) || ($_SERVER["SERVER_PORT"] === '443') ); + return ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off'); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a107a0fd79d0ee5f6292138a76398ed390041710 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Feb 2013 22:30:31 +0200 Subject: Fix some stuff from recent pull requests --- application/config/config.php | 7 +++++-- system/core/Common.php | 6 +++--- system/core/Log.php | 24 +++++++++++++++++------- system/libraries/Profiler.php | 3 +-- user_guide_src/source/changelog.rst | 6 +++--- 5 files changed, 29 insertions(+), 17 deletions(-) diff --git a/application/config/config.php b/application/config/config.php index 6f597b1e2..0608348c6 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -229,8 +229,11 @@ $config['log_path'] = ''; | Log File Extension |-------------------------------------------------------------------------- | -| Leave this BLANK unless you would like to set something other than the default -| 'php'. For example you could change it to 'log'. +| The default filename extension for log files. The default 'php' allows for +| protecting the log files via basic scripting, when they are to be stored +| under a publicly accessible directory. +| +| Note: Leaving it blank will default to 'php'. | */ $config['log_file_extension'] = ''; diff --git a/system/core/Common.php b/system/core/Common.php index 136dd521c..f8c1290f5 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -414,7 +414,7 @@ if ( ! function_exists('log_message')) function log_message($level = 'error', $message, $php_error = FALSE) { static $_log, $_log_threshold; - + if ($_log_threshold === NULL) { $_log_threshold = config_item('log_threshold'); @@ -429,7 +429,7 @@ if ( ! function_exists('log_message')) { $_log =& load_class('Log', 'core'); } - + $_log->write_log($level, $message, $php_error); } } @@ -713,4 +713,4 @@ if ( ! function_exists('function_usable')) } /* End of file Common.php */ -/* Location: ./system/core/Common.php */ +/* Location: ./system/core/Common.php */ \ No newline at end of file diff --git a/system/core/Log.php b/system/core/Log.php index 0749de8ba..a84d3dc22 100644 --- a/system/core/Log.php +++ b/system/core/Log.php @@ -72,6 +72,13 @@ class CI_Log { */ protected $_date_fmt = 'Y-m-d H:i:s'; + /** + * Filename extension + * + * @var string + */ + protected $_file_ext; + /** * Whether or not the logger can write to the log files * @@ -86,8 +93,10 @@ class CI_Log { */ protected $_levels = array('ERROR' => 1, 'DEBUG' => 2, 'INFO' => 3, 'ALL' => 4); + // -------------------------------------------------------------------- + /** - * Initialize Logging class + * Class constructor * * @return void */ @@ -96,8 +105,8 @@ class CI_Log { $config =& get_config(); $this->_log_path = ($config['log_path'] !== '') ? $config['log_path'] : APPPATH.'logs/'; - - $this->_log_ext = ($config['log_file_extension'] !== '') ? ltrim($config['log_file_extension'], '.') : $this->_log_ext; + $this->_file_ext = (isset($config['log_file_extension']) && $config['log_file_extension'] !== '') + ? ltrim($config['log_file_extension'], '.') : 'php'; file_exists($this->_log_path) OR mkdir($this->_log_path, DIR_WRITE_MODE, TRUE); @@ -149,15 +158,16 @@ class CI_Log { return FALSE; } - $filepath = $this->_log_path.'log-'.date('Y-m-d').'.php'; - $message = ''; + $filepath = $this->_log_path.'log-'.date('Y-m-d').'.'.$this->_file_ext; + $message = ''; if ( ! file_exists($filepath)) { $newfile = TRUE; - if($this->_log_ext === 'php') + // Only add protection to php files + if ($this->_file_ext === 'php') { - $message .= '<'."?php defined('BASEPATH') OR exit('No direct script access allowed'); ?".">\n\n"; + $message .= "\n\n"; } } diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php index 36e0431b2..470688fdc 100644 --- a/system/libraries/Profiler.php +++ b/system/libraries/Profiler.php @@ -238,7 +238,6 @@ class CI_Profiler { foreach ($dbs as $name => $db) { $hide_queries = (count($db->queries) > $this->_query_toggle_count) ? ' display:none' : ''; - $total_time = number_format(array_sum($db->query_times), 4).' '.$this->CI->lang->line('profiler_seconds'); $show_hide_js = '('.$this->CI->lang->line('profiler_section_hide').')'; @@ -252,7 +251,7 @@ class CI_Profiler { ."\n" .'  '.$this->CI->lang->line('profiler_database') .':  '.$db->database.' ('.$name.')   '.$this->CI->lang->line('profiler_queries') - .': '.count($db->queries).'('.$total_time.')'.'  '.$show_hide_js."\n\n\n" + .': '.count($db->queries).' ('.$total_time.')  '.$show_hide_js."\n\n\n" .'
\n"; if (count($db->queries) === 0) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 140fda8e7..8d3f3705d 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -55,7 +55,7 @@ Release Date: Not Released - Updated *ip_address* database field lengths from 16 to 45 for supporting IPv6 address on :doc:`Trackback Library ` and :doc:`Captcha Helper `. - Removed *cheatsheets* and *quick_reference* PDFs from the documentation. - Added availability checks where usage of dangerous functions like ``eval()`` and ``exec()`` is required. - - Added support for changing the file extension of CodeIgniter log files using $config['log_file_extension']. + - Added support for changing the file extension of log files using ``$config['log_file_extension']``. - Helpers @@ -273,8 +273,8 @@ Release Date: Not Released - Added support for hashing algorithms other than SHA1 and MD5. - Removed previously deprecated ``sha1()`` method. - :doc:`Profiler Library ` changes include: - - Database object names displayed. - - The sum of all queries running times in seconds displayed. + - Database object names are now being displayed. + - The sum of all queries running times in seconds is now being displayed. - :doc:`Migration Library ` changes include: - Added support for timestamp-based migrations (enabled by default). - Added ``$config['migration_type']`` to allow switching between *sequential* and *timestamp* migrations. -- cgit v1.2.3-24-g4f1b From 99ba3a26973848604719db08bbcafbfa82ca087f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 15 Feb 2013 22:42:22 +0200 Subject: Fix #2247 --- system/helpers/form_helper.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index f343b6c71..d6e3e85fa 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -228,13 +228,10 @@ if ( ! function_exists('form_upload')) */ function form_upload($data = '', $value = '', $extra = '') { - if ( ! is_array($data)) - { - $data = array('name' => $data); - } - + $default = array('type' => 'file', 'name' => ''); + is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; - return form_input($data, $value, $extra); + return '\n"; } } -- cgit v1.2.3-24-g4f1b From 687742109d5e8f06eadb1607501e5a94163aa902 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sat, 16 Feb 2013 02:01:47 -0500 Subject: Add the Project Name to the Composer File. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 7d60020c3..141ce2bfb 100644 --- a/composer.json +++ b/composer.json @@ -1,4 +1,5 @@ { + "name" : "EllisLab/CodeIgniter", "require": { "mikey179/vfsStream": "*" }, -- cgit v1.2.3-24-g4f1b From d20ed1dbc3b2e3f3b1dd60325f95fff745bfebbb Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sat, 16 Feb 2013 02:03:20 -0500 Subject: Lowercase the project name as uppercase letters are not allowed. --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 141ce2bfb..b48f8c118 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name" : "EllisLab/CodeIgniter", + "name" : "ellislab/codeigniter", "require": { "mikey179/vfsStream": "*" }, "require-dev": { - "phpunit/phpunit": "*" - } + "phpunit/phpunit": "*" + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 0fc08356b982807750464a7695c8fba47599d32e Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sat, 16 Feb 2013 02:52:00 -0500 Subject: Require at least PHP 5.1.6. --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index b48f8c118..bcab60f23 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name" : "ellislab/codeigniter", "require": { + "php": ">=5.1.6", "mikey179/vfsStream": "*" }, "require-dev": { -- cgit v1.2.3-24-g4f1b From 7a8db6506dfad2a8dbb7b9ba09133c8c0152d6e8 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sat, 16 Feb 2013 10:51:52 -0500 Subject: Update the required version of PHP to 5.2.4 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index bcab60f23..c13ac5aca 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name" : "ellislab/codeigniter", "require": { - "php": ">=5.1.6", + "php": ">=5.2.4", "mikey179/vfsStream": "*" }, "require-dev": { -- cgit v1.2.3-24-g4f1b From cf22557383fea89906633b8034ff9f08eb498621 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 01:08:04 +0530 Subject: Added keep-alive connection to SMTP. Fixed socket read/write timeouts. Added PHP useragent --- system/libraries/Email.php | 524 +++++++++++++++++++++++++-------------------- 1 file changed, 290 insertions(+), 234 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 997757b0a..36cebfab5 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -94,6 +94,13 @@ class CI_Email { * @var int */ public $smtp_timeout = 5; + + /** + * STMP Persistent connection + * + * @var bool + */ + public $smtp_keepalive = FALSE; /** * SMTP Encryption @@ -399,6 +406,19 @@ class CI_Email { log_message('debug', 'Email Class Initialized'); } + + // -------------------------------------------------------------------- + + /** + * Destructor - Releases Resources + * + * @return void + */ + function __destruct() + { + if(is_resource($this->_smtp_connect)) + $this->_send_command('quit'); + } // -------------------------------------------------------------------- @@ -770,6 +790,23 @@ class CI_Email { // -------------------------------------------------------------------- + /** + * Set Useragent + * + * @param string + * @return void + */ + public function set_useragent($type = '') + { + if( ! $type) + $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])? $_SERVER['HTTP_USER_AGENT'] : 'PHP/'.phpversion(); + else + $this->useragent = $type; + return $this; + } + + // -------------------------------------------------------------------- + /** * Set Wordwrap * @@ -1766,241 +1803,260 @@ class CI_Email { * @return bool */ protected function _send_with_smtp() - { - if ($this->smtp_host === '') - { - $this->_set_error_message('lang:email_no_hostname'); - return FALSE; - } - - if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) - { - return FALSE; - } - - $this->_send_command('from', $this->clean_email($this->_headers['From'])); - - foreach ($this->_recipients as $val) - { - $this->_send_command('to', $val); - } - - if (count($this->_cc_array) > 0) - { - foreach ($this->_cc_array as $val) - { - if ($val !== '') - { - $this->_send_command('to', $val); - } - } - } - - if (count($this->_bcc_array) > 0) - { - foreach ($this->_bcc_array as $val) - { - if ($val !== '') - { - $this->_send_command('to', $val); - } - } - } - - $this->_send_command('data'); - - // perform dot transformation on any lines that begin with a dot - $this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody)); - - $this->_send_data('.'); - - $reply = $this->_get_smtp_data(); - - $this->_set_error_message($reply); - - if (strpos($reply, '250') !== 0) - { - $this->_set_error_message('lang:email_smtp_error', $reply); - return FALSE; - } - - $this->_send_command('quit'); - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * SMTP Connect - * - * @return string - */ - protected function _smtp_connect() - { - $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; - - $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, - $this->smtp_port, - $errno, - $errstr, - $this->smtp_timeout); - - if ( ! is_resource($this->_smtp_connect)) - { - $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); - return FALSE; - } - - $this->_set_error_message($this->_get_smtp_data()); - - if ($this->smtp_crypto === 'tls') - { - $this->_send_command('hello'); - $this->_send_command('starttls'); - - $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); - - if ($crypto !== TRUE) - { - $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); - return FALSE; - } - } - - return $this->_send_command('hello'); - } - - // -------------------------------------------------------------------- + { + if ($this->smtp_host === '') + { + $this->_set_error_message('lang:email_no_hostname'); + return FALSE; + } + + if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) + { + return FALSE; + } + + $this->_send_command('from', $this->clean_email($this->_headers['From'])); + + foreach ($this->_recipients as $val) + { + $this->_send_command('to', $val); + } + + if (count($this->_cc_array) > 0) + { + foreach ($this->_cc_array as $val) + { + if ($val !== '') + { + $this->_send_command('to', $val); + } + } + } + + if (count($this->_bcc_array) > 0) + { + foreach ($this->_bcc_array as $val) + { + if ($val !== '') + { + $this->_send_command('to', $val); + } + } + } + + $this->_send_command('data'); + + // perform dot transformation on any lines that begin with a dot + $this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody)); + + $this->_send_data('.'); + + $reply = $this->_get_smtp_data(); + + $this->_set_error_message($reply); + + if (strpos($reply, '250') !== 0) + { + $this->_set_error_message('lang:email_smtp_error', $reply); + return FALSE; + } + + if($this->smtp_keepalive) + $this->_send_command('reset'); + else + $this->_send_command('quit'); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * SMTP Connect + * + * @param bool + * @return string + */ + protected function _smtp_connect($force=FALSE) + { + if( ! is_resource($this->_smtp_connect) || $force) + { + $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; + + $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, + $this->smtp_port, + $errno, + $errstr, + $this->smtp_timeout); + + if ( ! is_resource($this->_smtp_connect)) + { + $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); + return FALSE; + } + + stream_set_timeout($this->_smtp_connect, $this->smtp_timeout); + $this->_set_error_message($this->_get_smtp_data()); + + if ($this->smtp_crypto === 'tls') + { + $this->_send_command('hello'); + $this->_send_command('starttls'); + + $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); + + if ($crypto !== TRUE) + { + $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); + return FALSE; + } + } + + return $this->_send_command('hello'); + } + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Send SMTP command + * + * @param string + * @param string + * @return string + */ + protected function _send_command($cmd, $data = '') + { + switch ($cmd) + { + case 'hello' : + + if ($this->_smtp_auth OR $this->_get_encoding() === '8bit') + { + $this->_send_data('EHLO '.$this->_get_hostname()); + } + else + { + $this->_send_data('HELO '.$this->_get_hostname()); + } + + $resp = 250; + break; + case 'starttls' : + + $this->_send_data('STARTTLS'); + $resp = 220; + break; + case 'from' : + + $this->_send_data('MAIL FROM:<'.$data.'>'); + $resp = 250; + break; + case 'to' : + + if ($this->dsn) + { + $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + } + else + { + $this->_send_data('RCPT TO:<'.$data.'>'); + } + + $resp = 250; + break; + case 'data' : + + $this->_send_data('DATA'); + $resp = 354; + break; + case 'reset': + + $this->_send_data('RSET'); + + $resp = 250; + break; + case 'quit' : + + $this->_send_data('QUIT'); + $resp = 221; + break; + } + + $reply = $this->_get_smtp_data(); + + $this->_debug_msg[] = '
'.$cmd.': '.$reply.'
'; + + if ((int) substr($reply, 0, 3) !== $resp) + { + $this->_set_error_message('lang:email_smtp_error', $reply); + return FALSE; + } + + if ($cmd === 'quit') + { + fclose($this->_smtp_connect); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * SMTP Authenticate + * + * @return bool + */ + protected function _smtp_authenticate() + { + if ( ! $this->_smtp_auth) + { + return TRUE; + } + + if ($this->smtp_user === '' && $this->smtp_pass === '') + { + $this->_set_error_message('lang:email_no_smtp_unpw'); + return FALSE; + } + + $this->_send_data('AUTH LOGIN'); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '503') === 0) // Already authenticated + return TRUE; + + if (strpos($reply, '334') !== 0) + { + $this->_set_error_message('lang:email_failed_smtp_login', $reply); + return FALSE; + } + + $this->_send_data(base64_encode($this->smtp_user)); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '334') !== 0) + { + $this->_set_error_message('lang:email_smtp_auth_un', $reply); + return FALSE; + } + + $this->_send_data(base64_encode($this->smtp_pass)); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '235') !== 0) + { + $this->_set_error_message('lang:email_smtp_auth_pw', $reply); + return FALSE; + } - /** - * Send SMTP command - * - * @param string - * @param string - * @return string - */ - protected function _send_command($cmd, $data = '') - { - switch ($cmd) - { - case 'hello' : - - if ($this->_smtp_auth OR $this->_get_encoding() === '8bit') - { - $this->_send_data('EHLO '.$this->_get_hostname()); - } - else - { - $this->_send_data('HELO '.$this->_get_hostname()); - } - - $resp = 250; - break; - case 'starttls' : - - $this->_send_data('STARTTLS'); - $resp = 220; - break; - case 'from' : - - $this->_send_data('MAIL FROM:<'.$data.'>'); - $resp = 250; - break; - case 'to' : - - if ($this->dsn) - { - $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); - } - else - { - $this->_send_data('RCPT TO:<'.$data.'>'); - } - - $resp = 250; - break; - case 'data' : - - $this->_send_data('DATA'); - $resp = 354; - break; - case 'quit' : - - $this->_send_data('QUIT'); - $resp = 221; - break; - } - - $reply = $this->_get_smtp_data(); - - $this->_debug_msg[] = '
'.$cmd.': '.$reply.'
'; - - if ((int) substr($reply, 0, 3) !== $resp) - { - $this->_set_error_message('lang:email_smtp_error', $reply); - return FALSE; - } - - if ($cmd === 'quit') - { - fclose($this->_smtp_connect); - } - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * SMTP Authenticate - * - * @return bool - */ - protected function _smtp_authenticate() - { - if ( ! $this->_smtp_auth) - { - return TRUE; - } - - if ($this->smtp_user === '' && $this->smtp_pass === '') - { - $this->_set_error_message('lang:email_no_smtp_unpw'); - return FALSE; - } - - $this->_send_data('AUTH LOGIN'); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '334') !== 0) - { - $this->_set_error_message('lang:email_failed_smtp_login', $reply); - return FALSE; - } - - $this->_send_data(base64_encode($this->smtp_user)); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '334') !== 0) - { - $this->_set_error_message('lang:email_smtp_auth_un', $reply); - return FALSE; - } - - $this->_send_data(base64_encode($this->smtp_pass)); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '235') !== 0) - { - $this->_set_error_message('lang:email_smtp_auth_pw', $reply); - return FALSE; - } - - return TRUE; - } + return TRUE; + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 06ddcf05c6861a908a0b3b57c6ba4a05bb82e10a Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 18 Feb 2013 08:52:05 +0800 Subject: Fixed form helper variable error Signed-off-by: Bo-Yi Wu --- system/helpers/form_helper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php index d6e3e85fa..692909c79 100644 --- a/system/helpers/form_helper.php +++ b/system/helpers/form_helper.php @@ -228,7 +228,7 @@ if ( ! function_exists('form_upload')) */ function form_upload($data = '', $value = '', $extra = '') { - $default = array('type' => 'file', 'name' => ''); + $defaults = array('type' => 'file', 'name' => ''); is_array($data) OR $data = array('name' => $data); $data['type'] = 'file'; return '\n"; -- cgit v1.2.3-24-g4f1b From e8f15935a4f576d219708f495c19f234ac5a238a Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sun, 17 Feb 2013 23:20:54 -0500 Subject: Move mikey179/vfsStream to only be required on dev --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c13ac5aca..bf3b3d22b 100644 --- a/composer.json +++ b/composer.json @@ -2,9 +2,9 @@ "name" : "ellislab/codeigniter", "require": { "php": ">=5.2.4", - "mikey179/vfsStream": "*" }, "require-dev": { + "mikey179/vfsStream": "*" "phpunit/phpunit": "*" } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From cbe553072812de5cbfbdf4603d18d8b1cad4e453 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Sun, 17 Feb 2013 23:27:16 -0500 Subject: Fix a JSON validation error --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index bf3b3d22b..54f305e89 100644 --- a/composer.json +++ b/composer.json @@ -1,10 +1,10 @@ { "name" : "ellislab/codeigniter", "require": { - "php": ">=5.2.4", + "php": ">=5.2.4" }, "require-dev": { - "mikey179/vfsStream": "*" + "mikey179/vfsStream": "*", "phpunit/phpunit": "*" } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 59209deaf2467372ba0deef5a4266758b366ca70 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 17:02:13 +0530 Subject: Fixed tab-indentation. Made appropriate entries in changelog --- system/libraries/Email.php | 565 ++++++++++++++++++++++----------------------- 1 file changed, 282 insertions(+), 283 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 36cebfab5..7ea49a959 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -96,11 +96,11 @@ class CI_Email { public $smtp_timeout = 5; /** - * STMP Persistent connection - * - * @var bool - */ - public $smtp_keepalive = FALSE; + * SMTP persistent connection + * + * @var bool + */ + public $smtp_keepalive = FALSE; /** * SMTP Encryption @@ -406,19 +406,19 @@ class CI_Email { log_message('debug', 'Email Class Initialized'); } - + // -------------------------------------------------------------------- /** - * Destructor - Releases Resources - * - * @return void - */ - function __destruct() - { - if(is_resource($this->_smtp_connect)) - $this->_send_command('quit'); - } + * Destructor - Releases Resources + * + * @return void + */ + public function __destruct() + { + if(is_resource($this->_smtp_connect)) + $this->_send_command('quit'); + } // -------------------------------------------------------------------- @@ -789,22 +789,22 @@ class CI_Email { } // -------------------------------------------------------------------- - - /** - * Set Useragent - * - * @param string - * @return void - */ - public function set_useragent($type = '') - { - if( ! $type) - $this->useragent = isset($_SERVER['HTTP_USER_AGENT'])? $_SERVER['HTTP_USER_AGENT'] : 'PHP/'.phpversion(); - else - $this->useragent = $type; - return $this; - } + /** + * Set Useragent + * + * @param string + * @return void + */ + public function set_useragent($type = '') + { + if( ! $type) + $this->useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'PHP/'.phpversion(); + else + $this->useragent = $type; + return $this; + } + // -------------------------------------------------------------------- /** @@ -1803,260 +1803,259 @@ class CI_Email { * @return bool */ protected function _send_with_smtp() - { - if ($this->smtp_host === '') - { - $this->_set_error_message('lang:email_no_hostname'); - return FALSE; - } - - if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) - { - return FALSE; - } - - $this->_send_command('from', $this->clean_email($this->_headers['From'])); - - foreach ($this->_recipients as $val) - { - $this->_send_command('to', $val); - } - - if (count($this->_cc_array) > 0) - { - foreach ($this->_cc_array as $val) - { - if ($val !== '') - { - $this->_send_command('to', $val); - } - } - } - - if (count($this->_bcc_array) > 0) - { - foreach ($this->_bcc_array as $val) - { - if ($val !== '') - { - $this->_send_command('to', $val); - } - } - } - - $this->_send_command('data'); - - // perform dot transformation on any lines that begin with a dot - $this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody)); - - $this->_send_data('.'); - - $reply = $this->_get_smtp_data(); - - $this->_set_error_message($reply); - - if (strpos($reply, '250') !== 0) - { - $this->_set_error_message('lang:email_smtp_error', $reply); - return FALSE; - } - - if($this->smtp_keepalive) - $this->_send_command('reset'); - else - $this->_send_command('quit'); - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * SMTP Connect - * - * @param bool - * @return string - */ - protected function _smtp_connect($force=FALSE) - { - if( ! is_resource($this->_smtp_connect) || $force) - { - $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; - - $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, - $this->smtp_port, - $errno, - $errstr, - $this->smtp_timeout); - - if ( ! is_resource($this->_smtp_connect)) - { - $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); - return FALSE; - } - - stream_set_timeout($this->_smtp_connect, $this->smtp_timeout); - $this->_set_error_message($this->_get_smtp_data()); - - if ($this->smtp_crypto === 'tls') - { - $this->_send_command('hello'); - $this->_send_command('starttls'); - - $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); - - if ($crypto !== TRUE) - { - $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); - return FALSE; - } - } - - return $this->_send_command('hello'); - } - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * Send SMTP command - * - * @param string - * @param string - * @return string - */ - protected function _send_command($cmd, $data = '') - { - switch ($cmd) - { - case 'hello' : - - if ($this->_smtp_auth OR $this->_get_encoding() === '8bit') - { - $this->_send_data('EHLO '.$this->_get_hostname()); - } - else - { - $this->_send_data('HELO '.$this->_get_hostname()); - } - - $resp = 250; - break; - case 'starttls' : - - $this->_send_data('STARTTLS'); - $resp = 220; - break; - case 'from' : - - $this->_send_data('MAIL FROM:<'.$data.'>'); - $resp = 250; - break; - case 'to' : - - if ($this->dsn) - { - $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); - } - else - { - $this->_send_data('RCPT TO:<'.$data.'>'); - } - - $resp = 250; - break; - case 'data' : - - $this->_send_data('DATA'); - $resp = 354; - break; - case 'reset': - - $this->_send_data('RSET'); - - $resp = 250; - break; - case 'quit' : - - $this->_send_data('QUIT'); - $resp = 221; - break; - } - - $reply = $this->_get_smtp_data(); - - $this->_debug_msg[] = '
'.$cmd.': '.$reply.'
'; - - if ((int) substr($reply, 0, 3) !== $resp) - { - $this->_set_error_message('lang:email_smtp_error', $reply); - return FALSE; - } - - if ($cmd === 'quit') - { - fclose($this->_smtp_connect); - } - - return TRUE; - } - - // -------------------------------------------------------------------- - - /** - * SMTP Authenticate - * - * @return bool - */ - protected function _smtp_authenticate() - { - if ( ! $this->_smtp_auth) - { - return TRUE; - } - - if ($this->smtp_user === '' && $this->smtp_pass === '') - { - $this->_set_error_message('lang:email_no_smtp_unpw'); - return FALSE; - } - - $this->_send_data('AUTH LOGIN'); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '503') === 0) // Already authenticated - return TRUE; - - if (strpos($reply, '334') !== 0) - { - $this->_set_error_message('lang:email_failed_smtp_login', $reply); - return FALSE; - } - - $this->_send_data(base64_encode($this->smtp_user)); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '334') !== 0) - { - $this->_set_error_message('lang:email_smtp_auth_un', $reply); - return FALSE; - } - - $this->_send_data(base64_encode($this->smtp_pass)); - - $reply = $this->_get_smtp_data(); - - if (strpos($reply, '235') !== 0) - { - $this->_set_error_message('lang:email_smtp_auth_pw', $reply); - return FALSE; - } + { + if ($this->smtp_host === '') + { + $this->_set_error_message('lang:email_no_hostname'); + return FALSE; + } + + if ( ! $this->_smtp_connect() OR ! $this->_smtp_authenticate()) + { + return FALSE; + } + + $this->_send_command('from', $this->clean_email($this->_headers['From'])); + + foreach ($this->_recipients as $val) + { + $this->_send_command('to', $val); + } + + if (count($this->_cc_array) > 0) + { + foreach ($this->_cc_array as $val) + { + if ($val !== '') + { + $this->_send_command('to', $val); + } + } + } - return TRUE; - } + if (count($this->_bcc_array) > 0) + { + foreach ($this->_bcc_array as $val) + { + if ($val !== '') + { + $this->_send_command('to', $val); + } + } + } + + $this->_send_command('data'); + + // perform dot transformation on any lines that begin with a dot + $this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody)); + + $this->_send_data('.'); + + $reply = $this->_get_smtp_data(); + + $this->_set_error_message($reply); + + if (strpos($reply, '250') !== 0) + { + $this->_set_error_message('lang:email_smtp_error', $reply); + return FALSE; + } + + if($this->smtp_keepalive) + $this->_send_command('reset'); + else + $this->_send_command('quit'); + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * SMTP Connect + * + * @param bool + * @return string + */ + protected function _smtp_connect($force=FALSE) + { + if( ! is_resource($this->_smtp_connect) || $force) + { + $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; + + $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, + $this->smtp_port, + $errno, + $errstr, + $this->smtp_timeout); + + if ( ! is_resource($this->_smtp_connect)) + { + $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); + return FALSE; + } + + stream_set_timeout($this->_smtp_connect, $this->smtp_timeout); + $this->_set_error_message($this->_get_smtp_data()); + + if ($this->smtp_crypto === 'tls') + { + $this->_send_command('hello'); + $this->_send_command('starttls'); + + $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); + + if ($crypto !== TRUE) + { + $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); + return FALSE; + } + } + + return $this->_send_command('hello'); + } + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * Send SMTP command + * + * @param string + * @param string + * @return string + */ + protected function _send_command($cmd, $data = '') + { + switch ($cmd) + { + case 'hello' : + + if ($this->_smtp_auth OR $this->_get_encoding() === '8bit') + { + $this->_send_data('EHLO '.$this->_get_hostname()); + } + else + { + $this->_send_data('HELO '.$this->_get_hostname()); + } + + $resp = 250; + break; + case 'starttls' : + + $this->_send_data('STARTTLS'); + $resp = 220; + break; + case 'from' : + + $this->_send_data('MAIL FROM:<'.$data.'>'); + $resp = 250; + break; + case 'to' : + + if ($this->dsn) + { + $this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data); + } + else + { + $this->_send_data('RCPT TO:<'.$data.'>'); + } + + $resp = 250; + break; + case 'data' : + + $this->_send_data('DATA'); + $resp = 354; + break; + case 'reset': + + $this->_send_data('RSET'); + $resp = 250; + break; + case 'quit' : + + $this->_send_data('QUIT'); + $resp = 221; + break; + } + + $reply = $this->_get_smtp_data(); + + $this->_debug_msg[] = '
'.$cmd.': '.$reply.'
'; + + if ((int) substr($reply, 0, 3) !== $resp) + { + $this->_set_error_message('lang:email_smtp_error', $reply); + return FALSE; + } + + if ($cmd === 'quit') + { + fclose($this->_smtp_connect); + } + + return TRUE; + } + + // -------------------------------------------------------------------- + + /** + * SMTP Authenticate + * + * @return bool + */ + protected function _smtp_authenticate() + { + if ( ! $this->_smtp_auth) + { + return TRUE; + } + + if ($this->smtp_user === '' && $this->smtp_pass === '') + { + $this->_set_error_message('lang:email_no_smtp_unpw'); + return FALSE; + } + + $this->_send_data('AUTH LOGIN'); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '503') !== 0) // Already authenticated + return TRUE; + + if (strpos($reply, '334') !== 0) + { + $this->_set_error_message('lang:email_failed_smtp_login', $reply); + return FALSE; + } + + $this->_send_data(base64_encode($this->smtp_user)); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '334') !== 0) + { + $this->_set_error_message('lang:email_smtp_auth_un', $reply); + return FALSE; + } + + $this->_send_data(base64_encode($this->smtp_pass)); + + $reply = $this->_get_smtp_data(); + + if (strpos($reply, '235') !== 0) + { + $this->_set_error_message('lang:email_smtp_auth_pw', $reply); + return FALSE; + } + + return TRUE; + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 9ecde434cf660da53c8887f4e768f37fdf64dac1 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 17:06:12 +0530 Subject: Clean up --- user_guide_src/source/changelog.rst | 3 +++ user_guide_src/source/libraries/email.rst | 1 + 2 files changed, 4 insertions(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 8d3f3705d..94f7f9e4a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -250,6 +250,8 @@ Release Date: Not Released - Added Redis driver. - Added a *key_prefix* option for cache IDs. - :doc:`Email library ` changes include: + - Added SMTP keepalive option to avoid opening the connection for each ``Email::send()``. Accessible as ``$smtp_keepalive``. + - Empty string passed into useragent will be set to the first valid value in ``$_SERVER['HTTP_USER_AGENT']`` or ``PHP/``. - Added custom filename to ``Email::attach()`` as ``$this->email->attach($filename, $disposition, $newname)``. - Added possibility to send attachment as buffer string in ``Email::attach()`` as ``$this->email->attach($buffer, $disposition, $newname, $mime)``. - Added dsn (delivery status notification) option. @@ -337,6 +339,7 @@ Release Date: Not Released Bug fixes for 3.0 ------------------ +- Fixed a bug (#2255, #2256) where ``smtp_timeout`` was not being applied to read and writes for the socket. - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. - Fixed a bug (#159, #163) that mishandled Query Builder nested transactions because _trans_depth was not getting incremented. diff --git a/user_guide_src/source/libraries/email.rst b/user_guide_src/source/libraries/email.rst index 7d468251c..a55f1895d 100644 --- a/user_guide_src/source/libraries/email.rst +++ b/user_guide_src/source/libraries/email.rst @@ -89,6 +89,7 @@ Preference Default Value Options Descript **smtp_pass** No Default None SMTP Password. **smtp_port** 25 None SMTP Port. **smtp_timeout** 5 None SMTP Timeout (in seconds). +**smtp_keepalive** FALSE TRUE or FALSE (boolean) Enable persistent SMTP connections. **smtp_crypto** No Default tls or ssl SMTP Encryption **wordwrap** TRUE TRUE or FALSE (boolean) Enable word-wrap. **wrapchars** 76 Character count to wrap at. -- cgit v1.2.3-24-g4f1b From 758f40c3d971837d739fa5bc47529bccc846dcfd Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 17:18:51 +0530 Subject: Fixed curly braces. Removed redundant method set_useragent() --- system/libraries/Email.php | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 7ea49a959..b0d0921eb 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -416,8 +416,10 @@ class CI_Email { */ public function __destruct() { - if(is_resource($this->_smtp_connect)) + if (is_resource($this->_smtp_connect)) + { $this->_send_command('quit'); + } } // -------------------------------------------------------------------- @@ -788,23 +790,6 @@ class CI_Email { return $this; } - // -------------------------------------------------------------------- - - /** - * Set Useragent - * - * @param string - * @return void - */ - public function set_useragent($type = '') - { - if( ! $type) - $this->useragent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : 'PHP/'.phpversion(); - else - $this->useragent = $type; - return $this; - } - // -------------------------------------------------------------------- /** @@ -1861,10 +1846,14 @@ class CI_Email { return FALSE; } - if($this->smtp_keepalive) + if ($this->smtp_keepalive) + { $this->_send_command('reset'); + } else + { $this->_send_command('quit'); + } return TRUE; } @@ -1879,7 +1868,7 @@ class CI_Email { */ protected function _smtp_connect($force=FALSE) { - if( ! is_resource($this->_smtp_connect) || $force) + if ( ! is_resource($this->_smtp_connect) || $force) { $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; @@ -2026,7 +2015,9 @@ class CI_Email { $reply = $this->_get_smtp_data(); if (strpos($reply, '503') !== 0) // Already authenticated + { return TRUE; + } if (strpos($reply, '334') !== 0) { -- cgit v1.2.3-24-g4f1b From 9892d4d36b4ccfc647e9490b3c2e24de8b44964a Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 17:26:52 +0530 Subject: Styleguide fixes --- user_guide_src/source/changelog.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 94f7f9e4a..3824092b6 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -249,9 +249,7 @@ Release Date: Not Released - Added Wincache driver. - Added Redis driver. - Added a *key_prefix* option for cache IDs. - - :doc:`Email library ` changes include: - - Added SMTP keepalive option to avoid opening the connection for each ``Email::send()``. Accessible as ``$smtp_keepalive``. - - Empty string passed into useragent will be set to the first valid value in ``$_SERVER['HTTP_USER_AGENT']`` or ``PHP/``. + - :doc:`Email library ` changes include: - Added custom filename to ``Email::attach()`` as ``$this->email->attach($filename, $disposition, $newname)``. - Added possibility to send attachment as buffer string in ``Email::attach()`` as ``$this->email->attach($buffer, $disposition, $newname, $mime)``. - Added dsn (delivery status notification) option. @@ -264,6 +262,7 @@ Release Date: Not Released - Removed unused protected method ``_get_ip()`` (:doc:`Input Library `'s ``ip_address()`` should be used anyway). - Internal method ``_prep_q_encoding()`` now utilizes PHP's *mbstring* and *iconv* extensions (when available) and no longer has a second (``$from``) argument. - Added an optional parameter to ``print_debugger()`` to allow specifying which parts of the message should be printed ('headers', 'subject', 'body'). + - Added SMTP keepalive option to avoid opening the connection for each ``Email::send()``. Accessible as ``$smtp_keepalive``. - :doc:`Pagination Library ` changes include: - Added support for the anchor "rel" attribute. - Added support for setting custom attributes. @@ -339,7 +338,6 @@ Release Date: Not Released Bug fixes for 3.0 ------------------ -- Fixed a bug (#2255, #2256) where ``smtp_timeout`` was not being applied to read and writes for the socket. - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. - Fixed a bug (#159, #163) that mishandled Query Builder nested transactions because _trans_depth was not getting incremented. @@ -488,6 +486,7 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. +- Fixed a bug (#2255, #2256) where ``smtp_timeout`` was not being applied to read and writes for the socket. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 193f0c76edbd85cf98ae730006b459c7c55a5b78 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 17:29:23 +0530 Subject: removed PR from the bug list --- system/libraries/Email.php | 2 +- user_guide_src/source/changelog.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index b0d0921eb..91c119e02 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1868,7 +1868,7 @@ class CI_Email { */ protected function _smtp_connect($force=FALSE) { - if ( ! is_resource($this->_smtp_connect) || $force) + if ( ! is_resource($this->_smtp_connect) OR $force) { $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 3824092b6..f1bb0c58e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -486,7 +486,7 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. -- Fixed a bug (#2255, #2256) where ``smtp_timeout`` was not being applied to read and writes for the socket. +- Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From a44e6913324bd47e17bfd4109fc65b699c508006 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 18:07:03 +0530 Subject: Removed the unused $force paramter in Email::_smtp_connect() --- system/libraries/Email.php | 58 +++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 91c119e02..1bf1da15e 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1863,47 +1863,47 @@ class CI_Email { /** * SMTP Connect * - * @param bool * @return string */ - protected function _smtp_connect($force=FALSE) + protected function _smtp_connect() { - if ( ! is_resource($this->_smtp_connect) OR $force) + if (is_resource($this->_smtp_connect)) { - $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; + return TRUE; + } - $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, - $this->smtp_port, - $errno, - $errstr, - $this->smtp_timeout); + $ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : NULL; - if ( ! is_resource($this->_smtp_connect)) - { - $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); - return FALSE; - } + $this->_smtp_connect = fsockopen($ssl.$this->smtp_host, + $this->smtp_port, + $errno, + $errstr, + $this->smtp_timeout); - stream_set_timeout($this->_smtp_connect, $this->smtp_timeout); - $this->_set_error_message($this->_get_smtp_data()); + if ( ! is_resource($this->_smtp_connect)) + { + $this->_set_error_message('lang:email_smtp_error', $errno.' '.$errstr); + return FALSE; + } - if ($this->smtp_crypto === 'tls') - { - $this->_send_command('hello'); - $this->_send_command('starttls'); + stream_set_timeout($this->_smtp_connect, $this->smtp_timeout); + $this->_set_error_message($this->_get_smtp_data()); - $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); + if ($this->smtp_crypto === 'tls') + { + $this->_send_command('hello'); + $this->_send_command('starttls'); - if ($crypto !== TRUE) - { - $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); - return FALSE; - } - } + $crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT); - return $this->_send_command('hello'); + if ($crypto !== TRUE) + { + $this->_set_error_message('lang:email_smtp_error', $this->_get_smtp_data()); + return FALSE; + } } - return TRUE; + + return $this->_send_command('hello'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 73c75cbfa066b4e72b8e691199ad964d1c2b3719 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Mon, 18 Feb 2013 18:11:03 +0530 Subject: removed a stray tab --- user_guide_src/source/changelog.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index f1bb0c58e..4e55182e5 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -249,7 +249,7 @@ Release Date: Not Released - Added Wincache driver. - Added Redis driver. - Added a *key_prefix* option for cache IDs. - - :doc:`Email library ` changes include: + - :doc:`Email library ` changes include: - Added custom filename to ``Email::attach()`` as ``$this->email->attach($filename, $disposition, $newname)``. - Added possibility to send attachment as buffer string in ``Email::attach()`` as ``$this->email->attach($buffer, $disposition, $newname, $mime)``. - Added dsn (delivery status notification) option. -- cgit v1.2.3-24-g4f1b From 9ee847d9cee7c8490f1078102b33fb8401e2d8dc Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:10:21 -0500 Subject: Set the --dev option for travis composer install command. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 070b23c8a..1f6a59530 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ env: before_script: - curl -s http://getcomposer.org/installer | php - - php composer.phar install + - php composer.phar install --dev - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -- cgit v1.2.3-24-g4f1b From 21e91c53a79e9e3394be58381e759c952500ecd8 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:18:25 -0500 Subject: Set the --no-progress option for travis composer install command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1f6a59530..e94f1af83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ env: before_script: - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev + - php composer.phar install --dev --no-progress - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -- cgit v1.2.3-24-g4f1b From 1396a958a5b96cc6c617ae725034fa58542acd25 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:23:44 -0500 Subject: Attempt to get travis to work by adding php-invoker --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 54f305e89..ec34372ac 100644 --- a/composer.json +++ b/composer.json @@ -5,6 +5,7 @@ }, "require-dev": { "mikey179/vfsStream": "*", - "phpunit/phpunit": "*" + "phpunit/phpunit": "*", + "phpunit/php-invoker": ">=1.1.0,<1.2.0" } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bcc411efa6027f409eaf59d1d32422013e9c20da Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:32:13 -0500 Subject: Revert "Attempt to get travis to work by adding php-invoker" This reverts commit 1396a958a5b96cc6c617ae725034fa58542acd25. --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ec34372ac..54f305e89 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,6 @@ }, "require-dev": { "mikey179/vfsStream": "*", - "phpunit/phpunit": "*", - "phpunit/php-invoker": ">=1.1.0,<1.2.0" + "phpunit/phpunit": "*" } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From acd76670ebdd1d5775259af1dcdf8d5f17ec5738 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:35:45 -0500 Subject: Simplify the composer command --- .travis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e94f1af83..3b2f6bd57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,7 @@ env: - DB=pdo/sqlite before_script: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install --dev --no-progress + - composer install --dev - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -- cgit v1.2.3-24-g4f1b From b4a23d2af5309d5b264f3f12c272e93667b87aca Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:46:47 -0500 Subject: See how many errors are produced when no dependencies are included --- composer.json | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 54f305e89..48aea9ff9 100644 --- a/composer.json +++ b/composer.json @@ -2,9 +2,5 @@ "name" : "ellislab/codeigniter", "require": { "php": ">=5.2.4" - }, - "require-dev": { - "mikey179/vfsStream": "*", - "phpunit/phpunit": "*" - } + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b2834114746585b60a490992a02c1b136363e791 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 17:52:14 -0500 Subject: vfsStream is required for travis --- composer.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 48aea9ff9..e21aaed2e 100644 --- a/composer.json +++ b/composer.json @@ -2,5 +2,8 @@ "name" : "ellislab/codeigniter", "require": { "php": ">=5.2.4" - } + }, + "require-dev": { + "mikey179/vfsStream": "*" + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From eb5991ccd0686d15615bff3a730a641889063943 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Mon, 18 Feb 2013 18:04:45 -0500 Subject: Revert all changes to see if travis just doesn't like me. --- .travis.yml | 3 ++- composer.json | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3b2f6bd57..070b23c8a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,8 @@ env: - DB=pdo/sqlite before_script: - - composer install --dev + - curl -s http://getcomposer.org/installer | php + - php composer.phar install - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" diff --git a/composer.json b/composer.json index e21aaed2e..7d60020c3 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,8 @@ { - "name" : "ellislab/codeigniter", "require": { - "php": ">=5.2.4" + "mikey179/vfsStream": "*" }, "require-dev": { - "mikey179/vfsStream": "*" - } + "phpunit/phpunit": "*" + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From f399425bacfa461a77be2e841c3c1f48f9241c4a Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 19 Feb 2013 01:45:23 +0100 Subject: Fix a code comment in Upload->_file_mime_type() Availability of dangerous functions is now tested using function_usable(). --- system/libraries/Email.php | 6 +++--- system/libraries/Upload.php | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 1bf1da15e..074ce60fc 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -94,7 +94,7 @@ class CI_Email { * @var int */ public $smtp_timeout = 5; - + /** * SMTP persistent connection * @@ -408,7 +408,7 @@ class CI_Email { } // -------------------------------------------------------------------- - + /** * Destructor - Releases Resources * @@ -2018,7 +2018,7 @@ class CI_Email { { return TRUE; } - + if (strpos($reply, '334') !== 0) { $this->_set_error_message('lang:email_failed_smtp_login', $reply); diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index acd76b03b..1c14f99ed 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -1212,7 +1212,7 @@ class CI_Upload { * 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 + * due to security concerns, hence the function_usable() checks */ if (DIRECTORY_SEPARATOR !== '\\') { @@ -1223,7 +1223,7 @@ class CI_Upload { if (function_usable('exec')) { /* 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 + * However, we only need 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. */ -- cgit v1.2.3-24-g4f1b From a4d272e7ffbd76dcc824574348fd7cbaa7c8f085 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 19 Feb 2013 03:21:16 +0100 Subject: Fix typos in upgrade_300.rst --- user_guide_src/source/installation/upgrade_300.rst | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index a3ea01d02..41bac0146 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -1,5 +1,5 @@ ############################# -Upgrading from 2.1.2 to 3.0.0 +Upgrading from 2.1.3 to 3.0.0 ############################# .. note:: These upgrade notes are for a version that is yet to be released. @@ -104,9 +104,9 @@ regular expression:: (.+) // matches ANYTHING (:any) // matches any character, except for '/' -******************************************* -Step 9: Update your librararies' file names -******************************************* +***************************************** +Step 9: Update your libraries' file names +***************************************** CodeIgniter 3.0 only allows library file names to be named in a *ucfirst* manner (meaning that the first letter of the class name must be a capital). For example, @@ -238,7 +238,7 @@ Security helper do_hash() :doc:`Security Helper <../helpers/security_helper>` function ``do_hash()`` is now just an alias for PHP's native ``hash()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+. -.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner +.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later. File helper read_file() @@ -248,7 +248,7 @@ File helper read_file() PHP's native ``file_get_contents()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+. -.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner +.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later. String helper repeater() @@ -257,7 +257,7 @@ String helper repeater() :doc:`String Helper <../helpers/string_helper>` function :php:func:`repeater()` is now just an alias for PHP's native ``str_repeat()`` function. It is deprecated and scheduled for removal in CodeIgniter 3.1+. -.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner +.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later. String helper trim_slashes() @@ -267,7 +267,7 @@ String helper trim_slashes() for PHP's native ``trim()`` function (with a slash passed as its second argument). It is deprecated and scheduled for removal in CodeIgniter 3.1+. -.. note:: This function is still available, but you're strongly encouraged to remove it's usage sooner +.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later. Email helper functions @@ -292,7 +292,7 @@ Date helper standard_date() to the availability of native PHP `constants `_, which when combined with ``date()`` provide the same functionality. Furthermore, they have the exact same names as the ones supported by ``standard_date()``. Here are examples of how to replace -it's usage: +its usage: :: @@ -308,7 +308,7 @@ it's usage: // Replacement date(DATE_ATOM, $time); -.. note:: This function is still available, but you're strongly encouraged to remove its' usage sooner +.. note:: This function is still available, but you're strongly encouraged to remove its usage sooner rather than later as it is scheduled for removal in CodeIgniter 3.1+. Pagination library 'anchor_class' setting @@ -320,7 +320,7 @@ attribute to your anchors via the 'attributes' configuration setting. This inclu As a result of that, the 'anchor_class' setting is now deprecated and scheduled for removal in CodeIgniter 3.1+. -.. note:: This setting is still available, but you're strongly encouraged to remove its' usage sooner +.. note:: This setting is still available, but you're strongly encouraged to remove its usage sooner rather than later. String helper random_string() types 'unique' and 'encrypt' -- cgit v1.2.3-24-g4f1b From 92b8246ef31aa139925d3422838454e9f39f9351 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 19 Feb 2013 03:22:05 +0100 Subject: Add an upgrade note about change in the results of Directory Helper's directory_map() see issue #1978 --- user_guide_src/source/installation/upgrade_300.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/user_guide_src/source/installation/upgrade_300.rst b/user_guide_src/source/installation/upgrade_300.rst index 41bac0146..02841ab6e 100644 --- a/user_guide_src/source/installation/upgrade_300.rst +++ b/user_guide_src/source/installation/upgrade_300.rst @@ -136,8 +136,15 @@ Step 10: Check the calls to Array Helper's element() and elements() functions The default return value of these functions, when the required elements don't exist, has been changed from FALSE to NULL. +*********************************************************************** +Step 11: Check the calls to Directory Helper's directory_map() function +*********************************************************************** + +In the resulting array, directories now end with a trailing directory +separator (i.e. a slash, usually). + ************************************************************* -Step 11: Update usage of Database Forge's drop_table() method +Step 12: Update usage of Database Forge's drop_table() method ************************************************************* Up until now, ``drop_table()`` added an IF EXISTS clause by default or it didn't work @@ -159,7 +166,7 @@ If your application relies on IF EXISTS, you'll have to change its usage. all drivers with the exception of ODBC. *********************************************************** -Step 12: Change usage of Email library with multiple emails +Step 13: Change usage of Email library with multiple emails *********************************************************** The :doc:`Email Library <../libraries/email>` will automatically clear the @@ -174,7 +181,7 @@ pass FALSE as the first parameter in the ``send()`` method: } *************************************************** -Step 13: Update your Form_validation language lines +Step 14: Update your Form_validation language lines *************************************************** Two improvements have been made to the :doc:`Form Validation Library @@ -205,7 +212,7 @@ files and error messages format: later. **************************************************************** -Step 14: Remove usage of (previously) deprecated functionalities +Step 15: Remove usage of (previously) deprecated functionalities **************************************************************** In addition to the ``$autoload['core']`` configuration setting, there's a -- cgit v1.2.3-24-g4f1b From e1d5a7a0a6078d0edb0b9ac6e5d60a4c746ae365 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 19 Feb 2013 13:38:43 +0200 Subject: Fix form_upload() test --- tests/codeigniter/helpers/form_helper_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/codeigniter/helpers/form_helper_test.php b/tests/codeigniter/helpers/form_helper_test.php index 89165271e..e234f9c83 100644 --- a/tests/codeigniter/helpers/form_helper_test.php +++ b/tests/codeigniter/helpers/form_helper_test.php @@ -58,7 +58,7 @@ EOH; public function test_form_upload() { $expected = << + EOH; -- cgit v1.2.3-24-g4f1b From dc5c5a371aeab5af6440c0c39a4501405636b826 Mon Sep 17 00:00:00 2001 From: David Barratt Date: Tue, 19 Feb 2013 07:18:30 -0500 Subject: Revert "Revert all changes to see if travis just doesn't like me." This reverts commit eb5991ccd0686d15615bff3a730a641889063943. --- .travis.yml | 3 +-- composer.json | 7 ++++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 070b23c8a..3b2f6bd57 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,8 +14,7 @@ env: - DB=pdo/sqlite before_script: - - curl -s http://getcomposer.org/installer | php - - php composer.phar install + - composer install --dev - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" diff --git a/composer.json b/composer.json index 7d60020c3..e21aaed2e 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,9 @@ { + "name" : "ellislab/codeigniter", "require": { - "mikey179/vfsStream": "*" + "php": ">=5.2.4" }, "require-dev": { - "phpunit/phpunit": "*" - } + "mikey179/vfsStream": "*" + } } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b63f07a6b9d26fe55dd65d09e0de584629b7e8bc Mon Sep 17 00:00:00 2001 From: David Barratt Date: Tue, 19 Feb 2013 07:19:44 -0500 Subject: Set the --no-progress option for travis composer install command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3b2f6bd57..ab0aa5616 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,7 @@ env: - DB=pdo/sqlite before_script: - - composer install --dev + - composer install --dev --no-progress - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" -- cgit v1.2.3-24-g4f1b From 6bb98903662ed2870d1d46c492106fec3be1ca6f Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Tue, 19 Feb 2013 18:11:14 +0530 Subject: Fixed the issue with bcc_batch_mode and subject --- system/libraries/Email.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 1bf1da15e..0319ac5e7 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1205,8 +1205,11 @@ class CI_Email { { if ($this->protocol === 'mail') { - $this->_subject = $this->_headers['Subject']; - unset($this->_headers['Subject']); + if (isset($this->_headers['Subject'])) + { + $this->_subject = $this->_headers['Subject']; + unset($this->_headers['Subject']); + } } reset($this->_headers); -- cgit v1.2.3-24-g4f1b From 32c1e626d51517418acbecadde9a83d67517e0a8 Mon Sep 17 00:00:00 2001 From: nisheeth-barthwal Date: Tue, 19 Feb 2013 18:13:01 +0530 Subject: Updated changelog --- user_guide_src/source/changelog.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 4e55182e5..a5f560564 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -487,6 +487,7 @@ Bug fixes for 3.0 - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. - Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket. +- Fixed a bug (#2239) of missing subject when using ``bcc_batch_mode``. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From a1ff8b3c0ed9d5315cd4c22e5878d057204d9378 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 19 Feb 2013 15:08:31 +0200 Subject: [ci skip] Fix some changelog entries --- user_guide_src/source/changelog.rst | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index a5f560564..37bd2036a 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -60,12 +60,12 @@ Release Date: Not Released - Helpers - :doc:`Date Helper ` changes include: - - ``now()`` now works with all timezone strings supported by PHP. - - Added an optional third parameter to ``timespan()`` that constrains the number of time units displayed. - - Added an optional parameter to ``timezone_menu()`` that allows more attributes to be added to the generated select tag. + - :php:func:`now()` now works with all timezone strings supported by PHP. + - Added an optional third parameter to :php:func:`timespan()` that constrains the number of time units displayed. + - Added an optional parameter to :php:func:`timezone_menu()` that allows more attributes to be added to the generated select tag. - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants `_. - - Added function ``date_range()`` that generates a list of dates between a specified period. - - ``create_captcha()`` accepts additional colors parameter, allowing for color customization. + - Added function :php:func:`date_range()` that generates a list of dates between a specified period. + - :doc:`Captcha Helper ` :php:func:`create_captcha()` now accepts additional colors parameter, allowing for color customization. - :doc:`URL Helper ` changes include: - Deprecated *separator* options **dash** and **underscore** for function :php:func:`url_title()` (they are only aliases for '-' and '_' respectively). - :php:func:`url_title()` will now trim extra dashes from beginning and end. @@ -340,16 +340,15 @@ Bug fixes for 3.0 - Fixed a bug where ``unlink()`` raised an error if cache file did not exist when you try to delete it. - Fixed a bug (#181) where a mis-spelling was in the form validation language file. -- Fixed a bug (#159, #163) that mishandled Query Builder nested transactions because _trans_depth was not getting incremented. +- Fixed a bug (#159, #163) - :doc:`Query Builder ` nested transactions didn't work properly due to ``_trans_depth`` not being incremented. - Fixed a bug (#737, #75) - :doc:`Pagination ` anchor class was not set properly when using initialize method. -- Fixed a bug (#419) - ``auto_link()`` now recognizes URLs that come after a word boundary. +- Fixed a bug (#419) - :php:func:`auto_link()` didn't recognize URLs that come after a word boundary. - Fixed a bug (#724) - :doc:`Form Validation Library ` rule **is_unique** didn't check if a database connection exists. - Fixed a bug (#647) - :doc:`Zip Library ` internal method ``_get_mod_time()`` didn't suppress possible "stat failed" errors generated by ``filemtime()``. -- Fixed a bug (#608) - Fixes an issue with the Image_lib class not clearing properties completely. -- Fixed a bug (#157, #174) - the Image_lib clear() function now resets all variables to their default values. -- Fixed a bug where using $this->dbforge->create_table() with PostgreSQL database could lead to fetching whole table. -- Fixed a bug (#795) - Fixed form method and accept-charset when passing an empty array. -- Fixed a bug (#797) - timespan() was using incorrect seconds for year and month. +- Fixed a bug (#157, #174) - :doc:`Image Manipulation Library ` method ``clear()`` didn't completely clear properties. +- Fixed a bug where :doc:`Database Forge ` method ``create_table()`` with PostgreSQL database could lead to fetching the whole table. +- Fixed a bug (#795) - :doc:`Form Helper ` :php:func:`form_open()` didn't add the default form *method* and *accept-charset* when an empty array is passed to it. +- Fixed a bug (#797) - :php:func:`timespan()` was using incorrect seconds for year and month. - Fixed a bug in CI_Cart::contents() where if called without a TRUE (or equal) parameter, it would fail due to a typo. - Fixed a bug (#696) - make oci_execute() calls inside num_rows() non-committing, since they are only there to reset which row is next in line for oci_fetch calls and thus don't need to be committed. - Fixed a bug (#406) - SQLSRV DB driver not returning resource on ``db_pconnect()``. @@ -486,8 +485,8 @@ Bug fixes for 3.0 - Fixed a bug - :doc:`DB result ` method ``list_fields()`` didn't reset its field pointer for the *mysql*, *mysqli* and *mssql* drivers. - Fixed a bug (#73) - :doc:`Security Library ` method ``sanitize_filename()`` could be tricked by an XSS attack. - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. -- Fixed a bug (#2255) where ``smtp_timeout`` was not being applied to read and writes for the socket. -- Fixed a bug (#2239) of missing subject when using ``bcc_batch_mode``. +- Fixed a bug (#2255) - :doc:`Email Library ` didn't apply ``smtp_timeout``to socket reads and writes. +- Fixed a bug (#2239) - :doc:`Email Library ` improperly handled the Subject when used with ``bcc_batch_mode`` resulting in E_WARNING messages and an empty Subject. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 07a59548c0761c5ac4562019d13913f2b82c6018 Mon Sep 17 00:00:00 2001 From: Dionysis Arvanitis Date: Tue, 19 Feb 2013 22:31:05 +0200 Subject: Set transaction enabled flag default to TRUE --- system/database/drivers/pdo/pdo_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index 34adf0f86..ffbafea6b 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -53,7 +53,7 @@ class CI_DB_pdo_driver extends CI_DB { * * @var bool */ - public $trans_enabled = FALSE; + public $trans_enabled = TRUE; /** * PDO Options -- cgit v1.2.3-24-g4f1b From 635ced168ce1ce7a91cfef782a1a3c37789f8930 Mon Sep 17 00:00:00 2001 From: Dionysis Arvanitis Date: Tue, 19 Feb 2013 23:11:34 +0200 Subject: DB_driver's trans_complete exception fix --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 35ac8e870..05abd864b 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -625,7 +625,7 @@ abstract class CI_DB_driver { // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. - $this->trans_complete(); + $this->_trans_depth > 0 && $this->trans_complete(); // Display errors return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql)); -- cgit v1.2.3-24-g4f1b From f8e2d0ed10018f81db5814d421dbafbe6d0834e4 Mon Sep 17 00:00:00 2001 From: Dionysis Arvanitis Date: Tue, 19 Feb 2013 23:27:16 +0200 Subject: Issue #2086 Session_cookie's _update_db not guaranteed to update --- system/libraries/Session/drivers/Session_cookie.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/system/libraries/Session/drivers/Session_cookie.php b/system/libraries/Session/drivers/Session_cookie.php index 11bb32fe0..057e5a1d1 100644 --- a/system/libraries/Session/drivers/Session_cookie.php +++ b/system/libraries/Session/drivers/Session_cookie.php @@ -602,6 +602,9 @@ class CI_Session_cookie extends CI_Session_driver { $set['user_data'] = $this->_serialize($userdata); } + // Reset query builder values. + $this->CI->db->reset_query(); + // Run the update query // Any time we change the session id, it gets updated immediately, // so our where clause below is always safe -- cgit v1.2.3-24-g4f1b From 95da6e75c41bcef079215972efa4a0734be7e8c4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 20 Feb 2013 12:38:44 +0200 Subject: Remove CI_DB_pdo_driver:: Improving on PR #2265, the property is inherited with the same value and doesn't need to be set. --- system/database/drivers/pdo/pdo_driver.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/system/database/drivers/pdo/pdo_driver.php b/system/database/drivers/pdo/pdo_driver.php index ffbafea6b..fa89661b1 100644 --- a/system/database/drivers/pdo/pdo_driver.php +++ b/system/database/drivers/pdo/pdo_driver.php @@ -48,13 +48,6 @@ class CI_DB_pdo_driver extends CI_DB { */ public $dbdriver = 'pdo'; - /** - * Transaction enabled flag - * - * @var bool - */ - public $trans_enabled = TRUE; - /** * PDO Options * -- cgit v1.2.3-24-g4f1b From 4796cebc4a2c2028134bd59257ddce4f1387c8ff Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Wed, 20 Feb 2013 14:20:54 -0600 Subject: Update user_guide_src/source/tutorial/news_section.rst Clarified a part of the tutorial so it's obvious the code should be replaced/update rather than added. --- user_guide_src/source/tutorial/news_section.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/user_guide_src/source/tutorial/news_section.rst b/user_guide_src/source/tutorial/news_section.rst index 833e34ead..d7754e9f3 100644 --- a/user_guide_src/source/tutorial/news_section.rst +++ b/user_guide_src/source/tutorial/news_section.rst @@ -162,7 +162,7 @@ The news overview page is now done, but a page to display individual news items is still absent. The model created earlier is made in such way that it can easily be used for this functionality. You only need to add some code to the controller and create a new view. Go back to the -news controller and add the following lines to the file. +news controller and update ``view()`` with the following: :: @@ -211,4 +211,4 @@ a slug to the view method in the news controller. $route['default_controller'] = 'pages/view'; Point your browser to your document root, followed by index.php/news and -watch your news page. \ No newline at end of file +watch your news page. -- cgit v1.2.3-24-g4f1b From e84c0144bbd15094cc19716222b691ed3a27d2e4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 15:28:13 +0200 Subject: Fix Session tests --- tests/mocks/libraries/session.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/mocks/libraries/session.php b/tests/mocks/libraries/session.php index 562033bbf..adbecb329 100644 --- a/tests/mocks/libraries/session.php +++ b/tests/mocks/libraries/session.php @@ -33,4 +33,6 @@ class Mock_Libraries_Session_cookie extends CI_Session_cookie { $_COOKIE[$name] = $value; } } -} \ No newline at end of file +} + +class Mock_Libraries_Session_native extends CI_Session_native {} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 73cf876a65aa24c1dd4e25dd323f83a11bad3fbe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 15:36:13 +0200 Subject: [ci skip] Remove a changelog line for a non-existent change --- user_guide_src/source/changelog.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 37bd2036a..1b6cff10e 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -65,7 +65,6 @@ Release Date: Not Released - Added an optional parameter to :php:func:`timezone_menu()` that allows more attributes to be added to the generated select tag. - Deprecated ``standard_date()``, which now just uses the native ``date()`` with `DateTime constants `_. - Added function :php:func:`date_range()` that generates a list of dates between a specified period. - - :doc:`Captcha Helper ` :php:func:`create_captcha()` now accepts additional colors parameter, allowing for color customization. - :doc:`URL Helper ` changes include: - Deprecated *separator* options **dash** and **underscore** for function :php:func:`url_title()` (they are only aliases for '-' and '_' respectively). - :php:func:`url_title()` will now trim extra dashes from beginning and end. -- cgit v1.2.3-24-g4f1b From 3e01437a5b23d9ffdf1b1cc9fc0a0f8b66551342 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 15:59:34 +0200 Subject: Manually apply PR #2234 --- system/database/DB_query_builder.php | 1 + user_guide_src/source/changelog.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/system/database/DB_query_builder.php b/system/database/DB_query_builder.php index c7bc4a699..85a233b50 100644 --- a/system/database/DB_query_builder.php +++ b/system/database/DB_query_builder.php @@ -2627,6 +2627,7 @@ abstract class CI_DB_query_builder extends CI_DB_driver { $this->_reset_run(array( 'qb_set' => array(), 'qb_from' => array(), + 'qb_join' => array(), 'qb_where' => array(), 'qb_orderby' => array(), 'qb_keys' => array(), diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index 1b6cff10e..216bf80bc 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -486,6 +486,7 @@ Bug fixes for 3.0 - Fixed a bug (#2211) - :doc:`Migration Library ` extensions couldn't execute ``CI_Migration::__construct()``. - Fixed a bug (#2255) - :doc:`Email Library ` didn't apply ``smtp_timeout``to socket reads and writes. - Fixed a bug (#2239) - :doc:`Email Library ` improperly handled the Subject when used with ``bcc_batch_mode`` resulting in E_WARNING messages and an empty Subject. +- Fixed a bug (#2234) - :doc:`Query Builder ` didn't reset JOIN cache for write-type queries. Version 2.1.3 ============= -- cgit v1.2.3-24-g4f1b From 49e68de96b420a444c826995746a5f09470e76d9 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 16:30:55 +0200 Subject: Disable autoloader call from class_exists() occurences to improve performance Note: The Driver libary tests seem to depend on that, so one occurence in CI_Loader is left until we resolve that. --- system/core/CodeIgniter.php | 6 +++--- system/core/Common.php | 4 ++-- system/core/Hooks.php | 2 +- system/core/Loader.php | 10 +++++----- system/core/Output.php | 2 +- system/database/DB.php | 4 ++-- system/database/DB_driver.php | 4 ++-- system/libraries/Cache/drivers/Cache_memcached.php | 4 ++-- system/libraries/Migration.php | 2 +- system/libraries/Xmlrpcs.php | 2 +- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index cb4b735d5..7f76977b5 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -263,7 +263,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $class = $RTR->fetch_class(); $method = $RTR->fetch_method(); - if ( ! class_exists($class) OR $method[0] === '_' OR method_exists('CI_Controller', $method)) + if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method)) { if ( ! empty($RTR->routes['404_override'])) { @@ -272,7 +272,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $method = 'index'; } - if ( ! class_exists($class)) + if ( ! class_exists($class, FALSE)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) { @@ -310,7 +310,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); $method = 'index'; } - if ( ! class_exists($class)) + if ( ! class_exists($class, FALSE)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) { diff --git a/system/core/Common.php b/system/core/Common.php index f8c1290f5..ee9bb2e87 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -149,7 +149,7 @@ if ( ! function_exists('load_class')) { $name = $prefix.$class; - if (class_exists($name) === FALSE) + if (class_exists($name, FALSE) === FALSE) { require_once($path.$directory.'/'.$class.'.php'); } @@ -163,7 +163,7 @@ if ( ! function_exists('load_class')) { $name = config_item('subclass_prefix').$class; - if (class_exists($name) === FALSE) + if (class_exists($name, FALSE) === FALSE) { require_once(APPPATH.$directory.'/'.config_item('subclass_prefix').$class.'.php'); } diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 17f6a027e..b3b111991 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -195,7 +195,7 @@ class CI_Hooks { // Call the requested class and/or function if ($class !== FALSE) { - if ( ! class_exists($class)) + if ( ! class_exists($class, FALSE)) { require($filepath); } diff --git a/system/core/Loader.php b/system/core/Loader.php index 9306a09ef..6e5b58ba7 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -270,7 +270,7 @@ class CI_Loader { continue; } - if ($db_conn !== FALSE && ! class_exists('CI_DB')) + if ($db_conn !== FALSE && ! class_exists('CI_DB', FALSE)) { if ($db_conn === TRUE) { @@ -280,7 +280,7 @@ class CI_Loader { $CI->load->database($db_conn, FALSE, TRUE); } - if ( ! class_exists('CI_Model')) + if ( ! class_exists('CI_Model', FALSE)) { load_class('Model', 'core'); } @@ -1091,11 +1091,11 @@ class CI_Loader { if ($prefix === '') { - if (class_exists('CI_'.$class)) + if (class_exists('CI_'.$class, FALSE)) { $name = 'CI_'.$class; } - elseif (class_exists(config_item('subclass_prefix').$class)) + elseif (class_exists(config_item('subclass_prefix').$class, FALSE)) { $name = config_item('subclass_prefix').$class; } @@ -1110,7 +1110,7 @@ class CI_Loader { } // Is the class name valid? - if ( ! class_exists($name)) + if ( ! class_exists($name, FALSE)) { log_message('error', 'Non-existent class: '.$name); show_error('Non-existent class: '.$name); diff --git a/system/core/Output.php b/system/core/Output.php index a20841463..25ecd496c 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -395,7 +395,7 @@ class CI_Output { global $BM, $CFG; // Grab the super object if we can. - if (class_exists('CI_Controller')) + if (class_exists('CI_Controller', FALSE)) { $CI =& get_instance(); } diff --git a/system/database/DB.php b/system/database/DB.php index d9104747f..83d973304 100644 --- a/system/database/DB.php +++ b/system/database/DB.php @@ -149,7 +149,7 @@ function &DB($params = '', $query_builder_override = NULL) if ( ! isset($query_builder) OR $query_builder === TRUE) { require_once(BASEPATH.'database/DB_query_builder.php'); - if ( ! class_exists('CI_DB')) + if ( ! class_exists('CI_DB', FALSE)) { /** * CI_DB @@ -162,7 +162,7 @@ function &DB($params = '', $query_builder_override = NULL) class CI_DB extends CI_DB_query_builder { } } } - elseif ( ! class_exists('CI_DB')) + elseif ( ! class_exists('CI_DB', FALSE)) { /** * @ignore diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 35ac8e870..213e2c3a8 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -704,7 +704,7 @@ abstract class CI_DB_driver { { $driver = 'CI_DB_'.$this->dbdriver.'_result'; - if ( ! class_exists($driver)) + if ( ! class_exists($driver, FALSE)) { include_once(BASEPATH.'database/DB_result.php'); include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php'); @@ -1560,7 +1560,7 @@ abstract class CI_DB_driver { */ protected function _cache_init() { - if (class_exists('CI_DB_Cache')) + if (class_exists('CI_DB_Cache', FALSE)) { if (is_object($this->CACHE)) { diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 8096b2650..246a7a264 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -182,11 +182,11 @@ class CI_Cache_memcached extends CI_Driver { } } - if (class_exists('Memcached')) + if (class_exists('Memcached', FALSE)) { $this->_memcached = new Memcached(); } - elseif (class_exists('Memcache')) + elseif (class_exists('Memcache', FALSE)) { $this->_memcached = new Memcache(); } diff --git a/system/libraries/Migration.php b/system/libraries/Migration.php index b673e9cb7..cc6fe48f0 100644 --- a/system/libraries/Migration.php +++ b/system/libraries/Migration.php @@ -228,7 +228,7 @@ class CI_Migration { $class = 'Migration_'.ucfirst(strtolower($this->_get_migration_name(basename($file, '.php')))); // Validate the migration file structure - if ( ! class_exists($class)) + if ( ! class_exists($class, FALSE)) { $this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class); return FALSE; diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php index d4524d230..d263d789d 100644 --- a/system/libraries/Xmlrpcs.php +++ b/system/libraries/Xmlrpcs.php @@ -31,7 +31,7 @@ if ( ! function_exists('xml_parser_create')) show_error('Your PHP installation does not support XML'); } -if ( ! class_exists('CI_Xmlrpc')) +if ( ! class_exists('CI_Xmlrpc', FALSE)) { show_error('You must load the Xmlrpc class before loading the Xmlrpcs class in order to create a server.'); } -- cgit v1.2.3-24-g4f1b From 8cf596b5eabe431572ec1c4f21b9c32101feb22f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 16:44:12 +0200 Subject: DB_result tests seem to also depend on autoloading via the class_exists() checks ... --- system/database/DB_driver.php | 2 +- tests/mocks/database/ci_test.sqlite | Bin 19456 -> 19456 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 213e2c3a8..f03f56c85 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -704,7 +704,7 @@ abstract class CI_DB_driver { { $driver = 'CI_DB_'.$this->dbdriver.'_result'; - if ( ! class_exists($driver, FALSE)) + if ( ! class_exists($driver)) { include_once(BASEPATH.'database/DB_result.php'); include_once(BASEPATH.'database/drivers/'.$this->dbdriver.'/'.$this->dbdriver.'_result.php'); diff --git a/tests/mocks/database/ci_test.sqlite b/tests/mocks/database/ci_test.sqlite index 44dcef9ec..574d3ae53 100755 Binary files a/tests/mocks/database/ci_test.sqlite and b/tests/mocks/database/ci_test.sqlite differ -- cgit v1.2.3-24-g4f1b From 05f3ad292da185cfc18901070a84db952fed6274 Mon Sep 17 00:00:00 2001 From: Cory Date: Thu, 21 Feb 2013 10:36:31 -0500 Subject: Fix #2273 --- user_guide_src/source/libraries/migration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/user_guide_src/source/libraries/migration.rst b/user_guide_src/source/libraries/migration.rst index 9a7b10d64..b734f5c34 100644 --- a/user_guide_src/source/libraries/migration.rst +++ b/user_guide_src/source/libraries/migration.rst @@ -10,7 +10,7 @@ need to be run against the production machines next time you deploy. The database table **migration** tracks which migrations have already been run so all you have to do is update your application files and -call **$this->migrate->current()** to work out which migrations should be run. +call **$this->migration->current()** to work out which migrations should be run. The current version is found in **config/migration.php**. ******************** -- cgit v1.2.3-24-g4f1b From 452b668d4edda5ae04c16f494bffe09114afc3ba Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 19:05:52 +0200 Subject: Add CI_Utf8::convert_to_utf8() test --- tests/codeigniter/core/Utf8_test.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/codeigniter/core/Utf8_test.php diff --git a/tests/codeigniter/core/Utf8_test.php b/tests/codeigniter/core/Utf8_test.php new file mode 100644 index 000000000..caa7b6986 --- /dev/null +++ b/tests/codeigniter/core/Utf8_test.php @@ -0,0 +1,20 @@ +utf8 = new Mock_Core_Utf8(); + } + + // -------------------------------------------------------------------- + + public function test_convert_to_utf8() + { + $this->assertEquals( + $this->utf8->convert_to_utf8('', 'WINDOWS-1251'), + 'тест' + ); + } + +} \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b3a5d6e8ad90644760890182a43ed81a23b86efe Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 22:03:23 +0200 Subject: Some miscellaneous tests --- tests/codeigniter/core/Input_test.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/tests/codeigniter/core/Input_test.php b/tests/codeigniter/core/Input_test.php index ca1c6dfd7..5cf25fefa 100644 --- a/tests/codeigniter/core/Input_test.php +++ b/tests/codeigniter/core/Input_test.php @@ -95,8 +95,8 @@ class Input_test extends CI_TestCase { public function test_cookie() { $_COOKIE['foo'] = 'bar'; - $this->assertEquals('bar', $this->input->cookie('foo')); + $this->assertNull($this->input->cookie('bar')); } // -------------------------------------------------------------------- @@ -138,4 +138,27 @@ class Input_test extends CI_TestCase { } } + // -------------------------------------------------------------------- + + public function test_method() + { + $_SERVER['REQUEST_METHOD'] = 'GET'; + $this->assertEquals('get', $this->input->method()); + $this->assertEquals('GET', $this->input->method(TRUE)); + $_SERVER['REQUEST_METHOD'] = 'POST'; + $this->assertEquals('post', $this->input->method()); + $this->assertEquals('POST', $this->input->method(TRUE)); + } + + // -------------------------------------------------------------------- + + public function test_is_ajax_request() + { + $this->assertFalse($this->input->is_ajax_request()); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'test'; + $this->assertFalse($this->input->is_ajax_request()); + $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'; + $this->assertTrue($this->input->is_ajax_request()); + } + } \ No newline at end of file -- cgit v1.2.3-24-g4f1b From eb291c1d1e1116a4420fa30e587adeea0451eeb7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 21 Feb 2013 22:22:51 +0200 Subject: CI_Output [set/append/get]_output() tests --- tests/codeigniter/core/Output_test.php | 35 ++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/codeigniter/core/Output_test.php b/tests/codeigniter/core/Output_test.php index 728df3bf6..0eeb93f7b 100644 --- a/tests/codeigniter/core/Output_test.php +++ b/tests/codeigniter/core/Output_test.php @@ -3,6 +3,16 @@ class Output_test extends CI_TestCase { public $output; + protected $_output_data = << + + Basic HTML + + + Test + + +HTML; public function set_up() { @@ -13,6 +23,31 @@ class Output_test extends CI_TestCase { // -------------------------------------------------------------------- + public function test_set_get_append_output() + { + $append = "\n"; + + $this->assertEquals( + $this->_output_data.$append, + $this->output + ->set_output($this->_output_data) + ->append_output("\n") + ->get_output() + ); + } + + // -------------------------------------------------------------------- + + public function test_minify() + { + $this->assertEquals( + str_replace(array("\t", "\n"), '', $this->_output_data), + $this->output->minify($this->_output_data) + ); + } + + // -------------------------------------------------------------------- + public function test_get_content_type() { $this->assertEquals('text/html', $this->output->get_content_type()); -- cgit v1.2.3-24-g4f1b