summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
committerFlorian Pritz <bluewind@server-speed.net>2011-04-10 10:39:31 +0200
commit1bdc9c8903eb2db33fdb8174d61e15100dfbbca8 (patch)
treeb0c645ad99e04f34817fc4e6385792111db42274 /system
parent413d0cdac49257089a0790f6ac92973a36a6b69f (diff)
update to CI 2.0.2
Signed-off-by: Florian Pritz <bluewind@server-speed.net>
Diffstat (limited to 'system')
-rwxr-xr-xsystem/core/CodeIgniter.php50
-rwxr-xr-xsystem/core/Common.php44
-rwxr-xr-xsystem/core/Config.php30
-rwxr-xr-xsystem/core/Hooks.php10
-rwxr-xr-xsystem/core/Input.php68
-rwxr-xr-xsystem/core/Lang.php7
-rwxr-xr-xsystem/core/Loader.php45
-rwxr-xr-xsystem/core/Output.php77
-rwxr-xr-xsystem/core/Router.php12
-rwxr-xr-xsystem/core/Security.php820
-rwxr-xr-xsystem/core/URI.php69
-rwxr-xr-xsystem/core/Utf8.php2
-rwxr-xr-xsystem/database/DB.php13
-rwxr-xr-xsystem/database/DB_active_rec.php14
-rwxr-xr-xsystem/database/DB_driver.php12
-rwxr-xr-xsystem/database/DB_forge.php2
-rwxr-xr-xsystem/database/DB_result.php2
-rwxr-xr-xsystem/database/drivers/mssql/mssql_driver.php12
-rwxr-xr-xsystem/database/drivers/mysql/mysql_driver.php20
-rwxr-xr-xsystem/database/drivers/mysqli/mysqli_driver.php10
-rwxr-xr-xsystem/database/drivers/oci8/oci8_driver.php6
-rwxr-xr-xsystem/database/drivers/odbc/odbc_driver.php4
-rwxr-xr-xsystem/database/drivers/odbc/odbc_result.php4
-rwxr-xr-xsystem/database/drivers/postgre/postgre_driver.php14
-rwxr-xr-xsystem/database/drivers/sqlite/sqlite_driver.php4
-rwxr-xr-xsystem/helpers/array_helper.php1
-rwxr-xr-xsystem/helpers/captcha_helper.php2
-rwxr-xr-xsystem/helpers/cookie_helper.php4
-rwxr-xr-xsystem/helpers/download_helper.php9
-rwxr-xr-xsystem/helpers/file_helper.php13
-rwxr-xr-xsystem/helpers/form_helper.php11
-rwxr-xr-xsystem/helpers/html_helper.php11
-rwxr-xr-xsystem/helpers/inflector_helper.php28
-rwxr-xr-xsystem/helpers/language_helper.php2
-rwxr-xr-xsystem/helpers/number_helper.php2
-rwxr-xr-xsystem/helpers/security_helper.php34
-rwxr-xr-xsystem/helpers/smiley_helper.php22
-rwxr-xr-xsystem/helpers/text_helper.php12
-rwxr-xr-xsystem/helpers/typography_helper.php5
-rwxr-xr-xsystem/language/english/form_validation_lang.php3
-rwxr-xr-xsystem/language/english/ftp_lang.php14
-rwxr-xr-xsystem/libraries/Cache/Cache.php6
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_apc.php4
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_dummy.php2
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_file.php4
-rwxr-xr-xsystem/libraries/Cache/drivers/Cache_memcached.php4
-rwxr-xr-xsystem/libraries/Driver.php30
-rwxr-xr-xsystem/libraries/Email.php12
-rwxr-xr-xsystem/libraries/Form_validation.php77
-rwxr-xr-xsystem/libraries/Image_lib.php2
-rwxr-xr-xsystem/libraries/Javascript.php2
-rwxr-xr-xsystem/libraries/Profiler.php4
-rwxr-xr-xsystem/libraries/Session.php5
-rwxr-xr-xsystem/libraries/Sha1.php4
-rwxr-xr-xsystem/libraries/Table.php11
-rwxr-xr-xsystem/libraries/Trackback.php4
-rwxr-xr-xsystem/libraries/Upload.php27
-rwxr-xr-xsystem/libraries/User_agent.php16
-rwxr-xr-xsystem/libraries/Xmlrpc.php66
-rwxr-xr-xsystem/libraries/Xmlrpcs.php178
-rwxr-xr-xsystem/libraries/Zip.php2
61 files changed, 1573 insertions, 411 deletions
diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php
index 2d3f24958..e022e1b46 100755
--- 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.2');
+
+/*
+ * ------------------------------------------------------
+ * 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 (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT))
+ {
+ require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT);
+ }
+ else
+ {
+ require(APPPATH.'config/constants'.EXT);
+ }
/*
* ------------------------------------------------------
@@ -80,7 +94,7 @@
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}
-
+
/*
* ------------------------------------------------------
* Set a liberal script execution time limit
@@ -183,6 +197,13 @@
}
/*
+ * -----------------------------------------------------
+ * Load the security class for xss and csrf support
+ * -----------------------------------------------------
+ */
+ $SEC =& load_class('Security', 'core');
+
+/*
* ------------------------------------------------------
* Load the Input class and sanitize globals
* ------------------------------------------------------
@@ -289,7 +310,28 @@
// methods, so we'll use this workaround for consistent behavior
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
{
- show_404("{$class}/{$method}");
+ // Check and see if we are using a 404 override and use it.
+ if ( ! empty($RTR->routes['404_override']))
+ {
+ $x = explode('/', $RTR->routes['404_override']);
+ $class = $x[0];
+ $method = (isset($x[1]) ? $x[1] : 'index');
+ if ( ! class_exists($class))
+ {
+ if ( ! file_exists(APPPATH.'controllers/'.$class.EXT))
+ {
+ show_404("{$class}/{$method}");
+ }
+
+ include_once(APPPATH.'controllers/'.$class.EXT);
+ unset($CI);
+ $CI = new $class();
+ }
+ }
+ else
+ {
+ show_404("{$class}/{$method}");
+ }
}
// Call the requested method.
diff --git a/system/core/Common.php b/system/core/Common.php
index b5adfacb3..1aca809ab 100755
--- 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;
}
@@ -208,16 +208,20 @@
return $_config[0];
}
- // Fetch the config file
- if ( ! file_exists(APPPATH.'config/config'.EXT))
+ // Is the config file in the environment folder?
+ if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT))
{
- exit('The configuration file does not exist.');
+ $file_path = APPPATH.'config/config'.EXT;
}
- else
+
+ // Fetch the config file
+ if ( ! file_exists($file_path))
{
- require(APPPATH.'config/config'.EXT);
+ exit('The configuration file does not exist.');
}
+ require($file_path);
+
// Does the $config array exist in the file?
if ( ! isset($config) OR ! is_array($config))
{
@@ -472,28 +476,26 @@
* @param string
* @return string
*/
- function remove_invisible_characters($str)
+ function remove_invisible_characters($str, $url_encoded = TRUE)
{
- static $non_displayables;
-
- if ( ! isset($non_displayables))
+ $non_displayables = array();
+
+ // every control character except newline (dec 10)
+ // carriage return (dec 13), and horizontal tab (dec 09)
+
+ if ($url_encoded)
{
- // every control character except newline (dec 10), carriage return (dec 13), and horizontal tab (dec 09),
- $non_displayables = array(
- '/%0[0-8bcef]/', // url encoded 00-08, 11, 12, 14, 15
- '/%1[0-9a-f]/', // url encoded 16-31
- '/[\x00-\x08]/', // 00-08
- '/\x0b/', '/\x0c/', // 11, 12
- '/[\x0e-\x1f]/' // 14-31
- );
+ $non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
+ $non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
}
+
+ $non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
do
{
- $cleaned = $str;
- $str = preg_replace($non_displayables, '', $str);
+ $str = preg_replace($non_displayables, '', $str, -1, $count);
}
- while ($cleaned != $str);
+ while ($count);
return $str;
}
diff --git a/system/core/Config.php b/system/core/Config.php
index bfb60fa44..863c5ef4b 100755
--- a/system/core/Config.php
+++ b/system/core/Config.php
@@ -51,7 +51,7 @@ class CI_Config {
// Set the base_url automatically if none was provided
if ($this->config['base_url'] == '')
{
- if(isset($_SERVER['HTTP_HOST']))
+ if (isset($_SERVER['HTTP_HOST']))
{
$base_url = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http';
$base_url .= '://'. $_SERVER['HTTP_HOST'];
@@ -74,24 +74,40 @@ class CI_Config {
*
* @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
* @return boolean if the file was loaded correctly
*/
function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
$file = ($file == '') ? 'config' : str_replace(EXT, '', $file);
+ $found = FALSE;
$loaded = FALSE;
- foreach($this->_config_paths as $path)
+ foreach ($this->_config_paths as $path)
{
- $file_path = $path.'config/'.$file.EXT;
+ $check_locations = defined('ENVIRONMENT')
+ ? array(ENVIRONMENT.'/'.$file, $file)
+ : array($file);
- if (in_array($file_path, $this->is_loaded, TRUE))
+ foreach ($check_locations as $location)
{
- $loaded = TRUE;
- continue;
+ $file_path = $path.'config/'.$location.EXT;
+
+ if (in_array($file_path, $this->is_loaded, TRUE))
+ {
+ $loaded = TRUE;
+ continue 2;
+ }
+
+ if (file_exists($file_path))
+ {
+ $found = TRUE;
+ break;
+ }
}
- if ( ! file_exists($path.'config/'.$file.EXT))
+ if ($found === FALSE)
{
continue;
}
diff --git a/system/core/Hooks.php b/system/core/Hooks.php
index 75fd811b0..24fa1055b 100755
--- 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 (defined('ENVIRONMENT') AND 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 3e82874fd..dc7612e64 100755
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -53,11 +53,8 @@ class CI_Input {
$this->_enable_xss = (config_item('global_xss_filtering') === TRUE);
$this->_enable_csrf = (config_item('csrf_protection') === TRUE);
- // Do we need to load the security class?
- if ($this->_enable_xss == TRUE OR $this->_enable_csrf == TRUE)
- {
- $this->security =& load_class('Security');
- }
+ global $SEC;
+ $this->security =& $SEC;
// Do we need the UTF-8 class?
if (UTF8_ENABLED === TRUE)
@@ -92,8 +89,7 @@ class CI_Input {
if ($xss_clean === TRUE)
{
- $_security =& load_class('Security');
- return $_security->xss_clean($array[$index]);
+ return $this->security->xss_clean($array[$index]);
}
return $array[$index];
@@ -109,8 +105,21 @@ class CI_Input {
* @param bool
* @return string
*/
- function get($index = '', $xss_clean = FALSE)
+ function get($index = NULL, $xss_clean = FALSE)
{
+ // Check if a field has been provided
+ if ($index === NULL AND ! empty($_GET))
+ {
+ $get = array();
+
+ // loop through the full _GET array
+ foreach (array_keys($_GET) as $key)
+ {
+ $get[$key] = $this->_fetch_from_array($_GET, $key, $xss_clean);
+ }
+ return $get;
+ }
+
return $this->_fetch_from_array($_GET, $index, $xss_clean);
}
@@ -124,8 +133,21 @@ class CI_Input {
* @param bool
* @return string
*/
- function post($index = '', $xss_clean = FALSE)
+ function post($index = NULL, $xss_clean = FALSE)
{
+ // Check if a field has been provided
+ if ($index === NULL AND ! empty($_POST))
+ {
+ $post = array();
+
+ // Loop through the full _POST array and return it
+ foreach (array_keys($_POST) as $key)
+ {
+ $post[$key] = $this->_fetch_from_array($_POST, $key, $xss_clean);
+ }
+ return $post;
+ }
+
return $this->_fetch_from_array($_POST, $index, $xss_clean);
}
@@ -182,13 +204,15 @@ class CI_Input {
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
+ * @param bool true makes the cookie secure
* @return void
*/
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
if (is_array($name))
{
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') 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]))
{
@@ -209,6 +233,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))
{
@@ -219,7 +247,7 @@ class CI_Input {
$expire = ($expire > 0) ? time() + $expire : 0;
}
- setcookie($prefix.$name, $value, $expire, $path, $domain, 0);
+ setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
}
// --------------------------------------------------------------------
@@ -413,7 +441,7 @@ class CI_Input {
{
if (is_array($_GET) AND count($_GET) > 0)
{
- foreach($_GET as $key => $val)
+ foreach ($_GET as $key => $val)
{
$_GET[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
@@ -423,7 +451,7 @@ class CI_Input {
// Clean $_POST Data
if (is_array($_POST) AND count($_POST) > 0)
{
- foreach($_POST as $key => $val)
+ foreach ($_POST as $key => $val)
{
$_POST[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
@@ -441,7 +469,7 @@ class CI_Input {
unset($_COOKIE['$Path']);
unset($_COOKIE['$Domain']);
- foreach($_COOKIE as $key => $val)
+ foreach ($_COOKIE as $key => $val)
{
$_COOKIE[$this->_clean_input_keys($key)] = $this->_clean_input_data($val);
}
@@ -495,6 +523,9 @@ class CI_Input {
{
$str = $this->uni->clean_string($str);
}
+
+ // Remove control characters
+ $str = remove_invisible_characters($str);
// Should we filter the input data?
if ($this->_enable_xss === TRUE)
@@ -507,7 +538,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);
}
}
@@ -610,8 +641,7 @@ class CI_Input {
if ($xss_clean === TRUE)
{
- $_security =& load_class('Security');
- return $_security->xss_clean($this->headers[$index]);
+ return $this->security->xss_clean($this->headers[$index]);
}
return $this->headers[$index];
@@ -649,4 +679,4 @@ class CI_Input {
// END Input class
/* End of file Input.php */
-/* Location: ./system/core/Input.php */ \ No newline at end of file
+/* Location: ./system/core/Input.php */
diff --git a/system/core/Lang.php b/system/core/Lang.php
index fb177902e..0b926a303 100755
--- 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 07166188e..e75805d0e 100755
--- a/system/core/Loader.php
+++ b/system/core/Loader.php
@@ -79,9 +79,9 @@ class CI_Loader {
{
if (is_array($library))
{
- foreach($library as $read)
+ foreach ($library as $class)
{
- $this->library($read);
+ $this->library($class, $params);
}
return;
@@ -97,17 +97,7 @@ class CI_Loader {
$params = NULL;
}
- if (is_array($library))
- {
- foreach ($library as $class)
- {
- $this->_ci_load_class($class, $params, $object_name);
- }
- }
- else
- {
- $this->_ci_load_class($library, $params, $object_name);
- }
+ $this->_ci_load_class($library, $params, $object_name);
}
// --------------------------------------------------------------------
@@ -127,7 +117,7 @@ class CI_Loader {
{
if (is_array($model))
{
- foreach($model as $babe)
+ foreach ($model as $babe)
{
$this->model($babe);
}
@@ -880,8 +870,19 @@ class CI_Loader {
foreach ($config_component->_config_paths as $path)
{
// We test for both uppercase and lowercase, for servers that
- // are case-sensitive with regard to file names
- if (file_exists($path .'config/'.strtolower($class).EXT))
+ // are case-sensitive with regard to file names. Check for environment
+ // first, global next
+ if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
+ break;
+ }
+ elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
+ {
+ include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
+ break;
+ }
+ elseif (file_exists($path .'config/'.strtolower($class).EXT))
{
include_once($path .'config/'.strtolower($class).EXT);
break;
@@ -964,7 +965,15 @@ class CI_Loader {
*/
function _ci_autoloader()
{
- include_once(APPPATH.'config/autoload'.EXT);
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT))
+ {
+ include_once(APPPATH.'config/'.ENVIRONMENT.'/autoload'.EXT);
+ }
+ else
+ {
+ include_once(APPPATH.'config/autoload'.EXT);
+ }
+
if ( ! isset($autoload))
{
@@ -1092,4 +1101,4 @@ class CI_Loader {
}
/* End of file Loader.php */
-/* Location: ./system/core/Loader.php */ \ No newline at end of file
+/* Location: ./system/core/Loader.php */
diff --git a/system/core/Output.php b/system/core/Output.php
index 7fb9f7916..45a82f3cb 100755
--- 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();
+ 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();
+ protected $parse_exec_vars = TRUE; // whether or not to parse variables like {elapsed_time} and {memory_usage}
function __construct()
{
$this->_zlib_oc = @ini_get('zlib.output_compression');
+ // Get mime types for later
+ if (defined('ENVIRONMENT') AND 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 7be508fef..d451aab68 100755
--- 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 (defined('ENVIRONMENT') AND 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);
@@ -270,7 +278,7 @@ class CI_Router {
// If we've gotten this far it means that the URI does not correlate to a valid
// controller class. We will now see if there is an override
- if (!empty($this->routes['404_override']))
+ if ( ! empty($this->routes['404_override']))
{
$x = explode('/', $this->routes['404_override']);
diff --git a/system/core/Security.php b/system/core/Security.php
new file mode 100755
index 000000000..ceef9779c
--- /dev/null
+++ b/system/core/Security.php
@@ -0,0 +1,820 @@
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
+/**
+ * CodeIgniter
+ *
+ * An open source application development framework for PHP 5.1.6 or newer
+ *
+ * @package CodeIgniter
+ * @author ExpressionEngine Dev Team
+ * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
+ * @license http://codeigniter.com/user_guide/license.html
+ * @link http://codeigniter.com
+ * @since Version 1.0
+ * @filesource
+ */
+
+// ------------------------------------------------------------------------
+
+/**
+ * Security Class
+ *
+ * @package CodeIgniter
+ * @subpackage Libraries
+ * @category Security
+ * @author ExpressionEngine Dev Team
+ * @link http://codeigniter.com/user_guide/libraries/security.html
+ */
+class CI_Security {
+
+ protected $_xss_hash = '';
+ protected $_csrf_hash = '';
+ protected $_csrf_expire = 7200; // Two hours (in seconds)
+ protected $_csrf_token_name = 'ci_csrf_token';
+ protected $_csrf_cookie_name = 'ci_csrf_token';
+
+ /* never allowed, string replacement */
+ protected $_never_allowed_str = array(
+ 'document.cookie' => '[removed]',
+ 'document.write' => '[removed]',
+ '.parentNode' => '[removed]',
+ '.innerHTML' => '[removed]',
+ 'window.location' => '[removed]',
+ '-moz-binding' => '[removed]',
+ '<!--' => '&lt;!--',
+ '-->' => '--&gt;',
+ '<![CDATA[' => '&lt;![CDATA['
+ );
+
+ /* never allowed, regex replacement */
+ protected $_never_allowed_regex = array(
+ "javascript\s*:" => '[removed]',
+ "expression\s*(\(|&\#40;)" => '[removed]', // CSS and IE
+ "vbscript\s*:" => '[removed]', // IE, surprise!
+ "Redirect\s+302" => '[removed]'
+ );
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ // Append application specific cookie prefix to token name
+ $this->_csrf_cookie_name = (config_item('cookie_prefix')) ? config_item('cookie_prefix').$this->_csrf_token_name : $this->_csrf_token_name;
+
+ // Set the CSRF hash
+ $this->_csrf_set_hash();
+
+ log_message('debug', "Security Class Initialized");
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Verify Cross Site Request Forgery Protection
+ *
+ * @return object
+ */
+ public function csrf_verify()
+ {
+ // If no POST data exists we will set the CSRF cookie
+ if (count($_POST) == 0)
+ {
+ return $this->csrf_set_cookie();
+ }
+
+ // Do the tokens exist in both the _POST and _COOKIE arrays?
+ if ( ! isset($_POST[$this->_csrf_token_name]) OR
+ ! isset($_COOKIE[$this->_csrf_cookie_name]))
+ {
+ $this->csrf_show_error();
+ }
+
+ // Do the tokens match?
+ if ($_POST[$this->_csrf_token_name] != $_COOKIE[$this->_csrf_cookie_name])
+ {
+ $this->csrf_show_error();
+ }
+
+ // We kill this since we're done and we don't want to
+ // polute the _POST array
+ unset($_POST[$this->_csrf_token_name]);
+
+ // Nothing should last forever
+ unset($_COOKIE[$this->_csrf_cookie_name]);
+ $this->_csrf_set_hash();
+ $this->csrf_set_cookie();
+
+ log_message('debug', "CSRF token verified ");
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Cross Site Request Forgery Protection Cookie
+ *
+ * @return object
+ */
+ public function csrf_set_cookie()
+ {
+ $expire = time() + $this->_csrf_expire;
+ $secure_cookie = (config_item('cookie_secure') === TRUE) ? 1 : 0;
+
+ if ($secure_cookie)
+ {
+ $req = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : FALSE;
+
+ if ( ! $req OR $req == 'off')
+ {
+ return FALSE;
+ }
+ }
+
+ setcookie($this->_csrf_cookie_name, $this->_csrf_hash, $expire, config_item('cookie_path'), config_item('cookie_domain'), $secure_cookie);
+
+ log_message('debug', "CRSF cookie Set");
+
+ return $this;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Show CSRF Error
+ *
+ * @return void
+ */
+ public function csrf_show_error()
+ {
+ show_error('The action you have requested is not allowed.');
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get CSRF Hash
+ *
+ * Getter Method
+ *
+ * @return string self::_csrf_hash
+ */
+ public function get_csrf_hash()
+ {
+ return $this->_csrf_hash;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Get CSRF Token Name
+ *
+ * Getter Method
+ *
+ * @return string self::csrf_token_name
+ */
+ public function get_csrf_token_name()
+ {
+ return $this->_csrf_token_name;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * XSS Clean
+ *
+ * Sanitizes data so that Cross Site Scripting Hacks can be
+ * prevented. This function does a fair amount of work but
+ * it is extremely thorough, designed to prevent even the
+ * most obscure XSS attempts. Nothing is ever 100% foolproof,
+ * of course, but I haven't been able to get anything passed
+ * the filter.
+ *
+ * Note: This function should only be used to deal with data
+ * upon submission. It's not something that should
+ * be used for general runtime processing.
+ *
+ * This function was based in part on some code and ideas I
+ * got from Bitflux: http://channel.bitflux.ch/wiki/XSS_Prevention
+ *
+ * To help develop this script I used this great list of
+ * vulnerabilities along with a few other hacks I've
+ * harvested from examining vulnerabilities in other programs:
+ * http://ha.ckers.org/xss.html
+ *
+ * @param mixed string or array
+ * @return string
+ */
+ public function xss_clean($str, $is_image = FALSE)
+ {
+ /*
+ * Is the string an array?
+ *
+ */
+ if (is_array($str))
+ {
+ while (list($key) = each($str))
+ {
+ $str[$key] = $this->xss_clean($str[$key]);
+ }
+
+ return $str;
+ }
+
+ /*
+ * Remove Invisible Characters
+ */
+ $str = remove_invisible_characters($str);
+
+ // Validate Entities in URLs
+ $str = $this->_validate_entities($str);
+
+ /*
+ * URL Decode
+ *
+ * Just in case stuff like this is submitted:
+ *
+ * <a href="http://%77%77%77%2E%67%6F%6F%67%6C%65%2E%63%6F%6D">Google</a>
+ *
+ * Note: Use rawurldecode() so it does not remove plus signs
+ *
+ */
+ $str = rawurldecode($str);
+
+ /*
+ * Convert character entities to ASCII
+ *
+ * This permits our tests below to work reliably.
+ * We only convert entities that are within tags since
+ * these are the ones that will pose security problems.
+ *
+ */
+
+ $str = preg_replace_callback("/[a-z]+=([\'\"]).*?\\1/si", array($this, '_convert_attribute'), $str);
+
+ $str = preg_replace_callback("/<\w+.*?(?=>|<|$)/si", array($this, '_decode_entity'), $str);
+
+ /*
+ * Remove Invisible Characters Again!
+ */
+ $str = remove_invisible_characters($str);
+
+ /*
+ * Convert all tabs to spaces
+ *
+ * This prevents strings like this: ja vascript
+ * NOTE: we deal with spaces between characters later.
+ * NOTE: preg_replace was found to be amazingly slow here on
+ * large blocks of data, so we use str_replace.
+ */
+
+ if (strpos($str, "\t") !== FALSE)
+ {
+ $str = str_replace("\t", ' ', $str);
+ }
+
+ /*
+ * Capture converted string for later comparison
+ */
+ $converted_string = $str;
+
+ // Remove Strings that are never allowed
+ $str = $this->_do_never_allowed($str);
+
+ /*
+ * Makes PHP tags safe
+ *
+ * Note: XML tags are inadvertently replaced too:
+ *
+ * <?xml
+ *
+ * But it doesn't seem to pose a problem.
+ */
+ if ($is_image === TRUE)
+ {
+ // Images have a tendency to have the PHP short opening and
+ // closing tags every so often so we skip those and only
+ // do the long opening tags.
+ $str = preg_replace('/<\?(php)/i', "&lt;?\\1", $str);
+ }
+ else
+ {
+ $str = str_replace(array('<?', '?'.'>'), array('&lt;?', '?&gt;'), $str);
+ }
+
+ /*
+ * Compact any exploded words
+ *
+ * This corrects words like: j a v a s c r i p t
+ * These words are compacted back to their correct state.
+ */
+ $words = array(
+ 'javascript', 'expression', 'vbscript', 'script',
+ 'applet', 'alert', 'document', 'write', 'cookie', 'window'
+ );
+
+ foreach ($words as $word)
+ {
+ $temp = '';
+
+ for ($i = 0, $wordlen = strlen($word); $i < $wordlen; $i++)
+ {
+ $temp .= substr($word, $i, 1)."\s*";
+ }
+
+ // We only want to do this when it is followed by a non-word character
+ // That way valid stuff like "dealer to" does not become "dealerto"
+ $str = preg_replace_callback('#('.substr($temp, 0, -3).')(\W)#is', array($this, '_compact_exploded_words'), $str);
+ }
+
+ /*
+ * Remove disallowed Javascript in links or img tags
+ * We used to do some version comparisons and use of stripos for PHP5,
+ * but it is dog slow compared to these simplified non-capturing
+ * preg_match(), especially if the pattern exists in the string
+ */
+ do
+ {
+ $original = $str;
+
+ if (preg_match("/<a/i", $str))
+ {
+ $str = preg_replace_callback("#<a\s+([^>]*?)(>|$)#si", array($this, '_js_link_removal'), $str);
+ }
+
+ if (preg_match("/<img/i", $str))
+ {
+ $str = preg_replace_callback("#<img\s+([^>]*?)(\s?/?>|$)#si", array($this, '_js_img_removal'), $str);
+ }
+
+ if (preg_match("/script/i", $str) OR preg_match("/xss/i", $str))
+ {
+ $str = preg_replace("#<(/*)(script|xss)(.*?)\>#si", '[removed]', $str);
+ }
+ }
+ while($original != $str);
+
+ unset($original);
+
+ // Remove evil attributes such as style, onclick and xmlns
+ $str = $this->_remove_evil_attributes($str, $is_image);
+
+ /*
+ * Sanitize naughty HTML elements
+ *
+ * If a tag containing any of the words in the list
+ * below is found, the tag gets converted to entities.
+ *
+ * So this: <blink>
+ * Becomes: &lt;blink&gt;
+ */
+ $naughty = 'alert|applet|audio|basefont|base|behavior|bgsound|blink|body|embed|expression|form|frameset|frame|head|html|ilayer|iframe|input|isindex|layer|link|meta|object|plaintext|style|script|textarea|title|video|xml|xss';
+ $str = preg_replace_callback('#<(/*\s*)('.$naughty.')([^><]*)([><]*)#is', array($this, '_sanitize_naughty_html'), $str);
+
+ /*
+ * Sanitize naughty scripting elements
+ *
+ * Similar to above, only instead of looking for
+ * tags it looks for PHP and JavaScript commands
+ * that are disallowed. Rather than removing the
+ * code, it simply converts the parenthesis to entities
+ * rendering the code un-executable.
+ *
+ * For example: eval('some code')
+ * Becomes: eval&#40;'some code'&#41;
+ */
+ $str = preg_replace('#(alert|cmd|passthru|eval|exec|expression|system|fopen|fsockopen|file|file_get_contents|readfile|unlink)(\s*)\((.*?)\)#si', "\\1\\2&#40;\\3&#41;", $str);
+
+
+ // Final clean up
+ // This adds a bit of extra precaution in case
+ // something got through the above filters
+ $str = $this->_do_never_allowed($str);
+
+ /*
+ * Images are Handled in a Special Way
+ * - Essentially, we want to know that after all of the character
+ * conversion is done whether any unwanted, likely XSS, code was found.
+ * If not, we return TRUE, as the image is clean.
+ * However, if the string post-conversion does not matched the
+ * string post-removal of XSS, then it fails, as there was unwanted XSS
+ * code found and removed/changed during processing.
+ */
+
+ if ($is_image === TRUE)
+ {
+ return ($str == $converted_string) ? TRUE: FALSE;
+ }
+
+ log_message('debug', "XSS Filtering completed");
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Random Hash for protecting URLs
+ *
+ * @return string
+ */
+ public function xss_hash()
+ {
+ if ($this->_xss_hash == '')
+ {
+ if (phpversion() >= 4.2)
+ {
+ mt_srand();
+ }
+ else
+ {
+ mt_srand(hexdec(substr(md5(microtime()), -8)) & 0x7fffffff);
+ }
+
+ $this->_xss_hash = md5(time() + mt_rand(0, 1999999999));
+ }
+
+ return $this->_xss_hash;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * HTML Entities Decode
+ *
+ * This function is a replacement for html_entity_decode()
+ *
+ * In some versions of PHP the native function does not work
+ * when UTF-8 is the specified character set, so this gives us
+ * a work-around. More info here:
+ * http://bugs.php.net/bug.php?id=25670
+ *
+ * NOTE: html_entity_decode() has a bug in some PHP versions when UTF-8 is the
+ * character set, and the PHP developers said they were not back porting the
+ * fix to versions other than PHP 5.x.
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
+ public function entity_decode($str, $charset='UTF-8')
+ {
+ if (stristr($str, '&') === FALSE) return $str;
+
+ // The reason we are not using html_entity_decode() by itself is because
+ // while it is not technically correct to leave out the semicolon
+ // at the end of an entity most browsers will still interpret the entity
+ // correctly. html_entity_decode() does not convert entities without
+ // semicolons, so we are left with our own little solution here. Bummer.
+
+ if (function_exists('html_entity_decode') &&
+ (strtolower($charset) != 'utf-8'))
+ {
+ $str = html_entity_decode($str, ENT_COMPAT, $charset);
+ $str = preg_replace('~&#x(0*[0-9a-f]{2,5})~ei', 'chr(hexdec("\\1"))', $str);
+ return preg_replace('~&#([0-9]{2,4})~e', 'chr(\\1)', $str);
+ }
+
+ // Numeric Entities
+ $str = preg_replace('~&#x(0*[0-9a-f]{2,5});{0,1}~ei', 'chr(hexdec("\\1"))', $str);
+ $str = preg_replace('~&#([0-9]{2,4});{0,1}~e', 'chr(\\1)', $str);
+
+ // Literal Entities - Slightly slow so we do another check
+ if (stristr($str, '&') === FALSE)
+ {
+ $str = strtr($str, array_flip(get_html_translation_table(HTML_ENTITIES)));
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Filename Security
+ *
+ * @param string
+ * @return string
+ */
+ public function sanitize_filename($str, $relative_path = FALSE)
+ {
+ $bad = array(
+ "../",
+ "<!--",
+ "-->",
+ "<",
+ ">",
+ "'",
+ '"',
+ '&',
+ '$',
+ '#',
+ '{',
+ '}',
+ '[',
+ ']',
+ '=',
+ ';',
+ '?',
+ "%20",
+ "%22",
+ "%3c", // <
+ "%253c", // <
+ "%3e", // >
+ "%0e", // >
+ "%28", // (
+ "%29", // )
+ "%2528", // (
+ "%26", // &
+ "%24", // $
+ "%3f", // ?
+ "%3b", // ;
+ "%3d" // =
+ );
+
+ if ( ! $relative_path)
+ {
+ $bad[] = './';
+ $bad[] = '/';
+ }
+
+ $str = remove_invisible_characters($str, FALSE);
+ return stripslashes(str_replace($bad, '', $str));
+ }
+
+ // ----------------------------------------------------------------
+
+ /**
+ * Compact Exploded Words
+ *
+ * Callback function for xss_clean() to remove whitespace from
+ * things like j a v a s c r i p t
+ *
+ * @param type
+ * @return type
+ */
+ protected function _compact_exploded_words($matches)
+ {
+ return preg_replace('/\s+/s', '', $matches[1]).$matches[2];
+ }
+
+ // --------------------------------------------------------------------
+
+ /*
+ * Remove Evil HTML Attributes (like evenhandlers and style)
+ *
+ * It removes the evil attribute and either:
+ * - Everything up until a space
+ * For example, everything between the pipes:
+ * <a |style=document.write('hello');alert('world');| class=link>
+ * - Everything inside the quotes
+ * For example, everything between the pipes:
+ * <a |style="document.write('hello'); alert('world');"| class="link">
+ *
+ * @param string $str The string to check
+ * @param boolean $is_image TRUE if this is an image
+ * @return string The string with the evil attributes removed
+ */
+ protected function _remove_evil_attributes($str, $is_image)
+ {
+ // All javascript event handlers (e.g. onload, onclick, onmouseover), style, and xmlns
+ $evil_attributes = array('on\w*', 'style', 'xmlns');
+
+ if ($is_image === TRUE)
+ {
+ /*
+ * Adobe Photoshop puts XML metadata into JFIF images,
+ * including namespacing, so we have to allow this for images.
+ */
+ unset($evil_attributes[array_search('xmlns', $evil_attributes)]);
+ }
+
+ do {
+ $str = preg_replace(
+ "#<(/?[^><]+?)([^A-Za-z\-])(".implode('|', $evil_attributes).")(\s*=\s*)([\"][^>]*?[\"]|[\'][^>]*?[\']|[^>]*?)([\s><])([><]*)#i",
+ "<$1$6",
+ $str, -1, $count
+ );
+ } while ($count);
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Sanitize Naughty HTML
+ *
+ * Callback function for xss_clean() to remove naughty HTML elements
+ *
+ * @param array
+ * @return string
+ */
+ protected function _sanitize_naughty_html($matches)
+ {
+ // encode opening brace
+ $str = '&lt;'.$matches[1].$matches[2].$matches[3];
+
+ // encode captured opening or closing brace to prevent recursive vectors
+ $str .= str_replace(array('>', '<'), array('&gt;', '&lt;'),
+ $matches[4]);
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * JS Link Removal
+ *
+ * Callback function for xss_clean() to sanitize links
+ * This limits the PCRE backtracks, making it more performance friendly
+ * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+ * PHP 5.2+ on link-heavy strings
+ *
+ * @param array
+ * @return string
+ */
+ protected function _js_link_removal($match)
+ {
+ $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
+
+ return str_replace($match[1], preg_replace("#href=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * JS Image Removal
+ *
+ * Callback function for xss_clean() to sanitize image tags
+ * This limits the PCRE backtracks, making it more performance friendly
+ * and prevents PREG_BACKTRACK_LIMIT_ERROR from being triggered in
+ * PHP 5.2+ on image tag heavy strings
+ *
+ * @param array
+ * @return string
+ */
+ protected function _js_img_removal($match)
+ {
+ $attributes = $this->_filter_attributes(str_replace(array('<', '>'), '', $match[1]));
+
+ return str_replace($match[1], preg_replace("#src=.*?(alert\(|alert&\#40;|javascript\:|livescript\:|mocha\:|charset\=|window\.|document\.|\.cookie|<script|<xss|base64\s*,)#si", "", $attributes), $match[0]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Attribute Conversion
+ *
+ * Used as a callback for XSS Clean
+ *
+ * @param array
+ * @return string
+ */
+ protected function _convert_attribute($match)
+ {
+ return str_replace(array('>', '<', '\\'), array('&gt;', '&lt;', '\\\\'), $match[0]);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Filter Attributes
+ *
+ * Filters tag attributes for consistency and safety
+ *
+ * @param string
+ * @return string
+ */
+ protected function _filter_attributes($str)
+ {
+ $out = '';
+
+ if (preg_match_all('#\s*[a-z\-]+\s*=\s*(\042|\047)([^\\1]*?)\\1#is', $str, $matches))
+ {
+ foreach ($matches[0] as $match)
+ {
+ $out .= preg_replace("#/\*.*?\*/#s", '', $match);
+ }
+ }
+
+ return $out;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * HTML Entity Decode Callback
+ *
+ * Used as a callback for XSS Clean
+ *
+ * @param array
+ * @return string
+ */
+ protected function _decode_entity($match)
+ {
+ return $this->entity_decode($match[0], strtoupper(config_item('charset')));
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Validate URL entities
+ *
+ * Called by xss_clean()
+ *
+ * @param string
+ * @return string
+ */
+ protected function _validate_entities($str)
+ {
+ /*
+ * Protect GET variables in URLs
+ */
+
+ // 901119URL5918AMP18930PROTECT8198
+
+ $str = preg_replace('|\&([a-z\_0-9\-]+)\=([a-z\_0-9\-]+)|i', $this->xss_hash()."\\1=\\2", $str);
+
+ /*
+ * Validate standard character entities
+ *
+ * Add a semicolon if missing. We do this to enable
+ * the conversion of entities to ASCII later.
+ *
+ */
+ $str = preg_replace('#(&\#?[0-9a-z]{2,})([\x00-\x20])*;?#i', "\\1;\\2", $str);
+
+ /*
+ * Validate UTF16 two byte encoding (x00)
+ *
+ * Just as above, adds a semicolon if missing.
+ *
+ */
+ $str = preg_replace('#(&\#x?)([0-9A-F]+);?#i',"\\1\\2;",$str);
+
+ /*
+ * Un-Protect GET variables in URLs
+ */
+ $str = str_replace($this->xss_hash(), '&', $str);
+
+ return $str;
+ }
+
+ // ----------------------------------------------------------------------
+
+ /**
+ * Do Never Allowed
+ *
+ * A utility function for xss_clean()
+ *
+ * @param string
+ * @return string
+ */
+ protected function _do_never_allowed($str)
+ {
+ foreach ($this->_never_allowed_str as $key => $val)
+ {
+ $str = str_replace($key, $val, $str);
+ }
+
+ foreach ($this->_never_allowed_regex as $key => $val)
+ {
+ $str = preg_replace("#".$key."#i", $val, $str);
+ }
+
+ return $str;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Cross Site Request Forgery Protection Cookie
+ *
+ * @return string
+ */
+ protected function _csrf_set_hash()
+ {
+ if ($this->_csrf_hash == '')
+ {
+ // If the cookie exists we will use it's value.
+ // We don't necessarily want to regenerate it with
+ // each page load since a page could contain embedded
+ // sub-pages causing this feature to fail
+ if (isset($_COOKIE[$this->_csrf_cookie_name]) &&
+ $_COOKIE[$this->_csrf_cookie_name] != '')
+ {
+ return $this->_csrf_hash = $_COOKIE[$this->_csrf_cookie_name];
+ }
+
+ return $this->_csrf_hash = md5(uniqid(rand(), TRUE));
+ }
+
+ return $this->_csrf_hash;
+ }
+
+}
+// END Security Class
+
+/* End of file Security.php */
+/* Location: ./system/libraries/Security.php */ \ No newline at end of file
diff --git a/system/core/URI.php b/system/core/URI.php
index 88f237bcf..80dc62e58 100755
--- a/system/core/URI.php
+++ b/system/core/URI.php
@@ -61,17 +61,17 @@ class CI_URI {
{
if (strtoupper($this->config->item('uri_protocol')) == 'AUTO')
{
- // Arguments exist, it must be a command line request
- if ( ! empty($_SERVER['argv']))
+ // Is the request coming from the command line?
+ if (defined('STDIN'))
{
- $this->uri_string = $this->_parse_cli_args();
+ $this->_set_uri_string($this->_parse_cli_args());
return;
}
// Let's try the REQUEST_URI first, this will work in most situations
if ($uri = $this->_detect_uri())
{
- $this->uri_string = $uri;
+ $this->_set_uri_string($uri);
return;
}
@@ -80,7 +80,7 @@ class CI_URI {
$path = (isset($_SERVER['PATH_INFO'])) ? $_SERVER['PATH_INFO'] : @getenv('PATH_INFO');
if (trim($path, '/') != '' && $path != "/".SELF)
{
- $this->uri_string = $path;
+ $this->_set_uri_string($path);
return;
}
@@ -88,43 +88,54 @@ class CI_URI {
$path = (isset($_SERVER['QUERY_STRING'])) ? $_SERVER['QUERY_STRING'] : @getenv('QUERY_STRING');
if (trim($path, '/') != '')
{
- $this->uri_string = $path;
+ $this->_set_uri_string($path);
return;
}
// As a last ditch effort lets try using the $_GET array
if (is_array($_GET) && count($_GET) == 1 && trim(key($_GET), '/') != '')
{
- $this->uri_string = key($_GET);
+ $this->_set_uri_string(key($_GET));
return;
}
// We've exhausted all our options...
$this->uri_string = '';
+ return;
}
- else
- {
- $uri = strtoupper($this->config->item('uri_protocol'));
- if ($uri == 'REQUEST_URI')
- {
- $this->uri_string = $this->_detect_uri();
- return;
- }
- elseif ($uri == 'CLI')
- {
- $this->uri_string = $this->_parse_cli_args();
- return;
- }
+ $uri = strtoupper($this->config->item('uri_protocol'));
- $this->uri_string = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
+ if ($uri == 'REQUEST_URI')
+ {
+ $this->_set_uri_string($this->_detect_uri());
+ return;
}
-
- // If the URI contains only a slash we'll kill it
- if ($this->uri_string == '/')
+ elseif ($uri == 'CLI')
{
- $this->uri_string = '';
+ $this->_set_uri_string($this->_parse_cli_args());
+ return;
}
+
+ $path = (isset($_SERVER[$uri])) ? $_SERVER[$uri] : @getenv($uri);
+ $this->_set_uri_string($path);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set the URI String
+ *
+ * @access public
+ * @return string
+ */
+ function _set_uri_string($str)
+ {
+ // Filter out control characters
+ $str = remove_invisible_characters($str, FALSE);
+
+ // If the URI contains only a slash we'll kill it
+ $this->uri_string = ($str == '/') ? '' : $str;
}
// --------------------------------------------------------------------
@@ -173,10 +184,16 @@ class CI_URI {
$_SERVER['QUERY_STRING'] = '';
$_GET = array();
}
+
+ if ($uri == '/' || empty($uri))
+ {
+ return '/';
+ }
+
$uri = parse_url($uri, PHP_URL_PATH);
// Do some final cleaning of the URI and return it
- return str_replace(array('//', '../'), '/', ltrim($uri, '/'));
+ return str_replace(array('//', '../'), '/', trim($uri, '/'));
}
// --------------------------------------------------------------------
diff --git a/system/core/Utf8.php b/system/core/Utf8.php
index 5d5a7ef72..2a27d1f35 100755
--- a/system/core/Utf8.php
+++ b/system/core/Utf8.php
@@ -107,7 +107,7 @@ class CI_Utf8 {
*/
function safe_ascii_for_xml($str)
{
- return preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $str);
+ return remove_invisible_characters($str, FALSE);
}
// --------------------------------------------------------------------
diff --git a/system/database/DB.php b/system/database/DB.php
index fb0516ba4..8bf1ba8ba 100755
--- a/system/database/DB.php
+++ b/system/database/DB.php
@@ -27,7 +27,16 @@ function &DB($params = '', $active_record_override = NULL)
// Load the DB config file if a DSN string wasn't passed
if (is_string($params) AND strpos($params, '://') === FALSE)
{
- include(APPPATH.'config/database'.EXT);
+ // Is the config file in the environment folder?
+ if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database'.EXT))
+ {
+ if ( ! file_exists($file_path = APPPATH.'config/database'.EXT))
+ {
+ show_error('The configuration file database'.EXT.' does not exist.');
+ }
+ }
+
+ include($file_path);
if ( ! isset($db) OR count($db) == 0)
{
@@ -74,7 +83,7 @@ function &DB($params = '', $active_record_override = NULL)
{
parse_str($dns['query'], $extra);
- foreach($extra as $key => $val)
+ foreach ($extra as $key => $val)
{
// booleans please
if (strtoupper($val) == "TRUE")
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index ce9d1c1af..db8471364 100755
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -954,7 +954,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
else
{
- $this->ar_set[$this->_protect_identifiers($k)] = $this->escape($v);
+ $this->ar_set[$this->_protect_identifiers($k, FALSE, TRUE)] = $this->escape($v);
}
}
@@ -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;
}
// --------------------------------------------------------------------
@@ -1156,7 +1156,7 @@ class CI_DB_active_record extends CI_DB_driver {
$this->ar_set[] = array();
return;
}
-
+
ksort($row); // puts $row in the same order as our keys
if ($escape === FALSE)
@@ -1167,7 +1167,7 @@ class CI_DB_active_record extends CI_DB_driver {
{
$clean = array();
- foreach($row as $value)
+ foreach ($row as $value)
{
$clean[] = $this->escape($value);
}
@@ -1425,7 +1425,7 @@ class CI_DB_active_record extends CI_DB_driver {
$index_set = FALSE;
$clean = array();
- foreach($v as $k2 => $v2)
+ foreach ($v as $k2 => $v2)
{
if ($k2 == $index)
{
@@ -1569,7 +1569,7 @@ class CI_DB_active_record extends CI_DB_driver {
}
elseif (is_array($table))
{
- foreach($table as $single_table)
+ foreach ($table as $single_table)
{
$this->delete($single_table, $where, $limit, FALSE);
}
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index 2d8f592e3..e7a9de475 100755
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -767,7 +767,7 @@ class CI_DB_driver {
if ($query->num_rows() > 0)
{
- foreach($query->result_array() as $row)
+ foreach ($query->result_array() as $row)
{
if (isset($row['TABLE_NAME']))
{
@@ -834,7 +834,7 @@ class CI_DB_driver {
$query = $this->query($sql);
$retval = array();
- foreach($query->result_array() as $row)
+ foreach ($query->result_array() as $row)
{
if (isset($row['COLUMN_NAME']))
{
@@ -904,7 +904,7 @@ class CI_DB_driver {
$fields = array();
$values = array();
- foreach($data as $key => $val)
+ foreach ($data as $key => $val)
{
$fields[] = $this->_escape_identifiers($key);
$values[] = $this->escape($val);
@@ -932,7 +932,7 @@ class CI_DB_driver {
}
$fields = array();
- foreach($data as $key => $val)
+ foreach ($data as $key => $val)
{
$fields[$this->_protect_identifiers($key)] = $this->escape($val);
}
@@ -1175,7 +1175,7 @@ class CI_DB_driver {
$trace = debug_backtrace();
- foreach($trace as $call)
+ foreach ($trace as $call)
{
if (isset($call['file']) && strpos($call['file'], BASEPATH.'database') === FALSE)
{
@@ -1248,7 +1248,7 @@ class CI_DB_driver {
{
$escaped_array = array();
- foreach($item as $k => $v)
+ foreach ($item as $k => $v)
{
$escaped_array[$this->_protect_identifiers($k)] = $this->_protect_identifiers($v);
}
diff --git a/system/database/DB_forge.php b/system/database/DB_forge.php
index 27f2c372d..a71fca78f 100755
--- a/system/database/DB_forge.php
+++ b/system/database/DB_forge.php
@@ -99,7 +99,7 @@ class CI_DB_forge {
{
if (is_array($key))
{
- foreach($key as $one)
+ foreach ($key as $one)
{
$this->add_key($one, $primary);
}
diff --git a/system/database/DB_result.php b/system/database/DB_result.php
index fb4268c21..76e1d6abb 100755
--- a/system/database/DB_result.php
+++ b/system/database/DB_result.php
@@ -78,7 +78,7 @@ class CI_DB_result {
while ($row = $this->_fetch_object())
{
$object = new $class_name();
- foreach($row as $key => $value)
+ foreach ($row as $key => $value)
{
$object->$key = $value;
}
diff --git a/system/database/drivers/mssql/mssql_driver.php b/system/database/drivers/mssql/mssql_driver.php
index 5a69132cd..65397ed8f 100755
--- a/system/database/drivers/mssql/mssql_driver.php
+++ b/system/database/drivers/mssql/mssql_driver.php
@@ -253,7 +253,7 @@ class CI_DB_mssql_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -267,9 +267,11 @@ class CI_DB_mssql_driver extends CI_DB {
// escape LIKE condition wildcards
if ($like === TRUE)
{
- $str = str_replace( array('%', '_', $this->_like_escape_chr),
- array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
- $str);
+ $str = str_replace(
+ array($this->_like_escape_chr, '%', '_'),
+ array($this->_like_escape_chr.$this->_like_escape_chr, $this->_like_escape_chr.'%', $this->_like_escape_chr.'_'),
+ $str
+ );
}
return $str;
@@ -551,7 +553,7 @@ class CI_DB_mssql_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php
index df18c912e..4ff9b0a11 100755
--- a/system/database/drivers/mysql/mysql_driver.php
+++ b/system/database/drivers/mysql/mysql_driver.php
@@ -286,13 +286,13 @@ class CI_DB_mysql_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
- {
+ foreach ($str as $key => $val)
+ {
$str[$key] = $this->escape_str($val, $like);
- }
+ }
- return $str;
- }
+ return $str;
+ }
if (function_exists('mysql_real_escape_string') AND is_resource($this->conn_id))
{
@@ -590,9 +590,9 @@ class CI_DB_mysql_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
- $valstr[] = $key." = ".$val;
+ $valstr[] = $key . ' = ' . $val;
}
$limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
@@ -627,11 +627,11 @@ class CI_DB_mysql_driver extends CI_DB {
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$ids[] = $val[$index];
- foreach(array_keys($val) as $field)
+ foreach (array_keys($val) as $field)
{
if ($field != $index)
{
@@ -643,7 +643,7 @@ class CI_DB_mysql_driver extends CI_DB {
$sql = "UPDATE ".$table." SET ";
$cases = '';
- foreach($final as $k => $v)
+ foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php
index 8942100d4..ccdabce1a 100755
--- a/system/database/drivers/mysqli/mysqli_driver.php
+++ b/system/database/drivers/mysqli/mysqli_driver.php
@@ -287,7 +287,7 @@ class CI_DB_mysqli_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -571,7 +571,7 @@ class CI_DB_mysqli_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
@@ -607,11 +607,11 @@ class CI_DB_mysqli_driver extends CI_DB {
$ids = array();
$where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$ids[] = $val[$index];
- foreach(array_keys($val) as $field)
+ foreach (array_keys($val) as $field)
{
if ($field != $index)
{
@@ -623,7 +623,7 @@ class CI_DB_mysqli_driver extends CI_DB {
$sql = "UPDATE ".$table." SET ";
$cases = '';
- foreach($final as $k => $v)
+ foreach ($final as $k => $v)
{
$cases .= $k.' = CASE '."\n";
foreach ($v as $row)
diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php
index 64f53cc3f..14df104ff 100755
--- a/system/database/drivers/oci8/oci8_driver.php
+++ b/system/database/drivers/oci8/oci8_driver.php
@@ -253,7 +253,7 @@ class CI_DB_oci8_driver extends CI_DB {
$sql = "begin $package.$procedure(";
$have_cursor = FALSE;
- foreach($params as $param)
+ foreach ($params as $param)
{
$sql .= $param['name'] . ",";
@@ -395,7 +395,7 @@ class CI_DB_oci8_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -655,7 +655,7 @@ class CI_DB_oci8_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
diff --git a/system/database/drivers/odbc/odbc_driver.php b/system/database/drivers/odbc/odbc_driver.php
index c8e03c356..81e0d7cf2 100755
--- a/system/database/drivers/odbc/odbc_driver.php
+++ b/system/database/drivers/odbc/odbc_driver.php
@@ -264,7 +264,7 @@ class CI_DB_odbc_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -523,7 +523,7 @@ class CI_DB_odbc_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
diff --git a/system/database/drivers/odbc/odbc_result.php b/system/database/drivers/odbc/odbc_result.php
index a81a2b8b7..5d64a464f 100755
--- a/system/database/drivers/odbc/odbc_result.php
+++ b/system/database/drivers/odbc/odbc_result.php
@@ -188,7 +188,7 @@ class CI_DB_odbc_result extends CI_DB_result {
*/
function _odbc_fetch_object(& $odbc_result) {
$rs = array();
- $rs_obj = false;
+ $rs_obj = FALSE;
if (odbc_fetch_into($odbc_result, $rs)) {
foreach ($rs as $k=>$v) {
$field_name= odbc_field_name($odbc_result, $k+1);
@@ -210,7 +210,7 @@ class CI_DB_odbc_result extends CI_DB_result {
*/
function _odbc_fetch_array(& $odbc_result) {
$rs = array();
- $rs_assoc = false;
+ $rs_assoc = FALSE;
if (odbc_fetch_into($odbc_result, $rs)) {
$rs_assoc=array();
foreach ($rs as $k=>$v) {
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 0bb7974d8..47ff36246 100755
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -283,7 +283,7 @@ class CI_DB_postgre_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -330,21 +330,21 @@ class CI_DB_postgre_driver extends CI_DB {
$v = $this->_version();
$v = $v['server'];
- $table = func_num_args() > 0 ? func_get_arg(0) : null;
- $column = func_num_args() > 1 ? func_get_arg(1) : null;
+ $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
+ $column = func_num_args() > 1 ? func_get_arg(1) : NULL;
- if ($table == null && $v >= '8.1')
+ if ($table == NULL && $v >= '8.1')
{
$sql='SELECT LASTVAL() as ins_id';
}
- elseif ($table != null && $column != null && $v >= '8.0')
+ elseif ($table != NULL && $column != NULL && $v >= '8.0')
{
$sql = sprintf("SELECT pg_get_serial_sequence('%s','%s') as seq", $table, $column);
$query = $this->query($sql);
$row = $query->row();
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $row->seq);
}
- elseif ($table != null)
+ elseif ($table != NULL)
{
// seq_name passed in table parameter
$sql = sprintf("SELECT CURRVAL('%s') as ins_id", $table);
@@ -568,7 +568,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
diff --git a/system/database/drivers/sqlite/sqlite_driver.php b/system/database/drivers/sqlite/sqlite_driver.php
index 5bfc1f558..eb4e585b3 100755
--- a/system/database/drivers/sqlite/sqlite_driver.php
+++ b/system/database/drivers/sqlite/sqlite_driver.php
@@ -280,7 +280,7 @@ class CI_DB_sqlite_driver extends CI_DB {
{
if (is_array($str))
{
- foreach($str as $key => $val)
+ foreach ($str as $key => $val)
{
$str[$key] = $this->escape_str($val, $like);
}
@@ -537,7 +537,7 @@ class CI_DB_sqlite_driver extends CI_DB {
*/
function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
{
- foreach($values as $key => $val)
+ foreach ($values as $key => $val)
{
$valstr[] = $key." = ".$val;
}
diff --git a/system/helpers/array_helper.php b/system/helpers/array_helper.php
index 6b2415df2..075a31fdf 100755
--- a/system/helpers/array_helper.php
+++ b/system/helpers/array_helper.php
@@ -69,6 +69,7 @@ if ( ! function_exists('random_element'))
{
return $array;
}
+
return $array[array_rand($array)];
}
}
diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php
index c0e3798f4..19ec0c778 100755
--- a/system/helpers/captcha_helper.php
+++ b/system/helpers/captcha_helper.php
@@ -87,7 +87,7 @@ if ( ! function_exists('create_captcha'))
$current_dir = @opendir($img_path);
- while($filename = @readdir($current_dir))
+ while ($filename = @readdir($current_dir))
{
if ($filename != "." and $filename != ".." and $filename != "index.html")
{
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 7701d503f..7cee02827 100755
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -44,11 +44,11 @@
*/
if ( ! function_exists('set_cookie'))
{
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
// Set the config file options
$CI =& get_instance();
- $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix);
+ $CI->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure);
}
}
diff --git a/system/helpers/download_helper.php b/system/helpers/download_helper.php
index 6cecd0d11..f8073d238 100755
--- 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 (defined('ENVIRONMENT') AND 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 334eef87c..44344947e 100755
--- a/system/helpers/file_helper.php
+++ b/system/helpers/file_helper.php
@@ -128,7 +128,7 @@ if ( ! function_exists('delete_files'))
return FALSE;
}
- while(FALSE !== ($filename = @readdir($current_dir)))
+ while (FALSE !== ($filename = @readdir($current_dir)))
{
if ($filename != "." and $filename != "..")
{
@@ -352,7 +352,16 @@ if ( ! function_exists('get_mime_by_extension'))
if ( ! is_array($mimes))
{
- if ( ! require_once(APPPATH.'config/mimes.php'))
+ if (defined('ENVIRONMENT') AND 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..acd75c239 100755
--- a/system/helpers/form_helper.php
+++ b/system/helpers/form_helper.php
@@ -49,7 +49,14 @@ if ( ! function_exists('form_open'))
$attributes = 'method="post"';
}
- $action = ( strpos($action, '://') === FALSE) ? $CI->config->site_url($action) : $action;
+ // If an action is not a full URL then turn it into one
+ if ($action && strpos($action, '://') === FALSE)
+ {
+ $action = $CI->config->site_url($action);
+ }
+
+ // If no action is provided then set to the current url
+ $action OR $action = $CI->config->site_url($CI->uri->uri_string());
$form = '<form action="'.$action.'"';
@@ -60,7 +67,7 @@ if ( ! function_exists('form_open'))
// CSRF
if ($CI->config->item('csrf_protection') === TRUE)
{
- $hidden[$CI->security->csrf_token_name] = $CI->security->csrf_hash;
+ $hidden[$CI->security->get_csrf_token_name()] = $CI->security->get_csrf_hash();
}
if (is_array($hidden) AND count($hidden) > 0)
diff --git a/system/helpers/html_helper.php b/system/helpers/html_helper.php
index 68c6f5908..c6103ab6f 100755
--- 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 (defined('ENVIRONMENT') AND 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/inflector_helper.php b/system/helpers/inflector_helper.php
index 4cd7486b4..c7c113b8a 100755
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -41,20 +41,22 @@ if ( ! function_exists('singular'))
{
function singular($str)
{
- $str = strtolower(trim($str));
+ $str = trim($str);
$end = substr($str, -3);
-
- if ($end == 'ies')
+
+ $str = preg_replace('/(.*)?([s|c]h)es/i','$1$2',$str);
+
+ if (strtolower($end) == 'ies')
{
- $str = substr($str, 0, strlen($str)-3).'y';
+ $str = substr($str, 0, strlen($str)-3).(preg_match('/[a-z]/',$end) ? 'y' : 'Y');
}
- elseif ($end == 'ses')
+ elseif (strtolower($end) == 'ses')
{
$str = substr($str, 0, strlen($str)-2);
}
else
{
- $end = substr($str, -1);
+ $end = strtolower(substr($str, -1));
if ($end == 's')
{
@@ -81,19 +83,19 @@ if ( ! function_exists('singular'))
if ( ! function_exists('plural'))
{
function plural($str, $force = FALSE)
- {
- $str = strtolower(trim($str));
+ {
+ $str = trim($str);
$end = substr($str, -1);
- if ($end == 'y')
+ if (preg_match('/y/i',$end))
{
// Y preceded by vowel => regular plural
- $vowels = array('a', 'e', 'i', 'o', 'u');
+ $vowels = array('a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U');
$str = in_array(substr($str, -2, 1), $vowels) ? $str.'s' : substr($str, 0, -1).'ies';
}
- elseif ($end == 'h')
+ elseif (preg_match('/h/i',$end))
{
- if (substr($str, -2) == 'ch' OR substr($str, -2) == 'sh')
+ if(preg_match('/^[c|s]h$/i',substr($str, -2)))
{
$str .= 'es';
}
@@ -102,7 +104,7 @@ if ( ! function_exists('plural'))
$str .= 's';
}
}
- elseif ($end == 's')
+ elseif (preg_match('/s/i',$end))
{
if ($force == TRUE)
{
diff --git a/system/helpers/language_helper.php b/system/helpers/language_helper.php
index 68c1a1fc6..ac0d69da1 100755
--- a/system/helpers/language_helper.php
+++ b/system/helpers/language_helper.php
@@ -1,4 +1,4 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
diff --git a/system/helpers/number_helper.php b/system/helpers/number_helper.php
index a2caea5e3..611777559 100755
--- a/system/helpers/number_helper.php
+++ b/system/helpers/number_helper.php
@@ -1,4 +1,4 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
diff --git a/system/helpers/security_helper.php b/system/helpers/security_helper.php
index 61ebf46f9..678dac821 100755
--- a/system/helpers/security_helper.php
+++ b/system/helpers/security_helper.php
@@ -67,22 +67,6 @@ if ( ! function_exists('sanitize_filename'))
/**
* Hash encode a string
*
- * This is simply an alias for do_hash()
- * dohash() is now deprecated
- */
-if ( ! function_exists('dohash'))
-{
- function dohash($str, $type = 'sha1')
- {
- return do_hash($str, $type);
- }
-}
-
-// --------------------------------------------------------------------
-
-/**
- * Hash encode a string
- *
* @access public
* @param string
* @return string
@@ -93,23 +77,7 @@ if ( ! function_exists('do_hash'))
{
if ($type == 'sha1')
{
- if ( ! function_exists('sha1'))
- {
- if ( ! function_exists('mhash'))
- {
- require_once(BASEPATH.'libraries/Sha1'.EXT);
- $SH = new CI_SHA;
- return $SH->generate($str);
- }
- else
- {
- return bin2hex(mhash(MHASH_SHA1, $str));
- }
- }
- else
- {
- return sha1($str);
- }
+ return sha1($str);
}
else
{
diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php
index 80a8d79ad..a2d1031b3 100755
--- a/system/helpers/smiley_helper.php
+++ b/system/helpers/smiley_helper.php
@@ -59,7 +59,7 @@ if ( ! function_exists('smiley_js'))
if (is_array($alias))
{
- foreach($alias as $name => $id)
+ foreach ($alias as $name => $id)
{
$m[] = '"'.$name.'" : "'.$id.'"';
}
@@ -101,7 +101,7 @@ EOF;
{
if (is_array($alias))
{
- foreach($alias as $name => $id)
+ foreach ($alias as $name => $id)
{
$r .= 'smiley_map["'.$name.'"] = "'.$id.'";'."\n";
}
@@ -229,19 +229,21 @@ if ( ! function_exists('_get_smiley_array'))
{
function _get_smiley_array()
{
- if ( ! file_exists(APPPATH.'config/smileys'.EXT))
+ if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT))
{
- return FALSE;
+ include(APPPATH.'config/'.ENVIRONMENT.'/smileys'.EXT);
}
-
- include(APPPATH.'config/smileys'.EXT);
-
- if ( ! isset($smileys) OR ! is_array($smileys))
+ elseif (file_exists(APPPATH.'config/smileys'.EXT))
+ {
+ include(APPPATH.'config/smileys'.EXT);
+ }
+
+ if (isset($smileys) AND is_array($smileys))
{
- return FALSE;
+ return $smileys;
}
- return $smileys;
+ return FALSE;
}
}
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 47e6ccc93..cca093976 100755
--- 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 (defined('ENVIRONMENT') AND 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))
{
@@ -443,7 +445,7 @@ if ( ! function_exists('word_wrap'))
}
$temp = '';
- while((strlen($line)) > $charlim)
+ while ((strlen($line)) > $charlim)
{
// If the over-length word is a URL we won't wrap it
if (preg_match("!\[url.+\]|://|wwww.!", $line))
diff --git a/system/helpers/typography_helper.php b/system/helpers/typography_helper.php
index 302bf45c5..19b4eec03 100755
--- a/system/helpers/typography_helper.php
+++ b/system/helpers/typography_helper.php
@@ -84,9 +84,8 @@ if ( ! function_exists('entity_decode'))
{
function entity_decode($str, $charset='UTF-8')
{
- $CI =& get_instance();
- $CI->load->library('security');
- return $CI->security->entity_decode($str, $charset);
+ global $SEC;
+ return $SEC->entity_decode($str, $charset);
}
}
diff --git a/system/language/english/form_validation_lang.php b/system/language/english/form_validation_lang.php
index b01885091..3f2409007 100755
--- 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/language/english/ftp_lang.php b/system/language/english/ftp_lang.php
index 392b2b272..1e5168cf8 100755
--- a/system/language/english/ftp_lang.php
+++ b/system/language/english/ftp_lang.php
@@ -1,17 +1,17 @@
<?php
-$lang['ftp_no_connection'] = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
+$lang['ftp_no_connection'] = "Unable to locate a valid connection ID. Please make sure you are connected before peforming any file routines.";
$lang['ftp_unable_to_connect'] = "Unable to connect to your FTP server using the supplied hostname.";
-$lang['ftp_unable_to_login'] = "Unable to login to your FTP server. Please check your username and password.";
+$lang['ftp_unable_to_login'] = "Unable to login to your FTP server. Please check your username and password.";
$lang['ftp_unable_to_makdir'] = "Unable to create the directory you have specified.";
$lang['ftp_unable_to_changedir'] = "Unable to change directories.";
-$lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
-$lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path.";
-$lang['ftp_unable_to_download'] = "Unable to download the specified file. Please check your path.";
-$lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path.";
+$lang['ftp_unable_to_chmod'] = "Unable to set file permissions. Please check your path. Note: This feature is only available in PHP 5 or higher.";
+$lang['ftp_unable_to_upload'] = "Unable to upload the specified file. Please check your path.";
+$lang['ftp_unable_to_download'] = "Unable to download the specified file. Please check your path.";
+$lang['ftp_no_source_file'] = "Unable to locate the source file. Please check your path.";
$lang['ftp_unable_to_rename'] = "Unable to rename the file.";
$lang['ftp_unable_to_delete'] = "Unable to delete the file.";
-$lang['ftp_unable_to_move'] = "Unable to move the file. Please make sure the destination directory exists.";
+$lang['ftp_unable_to_move'] = "Unable to move the file. Please make sure the destination directory exists.";
/* End of file ftp_lang.php */
diff --git a/system/libraries/Cache/Cache.php b/system/libraries/Cache/Cache.php
index d3f6105ea..61e7aa761 100755
--- a/system/libraries/Cache/Cache.php
+++ b/system/libraries/Cache/Cache.php
@@ -24,11 +24,11 @@
* @author ExpressionEngine Dev Team
* @link
*/
-class Cache extends CI_Driver_Library {
+class CI_Cache extends CI_Driver_Library {
protected $valid_drivers = array(
- 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
- );
+ 'cache_apc', 'cache_file', 'cache_memcached', 'cache_dummy'
+ );
protected $_cache_path = NULL; // Path of cache files (if file-based cache)
protected $_adapter = 'dummy';
diff --git a/system/libraries/Cache/drivers/Cache_apc.php b/system/libraries/Cache/drivers/Cache_apc.php
index e82e8e1f5..de75719c4 100755
--- a/system/libraries/Cache/drivers/Cache_apc.php
+++ b/system/libraries/Cache/drivers/Cache_apc.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_apc extends CI_Driver {
+class CI_Cache_apc extends CI_Driver {
/**
* Get
@@ -114,7 +114,7 @@ class Cache_apc extends CI_Driver {
return FALSE;
}
- list($value, $time, $ttl) = $stored;
+ list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
diff --git a/system/libraries/Cache/drivers/Cache_dummy.php b/system/libraries/Cache/drivers/Cache_dummy.php
index 74f689241..de47acb43 100755
--- a/system/libraries/Cache/drivers/Cache_dummy.php
+++ b/system/libraries/Cache/drivers/Cache_dummy.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_dummy extends CI_Driver {
+class CI_Cache_dummy extends CI_Driver {
/**
* Get
diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php
index 3ed357f2f..13e2d1af6 100755
--- a/system/libraries/Cache/drivers/Cache_file.php
+++ b/system/libraries/Cache/drivers/Cache_file.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_file extends CI_Driver {
+class CI_Cache_file extends CI_Driver {
protected $_cache_path;
@@ -39,7 +39,7 @@ class Cache_file extends CI_Driver {
$path = $CI->config->item('cache_path');
- $this->_cache_path = ($path == '') ? BASEPATH.'cache/' : $path;
+ $this->_cache_path = ($path == '') ? APPPATH.'cache/' : $path;
}
// ------------------------------------------------------------------------
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index a7efdc5de..ec2fd216a 100755
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -25,7 +25,7 @@
* @link
*/
-class Cache_memcached extends CI_Driver {
+class CI_Cache_memcached extends CI_Driver {
private $_memcached; // Holds the memcached object
@@ -122,7 +122,7 @@ class Cache_memcached extends CI_Driver {
return FALSE;
}
- list($value, $time, $ttl) = $stored;
+ list($data, $time, $ttl) = $stored;
return array(
'expire' => $time + $ttl,
diff --git a/system/libraries/Driver.php b/system/libraries/Driver.php
index 15fc3da26..d1838f2c1 100755
--- a/system/libraries/Driver.php
+++ b/system/libraries/Driver.php
@@ -1,4 +1,4 @@
-<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
+<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter
*
@@ -36,7 +36,7 @@ class CI_Driver_Library {
// subsequents calls will go straight to the proper child.
function __get($child)
{
- if (! isset($this->lib_name))
+ if ( ! isset($this->lib_name))
{
$this->lib_name = get_class($this);
}
@@ -44,7 +44,11 @@ class CI_Driver_Library {
// The class will be prefixed with the parent lib
$child_class = $this->lib_name.'_'.$child;
- if (in_array(strtolower($child_class), array_map('strtolower', $this->valid_drivers)))
+ // Remove the CI_ prefix and lowercase
+ $lib_name = strtolower(preg_replace('/^CI_/', '', $this->lib_name));
+ $driver_name = strtolower(preg_replace('/^CI_/', '', $child_class));
+
+ if (in_array($driver_name, array_map('strtolower', $this->valid_drivers)))
{
// check and see if the driver is in a separate file
if ( ! class_exists($child_class))
@@ -52,19 +56,15 @@ class CI_Driver_Library {
// check application path first
foreach (array(APPPATH, BASEPATH) as $path)
{
- // and check for case sensitivity of both the parent and child libs
- foreach (array(ucfirst($this->lib_name), strtolower($this->lib_name)) as $lib)
+ // loves me some nesting!
+ foreach (array(ucfirst($driver_name), $driver_name) as $class)
{
- // loves me some nesting!
- foreach (array(ucfirst($child_class), strtolower($child_class)) as $class)
- {
- $filepath = $path.'libraries/'.$this->lib_name.'/drivers/'.$child_class.EXT;
+ $filepath = $path.'libraries/'.$lib_name.'/drivers/'.$class.EXT;
- if (file_exists($filepath))
- {
- include_once $filepath;
- break;
- }
+ if (file_exists($filepath))
+ {
+ include_once $filepath;
+ break;
}
}
}
@@ -143,7 +143,7 @@ class CI_Driver {
}
}
- foreach($r->getProperties() as $prop)
+ foreach ($r->getProperties() as $prop)
{
if ($prop->isPublic())
{
diff --git a/system/libraries/Email.php b/system/libraries/Email.php
index e5af38f45..6c21f114d 100755
--- a/system/libraries/Email.php
+++ b/system/libraries/Email.php
@@ -897,7 +897,7 @@ class CI_Email {
}
$temp = '';
- while((strlen($line)) > $charlim)
+ while ((strlen($line)) > $charlim)
{
// If the over-length word is a URL we won't wrap it
if (preg_match("!\[url.+\]|://|wwww.!", $line))
@@ -973,7 +973,7 @@ class CI_Email {
reset($this->_headers);
$this->_header_str = "";
- foreach($this->_headers as $key => $val)
+ foreach ($this->_headers as $key => $val)
{
$val = trim($val);
@@ -1607,14 +1607,14 @@ class CI_Email {
$this->_send_command('from', $this->clean_email($this->_headers['From']));
- foreach($this->_recipients as $val)
+ foreach ($this->_recipients as $val)
{
$this->_send_command('to', $val);
}
if (count($this->_cc_array) > 0)
{
- foreach($this->_cc_array as $val)
+ foreach ($this->_cc_array as $val)
{
if ($val != "")
{
@@ -1625,7 +1625,7 @@ class CI_Email {
if (count($this->_bcc_array) > 0)
{
- foreach($this->_bcc_array as $val)
+ foreach ($this->_bcc_array as $val)
{
if ($val != "")
{
@@ -1672,7 +1672,7 @@ class CI_Email {
$errstr,
$this->smtp_timeout);
- if( ! is_resource($this->_smtp_connect))
+ if ( ! is_resource($this->_smtp_connect))
{
$this->_set_error_message('email_smtp_error', $errno." ".$errstr);
return FALSE;
diff --git a/system/libraries/Form_validation.php b/system/libraries/Form_validation.php
index fc5b82ee3..cfc02eda9 100755
--- a/system/libraries/Form_validation.php
+++ b/system/libraries/Form_validation.php
@@ -138,14 +138,14 @@ class CI_Form_validation {
// Build our master array
$this->_field_data[$field] = array(
- 'field' => $field,
- 'label' => $label,
- 'rules' => $rules,
- 'is_array' => $is_array,
- 'keys' => $indexes,
- 'postdata' => NULL,
- 'error' => ''
- );
+ 'field' => $field,
+ 'label' => $label,
+ 'rules' => $rules,
+ 'is_array' => $is_array,
+ 'keys' => $indexes,
+ 'postdata' => NULL,
+ 'error' => ''
+ );
return $this;
}
@@ -1040,7 +1040,7 @@ class CI_Form_validation {
return $this->valid_email(trim($str));
}
- foreach(explode(',', $str) as $email)
+ foreach (explode(',', $str) as $email)
{
if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE)
{
@@ -1147,7 +1147,57 @@ class CI_Form_validation {
*/
function integer($str)
{
- return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str);
+ return (bool) preg_match('/^[\-+]?[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Decimal number
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function decimal($str)
+ {
+ return (bool) preg_match('/^[\-+]?[0-9]+\.[0-9]+$/', $str);
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Greather than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function greater_than($str, $min)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str > $min;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Less than
+ *
+ * @access public
+ * @param string
+ * @return bool
+ */
+ function less_than($str, $max)
+ {
+ if ( ! is_numeric($str))
+ {
+ return FALSE;
+ }
+ return $str < $max;
}
// --------------------------------------------------------------------
@@ -1161,7 +1211,7 @@ class CI_Form_validation {
*/
function is_natural($str)
{
- return (bool)preg_match( '/^[0-9]+$/', $str);
+ return (bool) preg_match( '/^[0-9]+$/', $str);
}
// --------------------------------------------------------------------
@@ -1286,11 +1336,6 @@ class CI_Form_validation {
*/
function xss_clean($str)
{
- if ( ! isset($this->CI->security))
- {
- $this->CI->load->library('security');
- }
-
return $this->CI->security->xss_clean($str);
}
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 41f9ad393..8902f524d 100755
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -749,7 +749,7 @@ class CI_Image_lib {
@chmod($this->full_dst_path, FILE_WRITE_MODE);
- return true;
+ return TRUE;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Javascript.php b/system/libraries/Javascript.php
index 167859abd..34e0d7001 100755
--- a/system/libraries/Javascript.php
+++ b/system/libraries/Javascript.php
@@ -855,7 +855,7 @@ class CI_Javascript {
}
elseif (is_string($result) OR $is_key)
{
- return '"'.str_replace(array('\\', "\t", "\n", "\r", '"'), array('\\\\', '\\t', '\\n', "\\r", '\"'), $result).'"';
+ return '"'.str_replace(array('\\', "\t", "\n", "\r", '"', '/'), array('\\\\', '\\t', '\\n', "\\r", '\"', '\/'), $result).'"';
}
elseif (is_scalar($result))
{
diff --git a/system/libraries/Profiler.php b/system/libraries/Profiler.php
index 6587eae0b..8a1f18ced 100755
--- a/system/libraries/Profiler.php
+++ b/system/libraries/Profiler.php
@@ -415,7 +415,7 @@ class CI_Profiler {
$output .= "\n\n<table style='width:100%'>\n";
- foreach(array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
+ foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header)
{
$val = (isset($_SERVER[$header])) ? $_SERVER[$header] : '';
$output .= "<tr><td style='vertical-align: top;width:50%;padding:5px;color:#900;background-color:#ddd;'>".$header."&nbsp;&nbsp;</td><td style='width:50%;padding:5px;color:#000;background-color:#ddd;'>".$val."</td></tr>\n";
@@ -446,7 +446,7 @@ class CI_Profiler {
$output .= "\n\n<table style='width:100%'>\n";
- foreach($this->CI->config->config as $config=>$val)
+ foreach ($this->CI->config->config as $config=>$val)
{
if (is_array($val))
{
diff --git a/system/libraries/Session.php b/system/libraries/Session.php
index 53ff4f5d3..182294059 100755
--- 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);
}
@@ -666,7 +667,7 @@ class CI_Session {
$expire,
$this->cookie_path,
$this->cookie_domain,
- 0
+ $this->cookie_secure
);
}
diff --git a/system/libraries/Sha1.php b/system/libraries/Sha1.php
index ad747a001..1a657572b 100755
--- a/system/libraries/Sha1.php
+++ b/system/libraries/Sha1.php
@@ -42,7 +42,7 @@
* @author ExpressionEngine Dev Team
* @link http://codeigniter.com/user_guide/general/encryption.html
*/
-class CI_SHA {
+class CI_SHA1 {
public function __construct()
{
@@ -88,7 +88,7 @@ class CI_SHA {
$oldd = $d;
$olde = $e;
- for($j = 0; $j < 80; $j++)
+ for ($j = 0; $j < 80; $j++)
{
if ($j < 16)
{
diff --git a/system/libraries/Table.php b/system/libraries/Table.php
index 485541630..def696776 100755
--- a/system/libraries/Table.php
+++ b/system/libraries/Table.php
@@ -108,7 +108,7 @@ class CI_Table {
}
$new = array();
- while(count($array) > 0)
+ while (count($array) > 0)
{
$temp = array_splice($array, 0, $col_limit);
@@ -280,7 +280,7 @@ class CI_Table {
$out .= $this->template['heading_row_start'];
$out .= $this->newline;
- foreach($this->heading as $heading)
+ foreach ($this->heading as $heading)
{
$temp = $this->template['heading_cell_start'];
@@ -310,7 +310,7 @@ class CI_Table {
$out .= $this->newline;
$i = 1;
- foreach($this->rows as $row)
+ foreach ($this->rows as $row)
{
if ( ! is_array($row))
{
@@ -323,7 +323,7 @@ class CI_Table {
$out .= $this->template['row_'.$name.'start'];
$out .= $this->newline;
- foreach($row as $cell)
+ foreach ($row as $cell)
{
$temp = $this->template['cell_'.$name.'start'];
@@ -367,6 +367,9 @@ class CI_Table {
$out .= $this->template['table_close'];
+ // Clear table class properties before generating the table
+ $this->clear();
+
return $out;
}
diff --git a/system/libraries/Trackback.php b/system/libraries/Trackback.php
index e29b35c7a..b0a767822 100755
--- a/system/libraries/Trackback.php
+++ b/system/libraries/Trackback.php
@@ -94,7 +94,7 @@ class CI_Trackback {
{
$$item = $this->convert_ascii($$item);
}
- elseif($item == 'blog_name')
+ elseif ($item == 'blog_name')
{
$$item = $this->convert_ascii($$item);
}
@@ -261,7 +261,7 @@ class CI_Trackback {
// Was it successful?
$this->response = "";
- while( ! feof($fp))
+ while ( ! feof($fp))
{
$this->response .= fgets($fp, 128);
}
diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php
index 8f84ffd7e..e80049fa4 100755
--- a/system/libraries/Upload.php
+++ b/system/libraries/Upload.php
@@ -142,7 +142,8 @@ class CI_Upload {
*/
public function do_upload($field = 'userfile')
{
- // Is $_FILES[$field] set? If not, no reason to continue.
+
+ // Is $_FILES[$field] set? If not, no reason to continue.
if ( ! isset($_FILES[$field]))
{
$this->set_error('upload_no_file_selected');
@@ -214,7 +215,7 @@ class CI_Upload {
$this->file_name = $this->_prep_filename($this->_file_name_override);
// If no extension was provided in the file_name config item, use the uploaded one
- if(strpos($this->_file_name_override, '.') === FALSE)
+ if (strpos($this->_file_name_override, '.') === FALSE)
{
$this->file_name .= $this->file_ext;
}
@@ -874,12 +875,6 @@ class CI_Upload {
}
$CI =& get_instance();
-
- if ( ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
return $CI->security->xss_clean($data, TRUE);
}
@@ -950,11 +945,21 @@ class CI_Upload {
if (count($this->mimes) == 0)
{
- if (@require_once(APPPATH.'config/mimes'.EXT))
+ if (defined('ENVIRONMENT') AND 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 c62174836..04cda7312 100755
--- 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 (defined('ENVIRONMENT') AND 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;
}
@@ -375,7 +383,11 @@ class CI_User_agent {
*/
public function is_referral()
{
- return ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '');
+ if ( ! isset($_SERVER['HTTP_REFERER']) OR $_SERVER['HTTP_REFERER'] == '')
+ {
+ return FALSE;
+ }
+ return TRUE;
}
// --------------------------------------------------------------------
diff --git a/system/libraries/Xmlrpc.php b/system/libraries/Xmlrpc.php
index 9cf307cc0..5da6ea6ae 100755
--- a/system/libraries/Xmlrpc.php
+++ b/system/libraries/Xmlrpc.php
@@ -207,7 +207,7 @@ class CI_Xmlrpc {
$this->data = array();
- foreach($incoming as $key => $value)
+ foreach ($incoming as $key => $value)
{
$this->data[$key] = $this->values_parsing($value);
}
@@ -232,7 +232,7 @@ class CI_Xmlrpc {
{
if (is_array($value) && array_key_exists(0, $value))
{
- if ( ! isset($value['1']) OR (! isset($this->xmlrpcTypes[$value['1']])))
+ if ( ! isset($value['1']) OR ( ! isset($this->xmlrpcTypes[$value['1']])))
{
if (is_array($value[0]))
{
@@ -243,7 +243,7 @@ class CI_Xmlrpc {
$temp = new XML_RPC_Values($value['0'], 'string');
}
}
- elseif(is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
+ elseif (is_array($value['0']) && ($value['1'] == 'struct' OR $value['1'] == 'array'))
{
while (list($k) = each($value['0']))
{
@@ -281,7 +281,7 @@ class CI_Xmlrpc {
$this->error = $this->result->errstr;
return FALSE;
}
- elseif( ! is_object($this->result->val))
+ elseif ( ! is_object($this->result->val))
{
$this->error = $this->result->errstr;
return FALSE;
@@ -358,7 +358,7 @@ class XML_RPC_Client extends CI_Xmlrpc
var $errno = '';
var $errstring = '';
var $timeout = 5;
- var $no_multicall = false;
+ var $no_multicall = FALSE;
public function __construct($path, $server, $port=80)
{
@@ -392,7 +392,7 @@ class XML_RPC_Client extends CI_Xmlrpc
return $r;
}
- if(empty($msg->payload))
+ if (empty($msg->payload))
{
// $msg = XML_RPC_Messages
$msg->createPayload();
@@ -504,12 +504,7 @@ class XML_RPC_Response
function decode($array=FALSE)
{
$CI =& get_instance();
-
- if ($this->xss_clean && ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
+
if ($array !== FALSE && is_array($array))
{
while (list($key) = each($array))
@@ -553,11 +548,11 @@ class XML_RPC_Response
{
$kind = $xmlrpc_val->kindOf();
- if($kind == 'scalar')
+ if ($kind == 'scalar')
{
return $xmlrpc_val->scalarval();
}
- elseif($kind == 'array')
+ elseif ($kind == 'array')
{
reset($xmlrpc_val->me);
list($a,$b) = each($xmlrpc_val->me);
@@ -565,18 +560,18 @@ class XML_RPC_Response
$arr = array();
- for($i = 0; $i < $size; $i++)
+ for ($i = 0; $i < $size; $i++)
{
$arr[] = $this->xmlrpc_decoder($xmlrpc_val->me['array'][$i]);
}
return $arr;
}
- elseif($kind == 'struct')
+ elseif ($kind == 'struct')
{
reset($xmlrpc_val->me['struct']);
$arr = array();
- while(list($key,$value) = each($xmlrpc_val->me['struct']))
+ while (list($key,$value) = each($xmlrpc_val->me['struct']))
{
$arr[$key] = $this->xmlrpc_decoder($value);
}
@@ -595,10 +590,8 @@ class XML_RPC_Response
$t = 0;
if (preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})/', $time, $regs))
{
- if ($utc == 1)
- $t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
- else
- $t = mktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
+ $fnc = ($utc == 1) ? 'gmmktime' : 'mktime';
+ $t = $fnc($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
}
return $t;
}
@@ -628,7 +621,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->method_name = $method;
if (is_array($pars) && count($pars) > 0)
{
- for($i=0; $i<count($pars); $i++)
+ for ($i=0; $i<count($pars); $i++)
{
// $pars[$i] = XML_RPC_Values
$this->params[] = $pars[$i];
@@ -646,7 +639,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->payload .= '<methodName>' . $this->method_name . "</methodName>\r\n";
$this->payload .= "<params>\r\n";
- for($i=0; $i<count($this->params); $i++)
+ for ($i=0; $i<count($this->params); $i++)
{
// $p = XML_RPC_Values
$p = $this->params[$i];
@@ -664,7 +657,7 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$data = '';
- while($datum = fread($fp, 4096))
+ while ($datum = fread($fp, 4096))
{
$data .= $datum;
}
@@ -684,7 +677,7 @@ class XML_RPC_Message extends CI_Xmlrpc
// Check for data
//-------------------------------------
- if($data == "")
+ if ($data == "")
{
error_log($this->xmlrpcstr['no_data']);
$r = new XML_RPC_Response(0, $this->xmlrpcerr['no_data'], $this->xmlrpcstr['no_data']);
@@ -896,7 +889,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['isf'] = 1;
break;
case 'PARAM':
- $this->xh[$the_parser]['value'] = null;
+ $this->xh[$the_parser]['value'] = NULL;
break;
case 'VALUE':
$this->xh[$the_parser]['vt'] = 'value';
@@ -925,7 +918,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['valuestack'][0]['name'] = '';
// Set NULL value to check to see if value passed for this param/member
- $this->xh[$the_parser]['value'] = null;
+ $this->xh[$the_parser]['value'] = NULL;
break;
case 'DATA':
case 'METHODCALL':
@@ -1108,7 +1101,7 @@ class XML_RPC_Message extends CI_Xmlrpc
$this->xh[$the_parser]['lv'] = 2; // Found a value
}
- if( ! @isset($this->xh[$the_parser]['ac']))
+ if ( ! @isset($this->xh[$the_parser]['ac']))
{
$this->xh[$the_parser]['ac'] = '';
}
@@ -1123,12 +1116,7 @@ class XML_RPC_Message extends CI_Xmlrpc
function output_parameters($array=FALSE)
{
$CI =& get_instance();
-
- if ($this->xss_clean && ! isset($CI->security))
- {
- $CI->load->library('security');
- }
-
+
if ($array !== FALSE && is_array($array))
{
while (list($key) = each($array))
@@ -1174,11 +1162,11 @@ class XML_RPC_Message extends CI_Xmlrpc
{
$kind = $param->kindOf();
- if($kind == 'scalar')
+ if ($kind == 'scalar')
{
return $param->scalarval();
}
- elseif($kind == 'array')
+ elseif ($kind == 'array')
{
reset($param->me);
list($a,$b) = each($param->me);
@@ -1192,13 +1180,13 @@ class XML_RPC_Message extends CI_Xmlrpc
return $arr;
}
- elseif($kind == 'struct')
+ elseif ($kind == 'struct')
{
reset($param->me['struct']);
$arr = array();
- while(list($key,$value) = each($param->me['struct']))
+ while (list($key,$value) = each($param->me['struct']))
{
$arr[$key] = $this->decode_message($value);
}
@@ -1343,7 +1331,7 @@ class XML_RPC_Values extends CI_Xmlrpc
// struct
$rs .= "<struct>\n";
reset($val);
- while(list($key2, $val2) = each($val))
+ while (list($key2, $val2) = each($val))
{
$rs .= "<member>\n<name>{$key2}</name>\n";
$rs .= $this->serializeval($val2);
diff --git a/system/libraries/Xmlrpcs.php b/system/libraries/Xmlrpcs.php
index 6bedfe324..9cd332147 100755
--- a/system/libraries/Xmlrpcs.php
+++ b/system/libraries/Xmlrpcs.php
@@ -59,10 +59,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
log_message('debug', "XML-RPC Server Class Initialized");
}
- //-------------------------------------
- // Initialize Prefs and Serve
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Initialize Prefs and Serve
+ *
+ * @access public
+ * @param mixed
+ * @return void
+ */
function initialize($config=array())
{
if (isset($config['functions']) && is_array($config['functions']))
@@ -86,11 +91,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
}
}
- //-------------------------------------
- // Setting of System Methods
- //-------------------------------------
+ // --------------------------------------------------------------------
- function set_system_methods ()
+ /**
+ * Setting of System Methods
+ *
+ * @access public
+ * @return void
+ */
+ function set_system_methods()
{
$this->methods = array(
'system.listMethods' => array(
@@ -112,11 +121,14 @@ class CI_Xmlrpcs extends CI_Xmlrpc
);
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Main Server Function
- //-------------------------------------
-
+ /**
+ * Main Server Function
+ *
+ * @access public
+ * @return void
+ */
function serve()
{
$r = $this->parseRequest();
@@ -129,11 +141,19 @@ class CI_Xmlrpcs extends CI_Xmlrpc
exit($payload);
}
- //-------------------------------------
- // Add Method to Class
- //-------------------------------------
+ // --------------------------------------------------------------------
- function add_to_map($methodname,$function,$sig,$doc)
+ /**
+ * Add Method to Class
+ *
+ * @access public
+ * @param string method name
+ * @param string function
+ * @param string signature
+ * @param string docstring
+ * @return void
+ */
+ function add_to_map($methodname, $function, $sig, $doc)
{
$this->methods[$methodname] = array(
'function' => $function,
@@ -142,11 +162,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
);
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Parse Server Request
- //-------------------------------------
-
+ /**
+ * Parse Server Request
+ *
+ * @access public
+ * @param string data
+ * @return object xmlrpc response
+ */
function parseRequest($data='')
{
global $HTTP_RAW_POST_DATA;
@@ -196,7 +220,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
xml_get_current_line_number($parser)));
xml_parser_free($parser);
}
- elseif($parser_object->xh[$parser]['isf'])
+ elseif ($parser_object->xh[$parser]['isf'])
{
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
}
@@ -207,7 +231,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$m = new XML_RPC_Message($parser_object->xh[$parser]['method']);
$plist='';
- for($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
+ for ($i=0; $i < count($parser_object->xh[$parser]['params']); $i++)
{
if ($this->debug === TRUE)
{
@@ -239,10 +263,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $r;
}
- //-------------------------------------
- // Executes the Method
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Executes the Method
+ *
+ * @access protected
+ * @param object
+ * @return mixed
+ */
function _execute($m)
{
$methName = $m->method_name;
@@ -297,13 +326,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc
if (isset($this->methods[$methName]['signature']))
{
$sig = $this->methods[$methName]['signature'];
- for($i=0; $i<count($sig); $i++)
+ for ($i=0; $i<count($sig); $i++)
{
$current_sig = $sig[$i];
if (count($current_sig) == count($m->params)+1)
{
- for($n=0; $n < count($m->params); $n++)
+ for ($n=0; $n < count($m->params); $n++)
{
$p = $m->params[$n];
$pt = ($p->kindOf() == 'scalar') ? $p->scalarval() : $p->kindOf();
@@ -352,23 +381,27 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return call_user_func($this->methods[$methName]['function'], $m);
}
}
+
+ // --------------------------------------------------------------------
-
- //-------------------------------------
- // Server Function: List Methods
- //-------------------------------------
-
+ /**
+ * Server Function: List Methods
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function listMethods($m)
{
$v = new XML_RPC_Values();
$output = array();
- foreach($this->methods as $key => $value)
+ foreach ($this->methods as $key => $value)
{
$output[] = new XML_RPC_Values($key, 'string');
}
- foreach($this->system_methods as $key => $value)
+ foreach ($this->system_methods as $key => $value)
{
$output[]= new XML_RPC_Values($key, 'string');
}
@@ -376,11 +409,16 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$v->addArray($output);
return new XML_RPC_Response($v);
}
+
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Server Function: Return Signature for Method
- //-------------------------------------
-
+ /**
+ * Server Function: Return Signature for Method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function methodSignature($m)
{
$parameters = $m->output_parameters();
@@ -393,11 +431,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$sigs = array();
$signature = $this->methods[$method_name]['signature'];
- for($i=0; $i < count($signature); $i++)
+ for ($i=0; $i < count($signature); $i++)
{
$cursig = array();
$inSig = $signature[$i];
- for($j=0; $j<count($inSig); $j++)
+ for ($j=0; $j<count($inSig); $j++)
{
$cursig[]= new XML_RPC_Values($inSig[$j], 'string');
}
@@ -417,10 +455,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return $r;
}
- //-------------------------------------
- // Server Function: Doc String for Method
- //-------------------------------------
+ // --------------------------------------------------------------------
+ /**
+ * Server Function: Doc String for Method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function methodHelp($m)
{
$parameters = $m->output_parameters();
@@ -437,11 +480,16 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
}
}
+
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Server Function: Multi-call
- //-------------------------------------
-
+ /**
+ * Server Function: Multi-call
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function multicall($m)
{
// Disabled
@@ -459,7 +507,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc
$m = new XML_RPC_Message($value[0]);
$plist='';
- for($i=0; $i < count($value[1]); $i++)
+ for ($i=0; $i < count($value[1]); $i++)
{
$m->addParam(new XML_RPC_Values($value[1][$i], 'string'));
}
@@ -477,11 +525,15 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Response(new XML_RPC_Values($result, 'array'));
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Multi-call Function: Error Handling
- //-------------------------------------
-
+ /**
+ * Multi-call Function: Error Handling
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function multicall_error($err)
{
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
@@ -493,29 +545,45 @@ class CI_Xmlrpcs extends CI_Xmlrpc
return new XML_RPC_Values($struct, 'struct');
}
+ // --------------------------------------------------------------------
- //-------------------------------------
- // Multi-call Function: Processes method
- //-------------------------------------
-
+ /**
+ * Multi-call Function: Processes method
+ *
+ * @access public
+ * @param mixed
+ * @return object
+ */
function do_multicall($call)
{
if ($call->kindOf() != 'struct')
+ {
return $this->multicall_error('notstruct');
+ }
elseif ( ! $methName = $call->me['struct']['methodName'])
+ {
return $this->multicall_error('nomethod');
+ }
list($scalar_type,$scalar_value)=each($methName->me);
$scalar_type = $scalar_type == $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
if ($methName->kindOf() != 'scalar' OR $scalar_type != 'string')
+ {
return $this->multicall_error('notstring');
+ }
elseif ($scalar_value == 'system.multicall')
+ {
return $this->multicall_error('recursion');
+ }
elseif ( ! $params = $call->me['struct']['params'])
+ {
return $this->multicall_error('noparams');
+ }
elseif ($params->kindOf() != 'array')
+ {
return $this->multicall_error('notarray');
+ }
list($a,$b)=each($params->me);
$numParams = count($b);
diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php
index 80633c708..666327d5c 100755
--- a/system/libraries/Zip.php
+++ b/system/libraries/Zip.php
@@ -289,7 +289,7 @@ class CI_Zip {
while (FALSE !== ($file = readdir($fp)))
{
- if(substr($file, 0, 1) == '.')
+ if (substr($file, 0, 1) == '.')
{
continue;
}