Skip to content

Commit

Permalink
Merge commit 'CI_2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
cpf-ch committed May 20, 2011
2 parents 8cd24b9 + ef565b4 commit 19418c8
Show file tree
Hide file tree
Showing 171 changed files with 1,125 additions and 686 deletions.
32 changes: 0 additions & 32 deletions CodeIgniter/application/migrations/001_Create_accounts.php

This file was deleted.

20 changes: 17 additions & 3 deletions CodeIgniter/system/core/CodeIgniter.php
Expand Up @@ -32,7 +32,7 @@
* Define the CodeIgniter Version
* ------------------------------------------------------
*/
define('CI_VERSION', '2.0.1');
define('CI_VERSION', '2.0.2');

/*
* ------------------------------------------------------
Expand All @@ -53,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);
}

/*
* ------------------------------------------------------
Expand Down Expand Up @@ -189,6 +196,13 @@
}
}

/*
* -----------------------------------------------------
* Load the security class for xss and csrf support
* -----------------------------------------------------
*/
$SEC =& load_class('Security', 'core');

/*
* ------------------------------------------------------
* Load the Input class and sanitize globals
Expand Down Expand Up @@ -365,4 +379,4 @@ function &get_instance()


/* End of file CodeIgniter.php */
/* Location: ./system/core/CodeIgniter.php */
/* Location: ./system/core/CodeIgniter.php */
45 changes: 21 additions & 24 deletions CodeIgniter/system/core/Common.php
Expand Up @@ -88,7 +88,7 @@ function is_really_writable($file)
@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;
}
Expand Down Expand Up @@ -208,19 +208,18 @@ function &get_config($replace = array())
return $_config[0];
}

$file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT;
// Is the config file in the environment folder?
if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/config'.EXT))
{
$file_path = APPPATH.'config/config'.EXT;
}

// Fetch the config file
if ( ! file_exists($file_path))
{
$file_path = APPPATH.'config/config'.EXT;

if ( ! file_exists($file_path))
{
exit('The configuration file does not exist.');
}
exit('The configuration file does not exist.');
}

require($file_path);

// Does the $config array exist in the file?
Expand Down Expand Up @@ -477,28 +476,26 @@ function _exception_handler($severity, $message, $filepath, $line)
* @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;
}
Expand Down
42 changes: 25 additions & 17 deletions CodeIgniter/system/core/Config.php
Expand Up @@ -81,29 +81,37 @@ function __construct()
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)
{
$file_path = $path.'config/'.ENVIRONMENT.'/'.$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 ( ! file_exists($file_path))
{
log_message('debug', 'Config for '.ENVIRONMENT.' environment is not found. Trying global config.');
$file_path = $path.'config/'.$file.EXT;

if ( ! file_exists($file_path))
if (in_array($file_path, $this->is_loaded, TRUE))
{
$loaded = TRUE;
continue 2;
}

if (file_exists($file_path))
{
continue;
$found = TRUE;
break;
}
}


if ($found === FALSE)
{
continue;
}

include($file_path);

if ( ! isset($config) OR ! is_array($config))
Expand Down Expand Up @@ -144,9 +152,9 @@ function load($file = '', $use_sections = FALSE, $fail_gracefully = FALSE)
{
return FALSE;
}
show_error('The configuration file '.ENVIRONMENT.'/'.$file.EXT.' and '.$file.EXT.' do not exist.');
show_error('The configuration file '.$file.EXT.' does not exist.');
}

return TRUE;
}

Expand Down Expand Up @@ -318,4 +326,4 @@ function _assign_to_config($items = array())
// END CI_Config class

/* End of file Config.php */
/* Location: ./system/core/Config.php */
/* Location: ./system/core/Config.php */
10 changes: 9 additions & 1 deletion CodeIgniter/system/core/Hooks.php
Expand Up @@ -65,7 +65,15 @@ function _initialize()
// 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))
{
Expand Down
18 changes: 8 additions & 10 deletions CodeIgniter/system/core/Input.php
Expand Up @@ -53,11 +53,8 @@ public function __construct()
$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)
Expand Down Expand Up @@ -92,8 +89,7 @@ function _fetch_from_array(&$array, $index = '', $xss_clean = FALSE)

if ($xss_clean === TRUE)
{
$_security =& load_class('Security');
return $_security->xss_clean($array[$index]);
return $this->security->xss_clean($array[$index]);
}

return $array[$index];
Expand Down Expand Up @@ -527,6 +523,9 @@ function _clean_input_data($str)
{
$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)
Expand All @@ -539,7 +538,7 @@ function _clean_input_data($str)
{
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);
}
}

Expand Down Expand Up @@ -642,8 +641,7 @@ public function get_request_header($index, $xss_clean = FALSE)

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];
Expand Down
7 changes: 7 additions & 0 deletions CodeIgniter/system/core/Lang.php
Expand Up @@ -130,6 +130,13 @@ function load($langfile = '', $idiom = '', $return = FALSE, $add_suffix = TRUE,
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;
}

Expand Down
32 changes: 15 additions & 17 deletions CodeIgniter/system/core/Loader.php
Expand Up @@ -79,9 +79,9 @@ function library($library = '', $params = NULL, $object_name = NULL)
{
if (is_array($library))
{
foreach ($library as $read)
foreach ($library as $class)
{
$this->library($read);
$this->library($class, $params);
}

return;
Expand All @@ -97,17 +97,7 @@ function library($library = '', $params = NULL, $object_name = NULL)
$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);
}

// --------------------------------------------------------------------
Expand Down Expand Up @@ -882,12 +872,12 @@ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NU
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names. Check for environment
// first, global next
if (file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
if (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT))
{
include_once($path .'config/'.ENVIRONMENT.'/'.strtolower($class).EXT);
break;
}
elseif (file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
elseif (defined('ENVIRONMENT') AND file_exists($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT))
{
include_once($path .'config/'.ENVIRONMENT.'/'.ucfirst(strtolower($class)).EXT);
break;
Expand Down Expand Up @@ -975,7 +965,15 @@ function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NU
*/
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))
{
Expand Down Expand Up @@ -1103,4 +1101,4 @@ function _ci_prep_filename($filename, $extension)
}

/* End of file Loader.php */
/* Location: ./system/core/Loader.php */
/* Location: ./system/core/Loader.php */

0 comments on commit 19418c8

Please sign in to comment.