diff options
Diffstat (limited to 'system/core')
-rw-r--r-- | system/core/CodeIgniter.php | 18 | ||||
-rw-r--r-- | system/core/Common.php | 2 | ||||
-rw-r--r-- | system/core/Config.php | 2 | ||||
-rw-r--r-- | system/core/Hooks.php | 10 | ||||
-rw-r--r-- | system/core/Input.php | 17 | ||||
-rw-r--r-- | system/core/Lang.php | 7 | ||||
-rw-r--r-- | system/core/Loader.php | 10 | ||||
-rw-r--r-- | system/core/Output.php | 77 | ||||
-rw-r--r-- | system/core/Router.php | 10 |
9 files changed, 129 insertions, 24 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 567e67f65..39a4d7ffd 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -32,7 +32,14 @@ * Define the CodeIgniter Version * ------------------------------------------------------ */ - define('CI_VERSION', '2.0'); + define('CI_VERSION', '2.0.1'); + +/* + * ------------------------------------------------------ + * Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE) + * ------------------------------------------------------ + */ + define('CI_CORE', FALSE); /* * ------------------------------------------------------ @@ -46,7 +53,14 @@ * Load the framework constants * ------------------------------------------------------ */ - require(APPPATH.'config/constants'.EXT); + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT)) + { + require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT); + } + else + { + require(APPPATH.'config/constants'.EXT); + } /* * ------------------------------------------------------ diff --git a/system/core/Common.php b/system/core/Common.php index cd6b93355..f424a2cc9 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -88,7 +88,7 @@ @unlink($file); return TRUE; } - elseif (($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) + elseif ( ! is_file($file) OR ($fp = @fopen($file, FOPEN_WRITE_CREATE)) === FALSE) { return FALSE; } diff --git a/system/core/Config.php b/system/core/Config.php index 75f945efd..a2a7dd564 100644 --- a/system/core/Config.php +++ b/system/core/Config.php @@ -318,4 +318,4 @@ class CI_Config { // END CI_Config class /* End of file Config.php */ -/* Location: ./system/core/Config.php */
\ No newline at end of file +/* Location: ./system/core/Config.php */ diff --git a/system/core/Hooks.php b/system/core/Hooks.php index 75fd811b0..d1e5586de 100644 --- a/system/core/Hooks.php +++ b/system/core/Hooks.php @@ -65,7 +65,15 @@ class CI_Hooks { // Grab the "hooks" definition file. // If there are no hooks, we're done. - @include(APPPATH.'config/hooks'.EXT); + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT)) + { + include(APPPATH.'config/'.ENVIRONMENT.'/hooks'.EXT); + } + elseif (is_file(APPPATH.'config/hooks'.EXT)) + { + include(APPPATH.'config/hooks'.EXT); + } + if ( ! isset($hook) OR ! is_array($hook)) { diff --git a/system/core/Input.php b/system/core/Input.php index 25fe102b5..18131350f 100644 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -211,11 +211,12 @@ class CI_Input { * @param bool true makes the cookie secure * @return void */ - function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = NULL) + function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) { if (is_array($name)) { - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name', 'secure') as $item) + // 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) { if (isset($name[$item])) { @@ -236,6 +237,10 @@ class CI_Input { { $path = config_item('cookie_path'); } + if ($secure == FALSE AND config_item('cookie_secure') != FALSE) + { + $secure = config_item('cookie_secure'); + } if ( ! is_numeric($expire)) { @@ -246,12 +251,6 @@ class CI_Input { $expire = ($expire > 0) ? time() + $expire : 0; } - // If TRUE/FALSE is not provided, use the config - if ( ! is_bool($secure)) - { - $secure = (bool) (config_item('cookie_secure') === TRUE); - } - setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); } @@ -540,7 +539,7 @@ class CI_Input { { if (strpos($str, "\r") !== FALSE) { - $str = str_replace(array("\r\n", "\r"), PHP_EOL, $str); + $str = str_replace(array("\r\n", "\r", "\r\n\n"), PHP_EOL, $str); } } diff --git a/system/core/Lang.php b/system/core/Lang.php index fb177902e..0b926a303 100644 --- a/system/core/Lang.php +++ b/system/core/Lang.php @@ -130,6 +130,13 @@ class CI_Lang { function line($line = '') { $line = ($line == '' OR ! isset($this->language[$line])) ? FALSE : $this->language[$line]; + + // Because killer robots like unicorns! + if ($line === FALSE) + { + log_message('error', 'Could not find the language line "'.$line.'"'); + } + return $line; } diff --git a/system/core/Loader.php b/system/core/Loader.php index 7003318ee..75c09435d 100644 --- a/system/core/Loader.php +++ b/system/core/Loader.php @@ -975,7 +975,15 @@ class CI_Loader { */ function _ci_autoloader() { - include_once(APPPATH.'config/autoload'.EXT); + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT)) + { + include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT); + } + else + { + include_once(APPPATH.'config/autoload'.EXT); + } + if ( ! isset($autoload)) { diff --git a/system/core/Output.php b/system/core/Output.php index 7fb9f7916..5ec096a47 100644 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -28,19 +28,32 @@ */ class CI_Output { - var $final_output; - var $cache_expiration = 0; - var $headers = array(); - var $enable_profiler = FALSE; - var $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} - - var $_zlib_oc = FALSE; - var $_profiler_sections = array(); + public $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage} + protected $final_output; + protected $cache_expiration = 0; + protected $headers = array(); + protected $mime_types = array(); + protected $enable_profiler = FALSE; + protected $_zlib_oc = FALSE; + protected $_profiler_sections = array(); function __construct() { $this->_zlib_oc = @ini_get('zlib.output_compression'); + // Get mime types for later + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT)) + { + include APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT; + } + else + { + include APPPATH.'config/mimes'.EXT; + } + + + $this->mime_types = $mimes; + log_message('debug', "Output Class Initialized"); } @@ -73,6 +86,8 @@ class CI_Output { function set_output($output) { $this->final_output = $output; + + return $this; } // -------------------------------------------------------------------- @@ -96,6 +111,8 @@ class CI_Output { { $this->final_output .= $output; } + + return $this; } // -------------------------------------------------------------------- @@ -125,6 +142,42 @@ class CI_Output { } $this->headers[] = array($header, $replace); + + return $this; + } + + // -------------------------------------------------------------------- + + /** + * Set Content Type Header + * + * @access public + * @param string extension of the file we're outputting + * @return void + */ + function set_content_type($mime_type) + { + if (strpos($mime_type, '/') === FALSE) + { + $extension = ltrim($mime_type, '.'); + + // Is this extension supported? + if (isset($this->mime_types[$extension])) + { + $mime_type =& $this->mime_types[$extension]; + + if (is_array($mime_type)) + { + $mime_type = current($mime_type); + } + } + } + + $header = 'Content-Type: '.$mime_type; + + $this->headers[] = array($header, TRUE); + + return $this; } // -------------------------------------------------------------------- @@ -141,6 +194,8 @@ class CI_Output { function set_status_header($code = 200, $text = '') { set_status_header($code, $text); + + return $this; } // -------------------------------------------------------------------- @@ -155,6 +210,8 @@ class CI_Output { function enable_profiler($val = TRUE) { $this->enable_profiler = (is_bool($val)) ? $val : TRUE; + + return $this; } // -------------------------------------------------------------------- @@ -174,6 +231,8 @@ class CI_Output { { $this->_profiler_sections[$section] = ($enable !== FALSE) ? TRUE : FALSE; } + + return $this; } // -------------------------------------------------------------------- @@ -188,6 +247,8 @@ class CI_Output { function cache($time) { $this->cache_expiration = ( ! is_numeric($time)) ? 0 : $time; + + return $this; } // -------------------------------------------------------------------- diff --git a/system/core/Router.php b/system/core/Router.php index 6893e6e92..2c78efe07 100644 --- a/system/core/Router.php +++ b/system/core/Router.php @@ -87,7 +87,15 @@ class CI_Router { } // Load the routes.php file. - @include(APPPATH.'config/routes'.EXT); + if (is_file(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT)) + { + include(APPPATH.'config/'.ENVIRONMENT.'/routes'.EXT); + } + elseif (is_file(APPPATH.'config/routes'.EXT)) + { + include(APPPATH.'config/routes'.EXT); + } + $this->routes = ( ! isset($route) OR ! is_array($route)) ? array() : $route; unset($route); |