From 689f95d2c8bcbd0ac2f538c237dff471fbcff048 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 26 Apr 2011 09:59:29 -0400 Subject: Automatic base_url generation was missing a ending slash. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Config.php b/system/core/Config.php index fa71f4d3d..55c623b3c 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -55,7 +55,7 @@ class CI_Config { { $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST']; - $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + $base_url .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']).'/'; } else -- cgit v1.2.3-24-g4f1b From 2e00c2490fb544596fba06483ad1c1d626c1fd4f Mon Sep 17 00:00:00 2001 From: Stephen Date: Sun, 28 Aug 2011 10:25:40 +0200 Subject: Added tests for CI_URI class. Made modifications to core class which helped with isolation for testing. --- system/core/URI.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/URI.php b/system/core/URI.php index a3ae20cc3..51c2191af 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -87,7 +87,7 @@ class CI_URI { if (strtoupper($this->config->item('uri_protocol')) == 'AUTO') { // Is the request coming from the command line? - if (php_sapi_name() == 'cli' or defined('STDIN')) + if ($this->_is_cli_request()) { $this->_set_uri_string($this->_parse_cli_args()); return; @@ -222,6 +222,21 @@ class CI_URI { return str_replace(array('//', '../'), '/', trim($uri, '/')); } + // -------------------------------------------------------------------- + + /** + * Is cli Request? + * + * Duplicate of function from the Input class to test to see if a request was made from the command line + * + * @return boolean + */ + protected function _is_cli_request() + { + return (php_sapi_name() == 'cli') OR defined('STDIN'); + } + + // -------------------------------------------------------------------- /** -- cgit v1.2.3-24-g4f1b From 07c1ac830b4e98aa40f48baef3dd05fb68c0a836 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Fri, 9 Mar 2012 17:03:37 +0000 Subject: Bumped CodeIgniter's PHP requirement to 5.2.4. Yes I know PHP 5.4 just came out, and yes I know PHP 5.3 has lovely features, but there are plenty of corporate systems running on CodeIgniter and PHP 5.3 still is not widely supported enough. CodeIgniter is great for distributed applications, and this is the highest we can reasonably go without breaking support. PHP 5.3 will most likely happen in another year or so. Fingers crossed on that one anyway... --- system/core/Benchmark.php | 2 +- system/core/CodeIgniter.php | 2 +- system/core/Common.php | 2 +- system/core/Config.php | 2 +- system/core/Controller.php | 2 +- system/core/Exceptions.php | 2 +- system/core/Hooks.php | 2 +- system/core/Input.php | 2 +- system/core/Lang.php | 2 +- system/core/Loader.php | 2 +- system/core/Model.php | 2 +- system/core/Output.php | 2 +- system/core/Router.php | 2 +- system/core/Security.php | 2 +- system/core/URI.php | 2 +- system/core/Utf8.php | 2 +- 16 files changed, 16 insertions(+), 16 deletions(-) (limited to 'system/core') diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index f4dfd3dab..f6b634deb 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 7af3c485d..a79a69590 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Common.php b/system/core/Common.php index 491979350..f20acafd4 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Config.php b/system/core/Config.php index 68417435d..1e149d005 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Controller.php b/system/core/Controller.php index 0dc131701..05e1bf5bf 100644 --- a/system/core/Controller.php +++ b/system/core/Controller.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index bf9901252..d7282b1f3 100755 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Hooks.php b/system/core/Hooks.php index e1ac58e6e..493822f36 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Input.php b/system/core/Input.php index ee15f4013..9a05034ba 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Lang.php b/system/core/Lang.php index c40a6856e..9ef76f4d6 100755 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Loader.php b/system/core/Loader.php index 12daaa928..971d30325 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Model.php b/system/core/Model.php index a595a6ae2..49b8d34e4 100755 --- a/system/core/Model.php +++ b/system/core/Model.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Output.php b/system/core/Output.php index abd8a0ea9..faebbbe72 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Router.php b/system/core/Router.php index d21319565..b251abb4b 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Security.php b/system/core/Security.php index 6f25fb5bb..bf73bd15d 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/URI.php b/system/core/URI.php index b28ee198b..db5b8e44b 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * diff --git a/system/core/Utf8.php b/system/core/Utf8.php index 0e180d36f..ba3567453 100644 --- a/system/core/Utf8.php +++ b/system/core/Utf8.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.1.6 or newer + * An open source application development framework for PHP 5.2.4 or newer * * NOTICE OF LICENSE * -- cgit v1.2.3-24-g4f1b From 9929d6f77a0e54288b1696343439b0e91b21866e Mon Sep 17 00:00:00 2001 From: Christopher Guiney Date: Fri, 9 Mar 2012 19:53:24 -0800 Subject: Allow drivers to be loaded as an array, like models and libraries. --- system/core/Loader.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Loader.php b/system/core/Loader.php index 3d91915c4..42d8162bb 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -615,13 +615,22 @@ class CI_Loader { * * Loads a driver library * - * @param string the name of the class + * @param mixed the name of the class or array of classes * @param mixed the optional parameters * @param string an optional object name * @return void */ public function driver($library = '', $params = NULL, $object_name = NULL) { + if(is_array($library)) + { + foreach ( $library as $driver ) + { + $this->driver($driver); + } + return FALSE; + } + if ( ! class_exists('CI_Driver_Library')) { // we aren't instantiating an object here, that'll be done by the Library itself -- cgit v1.2.3-24-g4f1b From 1ae651655888383a4d7f97fbf6e97a7ac00a9630 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 10 Mar 2012 16:11:34 +0200 Subject: Remove PHP 5.1.6-specific code --- system/core/Input.php | 31 +------------------------------ system/core/URI.php | 4 +--- 2 files changed, 2 insertions(+), 33 deletions(-) (limited to 'system/core') diff --git a/system/core/Input.php b/system/core/Input.php index 54b7e0923..901b4147e 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -366,36 +366,7 @@ class CI_Input { */ public function valid_ip($ip) { - // if php version >= 5.2, use filter_var to check validate ip. - if (function_exists('filter_var')) - { - return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); - } - - $ip_segments = explode('.', $ip); - - // Always 4 segments needed - if (count($ip_segments) !== 4) - { - return FALSE; - } - // IP can not start with 0 - if ($ip_segments[0][0] == '0') - { - return FALSE; - } - // Check each segment - foreach ($ip_segments as $segment) - { - // IP segments must be digits and can not be - // longer than 3 digits or greater then 255 - if ($segment == '' OR preg_match('/[^0-9]/', $segment) OR $segment > 255 OR strlen($segment) > 3) - { - return FALSE; - } - } - - return TRUE; + return (bool) filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4); } // -------------------------------------------------------------------- diff --git a/system/core/URI.php b/system/core/URI.php index db5b8e44b..4a2e87c2a 100755 --- a/system/core/URI.php +++ b/system/core/URI.php @@ -444,9 +444,7 @@ class CI_URI { return array(); } - return function_exists('array_fill_keys') - ? array_fill_keys($default, FALSE) - : array_combine($default, array_fill(0, count($default), FALSE)); + return array_fill_keys($default, FALSE); } $segments = array_slice($this->$segment_array(), ($n - 1)); -- cgit v1.2.3-24-g4f1b From b54d355faabef775703119a23dd55004b84a1140 Mon Sep 17 00:00:00 2001 From: Christopher Guiney Date: Sat, 10 Mar 2012 08:38:10 -0800 Subject: Fixing some spacing. --- system/core/Loader.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core') diff --git a/system/core/Loader.php b/system/core/Loader.php index 42d8162bb..9b9cc2fef 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -622,9 +622,9 @@ class CI_Loader { */ public function driver($library = '', $params = NULL, $object_name = NULL) { - if(is_array($library)) + if (is_array($library)) { - foreach ( $library as $driver ) + foreach ($library as $driver) { $this->driver($driver); } -- cgit v1.2.3-24-g4f1b From 8749bc7e836c196dfef37d3b7b5a67736a15092c Mon Sep 17 00:00:00 2001 From: Taufan Aditya Date: Sun, 11 Mar 2012 05:43:45 +0700 Subject: Fix incomplete and skipped test --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Config.php b/system/core/Config.php index 68417435d..5424e5eb1 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,7 +76,7 @@ class CI_Config { log_message('debug', 'Config Class Initialized'); // Set the base_url automatically if none was provided - if ($this->config['base_url'] == '') + if (empty($this->config['base_url'])) { if (isset($_SERVER['HTTP_HOST'])) { -- cgit v1.2.3-24-g4f1b From 4ad0fd86e8dc6dba74305dbb0c88c593b46a19a2 Mon Sep 17 00:00:00 2001 From: freewil Date: Tue, 13 Mar 2012 22:37:42 -0400 Subject: add support for httponly cookies --- system/core/Input.php | 13 +++++++++---- system/core/Security.php | 10 +++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'system/core') diff --git a/system/core/Input.php b/system/core/Input.php index 901b4147e..6e6885992 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -228,7 +228,7 @@ class CI_Input { /** * Set cookie * - * Accepts six parameter, or you can submit an associative + * Accepts seven parameters, or you can submit an associative * array in the first parameter containing all the values. * * @param mixed @@ -238,14 +238,15 @@ class CI_Input { * @param string the cookie path * @param string the cookie prefix * @param bool true makes the cookie secure + * @param bool true makes the cookie accessible via http(s) only (no javascript) * @return void */ - public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) + public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { if (is_array($name)) { // always leave 'name' in last place, as the loop will break otherwise, due to $$item - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item) { if (isset($name[$item])) { @@ -270,6 +271,10 @@ class CI_Input { { $secure = config_item('cookie_secure'); } + if ($httponly == FALSE && config_item('cookie_httponly') != FALSE) + { + $httponly = config_item('cookie_httponly'); + } if ( ! is_numeric($expire)) { @@ -280,7 +285,7 @@ class CI_Input { $expire = ($expire > 0) ? time() + $expire : 0; } - setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); + setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly); } // -------------------------------------------------------------------- diff --git a/system/core/Security.php b/system/core/Security.php index cd8a61028..ac39ce97b 100755 --- a/system/core/Security.php +++ b/system/core/Security.php @@ -196,7 +196,15 @@ class CI_Security { return FALSE; } - setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie); + setcookie( + $this->_csrf_cookie_name, + $this->_csrf_hash, + $expire, + config_item('cookie_path'), + config_item('cookie_domain'), + $secure_cookie, + config_item('cookie_httponly') + ); log_message('debug', 'CRSF cookie Set'); return $this; -- cgit v1.2.3-24-g4f1b From c6a68e04169802c8aa82e41634ce350eafd1ec1e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:30:10 +0300 Subject: Add visibility declarations where they remain missing --- system/core/Exceptions.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system/core') diff --git a/system/core/Exceptions.php b/system/core/Exceptions.php index d7282b1f3..f36b31598 100755 --- a/system/core/Exceptions.php +++ b/system/core/Exceptions.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Exceptions Class * @@ -163,7 +161,7 @@ class CI_Exceptions { * @param string the error line number * @return string */ - function show_php_error($severity, $message, $filepath, $line) + public function show_php_error($severity, $message, $filepath, $line) { $severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity]; $filepath = str_replace('\\', '/', $filepath); @@ -189,4 +187,4 @@ class CI_Exceptions { } /* End of file Exceptions.php */ -/* Location: ./system/core/Exceptions.php */ +/* Location: ./system/core/Exceptions.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a5dd2976044b856a875d50e612a2b39ae05787ea Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 14:43:01 +0300 Subject: Make _initialize() a constructor and rename _call_hook() to call_hook in the Hooks class --- system/core/CodeIgniter.php | 14 +++++++------- system/core/Hooks.php | 32 ++++++++++++-------------------- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'system/core') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index a79a69590..4885f310c 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -133,7 +133,7 @@ * Is there a "pre_system" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('pre_system'); + $EXT->call_hook('pre_system'); /* * ------------------------------------------------------ @@ -194,7 +194,7 @@ * Is there a valid cache file? If so, we're done... * ------------------------------------------------------ */ - if ($EXT->_call_hook('cache_override') === FALSE + if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) == TRUE) { exit; @@ -297,7 +297,7 @@ * Is there a "pre_controller" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('pre_controller'); + $EXT->call_hook('pre_controller'); /* * ------------------------------------------------------ @@ -314,7 +314,7 @@ * Is there a "post_controller_constructor" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_controller_constructor'); + $EXT->call_hook('post_controller_constructor'); /* * ------------------------------------------------------ @@ -369,14 +369,14 @@ * Is there a "post_controller" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_controller'); + $EXT->call_hook('post_controller'); /* * ------------------------------------------------------ * Send the final rendered output to the browser * ------------------------------------------------------ */ - if ($EXT->_call_hook('display_override') === FALSE) + if ($EXT->call_hook('display_override') === FALSE) { $OUT->_display(); } @@ -386,7 +386,7 @@ * Is there a "post_system" hook? * ------------------------------------------------------ */ - $EXT->_call_hook('post_system'); + $EXT->call_hook('post_system'); /* * ------------------------------------------------------ diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 493822f36..68e30ef0f 100755 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Hooks Class * @@ -51,7 +49,7 @@ class CI_Hooks { * * @var array */ - public $hooks = array(); + public $hooks = array(); /** * Determines wether hook is in progress, used to prevent infinte loops * @@ -59,23 +57,17 @@ class CI_Hooks { */ public $in_progress = FALSE; - public function __construct() - { - $this->_initialize(); - log_message('debug', 'Hooks Class Initialized'); - } - - // -------------------------------------------------------------------- - /** * Initialize the Hooks Preferences * * @return void */ - private function _initialize() + public function __construct() { $CFG =& load_class('Config', 'core'); + log_message('debug', 'Hooks Class Initialized'); + // If hooks are not enabled in the config file // there is nothing else to do if ($CFG->item('enable_hooks') == FALSE) @@ -84,7 +76,7 @@ class CI_Hooks { } // Grab the "hooks" definition file. - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/hooks.php'); } @@ -113,14 +105,14 @@ class CI_Hooks { * @param string the hook name * @return mixed */ - public function _call_hook($which = '') + public function call_hook($which = '') { if ( ! $this->enabled OR ! isset($this->hooks[$which])) { return FALSE; } - if (isset($this->hooks[$which][0]) AND is_array($this->hooks[$which][0])) + if (isset($this->hooks[$which][0]) && is_array($this->hooks[$which][0])) { foreach ($this->hooks[$which] as $val) { @@ -167,7 +159,7 @@ class CI_Hooks { // Set file path // ----------------------------------- - if ( ! isset($data['filepath']) OR ! isset($data['filename'])) + if ( ! isset($data['filepath'], $data['filename'])) { return FALSE; } @@ -187,12 +179,12 @@ class CI_Hooks { $function = FALSE; $params = ''; - if (isset($data['class']) AND $data['class'] != '') + if ( ! empty($data['class'])) { $class = $data['class']; } - if (isset($data['function'])) + if ( ! empty($data['function'])) { $function = $data['function']; } @@ -202,7 +194,7 @@ class CI_Hooks { $params = $data['params']; } - if ($class === FALSE AND $function === FALSE) + if ($class === FALSE && $function === FALSE) { return FALSE; } @@ -244,4 +236,4 @@ class CI_Hooks { } /* End of file Hooks.php */ -/* Location: ./system/core/Hooks.php */ +/* Location: ./system/core/Hooks.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From bb30d79ef0a7d2a3949c479783ab2a1390118836 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 15:49:09 +0300 Subject: Remove access description lines and fix comments in system/core/Common.php --- system/core/Common.php | 190 +++++++++++++++++++++++++------------------------ 1 file changed, 96 insertions(+), 94 deletions(-) (limited to 'system/core') diff --git a/system/core/Common.php b/system/core/Common.php index f20acafd4..aeb784bbe 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Common Functions * @@ -42,15 +40,14 @@ // ------------------------------------------------------------------------ /** -* Determines if the current version of PHP is greater then the supplied value -* -* Since there are a few places where we conditionally test for PHP > 5 -* we'll set a static variable. -* -* @access public -* @param string -* @return bool TRUE if the current version is $version or higher -*/ + * Determines if the current version of PHP is greater then the supplied value + * + * Since there are a few places where we conditionally test for PHP > 5 + * we'll set a static variable. + * + * @param string + * @return bool TRUE if the current version is $version or higher + */ if ( ! function_exists('is_php')) { function is_php($version = '5.0.0') @@ -76,7 +73,7 @@ if ( ! function_exists('is_php')) * the file, based on the read-only attribute. is_writable() is also unreliable * on Unix servers if safe_mode is on. * - * @access public + * @param string * @return void */ if ( ! function_exists('is_really_writable')) @@ -118,18 +115,17 @@ if ( ! function_exists('is_really_writable')) // ------------------------------------------------------------------------ /** -* Class registry -* -* This function acts as a singleton. If the requested class does not -* exist it is instantiated and set to a static variable. If it has -* previously been instantiated the variable is returned. -* -* @access public -* @param string the class name being requested -* @param string the directory where the class should be found -* @param string the class name prefix -* @return object -*/ + * Class registry + * + * This function acts as a singleton. If the requested class does not + * exist it is instantiated and set to a static variable. If it has + * previously been instantiated the variable is returned. + * + * @param string the class name being requested + * @param string the directory where the class should be found + * @param string the class name prefix + * @return object + */ if ( ! function_exists('load_class')) { function &load_class($class, $directory = 'libraries', $prefix = 'CI_') @@ -192,12 +188,12 @@ if ( ! function_exists('load_class')) // -------------------------------------------------------------------- /** -* Keeps track of which libraries have been loaded. This function is -* called by the load_class() function above -* -* @access public -* @return array -*/ + * Keeps track of which libraries have been loaded. This function is + * called by the load_class() function above + * + * @param string + * @return array + */ if ( ! function_exists('is_loaded')) { function &is_loaded($class = '') @@ -216,14 +212,14 @@ if ( ! function_exists('is_loaded')) // ------------------------------------------------------------------------ /** -* Loads the main config.php file -* -* This function lets us grab the config file even if the Config class -* hasn't been instantiated yet -* -* @access private -* @return array -*/ + * Loads the main config.php file + * + * This function lets us grab the config file even if the Config class + * hasn't been instantiated yet + * + * @param array + * @return array + */ if ( ! function_exists('get_config')) { function &get_config($replace = array()) @@ -276,11 +272,11 @@ if ( ! function_exists('get_config')) // ------------------------------------------------------------------------ /** -* Returns the specified config item -* -* @access public -* @return mixed -*/ + * Returns the specified config item + * + * @param string + * @return mixed + */ if ( ! function_exists('config_item')) { function config_item($item) @@ -305,17 +301,19 @@ if ( ! function_exists('config_item')) // ------------------------------------------------------------------------ /** -* Error Handler -* -* This function lets us invoke the exception class and -* display errors using the standard error template located -* in application/errors/errors.php -* This function will send the error page directly to the -* browser and exit. -* -* @access public -* @return void -*/ + * Error Handler + * + * This function lets us invoke the exception class and + * display errors using the standard error template located + * in application/errors/errors.php + * This function will send the error page directly to the + * browser and exit. + * + * @param string + * @param int + * @param string + * @return void + */ if ( ! function_exists('show_error')) { function show_error($message, $status_code = 500, $heading = 'An Error Was Encountered') @@ -329,15 +327,16 @@ if ( ! function_exists('show_error')) // ------------------------------------------------------------------------ /** -* 404 Page Handler -* -* This function is similar to the show_error() function above -* However, instead of the standard error template it displays -* 404 errors. -* -* @access public -* @return void -*/ + * 404 Page Handler + * + * This function is similar to the show_error() function above + * However, instead of the standard error template it displays + * 404 errors. + * + * @param string + * @param bool + * @return void + */ if ( ! function_exists('show_404')) { function show_404($page = '', $log_error = TRUE) @@ -351,14 +350,16 @@ if ( ! function_exists('show_404')) // ------------------------------------------------------------------------ /** -* Error Logging Interface -* -* We use this as a simple mechanism to access the logging -* class and send messages to be logged. -* -* @access public -* @return void -*/ + * Error Logging Interface + * + * We use this as a simple mechanism to access the logging + * class and send messages to be logged. + * + * @param string + * @param string + * @param bool + * @return void + */ if ( ! function_exists('log_message')) { function log_message($level = 'error', $message, $php_error = FALSE) @@ -380,8 +381,7 @@ if ( ! function_exists('log_message')) /** * Set HTTP Status Header * - * @access public - * @param int the status code + * @param int the status code * @param string * @return void */ @@ -467,19 +467,22 @@ if ( ! function_exists('set_status_header')) // -------------------------------------------------------------------- /** -* Exception Handler -* -* This is the custom exception handler that is declaired at the top -* of Codeigniter.php. The main reason we use this is to permit -* PHP errors to be logged in our own log files since the user may -* not have access to server logs. Since this function -* effectively intercepts PHP errors, however, we also need -* to display errors based on the current error_reporting level. -* We do that with the use of a PHP error template. -* -* @access private -* @return void -*/ + * Exception Handler + * + * This is the custom exception handler that is declaired at the top + * of Codeigniter.php. The main reason we use this is to permit + * PHP errors to be logged in our own log files since the user may + * not have access to server logs. Since this function + * effectively intercepts PHP errors, however, we also need + * to display errors based on the current error_reporting level. + * We do that with the use of a PHP error template. + * + * @param int + * @param string + * @param string + * @param int + * @return void + */ if ( ! function_exists('_exception_handler')) { function _exception_handler($severity, $message, $filepath, $line) @@ -521,8 +524,8 @@ if ( ! function_exists('_exception_handler')) * This prevents sandwiching null characters * between ascii characters, like Java\0script. * - * @access public * @param string + * @param bool * @return string */ if ( ! function_exists('remove_invisible_characters')) @@ -554,12 +557,11 @@ if ( ! function_exists('remove_invisible_characters')) // ------------------------------------------------------------------------ /** -* Returns HTML escaped variable -* -* @access public -* @param mixed -* @return mixed -*/ + * Returns HTML escaped variable + * + * @param mixed + * @return mixed + */ if ( ! function_exists('html_escape')) { function html_escape($var) @@ -571,4 +573,4 @@ if ( ! function_exists('html_escape')) } /* 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 7b53d04eb4b89868307c65b7c64bc0889b25b4db Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 23:02:32 +0300 Subject: Some style adjustments and fixed comments in Router and Output classes --- system/core/Output.php | 20 +++++++++----------- system/core/Router.php | 32 +++++++++++++++----------------- 2 files changed, 24 insertions(+), 28 deletions(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index faebbbe72..9bf818e88 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Output Class * @@ -94,7 +92,7 @@ class CI_Output { $this->_zlib_oc = @ini_get('zlib.output_compression'); // Get mime types for later - if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) + if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes.php')) { include APPPATH.'config/'.ENVIRONMENT.'/mimes.php'; } @@ -229,7 +227,7 @@ class CI_Output { * Set HTTP Status Header * moved to Common procedural functions in 1.7.2 * - * @param int the status code + * @param int the status code * @param string * @return void */ @@ -249,7 +247,7 @@ class CI_Output { */ public function enable_profiler($val = TRUE) { - $this->enable_profiler = (is_bool($val)) ? $val : TRUE; + $this->enable_profiler = is_bool($val) ? $val : TRUE; return $this; } @@ -267,7 +265,7 @@ class CI_Output { { foreach ($sections as $section => $enable) { - $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE; + $this->_profiler_sections[$section] = ($enable !== FALSE); } return $this; @@ -278,12 +276,12 @@ class CI_Output { /** * Set Cache * - * @param integer + * @param int * @return void */ public function cache($time) { - $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; + $this->cache_expiration = is_numeric($time) ? $time : 0; return $this; } @@ -297,7 +295,7 @@ class CI_Output { * $this->final_output * * This function sends the finalized output data to the browser along - * with any server headers and profile data. It also stops the + * with any server headers and profile data. It also stops the * benchmark timer so the page rendering speed and memory usage can be shown. * * @param string @@ -343,7 +341,7 @@ class CI_Output { if ($this->parse_exec_vars === TRUE) { - $memory = ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).'MB'; + $memory = function_exists('memory_get_usage') ? round(memory_get_usage()/1024/1024, 2).'MB' : '0'; $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output); } @@ -520,4 +518,4 @@ class CI_Output { } /* End of file Output.php */ -/* Location: ./system/core/Output.php */ +/* Location: ./system/core/Output.php */ \ No newline at end of file diff --git a/system/core/Router.php b/system/core/Router.php index b251abb4b..5477fed5d 100755 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Router Class * @@ -111,7 +109,7 @@ class CI_Router { // since URI segments are more search-engine friendly, but they can optionally be used. // If this feature is enabled, we will gather the directory/class/method a little differently $segments = array(); - if ($this->config->item('enable_query_strings') === TRUE AND isset($_GET[$this->config->item('controller_trigger')])) + if ($this->config->item('enable_query_strings') === TRUE && isset($_GET[$this->config->item('controller_trigger')])) { if (isset($_GET[$this->config->item('directory_trigger')])) { @@ -133,7 +131,7 @@ class CI_Router { } // Load the routes.php file. - if (defined('ENVIRONMENT') AND is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) + if (defined('ENVIRONMENT') && is_file(APPPATH.'config/'.ENVIRONMENT.'/routes.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/routes.php'); } @@ -147,7 +145,7 @@ class CI_Router { // Set the default controller so we can display it in the event // the URI doesn't correlated to a valid controller. - $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']); + $this->default_controller = empty($this->routes['default_controller']) ? FALSE : strtolower($this->routes['default_controller']); // Were there any query string segments? If so, we'll validate them and bail out since we're done. if (count($segments) > 0) @@ -248,8 +246,8 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Validates the supplied segments. Attempts to determine the path to - * the controller. + * Validates the supplied segments. + * Attempts to determine the path to the controller. * * @param array * @return array @@ -340,7 +338,7 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Parse Routes + * Parse Routes * * This function matches any routes that may exist in * the config/routes.php file against the URI to @@ -369,7 +367,7 @@ class CI_Router { if (preg_match('#^'.$key.'$#', $uri)) { // Do we have a back-reference? - if (strpos($val, '$') !== FALSE AND strpos($key, '(') !== FALSE) + if (strpos($val, '$') !== FALSE && strpos($key, '(') !== FALSE) { $val = preg_replace('#^'.$key.'$#', $val, $uri); } @@ -411,7 +409,7 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Set the method name + * Set the method name * * @param string * @return void @@ -424,7 +422,7 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Fetch the current method + * Fetch the current method * * @return string */ @@ -441,7 +439,7 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Set the directory name + * Set the directory name * * @param string * @return void @@ -454,7 +452,7 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Fetch the sub-directory (if any) that contains the requested controller class + * Fetch the sub-directory (if any) that contains the requested controller class * * @return string */ @@ -466,10 +464,10 @@ class CI_Router { // -------------------------------------------------------------------- /** - * Set the controller overrides + * Set the controller overrides * * @param array - * @return null + * @return void */ public function _set_overrides($routing) { @@ -483,7 +481,7 @@ class CI_Router { $this->set_directory($routing['directory']); } - if (isset($routing['controller']) AND $routing['controller'] != '') + if (isset($routing['controller']) && $routing['controller'] != '') { $this->set_class($routing['controller']); } @@ -498,4 +496,4 @@ class CI_Router { } /* End of file Router.php */ -/* Location: ./system/core/Router.php */ +/* Location: ./system/core/Router.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 94af355dd00417424675f7b24c42affb827db0cd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Mar 2012 23:10:42 +0300 Subject: Some style adjustments and fixed comments in the Loader class --- system/core/Loader.php | 59 +++++++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'system/core') diff --git a/system/core/Loader.php b/system/core/Loader.php index 9b9cc2fef..976a5a575 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * Loader Class * @@ -281,7 +279,7 @@ class CI_Loader { continue; } - if ($db_conn !== FALSE AND ! class_exists('CI_DB')) + if ($db_conn !== FALSE && ! class_exists('CI_DB')) { if ($db_conn === TRUE) { @@ -324,7 +322,7 @@ class CI_Loader { $CI =& get_instance(); // Do we even need to load the database class? - if (class_exists('CI_DB') AND $return == FALSE AND $active_record == NULL AND isset($CI->db) AND is_object($CI->db)) + if (class_exists('CI_DB') && $return == FALSE && $active_record == NULL && isset($CI->db) && is_object($CI->db)) { return FALSE; } @@ -399,13 +397,13 @@ class CI_Loader { /** * Load View * - * This function is used to load a "view" file. It has three parameters: + * This function is used to load a "view" file. It has three parameters: * * 1. The name of the "view" file to be included. * 2. An associative array of data to be extracted for use in the view. - * 3. TRUE/FALSE - whether to return the data or load it. In - * some cases it's advantageous to be able to return data so that - * a developer can process it in some way. + * 3. TRUE/FALSE - whether to return the data or load it. In + * some cases it's advantageous to be able to return data so that + * a developer can process it in some way. * * @param string * @param array @@ -447,14 +445,14 @@ class CI_Loader { */ public function vars($vars = array(), $val = '') { - if ($val != '' AND is_string($vars)) + if ($val != '' && is_string($vars)) { $vars = array($vars => $val); } $vars = $this->_ci_object_to_array($vars); - if (is_array($vars) AND count($vars) > 0) + if (is_array($vars) && count($vars) > 0) { foreach ($vars as $key => $val) { @@ -660,7 +658,7 @@ class CI_Loader { * Prepends a parent path to the library, model, helper, and config path arrays * * @param string - * @param boolean + * @param bool * @return void */ public function add_package_path($path, $view_cascade=TRUE) @@ -701,9 +699,9 @@ class CI_Loader { * Remove a path from the library, model, and helper path arrays if it exists * If no path is provided, the most recently added path is removed. * - * @param type + * @param string * @param bool - * @return type + * @return void */ public function remove_package_path($path = '', $remove_config_path = TRUE) { @@ -764,7 +762,7 @@ class CI_Loader { // Set the default data variables foreach (array('_ci_view', '_ci_vars', '_ci_path', '_ci_return') as $_ci_val) { - $$_ci_val = ( ! isset($_ci_data[$_ci_val])) ? FALSE : $_ci_data[$_ci_val]; + $$_ci_val = isset($_ci_data[$_ci_val]) ? $_ci_data[$_ci_val] : FALSE; } $file_exists = FALSE; @@ -1019,11 +1017,11 @@ class CI_Loader { * @param string * @param bool * @param string an optional object name - * @return null + * @return void */ protected function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL) { - // Is there an associated config file for this class? Note: these should always be lowercase + // Is there an associated config file for this class? Note: these should always be lowercase if ($config === NULL) { // Fetch the config paths containing any package paths @@ -1038,24 +1036,24 @@ 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') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) + if (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php')) { - include($path .'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); + include($path.'config/'.ENVIRONMENT.'/'.strtolower($class).'.php'); break; } - elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) + elseif (defined('ENVIRONMENT') && file_exists($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php')) { - include($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); + include($path.'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).'.php'); break; } - elseif (file_exists($path .'config/'.strtolower($class).'.php')) + elseif (file_exists($path.'config/'.strtolower($class).'.php')) { - include($path .'config/'.strtolower($class).'.php'); + include($path.'config/'.strtolower($class).'.php'); break; } - elseif (file_exists($path .'config/'.ucfirst(strtolower($class)).'.php')) + elseif (file_exists($path.'config/'.ucfirst(strtolower($class)).'.php')) { - include($path .'config/'.ucfirst(strtolower($class)).'.php'); + include($path.'config/'.ucfirst(strtolower($class)).'.php'); break; } } @@ -1095,7 +1093,7 @@ class CI_Loader { if (is_null($object_name)) { - $classvar = ( ! isset($this->_ci_varmap[$class])) ? $class : $this->_ci_varmap[$class]; + $classvar = isset($this->_ci_varmap[$class]) ? $this->_ci_varmap[$class] : $class; } else { @@ -1130,7 +1128,7 @@ class CI_Loader { */ protected function _ci_autoloader() { - if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) + if (defined('ENVIRONMENT') && file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload.php')) { include(APPPATH.'config/'.ENVIRONMENT.'/autoload.php'); } @@ -1166,14 +1164,14 @@ class CI_Loader { // Autoload helpers and languages foreach (array('helper', 'language') as $type) { - if (isset($autoload[$type]) AND count($autoload[$type]) > 0) + if (isset($autoload[$type]) && count($autoload[$type]) > 0) { $this->$type($autoload[$type]); } } // Load libraries - if (isset($autoload['libraries']) AND count($autoload['libraries']) > 0) + if (isset($autoload['libraries']) && count($autoload['libraries']) > 0) { // Load the database driver. if (in_array('database', $autoload['libraries'])) @@ -1208,7 +1206,7 @@ class CI_Loader { */ protected function _ci_object_to_array($object) { - return (is_object($object)) ? get_object_vars($object) : $object; + return is_object($object) ? get_object_vars($object) : $object; } // -------------------------------------------------------------------- @@ -1252,7 +1250,8 @@ class CI_Loader { return $filename; } } + } /* End of file Loader.php */ -/* Location: ./system/core/Loader.php */ +/* Location: ./system/core/Loader.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From a11b16b1af42bbb4ffbc15eeee50a3d3ceb402d5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 28 Mar 2012 12:22:04 +0300 Subject: Fix a CI_Loader::_ci_load_class() bug --- system/core/Loader.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Loader.php b/system/core/Loader.php index 976a5a575..027ed20e5 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -1111,7 +1111,7 @@ class CI_Loader { } else { - $CI->$classvar = new $name; + $CI->$classvar = new $name(); } } -- cgit v1.2.3-24-g4f1b From 52fe7bb68f9961cdd765dd38e54779ae3b66e586 Mon Sep 17 00:00:00 2001 From: Songpol Sripaoeiam Date: Sun, 1 Apr 2012 11:43:20 +0700 Subject: add function get_current_content_type to output class and user manual library --- system/core/Output.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index 9bf818e88..673ceb0ee 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -220,6 +220,24 @@ class CI_Output { $this->headers[] = array($header, TRUE); return $this; } + + // -------------------------------------------------------------------- + + /** + * Get Current Content Type Header + * Return text/html if Content-Type is not set + * + * @return string + */ + public function get_current_content_type() + { + foreach($this->headers as $header){ + if(preg_match('/^Content-Type/', $header[0])){ + return str_replace('Content-Type: ', '', $header[0]); + } + } + return 'text/html'; + } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From b966701fad01c094199a89f7e4df72d981e5cf48 Mon Sep 17 00:00:00 2001 From: Songpol Sripaoeiam Date: Sun, 1 Apr 2012 17:13:44 +0700 Subject: bracket on a new line Also add space after foreach bracket on a new line... Also add a space after if Follow up from https://github.com/EllisLab/CodeIgniter/pull/1234/files#r630522 --- system/core/Output.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index 673ceb0ee..c0de24bb9 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -231,12 +231,13 @@ class CI_Output { */ public function get_current_content_type() { - foreach($this->headers as $header){ - if(preg_match('/^Content-Type/', $header[0])){ - return str_replace('Content-Type: ', '', $header[0]); - } + foreach ($this->headers as $header){ + if (preg_match('/^Content-Type/', $header[0])) + { + return str_replace('Content-Type: ', '', $header[0]); } - return 'text/html'; + } + return 'text/html'; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 38c0a72169ffbf002c7f3c7fd3b4fd41f0d75f09 Mon Sep 17 00:00:00 2001 From: Songpol Sripao-eiam Date: Sun, 1 Apr 2012 20:10:35 +0700 Subject: Fix style coding --- system/core/Output.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index c0de24bb9..ea39b0223 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -231,7 +231,8 @@ class CI_Output { */ public function get_current_content_type() { - foreach ($this->headers as $header){ + foreach ($this->headers as $header) + { if (preg_match('/^Content-Type/', $header[0])) { return str_replace('Content-Type: ', '', $header[0]); -- cgit v1.2.3-24-g4f1b From 614db07c77e341bfe4bf92d7576f01a6cabd43ff Mon Sep 17 00:00:00 2001 From: Songpol Sripaoeiam Date: Tue, 3 Apr 2012 01:29:28 +0700 Subject: The current name is too wide change to get_content_type()consistent with set_content_type() --- system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index ea39b0223..09d74f0c0 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -229,7 +229,7 @@ class CI_Output { * * @return string */ - public function get_current_content_type() + public function get_content_type() { foreach ($this->headers as $header) { -- cgit v1.2.3-24-g4f1b From 00adf1d480f94692a625ec2165e0fcc9171c6e2f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 3 Apr 2012 12:30:50 +0300 Subject: Some improvements to the additions from pull #1234 --- system/core/Output.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index 09d74f0c0..01fd1d867 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -220,24 +220,24 @@ class CI_Output { $this->headers[] = array($header, TRUE); return $this; } - + // -------------------------------------------------------------------- - + /** * Get Current Content Type Header - * Return text/html if Content-Type is not set * - * @return string + * @return string 'text/html', if not already set */ public function get_content_type() { - foreach ($this->headers as $header) + for ($i = 0, $c = count($this->headers); $i < $c; $i++) { - if (preg_match('/^Content-Type/', $header[0])) + if (preg_match('/^Content-Type:\s(.+)$/', $this->headers[$i][0], $matches)) { - return str_replace('Content-Type: ', '', $header[0]); + return $matches[1]; } } + return 'text/html'; } -- cgit v1.2.3-24-g4f1b From 0f2211711deceb74157d6811116acc0376d3157d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 13 Apr 2012 14:52:16 +0300 Subject: Switch erroneously declared protected properties in Output class to public --- system/core/Output.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system/core') diff --git a/system/core/Output.php b/system/core/Output.php index 01fd1d867..3cb40626a 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -43,37 +43,37 @@ class CI_Output { * * @var string */ - protected $final_output; + public $final_output; /** * Cache expiration time * * @var int */ - protected $cache_expiration = 0; + public $cache_expiration = 0; /** * List of server headers * * @var array */ - protected $headers = array(); + public $headers = array(); /** * List of mime types * * @var array */ - protected $mime_types = array(); + public $mime_types = array(); /** * Determines wether profiler is enabled * * @var book */ - protected $enable_profiler = FALSE; + public $enable_profiler = FALSE; /** * Determines if output compression is enabled * * @var bool */ - protected $_zlib_oc = FALSE; + protected $_zlib_oc = FALSE; /** * List of profiler sections * @@ -85,7 +85,7 @@ class CI_Output { * * @var bool */ - protected $parse_exec_vars = TRUE; + public $parse_exec_vars = TRUE; public function __construct() { -- cgit v1.2.3-24-g4f1b From ab3cab5a8f2afdd45ec8c6c365e43722781e54e6 Mon Sep 17 00:00:00 2001 From: dixy Date: Sat, 21 Apr 2012 00:58:00 +0200 Subject: Use parameter 'get_as_float' of microtime() --- system/core/Benchmark.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'system/core') diff --git a/system/core/Benchmark.php b/system/core/Benchmark.php index f6b634deb..39027e809 100755 --- a/system/core/Benchmark.php +++ b/system/core/Benchmark.php @@ -61,7 +61,7 @@ class CI_Benchmark { */ public function mark($name) { - $this->marker[$name] = microtime(); + $this->marker[$name] = microtime(TRUE); } // -------------------------------------------------------------------- @@ -93,13 +93,10 @@ class CI_Benchmark { if ( ! isset($this->marker[$point2])) { - $this->marker[$point2] = microtime(); + $this->marker[$point2] = microtime(TRUE); } - list($sm, $ss) = explode(' ', $this->marker[$point1]); - list($em, $es) = explode(' ', $this->marker[$point2]); - - return number_format(($em + $es) - ($sm + $ss), $decimals); + return number_format($this->marker[$point2] - $this->marker[$point1], $decimals); } // -------------------------------------------------------------------- @@ -122,4 +119,4 @@ class CI_Benchmark { } /* End of file Benchmark.php */ -/* Location: ./system/core/Benchmark.php */ +/* Location: ./system/core/Benchmark.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From b3f774bbbb81293326136e3e13297c3b8d49dfa4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 23 Apr 2012 12:57:57 +0300 Subject: Fix issue #1265 --- system/core/CodeIgniter.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'system/core') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 4885f310c..92187fa16 100755 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -275,12 +275,12 @@ { $x = explode('/', $RTR->routes['404_override'], 2); $class = $x[0]; - $method = (isset($x[1]) ? $x[1] : 'index'); + $method = isset($x[1]) ? $x[1] : 'index'; if ( ! class_exists($class)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) { - show_404("{$class}/{$method}"); + show_404($class.'/'.$method); } include_once(APPPATH.'controllers/'.$class.'.php'); @@ -288,7 +288,7 @@ } else { - show_404("{$class}/{$method}"); + show_404($class.'/'.$method); } } @@ -337,12 +337,12 @@ { $x = explode('/', $RTR->routes['404_override'], 2); $class = $x[0]; - $method = (isset($x[1]) ? $x[1] : 'index'); + $method = isset($x[1]) ? $x[1] : 'index'; if ( ! class_exists($class)) { if ( ! file_exists(APPPATH.'controllers/'.$class.'.php')) { - show_404("{$class}/{$method}"); + show_404($class.'/'.$method); } include_once(APPPATH.'controllers/'.$class.'.php'); @@ -352,7 +352,7 @@ } else { - show_404("{$class}/{$method}"); + show_404($class.'/'.$method); } } @@ -393,10 +393,10 @@ * Close the DB connection if one exists * ------------------------------------------------------ */ - if (class_exists('CI_DB') && isset($CI->db)) + if (class_exists('CI_DB') && isset($CI->db) && ! $CI->db->pconnect) { $CI->db->close(); } /* End of file CodeIgniter.php */ -/* Location: ./system/core/CodeIgniter.php */ +/* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b