Skip to content
This repository has been archived by the owner on Nov 27, 2017. It is now read-only.

Commit

Permalink
upgrading to CI 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
emad-elsaid committed Apr 8, 2011
1 parent 79fc563 commit 921b0e0
Show file tree
Hide file tree
Showing 66 changed files with 1,158 additions and 691 deletions.
5 changes: 3 additions & 2 deletions application/config/mimes.php
Expand Up @@ -56,7 +56,7 @@
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3'),
'mp3' => array('audio/mpeg', 'audio/mpg', 'audio/mpeg3', 'audio/mp3'),
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
Expand Down Expand Up @@ -97,7 +97,8 @@
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822'
'eml' => 'message/rfc822',
'json' => array('application/json', 'text/json')
);


Expand Down
2 changes: 1 addition & 1 deletion application/libraries/datamapper.php
Expand Up @@ -6328,7 +6328,7 @@ protected function _load_helpers()
$this->load->helper('inflector');

// Load security helper for prepping functions
$this->load->helper('security');
//$this->load->helper('security');
}
}

Expand Down
2 changes: 1 addition & 1 deletion config.php
Expand Up @@ -4,5 +4,5 @@
$db_hostname = "localhost";
$db_database = "egypt";
$db_username = "root";
$db_password = "";
$db_password = "1234";
$db_dbdriver = "mysql";
58 changes: 48 additions & 10 deletions index.php
Expand Up @@ -2,15 +2,49 @@

/*
*---------------------------------------------------------------
* PHP ERROR REPORTING LEVEL
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*
* By default CI runs with error reporting set to ALL. For security
* reasons you are encouraged to change this to 0 when your site goes live.
* For more info visit: http://www.php.net/error_reporting
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
error_reporting(E_ALL);
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/

if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;

case 'testing':
case 'production':
error_reporting(0);
break;

default:
exit('The application environment is not set correctly.');
}
}

/*
*---------------------------------------------------------------
Expand All @@ -22,7 +56,7 @@
* as this file.
*
*/
$system_path = "system";
$system_path = 'system';

/*
*---------------------------------------------------------------
Expand All @@ -38,7 +72,7 @@
* NO TRAILING SLASH!
*
*/
$application_folder = "application";
$application_folder = 'application';

/*
* --------------------------------------------------------------------
Expand Down Expand Up @@ -94,14 +128,18 @@
// END OF USER CONFIGURABLE SETTINGS. DO NOT EDIT BELOW THIS LINE
// --------------------------------------------------------------------




/*
* ---------------------------------------------------------------
* Resolve the system path for increased reliability
* ---------------------------------------------------------------
*/

// Set the current directory correctly for CLI requests
if (defined('STDIN'))
{
chdir(dirname(__FILE__));
}

if (realpath($system_path) !== FALSE)
{
$system_path = realpath($system_path).'/';
Expand Down
50 changes: 46 additions & 4 deletions system/core/CodeIgniter.php
Expand Up @@ -32,7 +32,14 @@
* Define the CodeIgniter Version
* ------------------------------------------------------
*/
define('CI_VERSION', '2.0');
define('CI_VERSION', '2.0.1');

/*
* ------------------------------------------------------
* Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
* ------------------------------------------------------
*/
define('CI_CORE', FALSE);

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

/*
* ------------------------------------------------------
Expand Down Expand Up @@ -80,7 +94,7 @@
{
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
}

/*
* ------------------------------------------------------
* Set a liberal script execution time limit
Expand Down Expand Up @@ -182,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 @@ -289,7 +310,28 @@ function &get_instance()
// 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.
Expand Down
44 changes: 23 additions & 21 deletions 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,16 +208,20 @@ function &get_config($replace = array())
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))
{
Expand Down Expand Up @@ -472,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
30 changes: 23 additions & 7 deletions system/core/Config.php
Expand Up @@ -51,7 +51,7 @@ function __construct()
// 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'];
Expand All @@ -74,24 +74,40 @@ function __construct()
*
* @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;
}
Expand Down
10 changes: 9 additions & 1 deletion 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

0 comments on commit 921b0e0

Please sign in to comment.