From f4a4bd8fac188ebc9cda822ffc811c218fd92b45 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Thu, 20 Oct 2011 12:18:42 -0500 Subject: adding new license file (OSL 3.0) and updating readme to ReST added notice of license to all source files. OSL to all except the few files we ship inside of the application folder, those are AFL. Updated license in user guide. incrementing next dev version to 3.0 due to licensing change --- system/core/Config.php | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 714c4667b..abd2767d5 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -4,10 +4,22 @@ * * An open source application development framework for PHP 5.1.6 or newer * + * NOTICE OF LICENSE + * + * Licensed under the Open Software License version 3.0 + * + * This source file is subject to the Open Software License (OSL 3.0) that is + * bundled with this package in the files license.txt / license.rst. It is + * also available through the world wide web at this URL: + * http://opensource.org/licenses/OSL-3.0 + * If you did not receive a copy of the license and are unable to obtain it + * through the world wide web, please send an email to + * licensing@ellislab.com so we can send you a copy immediately. + * * @package CodeIgniter - * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. - * @license http://codeigniter.com/user_guide/license.html + * @author EllisLab Dev Team + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 * @filesource @@ -23,7 +35,7 @@ * @package CodeIgniter * @subpackage Libraries * @category Libraries - * @author ExpressionEngine Dev Team + * @author EllisLab Dev Team * @link http://codeigniter.com/user_guide/libraries/config.html */ class CI_Config { -- cgit v1.2.3-24-g4f1b From 03abee3df4534028c795e3c3da91034a3d3ee0f4 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 25 Dec 2011 00:31:29 -0600 Subject: Fixing soft tabs in a few files. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index abd2767d5..b0b4c9aa4 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -328,7 +328,7 @@ class CI_Config { $uri = $str; } } - return $uri; + return $uri; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 0defe5d33ee2633f377a109519ca818becc60f64 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Sun, 1 Jan 2012 18:46:41 -0600 Subject: Updating copyright date to 2012 --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index b0b4c9aa4..3e2635494 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From ccabcfd68919ecf146cd5f21079365afbffad000 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 19:30:47 +0200 Subject: Improve the Config library --- system/core/Config.php | 114 +++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 74 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 3e2635494..55da4e338 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -1,13 +1,13 @@ -config =& get_config(); log_message('debug', "Config Class Initialized"); @@ -81,10 +81,9 @@ class CI_Config { if (isset($_SERVER['HTTP_HOST'])) { $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 .= '://'. $_SERVER['HTTP_HOST'] + . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } - else { $base_url = 'http://localhost/'; @@ -99,27 +98,25 @@ class CI_Config { /** * Load Config File * - * @access public * @param string the config file name - * @param boolean if configuration values should be loaded into their own section - * @param boolean true if errors should just return false, false if an error message should be displayed + * @param boolean if configuration values should be loaded into their own section + * @param boolean true if errors should just return false, false if an error message should be displayed * @return boolean if the file was loaded correctly */ - function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) + public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file == '') ? 'config' : str_replace('.php', '', $file); - $found = FALSE; - $loaded = FALSE; + $found = $loaded = FALSE; foreach ($this->_config_paths as $path) { $check_locations = defined('ENVIRONMENT') - ? array(ENVIRONMENT.'/'.$file, $file) + ? array(ENVIRONMENT.DIRECTORY_SEPARATOR.$file, $file) : array($file); foreach ($check_locations as $location) { - $file_path = $path.'config/'.$location.'.php'; + $file_path = $path.'config'.DIRECTORY_SEPARATOR.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { @@ -192,39 +189,19 @@ class CI_Config { * Fetch a config file item * * - * @access public * @param string the config item name * @param string the index name * @param bool * @return string */ - function item($item, $index = '') + public function item($item, $index = '') { if ($index == '') { - if ( ! isset($this->config[$item])) - { - return FALSE; - } - - $pref = $this->config[$item]; - } - else - { - if ( ! isset($this->config[$index])) - { - return FALSE; - } - - if ( ! isset($this->config[$index][$item])) - { - return FALSE; - } - - $pref = $this->config[$index][$item]; + return isset($this->config[$item]) ? $this->config[$item] : FALSE; } - return $pref; + return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : FALSE; } // -------------------------------------------------------------------- @@ -232,18 +209,17 @@ class CI_Config { /** * Fetch a config file item - adds slash after item (if item is not empty) * - * @access public * @param string the config item name * @param bool * @return string */ - function slash_item($item) + public function slash_item($item) { if ( ! isset($this->config[$item])) { return FALSE; } - if( trim($this->config[$item]) == '') + elseif (trim($this->config[$item]) == '') { return ''; } @@ -257,11 +233,10 @@ class CI_Config { * Site URL * Returns base_url . index_page [. uri_string] * - * @access public * @param string the URI string * @return string */ - function site_url($uri = '') + public function site_url($uri = '') { if ($uri == '') { @@ -285,11 +260,10 @@ class CI_Config { * Base URL * Returns base_url [. uri_string] * - * @access public * @param string $uri * @return string */ - function base_url($uri = '') + public function base_url($uri = '') { return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/'); } @@ -299,8 +273,7 @@ class CI_Config { /** * Build URI string for use in Config::site_url() and Config::base_url() * - * @access protected - * @param $uri + * @param mixed $uri * @return string */ protected function _uri_string($uri) @@ -311,23 +284,21 @@ class CI_Config { { $uri = implode('/', $uri); } - $uri = trim($uri, '/'); + return trim($uri, '/'); } - else + elseif (is_array($uri)) { - if (is_array($uri)) + $i = 0; + $str = ''; + foreach ($uri as $key => $val) { - $i = 0; - $str = ''; - foreach ($uri as $key => $val) - { - $prefix = ($i == 0) ? '' : '&'; - $str .= $prefix.$key.'='.$val; - $i++; - } - $uri = $str; + $prefix = ($i === 0) ? '' : '&'; + $str .= $prefix.$key.'='.$val; + $i++; } + return $str; } + return $uri; } @@ -336,12 +307,11 @@ class CI_Config { /** * System URL * - * @access public * @return string */ - function system_url() + public function system_url() { - $x = explode("/", preg_replace("|/*(.+?)/*$|", "\\1", BASEPATH)); + $x = explode('/', preg_replace('|/*(.+?)/*$|', '\\1', BASEPATH)); return $this->slash_item('base_url').end($x).'/'; } @@ -350,12 +320,11 @@ class CI_Config { /** * Set a config file item * - * @access public * @param string the config item key * @param string the config item value * @return void */ - function set_item($item, $value) + public function set_item($item, $value) { $this->config[$item] = $value; } @@ -366,14 +335,13 @@ class CI_Config { * Assign to Config * * This function is called by the front controller (CodeIgniter.php) - * after the Config class is instantiated. It permits config items + * after the Config class is instantiated. It permits config items * to be assigned or overriden by variables contained in the index.php file * - * @access private * @param array * @return void */ - function _assign_to_config($items = array()) + public function _assign_to_config($items = array()) { if (is_array($items)) { @@ -385,7 +353,5 @@ class CI_Config { } } -// END CI_Config class - /* End of file Config.php */ /* Location: ./system/core/Config.php */ -- cgit v1.2.3-24-g4f1b From d52b242545376db2eb8146f16125819a391db763 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 7 Jan 2012 21:28:32 +0200 Subject: Reverted DIRECTORY_SEPARATOR changes --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 55da4e338..66369115a 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -73,7 +73,7 @@ class CI_Config { public function __construct() { $this->config =& get_config(); - log_message('debug', "Config Class Initialized"); + log_message('debug', 'Config Class Initialized'); // Set the base_url automatically if none was provided if ($this->config['base_url'] == '') @@ -111,12 +111,12 @@ class CI_Config { foreach ($this->_config_paths as $path) { $check_locations = defined('ENVIRONMENT') - ? array(ENVIRONMENT.DIRECTORY_SEPARATOR.$file, $file) + ? array(ENVIRONMENT.'/'.$file, $file) : array($file); foreach ($check_locations as $location) { - $file_path = $path.'config'.DIRECTORY_SEPARATOR.$location.'.php'; + $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { -- cgit v1.2.3-24-g4f1b From 0a9325c86cd5ccbdfe0c70ffb9bf816c8e15e148 Mon Sep 17 00:00:00 2001 From: Ross Duggan Date: Tue, 31 Jan 2012 15:47:52 +0000 Subject: HTTPS detection fix More closely follow the wording of the $_SERVER['HTTPS'] description in the PHP manual, which specifies a "non-empty" value rather than "non-null" --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 66369115a..68417435d 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -80,7 +80,7 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; + $base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; $base_url .= '://'. $_SERVER['HTTP_HOST'] . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } -- 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/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') 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 * -- 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/Config.php') 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 ad4750509885ad5bb368fc308f86d8c06d45b15c Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 19 Apr 2012 13:21:06 -0400 Subject: Normalize comments in core files --- system/core/Config.php | 1 - 1 file changed, 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 91826bd41..e94362912 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -188,7 +188,6 @@ class CI_Config { /** * Fetch a config file item * - * * @param string the config item name * @param string the index name * @param bool -- cgit v1.2.3-24-g4f1b From 40403d21274d5e0792c7ab816ad984d6387d5c20 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 19 Apr 2012 16:38:50 -0400 Subject: Additional formatting fixes --- system/core/Config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index e94362912..fc6183444 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -46,12 +46,14 @@ class CI_Config { * @var array */ public $config = array(); + /** * List of all loaded config files * * @var array */ public $is_loaded = array(); + /** * List of paths to search when trying to load a config file. * This must be public as it's used by the Loader class. @@ -353,4 +355,4 @@ class CI_Config { } /* End of file Config.php */ -/* Location: ./system/core/Config.php */ +/* Location: ./system/core/Config.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 48a7fbbeb53e82e9298036d40c42ec2564699ed0 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Mon, 23 Apr 2012 11:58:16 -0400 Subject: Use tabs to separate class properties --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index fc6183444..1eab08b82 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -45,14 +45,14 @@ class CI_Config { * * @var array */ - public $config = array(); + public $config = array(); /** * List of all loaded config files * * @var array */ - public $is_loaded = array(); + public $is_loaded = array(); /** * List of paths to search when trying to load a config file. @@ -60,7 +60,7 @@ class CI_Config { * * @var array */ - public $_config_paths = array(APPPATH); + public $_config_paths = array(APPPATH); /** * Constructor -- cgit v1.2.3-24-g4f1b From b8e6285feff1b699a94ea56fd9c2067c3a60d3f5 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 26 Apr 2012 18:40:54 -0400 Subject: Fix Config.php and partially fix Image_lib.php --- system/core/Config.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 1eab08b82..9cebe6c86 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -66,11 +66,6 @@ class CI_Config { * Constructor * * Sets the $config data from the primary config.php file as a class variable - * - * @param string the config file name - * @param boolean if configuration values should be loaded into their own section - * @param boolean true if errors should just return false, false if an error message should be displayed - * @return boolean if the file was successfully loaded or not */ public function __construct() { @@ -192,7 +187,6 @@ class CI_Config { * * @param string the config item name * @param string the index name - * @param bool * @return string */ public function item($item, $index = '') @@ -211,7 +205,6 @@ class CI_Config { * Fetch a config file item - adds slash after item (if item is not empty) * * @param string the config item name - * @param bool * @return string */ public function slash_item($item) -- cgit v1.2.3-24-g4f1b From 92ebfb65ac044f5c2e6d88fba137253854cf1b94 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 17 May 2012 12:49:24 +0300 Subject: Cleanup the core classes --- system/core/Config.php | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 9cebe6c86..c07ffa591 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -25,8 +25,6 @@ * @filesource */ -// ------------------------------------------------------------------------ - /** * CodeIgniter Config Class * @@ -46,14 +44,14 @@ class CI_Config { * @var array */ public $config = array(); - + /** * List of all loaded config files * * @var array */ public $is_loaded = array(); - + /** * List of paths to search when trying to load a config file. * This must be public as it's used by the Loader class. @@ -77,9 +75,9 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'; - $base_url .= '://'. $_SERVER['HTTP_HOST'] - . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + $base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http'; + $base_url .= '://'.$_SERVER['HTTP_HOST'] + .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } else { @@ -96,9 +94,9 @@ class CI_Config { * Load Config File * * @param string the config file name - * @param boolean if configuration values should be loaded into their own section - * @param boolean true if errors should just return false, false if an error message should be displayed - * @return boolean if the file was loaded correctly + * @param bool if configuration values should be loaded into their own section + * @param bool true if errors should just return false, false if an error message should be displayed + * @return bool if the file was loaded correctly */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { @@ -254,8 +252,8 @@ class CI_Config { * Base URL * Returns base_url [. uri_string] * - * @param string $uri - * @return string + * @param string $uri + * @return string */ public function base_url($uri = '') { @@ -267,8 +265,8 @@ class CI_Config { /** * Build URI string for use in Config::site_url() and Config::base_url() * - * @param mixed $uri - * @return string + * @param mixed $uri + * @return string */ protected function _uri_string($uri) { @@ -345,6 +343,7 @@ class CI_Config { } } } + } /* End of file Config.php */ -- cgit v1.2.3-24-g4f1b From ed944a3c70a0bad158cd5a6ca5ce1f2e717aff5d Mon Sep 17 00:00:00 2001 From: Alex Bilbie Date: Sat, 2 Jun 2012 11:07:47 +0100 Subject: Replaced `==` with `===` and `!=` with `!==` in /system/core --- system/core/Config.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index c07ffa591..0e5fa5265 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -100,7 +100,7 @@ class CI_Config { */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { - $file = ($file == '') ? 'config' : str_replace('.php', '', $file); + $file = ($file === '') ? 'config' : str_replace('.php', '', $file); $found = $loaded = FALSE; foreach ($this->_config_paths as $path) @@ -189,7 +189,7 @@ class CI_Config { */ public function item($item, $index = '') { - if ($index == '') + if ($index === '') { return isset($this->config[$item]) ? $this->config[$item] : FALSE; } @@ -211,7 +211,7 @@ class CI_Config { { return FALSE; } - elseif (trim($this->config[$item]) == '') + elseif (trim($this->config[$item]) === '') { return ''; } @@ -230,14 +230,14 @@ class CI_Config { */ public function site_url($uri = '') { - if ($uri == '') + if ($uri === '') { return $this->slash_item('base_url').$this->item('index_page'); } - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { - $suffix = ($this->item('url_suffix') == FALSE) ? '' : $this->item('url_suffix'); + $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } else @@ -270,7 +270,7 @@ class CI_Config { */ protected function _uri_string($uri) { - if ($this->item('enable_query_strings') == FALSE) + if ($this->item('enable_query_strings') === FALSE) { if (is_array($uri)) { -- cgit v1.2.3-24-g4f1b From 9ba661b02c492e89028e5c67b7edbfc0efefc9f1 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 4 Jun 2012 14:44:34 +0300 Subject: Revert/optimize some changes from ed944a3c70a0bad158cd5a6ca5ce1f2e717aff5d --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 0e5fa5265..3de1bcb96 100755 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -189,7 +189,7 @@ class CI_Config { */ public function item($item, $index = '') { - if ($index === '') + if ($index == '') { return isset($this->config[$item]) ? $this->config[$item] : FALSE; } -- cgit v1.2.3-24-g4f1b From 0d2c06ea1d96ea3f35dd1e7856977a24cec43233 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 12 Jun 2012 02:33:45 +0300 Subject: Change file permissions for system/core/*.php and system/database/DB.php so that they don't differ from the rest --- system/core/Config.php | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 system/core/Config.php (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php old mode 100755 new mode 100644 -- cgit v1.2.3-24-g4f1b From 1764dd7d4ab6e6e5c799eaa9ce007fce48fa0b63 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 18:48:19 +0300 Subject: Fix issue #938 + some related improvements --- system/core/Config.php | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 3de1bcb96..656382716 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -225,12 +225,12 @@ class CI_Config { * Site URL * Returns base_url . index_page [. uri_string] * - * @param string the URI string + * @param mixed the URI string or an array of segments * @return string */ public function site_url($uri = '') { - if ($uri === '') + if (empty($uri)) { return $this->slash_item('base_url').$this->item('index_page'); } @@ -240,10 +240,12 @@ class CI_Config { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; } - else + elseif (is_array($uri) OR strpos($uri, '?') === FALSE) { - return $this->slash_item('base_url').$this->item('index_page').'?'.$this->_uri_string($uri); + $uri = '?'.$this->_uri_string($uri); } + + return $this->slash_item('base_url').$this->item('index_page').$uri; } // ------------------------------------------------------------- @@ -280,15 +282,7 @@ class CI_Config { } elseif (is_array($uri)) { - $i = 0; - $str = ''; - foreach ($uri as $key => $val) - { - $prefix = ($i === 0) ? '' : '&'; - $str .= $prefix.$key.'='.$val; - $i++; - } - return $str; + return http_build_query($uri); } return $uri; -- cgit v1.2.3-24-g4f1b From 95d78cf4f78c0fb685a789c280d106ab242318ef Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 16 Jun 2012 19:54:33 +0300 Subject: Fix issue #999 --- system/core/Config.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 656382716..4b4e5a7ba 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -235,14 +235,26 @@ class CI_Config { return $this->slash_item('base_url').$this->item('index_page'); } + $uri = $this->_uri_string($uri); + if ($this->item('enable_query_strings') === FALSE) { $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); - return $this->slash_item('base_url').$this->slash_item('index_page').$this->_uri_string($uri).$suffix; + + if ($suffix !== '' && ($offset = strpos($uri, '?')) !== FALSE) + { + $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); + } + else + { + $uri .= $suffix; + } + + return $this->slash_item('base_url').$this->slash_item('index_page').$uri; } - elseif (is_array($uri) OR strpos($uri, '?') === FALSE) + elseif (strpos($uri, '?') === FALSE) { - $uri = '?'.$this->_uri_string($uri); + $uri = '?'.$uri; } return $this->slash_item('base_url').$this->item('index_page').$uri; -- cgit v1.2.3-24-g4f1b From d6ab7a297d26ab148d819ae7ca95c0e604abf188 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Wed, 4 Jul 2012 01:56:04 -0500 Subject: Moved redundant $check_locations definition out of loop. --- system/core/Config.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 4b4e5a7ba..b21d7a588 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -102,13 +102,13 @@ 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) { - $check_locations = defined('ENVIRONMENT') - ? array(ENVIRONMENT.'/'.$file, $file) - : array($file); - foreach ($check_locations as $location) { $file_path = $path.'config/'.$location.'.php'; -- cgit v1.2.3-24-g4f1b From aa141a5e20318608d42e3cda7ebcc0d69fa9b9b8 Mon Sep 17 00:00:00 2001 From: Eric Roberts Date: Wed, 4 Jul 2012 02:13:56 -0500 Subject: Fix some whitespace, removed unnecessary string concatenation. --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index b21d7a588..2f6a9e085 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -43,7 +43,7 @@ class CI_Config { * * @var array */ - public $config = array(); + public $config = array(); /** * List of all loaded config files @@ -172,7 +172,7 @@ class CI_Config { { return FALSE; } - show_error('The configuration file '.$file.'.php'.' does not exist.'); + show_error('The configuration file '.$file.'.php does not exist.'); } return TRUE; @@ -271,7 +271,7 @@ class CI_Config { */ public function base_url($uri = '') { - return $this->slash_item('base_url').ltrim($this->_uri_string($uri),'/'); + return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/'); } // ------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 9438e26671ee1f0b49c8da7a56a0a195788fd5da Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 5 Oct 2012 13:16:27 +0300 Subject: Fix issue #116 + other space/style fixes [ci skip --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 2f6a9e085..8e4f998ef 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -102,7 +102,7 @@ class CI_Config { { $file = ($file === '') ? 'config' : str_replace('.php', '', $file); $found = $loaded = FALSE; - + $check_locations = defined('ENVIRONMENT') ? array(ENVIRONMENT.'/'.$file, $file) : array($file); -- cgit v1.2.3-24-g4f1b From 3fb026713013b60845c4cfe633a8a59a30b9c7dd Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 22 Oct 2012 16:48:01 +0300 Subject: Add is_https() as a common function --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 8e4f998ef..e78128c76 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -75,7 +75,7 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = ( ! empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') ? 'https' : 'http'; + $base_url = is_https() ? 'https' : 'http'; $base_url .= '://'.$_SERVER['HTTP_HOST'] .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); } -- cgit v1.2.3-24-g4f1b From 5232ba07752ffa783d03754c3a869d9f73ccae69 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 27 Oct 2012 15:25:05 +0300 Subject: Docblock improvements to the Config library and remove CI_Config::_assign_to_config() Existance of _assign_to_config() is pointless as this method consists just of a foreach calling CI_Config::set_item() and is only called by CodeIgniter.php - moved that foreach() in there instead. --- system/core/Config.php | 80 +++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 46 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index e78128c76..152e9af68 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -26,7 +26,7 @@ */ /** - * CodeIgniter Config Class + * Config Class * * This class contains functions that enable config files to be managed * @@ -41,29 +41,31 @@ class CI_Config { /** * List of all loaded config values * - * @var array + * @var array */ public $config = array(); /** * List of all loaded config files * - * @var array + * @var array */ public $is_loaded = array(); /** * List of paths to search when trying to load a config file. - * This must be public as it's used by the Loader class. * - * @var array + * @used-by CI_Loader Must be public + * @var array */ public $_config_paths = array(APPPATH); /** - * Constructor + * Class constructor * - * Sets the $config data from the primary config.php file as a class variable + * Sets the $config data from the primary config.php file as a class variable. + * + * @return void */ public function __construct() { @@ -93,10 +95,10 @@ class CI_Config { /** * Load Config File * - * @param string the config file name - * @param bool if configuration values should be loaded into their own section - * @param bool true if errors should just return false, false if an error message should be displayed - * @return bool if the file was loaded correctly + * @param string $file Configuration file name + * @param bool $use_sections Whether configuration values should be loaded into their own section + * @param bool $fail_gracefully Whether to just return FALSE or display an error message + * @return bool TRUE if the file was loaded correctly or FALSE on failure */ public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { @@ -183,9 +185,9 @@ class CI_Config { /** * Fetch a config file item * - * @param string the config item name - * @param string the index name - * @return string + * @param string $item Config item name + * @param string $index Index name + * @return string|bool The configuration item or FALSE on failure */ public function item($item, $index = '') { @@ -200,10 +202,10 @@ class CI_Config { // -------------------------------------------------------------------- /** - * Fetch a config file item - adds slash after item (if item is not empty) + * Fetch a config file item with slash appended (if not empty) * - * @param string the config item name - * @return string + * @param string $item Config item name + * @return string|bool The configuration item or FALSE on failure */ public function slash_item($item) { @@ -223,9 +225,12 @@ class CI_Config { /** * Site URL + * * Returns base_url . index_page [. uri_string] * - * @param mixed the URI string or an array of segments + * @uses CI_Config::_uri_string() + * + * @param string|string[] $uri URI string or an array of segments * @return string */ public function site_url($uri = '') @@ -264,9 +269,12 @@ class CI_Config { /** * Base URL + * * Returns base_url [. uri_string] * - * @param string $uri + * @uses CI_Config::_uri_string() + * + * @param string|string[] $uri URI string or an array of segments * @return string */ public function base_url($uri = '') @@ -277,9 +285,12 @@ class CI_Config { // ------------------------------------------------------------- /** - * Build URI string for use in Config::site_url() and Config::base_url() + * Build URI string + * + * @used-by CI_Config::site_url() + * @used-by CI_Config::base_url() * - * @param mixed $uri + * @param string|string[] $uri URI string or an array of segments * @return string */ protected function _uri_string($uri) @@ -318,8 +329,8 @@ class CI_Config { /** * Set a config file item * - * @param string the config item key - * @param string the config item value + * @param string $item Config item key + * @param string $value Config item value * @return void */ public function set_item($item, $value) @@ -327,29 +338,6 @@ class CI_Config { $this->config[$item] = $value; } - // -------------------------------------------------------------------- - - /** - * Assign to Config - * - * This function is called by the front controller (CodeIgniter.php) - * after the Config class is instantiated. It permits config items - * to be assigned or overriden by variables contained in the index.php file - * - * @param array - * @return void - */ - public function _assign_to_config($items = array()) - { - if (is_array($items)) - { - foreach ($items as $key => $val) - { - $this->set_item($key, $val); - } - } - } - } /* End of file Config.php */ -- cgit v1.2.3-24-g4f1b From 1887ec69c9230ff3fbde63f209b50ce69b28fc62 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 27 Oct 2012 16:22:07 +0300 Subject: Input class improvements - Disable register_globals replication on PHP 5.4+ (no longer exists). - DocBlock improvements. - Add missing changelog entry. - Change user_agent() to return NULL when no value is found (for consistency with other fetcher methods). --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 152e9af68..642cee798 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -55,7 +55,7 @@ class CI_Config { /** * List of paths to search when trying to load a config file. * - * @used-by CI_Loader Must be public + * @used-by CI_Loader * @var array */ public $_config_paths = array(APPPATH); -- cgit v1.2.3-24-g4f1b From c5536aac5752054f7f76e448d58b86407d8f574e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 1 Nov 2012 17:33:58 +0200 Subject: Manually apply PR #1594 (fixing phpdoc page-level generation/warnings) Also partially fixes issue #1295, fixes inconsistencies in some page-level docblocks and adds include checks in language files. --- system/core/Config.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 642cee798..8250b5b1a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -1,4 +1,4 @@ - Date: Mon, 3 Dec 2012 10:43:44 +0100 Subject: config->site_url() optimizations - direct access to config array, instead of item() calls - the string cast is just in case 'url_suffix' would be set to false or null; the function produces the same results without this cast, but it leads to a robuster code, as false and null are sanitized and skip the suffix insertion code - altered conditional structure: if no suffix, skip the appending of an empty string to $uri --- system/core/Config.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 8250b5b1a..9e6d2cbf2 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -245,15 +245,18 @@ class CI_Config { if ($this->item('enable_query_strings') === FALSE) { - $suffix = ($this->item('url_suffix') === FALSE) ? '' : $this->item('url_suffix'); + $suffix = isset($this->config['url_suffix']) ? (string) $this->config['url_suffix'] : ''; - if ($suffix !== '' && ($offset = strpos($uri, '?')) !== FALSE) + if ($suffix !== '') { - $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); - } - else - { - $uri .= $suffix; + if (($offset = strpos($uri, '?')) !== FALSE) + { + $uri = substr($uri, 0, $offset).$suffix.substr($uri, $offset); + } + else + { + $uri .= $suffix; + } } return $this->slash_item('base_url').$this->slash_item('index_page').$uri; -- cgit v1.2.3-24-g4f1b From 4d9fd19e6e224042e04f71c35b174990a177527d Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 3 Dec 2012 11:31:00 +0100 Subject: config->site_url(): remove useless cast thanks to narfbg --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 9e6d2cbf2..38bcd5c8f 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -245,7 +245,7 @@ class CI_Config { if ($this->item('enable_query_strings') === FALSE) { - $suffix = isset($this->config['url_suffix']) ? (string) $this->config['url_suffix'] : ''; + $suffix = isset($this->config['url_suffix']) ? $this->config['url_suffix'] : ''; if ($suffix !== '') { -- cgit v1.2.3-24-g4f1b From 80500afbd188600212ca913a7bac073009feac73 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 1 Jan 2013 08:16:53 +0200 Subject: [ci skip] Happy new year --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 38bcd5c8f..0160d1a15 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From 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 --- system/core/Config.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'system/core/Config.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'; -- cgit v1.2.3-24-g4f1b From 184cf1b5a719f4559767a221520d5ba96d1e4d8b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 24 Jul 2013 03:43:39 +0200 Subject: config->item() now returns NULL instead of FALSE when the required item doesn't exist. Uniformization with other functions. This also brings the ability to properly use booleans in configuration. --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 7e64444bc..14ade7248 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -184,16 +184,16 @@ class CI_Config { * * @param string $item Config item name * @param string $index Index name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL on failure */ public function item($item, $index = '') { if ($index == '') { - return isset($this->config[$item]) ? $this->config[$item] : FALSE; + return isset($this->config[$item]) ? $this->config[$item] : NULL; } - return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : FALSE; + return isset($this->config[$index], $this->config[$index][$item]) ? $this->config[$index][$item] : NULL; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 90f316a8615fbbbc0810d945dd1a237662c6bfbf Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 25 Jul 2013 04:33:56 +0200 Subject: Adjustments to the previous commit --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 14ade7248..e7cbe5624 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -184,7 +184,7 @@ class CI_Config { * * @param string $item Config item name * @param string $index Index name - * @return string|null The configuration item or NULL on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function item($item, $index = '') { -- cgit v1.2.3-24-g4f1b From c1044cb62e39709aa14f86a56bc950a78cfc713c Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 25 Jul 2013 12:18:43 +0200 Subject: Uniformize slash_item() with item() --- system/core/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index e7cbe5624..109ee6424 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -202,13 +202,13 @@ class CI_Config { * Fetch a config file item with slash appended (if not empty) * * @param string $item Config item name - * @return string|bool The configuration item or FALSE on failure + * @return string|null The configuration item or NULL if the item doesn't exist */ public function slash_item($item) { if ( ! isset($this->config[$item])) { - return FALSE; + return NULL; } elseif (trim($this->config[$item]) === '') { -- cgit v1.2.3-24-g4f1b From 4c07fce7191ed5d9c393479406cce454a9c4a7cc Mon Sep 17 00:00:00 2001 From: vlakoff Date: Fri, 25 Oct 2013 01:20:32 +0200 Subject: Implement $protocol parameter in Config base_url() and site_url() methods Let's keep the implementation logic in one place. Improves 2023c3d05b042cf1322286d69557c2b8bf3bd8d5. --- system/core/Config.php | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 109ee6424..a0e830abe 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -228,13 +228,21 @@ class CI_Config { * @uses CI_Config::_uri_string() * * @param string|string[] $uri URI string or an array of segments + * @param string $protocol * @return string */ - public function site_url($uri = '') + public function site_url($uri = '', $protocol = NULL) { + $base_url = $this->slash_item('base_url'); + + if (isset($protocol)) + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } + if (empty($uri)) { - return $this->slash_item('base_url').$this->item('index_page'); + return $base_url.$this->item('index_page'); } $uri = $this->_uri_string($uri); @@ -255,14 +263,14 @@ class CI_Config { } } - return $this->slash_item('base_url').$this->slash_item('index_page').$uri; + return $base_url.$this->slash_item('index_page').$uri; } elseif (strpos($uri, '?') === FALSE) { $uri = '?'.$uri; } - return $this->slash_item('base_url').$this->item('index_page').$uri; + return $base_url.$this->item('index_page').$uri; } // ------------------------------------------------------------- @@ -275,11 +283,19 @@ class CI_Config { * @uses CI_Config::_uri_string() * * @param string|string[] $uri URI string or an array of segments + * @param string $protocol * @return string */ - public function base_url($uri = '') + public function base_url($uri = '', $protocol = NULL) { - return $this->slash_item('base_url').ltrim($this->_uri_string($uri), '/'); + $base_url = $this->slash_item('base_url'); + + if (isset($protocol)) + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } + + return $base_url.ltrim($this->_uri_string($uri), '/'); } // ------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From e4e1091d42e854e96706c153c71410301b3c3047 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 8 Feb 2014 19:58:48 +0200 Subject: Deprecate CI_Config::system_url() --- system/core/Config.php | 1 + 1 file changed, 1 insertion(+) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index a0e830abe..93c950e2e 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -332,6 +332,7 @@ class CI_Config { /** * System URL * + * @deprecated 3.0.0 Encourages insecure practices * @return string */ public function system_url() -- cgit v1.2.3-24-g4f1b From 871754af60251993d640981e107d2def5f2db396 Mon Sep 17 00:00:00 2001 From: darwinel Date: Tue, 11 Feb 2014 17:34:57 +0100 Subject: 2013 > 2014 Update copyright notices from 2013 to 2014. And update one calendar example in user_guide from year 2013/2014 to 2014/2015. --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 93c950e2e..f630d1709 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -18,7 +18,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From dfd51cb0379936a5cc90b980ddf46b170f3b365b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 31 Mar 2014 20:41:07 +0200 Subject: Refactoring in Config->__construct() Put the $_SERVER['HTTP_HOST'] fallback in a more logical place. --- system/core/Config.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index f630d1709..56259bd06 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,16 +76,9 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - if (isset($_SERVER['HTTP_HOST'])) - { - $base_url = is_https() ? 'https' : 'http'; - $base_url .= '://'.$_SERVER['HTTP_HOST'] - .str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); - } - else - { - $base_url = 'http://localhost/'; - } + $base_url = (is_https() ? 'https' : 'http') . '://' + . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') + . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From 2516f3b3945106aeebda87bd6a35454b7d72bdba Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 31 Mar 2014 20:46:04 +0200 Subject: Robuster determination of "base_url" config item Remove the basename only at the end, to avoid edge cases. --- system/core/Config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 56259bd06..728e28dd8 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,9 +76,11 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { + $script_basename = basename($_SERVER['SCRIPT_NAME']); + $base_url = (is_https() ? 'https' : 'http') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - . str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']); + . preg_replace('/'.preg_quote($script_basename).'$/', '', $_SERVER['SCRIPT_NAME']); $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From 93836ff351e3035bf368ed56da09ac27e354989f Mon Sep 17 00:00:00 2001 From: vlakoff Date: Mon, 31 Mar 2014 20:46:14 +0200 Subject: Different method for determining "base_url" Better performance by not using regex. --- system/core/Config.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 728e28dd8..ec852b133 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,11 +76,16 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - $script_basename = basename($_SERVER['SCRIPT_NAME']); + $script_dir = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'); + + if ($script_dir !== '/') + { + $script_dir .= '/'; + } $base_url = (is_https() ? 'https' : 'http') . '://' . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - . preg_replace('/'.preg_quote($script_basename).'$/', '', $_SERVER['SCRIPT_NAME']); + . $script_dir; $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From 8bec33f37bd0e4542d5f963a446283c10a2b2ffe Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 1 Apr 2014 01:03:48 +0200 Subject: Remove spaces around concatenations per request --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index ec852b133..b2689a6bb 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -83,9 +83,9 @@ class CI_Config { $script_dir .= '/'; } - $base_url = (is_https() ? 'https' : 'http') . '://' - . (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - . $script_dir; + $base_url = (is_https() ? 'https' : 'http').'://' + .(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') + .$script_dir; $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From b208f6502917b42a07b4bb7e5ffe2ef4b1359267 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 1 Apr 2014 01:21:51 +0200 Subject: Yet another method for determining "base_url" This one is great because we don't have to deal with the special cases: * in Windows, dirname('/foo/index.php') gives "/foo", but dirname('/index.php') gives "\" instead of "/" * dirname() doesn't include the trailing slash, with the expection of "/" (root) props @narfbg --- system/core/Config.php | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index b2689a6bb..41367d353 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,16 +76,9 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - $script_dir = strtr(dirname($_SERVER['SCRIPT_NAME']), '\\', '/'); - - if ($script_dir !== '/') - { - $script_dir .= '/'; - } - $base_url = (is_https() ? 'https' : 'http').'://' .(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - .$script_dir; + .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From 7ead65b5dc48c477dc3dfe3b969b1e14bb9a1b79 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 1 Apr 2014 02:09:25 +0200 Subject: Discard the unwanted changes --- system/core/Config.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 41367d353..ad0e5f981 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -76,9 +76,16 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - $base_url = (is_https() ? 'https' : 'http').'://' - .(isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : 'localhost') - .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); + if (isset($_SERVER['HTTP_HOST'])) + { + $base_url = (is_https() ? 'https' : 'http') + .'://'.$_SERVER['HTTP_HOST'] + .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); + } + else + { + $base_url = 'http://localhost/'; + } $this->set_item('base_url', $base_url); } -- cgit v1.2.3-24-g4f1b From b3355196d8a0541812fa0883e7fcdac912fa6d98 Mon Sep 17 00:00:00 2001 From: Fu Xu Date: Thu, 12 Jun 2014 16:45:00 +0800 Subject: config load bug fix --- system/core/Config.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index ad0e5f981..6650c4cc9 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -104,10 +104,11 @@ class CI_Config { public function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE) { $file = ($file === '') ? 'config' : str_replace('.php', '', $file); - $found = $loaded = FALSE; + $loaded = FALSE; foreach ($this->_config_paths as $path) { + $found = FALSE; foreach (array(ENVIRONMENT.'/'.$file, $file) as $location) { $file_path = $path.'config/'.$location.'.php'; @@ -358,4 +359,4 @@ class CI_Config { } /* End of file Config.php */ -/* Location: ./system/core/Config.php */ \ No newline at end of file +/* Location: ./system/core/Config.php */ -- cgit v1.2.3-24-g4f1b From 66b181e56c38f0834342abc1bb9ed20c51aef240 Mon Sep 17 00:00:00 2001 From: Fu Xu Date: Thu, 12 Jun 2014 16:49:11 +0800 Subject: style change --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 6650c4cc9..bd197925a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -108,7 +108,7 @@ class CI_Config { foreach ($this->_config_paths as $path) { - $found = FALSE; + $found = FALSE; foreach (array(ENVIRONMENT.'/'.$file, $file) as $location) { $file_path = $path.'config/'.$location.'.php'; -- cgit v1.2.3-24-g4f1b From 0bd32a66e5787ddb22a903d2ee718b3c872be454 Mon Sep 17 00:00:00 2001 From: Fu Xu Date: Thu, 12 Jun 2014 19:58:51 +0800 Subject: remove the empty line at the end of file --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index bd197925a..db406dfde 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -359,4 +359,4 @@ class CI_Config { } /* End of file Config.php */ -/* Location: ./system/core/Config.php */ +/* Location: ./system/core/Config.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 4bdb66759c24c41fefec7952b12a0595a671eaa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Wed, 8 Oct 2014 00:29:26 +0300 Subject: Attempt a better base_url auto-detection --- system/core/Config.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index db406dfde..18380a0db 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -78,9 +78,11 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = (is_https() ? 'https' : 'http') - .'://'.$_SERVER['HTTP_HOST'] - .substr($_SERVER['SCRIPT_NAME'], 0, -strlen(basename($_SERVER['SCRIPT_NAME']))); + $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].'/'; + if ( ! empty($_SERVER['DOCUMENT_ROOT'])) + { + $base_url .= ltrim(str_replace('\\', '/', substr(FCPATH, strlen($_SERVER['DOCUMENT_ROOT']))), '/\\'); + } } else { -- cgit v1.2.3-24-g4f1b From f35ae5eb7fc81b1c6a903591c6ff56103e6e247f Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 10 Oct 2014 15:40:56 +0300 Subject: Fix #3270 Related: #3268, 4bdb66759c24c41fefec7952b12a0595a671eaa2 --- system/core/Config.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 18380a0db..ee738d752 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -78,11 +78,8 @@ class CI_Config { { if (isset($_SERVER['HTTP_HOST'])) { - $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'].'/'; - if ( ! empty($_SERVER['DOCUMENT_ROOT'])) - { - $base_url .= ltrim(str_replace('\\', '/', substr(FCPATH, strlen($_SERVER['DOCUMENT_ROOT']))), '/\\'); - } + $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'] + .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); } else { -- cgit v1.2.3-24-g4f1b From bdb96ca1b1dbfc1791172fd169d7751cbc4d7d55 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 00:13:31 +0200 Subject: [ci skip] Switch to MIT license; close #3293 --- system/core/Config.php | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index ee738d752..02e6dd84f 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -4,24 +4,35 @@ * * An open source application development framework for PHP 5.2.4 or newer * - * NOTICE OF LICENSE + * This content is released under the MIT License (MIT) * - * Licensed under the Open Software License version 3.0 + * Copyright (c) 2014, British Columbia Institute of Technology * - * This source file is subject to the Open Software License (OSL 3.0) that is - * bundled with this package in the files license.txt / license.rst. It is - * also available through the world wide web at this URL: - * http://opensource.org/licenses/OSL-3.0 - * If you did not receive a copy of the license and are unable to obtain it - * through the world wide web, please send an email to - * licensing@ellislab.com so we can send you a copy immediately. + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: * - * @package CodeIgniter - * @author EllisLab Dev Team + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * @package CodeIgniter + * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) - * @link http://codeigniter.com - * @since Version 1.0 + * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @license http://opensource.org/licenses/MIT MIT License + * @link http://codeigniter.com + * @since Version 1.0.0 * @filesource */ defined('BASEPATH') OR exit('No direct script access allowed'); -- cgit v1.2.3-24-g4f1b From 815ac8a3be770b7de7a805a551f136cc6bb9f83c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 28 Oct 2014 21:32:20 +0200 Subject: Close #3292 --- system/core/Config.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 02e6dd84f..d8a606c14 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -87,7 +87,9 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - if (isset($_SERVER['HTTP_HOST'])) + // The regular expression is only a basic validation for a valid "Host" header. + // It's not exhaustive, only checks for valid characters. + if (isset($_SERVER['HTTP_HOST']) && preg_match('/^((\[[0-9a-f:]+\])|(\d{1,3}(\.\d{1,3}){3})|[a-z0-9\-\.]+)(:\d+)?$/i', $_SERVER['HTTP_HOST'])) { $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'] .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); -- cgit v1.2.3-24-g4f1b From 42bc6d51e15c180f35632d5c03c649225f8dbf74 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 16 Dec 2014 16:16:45 +0200 Subject: Fix #3419 --- system/core/Config.php | 69 ++++++++++++++++++++------------------------------ 1 file changed, 28 insertions(+), 41 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index d8a606c14..ca865cebf 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -120,74 +120,61 @@ class CI_Config { foreach ($this->_config_paths as $path) { - $found = FALSE; - foreach (array(ENVIRONMENT.'/'.$file, $file) as $location) + foreach (array($file, ENVIRONMENT.'/'.$file) as $location) { $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) { - $loaded = TRUE; - continue 2; + return TRUE; } - if (file_exists($file_path)) + if ( ! file_exists($file_path)) { - $found = TRUE; - break; + continue; } - } - - if ($found === FALSE) - { - continue; - } - include($file_path); + include($file_path); - if ( ! isset($config) OR ! is_array($config)) - { - if ($fail_gracefully === TRUE) + if ( ! isset($config) OR ! is_array($config)) { - return FALSE; + if ($fail_gracefully === TRUE) + { + return FALSE; + } + + show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); } - show_error('Your '.$file_path.' file does not appear to contain a valid configuration array.'); - } - if ($use_sections === TRUE) - { - if (isset($this->config[$file])) + if ($use_sections === TRUE) { - $this->config[$file] = array_merge($this->config[$file], $config); + $this->config[$file] = isset($this->config[$file]) + ? array_merge($this->config[$file], $config) + : $config; } else { - $this->config[$file] = $config; + $this->config = array_merge($this->config, $config); } + + $this->is_loaded[] = $file_path; + $config = NULL; + $loaded = TRUE; + log_message('debug', 'Config file loaded: '.$file_path); } - else + + if ($loaded === TRUE) { - $this->config = array_merge($this->config, $config); + return TRUE; } - - $this->is_loaded[] = $file_path; - unset($config); - - $loaded = TRUE; - log_message('debug', 'Config file loaded: '.$file_path); - break; } - if ($loaded === FALSE) + if ($fail_gracefully === TRUE) { - if ($fail_gracefully === TRUE) - { - return FALSE; - } - show_error('The configuration file '.$file.'.php does not exist.'); + return FALSE; } - return TRUE; + show_error('The configuration file '.$file.'.php does not exist.'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From fe9309d22c1b088f5363954d6dac013c8c955894 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 9 Jan 2015 17:48:58 +0200 Subject: Bulk (mostly documentation) update - Remove PHP version from license notices - Bump year number in copyright notices - Recommend PHP 5.4 or newer to be used - Tell Travis-CI to test on PHP 5.3.0 instead of the latest 5.3 version Related: #3450 --- system/core/Config.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index ca865cebf..d5ce91f48 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -2,11 +2,11 @@ /** * CodeIgniter * - * An open source application development framework for PHP 5.2.4 or newer + * An open source application development framework for PHP * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014, British Columbia Institute of Technology + * Copyright (c) 2014 - 2015, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From 90726b8c769ea75aec34814ddfa91655d488e6c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 20 Jan 2015 12:39:22 +0200 Subject: [ci skip] Change some log messages' level 'Class Loaded' type of messages flood log files when log_threshold is set to 2 (debug). They're now logged as 'info' level. This is manually applying PR #1528, which was created to do the same thing, but became outdated. --- system/core/Config.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index d5ce91f48..3828fae65 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -72,6 +72,8 @@ class CI_Config { */ public $_config_paths = array(APPPATH); + // -------------------------------------------------------------------- + /** * Class constructor * @@ -82,7 +84,6 @@ class CI_Config { public function __construct() { $this->config =& get_config(); - log_message('debug', 'Config Class Initialized'); // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) @@ -101,6 +102,8 @@ class CI_Config { $this->set_item('base_url', $base_url); } + + log_message('info', 'Config Class Initialized'); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 4cbe463b4c442e0e2dae2f43565e77f7ac5ecb86 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Wed, 21 Jan 2015 22:56:22 +0100 Subject: Remove closing blocks at end of PHP files --- system/core/Config.php | 3 --- 1 file changed, 3 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 3828fae65..a191a7727 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -359,6 +359,3 @@ class CI_Config { } } - -/* End of file Config.php */ -/* Location: ./system/core/Config.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 137aa20e0b0fd71ff8f672c57c07c4972c91c6a4 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 5 Mar 2015 11:36:25 +0200 Subject: Fix #3642 --- system/core/Config.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index a191a7727..b9af8e3b2 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -126,7 +126,6 @@ class CI_Config { foreach (array($file, ENVIRONMENT.'/'.$file) as $location) { $file_path = $path.'config/'.$location.'.php'; - if (in_array($file_path, $this->is_loaded, TRUE)) { return TRUE; @@ -165,14 +164,13 @@ class CI_Config { $loaded = TRUE; log_message('debug', 'Config file loaded: '.$file_path); } - - if ($loaded === TRUE) - { - return TRUE; - } } - if ($fail_gracefully === TRUE) + if ($loaded === TRUE) + { + return TRUE; + } + elseif ($fail_gracefully === TRUE) { return FALSE; } -- cgit v1.2.3-24-g4f1b From 7f310d63d61e9b334385ef5f6501129d685924ba Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sun, 15 Mar 2015 19:03:43 +0200 Subject: [ci skip] Use DIRECTORY_SEPARATOR instead of / in CI_Config --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index b9af8e3b2..d07000ac9 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -123,7 +123,7 @@ class CI_Config { foreach ($this->_config_paths as $path) { - foreach (array($file, ENVIRONMENT.'/'.$file) as $location) + foreach (array($file, ENVIRONMENT.DIRECTORY_SEPARATOR.$file) as $location) { $file_path = $path.'config/'.$location.'.php'; if (in_array($file_path, $this->is_loaded, TRUE)) -- cgit v1.2.3-24-g4f1b From 392f8da2ebc22efeb1b688a75c49c1a52e12f0f2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 14 Sep 2015 14:52:48 +0300 Subject: Close #4098 --- system/core/Config.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index d07000ac9..feea7c85a 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -238,7 +238,15 @@ class CI_Config { if (isset($protocol)) { - $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + // For protocol-relative links + if ($protocol === '') + { + $base_url = substr($base_url, strpos($base_url, '//')); + } + else + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } } if (empty($uri)) @@ -293,7 +301,15 @@ class CI_Config { if (isset($protocol)) { - $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + // For protocol-relative links + if ($protocol === '') + { + $base_url = substr($base_url, strpos($base_url, '//')); + } + else + { + $base_url = $protocol.substr($base_url, strpos($base_url, '://')); + } } return $base_url.ltrim($this->_uri_string($uri), '/'); -- cgit v1.2.3-24-g4f1b From 0a6b0661305f20ac1fbd219d43f59193bea90d1d Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 26 Oct 2015 15:31:38 +0200 Subject: Prevent Host header injections --- system/core/Config.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index feea7c85a..0264776f9 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -88,11 +88,9 @@ class CI_Config { // Set the base_url automatically if none was provided if (empty($this->config['base_url'])) { - // The regular expression is only a basic validation for a valid "Host" header. - // It's not exhaustive, only checks for valid characters. - if (isset($_SERVER['HTTP_HOST']) && preg_match('/^((\[[0-9a-f:]+\])|(\d{1,3}(\.\d{1,3}){3})|[a-z0-9\-\.]+)(:\d+)?$/i', $_SERVER['HTTP_HOST'])) + if (isset($_SERVER['SERVER_ADDR'])) { - $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'] + $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR'] .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); } else -- cgit v1.2.3-24-g4f1b From 20edad807645a42df7f4b0baa6e6a2eb29bd2b0c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Nov 2015 10:56:30 +0200 Subject: Merge pull request #4217 from natesilva/fix-ipv6-base_url Build base_url correctly if SERVER_ADDR is IPv6 --- system/core/Config.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 0264776f9..c507f342c 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -90,7 +90,16 @@ class CI_Config { { if (isset($_SERVER['SERVER_ADDR'])) { - $base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['SERVER_ADDR'] + if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE) + { + $server_addr = '['.$_SERVER['SERVER_ADDR'].']'; + } + else + { + $server_addr = $_SERVER['SERVER_ADDR']; + } + + $base_url = (is_https() ? 'https' : 'http').'://'.$server_addr .substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME']))); } else -- cgit v1.2.3-24-g4f1b From 125ef4751080a2118cb203357d77687699e3eb25 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:33:00 +0200 Subject: [ci skip] Bump year to 2016 --- system/core/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index c507f342c..d03e02d4d 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2015, British Columbia Institute of Technology + * Copyright (c) 2014 - 2016, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) - * @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link http://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b From bd202c91b0e9cf0a8c93bcaa71df9574f5909346 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:50:18 +0200 Subject: [ci skip] Update codeigniter.com links to https --- system/core/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index d03e02d4d..587877da6 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -31,7 +31,7 @@ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License - * @link http://codeigniter.com + * @link https://codeigniter.com * @since Version 1.0.0 * @filesource */ @@ -46,7 +46,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); * @subpackage Libraries * @category Libraries * @author EllisLab Dev Team - * @link http://codeigniter.com/user_guide/libraries/config.html + * @link https://codeigniter.com/user_guide/libraries/config.html */ class CI_Config { -- cgit v1.2.3-24-g4f1b From 1924e879b165fb119847a49a7a5eab2f28295fa2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 11 Jan 2016 12:55:34 +0200 Subject: [ci skip] Update ellislab.com links to https too --- system/core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 587877da6..ca6fb3793 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -28,7 +28,7 @@ * * @package CodeIgniter * @author EllisLab Dev Team - * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/) + * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com -- cgit v1.2.3-24-g4f1b From 4ac24c201c673b52b39b7efc2235f1d84d1acd08 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 28 Apr 2016 14:28:07 +0300 Subject: Fix #4605 --- system/core/Config.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index ca6fb3793..9fd3e4a7d 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -319,7 +319,7 @@ class CI_Config { } } - return $base_url.ltrim($this->_uri_string($uri), '/'); + return $base_url.$this->_uri_string($uri); } // ------------------------------------------------------------- @@ -337,11 +337,8 @@ class CI_Config { { if ($this->item('enable_query_strings') === FALSE) { - if (is_array($uri)) - { - $uri = implode('/', $uri); - } - return trim($uri, '/'); + is_array($uri) && $uri = implode('/', $uri); + return ltrim($uri, '/'); } elseif (is_array($uri)) { -- cgit v1.2.3-24-g4f1b From da60e9bc66ec90970fbd2dfd08b0a6e66b9f5f5f Mon Sep 17 00:00:00 2001 From: Master Yoda Date: Sat, 31 Dec 2016 08:46:18 -0800 Subject: Update copyright data to 2017 --- system/core/Config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'system/core/Config.php') diff --git a/system/core/Config.php b/system/core/Config.php index 9fd3e4a7d..cda62241b 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -6,7 +6,7 @@ * * This content is released under the MIT License (MIT) * - * Copyright (c) 2014 - 2016, British Columbia Institute of Technology + * Copyright (c) 2014 - 2017, British Columbia Institute of Technology * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -29,7 +29,7 @@ * @package CodeIgniter * @author EllisLab Dev Team * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/) - * @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/) + * @copyright Copyright (c) 2014 - 2017, British Columbia Institute of Technology (http://bcit.ca/) * @license http://opensource.org/licenses/MIT MIT License * @link https://codeigniter.com * @since Version 1.0.0 -- cgit v1.2.3-24-g4f1b