summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/CodeIgniter.php18
-rw-r--r--system/core/Common.php2
-rw-r--r--system/core/Config.php2
-rw-r--r--system/core/Hooks.php10
-rw-r--r--system/core/Input.php17
-rw-r--r--system/core/Lang.php7
-rw-r--r--system/core/Loader.php10
-rw-r--r--system/core/Output.php77
-rw-r--r--system/core/Router.php10
-rw-r--r--system/database/DB_active_rec.php4
-rw-r--r--system/helpers/download_helper.php9
-rw-r--r--system/helpers/file_helper.php11
-rw-r--r--system/helpers/form_helper.php5
-rw-r--r--system/helpers/html_helper.php11
-rw-r--r--system/helpers/smiley_helper.php13
-rw-r--r--system/helpers/text_helper.php10
-rw-r--r--system/language/english/form_validation_lang.php3
-rw-r--r--system/libraries/Session.php7
-rw-r--r--system/libraries/Upload.php18
-rw-r--r--system/libraries/User_agent.php10
20 files changed, 208 insertions, 46 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);
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index ee72dbbf4..db8471364 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -1020,11 +1020,11 @@ class CI_DB_active_record extends CI_DB_driver {
if ($query->num_rows() == 0)
{
- return '0';
+ return 0;
}
$row = $query->row();
- return $row->numrows;
+ return (int) $row->numrows;
}
// --------------------------------------------------------------------
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 6cecd0d11..e537cdeca 100644
--- a/system/helpers/download_helper.php
+++ b/system/helpers/download_helper.php
@@ -58,7 +58,14 @@ if ( ! function_exists('force_download'))
$extension = end($x);
// Load the mime types
- @include(APPPATH.'config/mimes'.EXT);
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/mimes'.EXT))
+ {
+ include(APPPATH.'config/mimes'.EXT);
+ }
// Set a default mime if we can't find it
if ( ! isset($mimes[$extension]))
diff --git a/system/helpers/file_helper.php b/system/helpers/file_helper.php
index 9518e4843..7a35c3fa1 100644
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -352,7 +352,16 @@ if ( ! function_exists('get_mime_by_extension'))
if ( ! is_array($mimes))
{
- if ( ! require_once(APPPATH.'config/mimes.php'))
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/mimes'.EXT))
+ {
+ include(APPPATH.'config/mimes'.EXT);
+ }
+
+ if ( ! is_array($mimes))
{
return FALSE;
}
diff --git a/system/helpers/form_helper.php b/system/helpers/form_helper.php
index 758056b50..532309794 100644
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -49,7 +49,10 @@ if ( ! function_exists('form_open'))
$attributes = 'method="post"';
}
- $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action;
+ if ($action && strpos($action, '://') === FALSE)
+ {
+ $action = $CI->config->site_url($action);
+ }
$form = '<form action="'.$action.'"';
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 68c6f5908..53fc899a3 100644
--- a/system/helpers/html_helper.php
+++ b/system/helpers/html_helper.php
@@ -258,7 +258,16 @@ if ( ! function_exists('doctype'))
if ( ! is_array($_doctypes))
{
- if ( ! require_once(APPPATH.'config/doctypes.php'))
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/doctypes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/doctypes'.EXT))
+ {
+ include(APPPATH.'config/doctypes'.EXT);
+ }
+
+ if ( ! is_array($_doctypes))
{
return FALSE;
}
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 463881f58..6c901515d 100644
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -229,13 +229,20 @@ if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ if ( ! file_exists(APPPATH.'config/smileys'.EXT) AND ! file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
{
return FALSE;
}
- include(APPPATH.'config/smileys'.EXT);
-
+ if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
+ }
+ else
+ {
+ include(APPPATH.'config/smileys'.EXT);
+ }
+
if ( ! isset($smileys) OR ! is_array($smileys))
{
return FALSE;
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 96afd4cee..664408912 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -366,12 +366,14 @@ if ( ! function_exists('convert_accented_characters'))
{
function convert_accented_characters($str)
{
- if ( ! file_exists(APPPATH.'config/foreign_chars'.EXT))
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT))
{
- return $str;
+ include(APPPATH.'config/'.ENVIRONMENT.'/foreign_chars'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/foreign_chars'.EXT))
+ {
+ include(APPPATH.'config/foreign_chars'.EXT);
}
-
- include APPPATH.'config/foreign_chars'.EXT;
if ( ! isset($foreign_characters))
{
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index b01885091..3f2409007 100644
--- a/system/language/english/form_validation_lang.php
+++ b/system/language/english/form_validation_lang.php
@@ -19,6 +19,9 @@ $lang['regex_match'] = "The %s field is not in the correct format.";
$lang['matches'] = "The %s field does not match the %s field.";
$lang['is_natural'] = "The %s field must contain only positive numbers.";
$lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero.";
+$lang['decimal'] = "The %s field must contain a decimal number.";
+$lang['less_than'] = "The %s field must contain a number less than %s.";
+$lang['greater_than'] = "The %s field must contain a number greater than %s.";
/* End of file form_validation_lang.php */
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 0b94340d5..182294059 100644
--- a/system/libraries/Session.php
+++ b/system/libraries/Session.php
@@ -37,6 +37,7 @@ class CI_Session {
var $cookie_prefix = '';
var $cookie_path = '';
var $cookie_domain = '';
+ var $cookie_secure = FALSE;
var $sess_time_to_update = 300;
var $encryption_key = '';
var $flashdata_key = 'flash';
@@ -61,7 +62,7 @@ class CI_Session {
// Set all the session preferences, which can either be set
// manually via the $params array above or via the config file
- foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
+ foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key)
{
$this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
}
@@ -658,8 +659,6 @@ class CI_Session {
}
$expire = ($this->sess_expire_on_close === TRUE) ? 0 : $this->sess_expiration + time();
-
- $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0;
// Set the cookie
setcookie(
@@ -668,7 +667,7 @@ class CI_Session {
$expire,
$this->cookie_path,
$this->cookie_domain,
- $secure_cookie
+ $this->cookie_secure
);
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index e15ea1b5d..5816a5558 100644
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -142,7 +142,7 @@ class CI_Upload {
*/
public function do_upload($field = 'userfile')
{
-
+
// Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
@@ -951,11 +951,21 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (@require_once(APPPATH.'config/mimes'.EXT))
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/mimes'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/mimes'.EXT))
+ {
+ include(APPPATH.'config//mimes'.EXT);
+ }
+ else
{
- $this->mimes = $mimes;
- unset($mimes);
+ return FALSE;
}
+
+ $this->mimes = $mimes;
+ unset($mimes);
}
return ( ! isset($this->mimes[$mime])) ? FALSE : $this->mimes[$mime];
diff --git a/system/libraries/User_agent.php b/system/libraries/User_agent.php
index 3774fc283..11af21491 100644
--- a/system/libraries/User_agent.php
+++ b/system/libraries/User_agent.php
@@ -84,7 +84,15 @@ class CI_User_agent {
*/
private function _load_agent_file()
{
- if ( ! @include(APPPATH.'config/user_agents'.EXT))
+ if (is_file(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT))
+ {
+ include(APPPATH.'config/'.ENVIRONMENT.'/user_agents'.EXT);
+ }
+ elseif (is_file(APPPATH.'config/user_agents'.EXT))
+ {
+ include(APPPATH.'config/user_agents'.EXT);
+ }
+ else
{
return FALSE;
}