From b97d21f92c3f38aaab36d2c1f885918375417845 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 2 Mar 2010 12:53:43 -0600 Subject: moving core library files out of libraries into new core folder --- system/core/CodeIgniter.php | 280 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 280 insertions(+) create mode 100644 system/core/CodeIgniter.php (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php new file mode 100644 index 000000000..5d5bb144b --- /dev/null +++ b/system/core/CodeIgniter.php @@ -0,0 +1,280 @@ +mark('total_execution_time_start'); +$BM->mark('loading_time_base_classes_start'); + +/* + * ------------------------------------------------------ + * Instantiate the hooks class + * ------------------------------------------------------ + */ + +$EXT =& load_class('Hooks'); + +/* + * ------------------------------------------------------ + * Is there a "pre_system" hook? + * ------------------------------------------------------ + */ +$EXT->_call_hook('pre_system'); + +/* + * ------------------------------------------------------ + * Instantiate the base classes + * ------------------------------------------------------ + */ + +$CFG =& load_class('Config'); +$URI =& load_class('URI'); +$RTR =& load_class('Router'); +$OUT =& load_class('Output'); + +/* + * ------------------------------------------------------ + * Is there a valid cache file? If so, we're done... + * ------------------------------------------------------ + */ + +if ($EXT->_call_hook('cache_override') === FALSE) +{ + if ($OUT->_display_cache($CFG, $URI) == TRUE) + { + exit; + } +} + +/* + * ------------------------------------------------------ + * Load the remaining base classes + * ------------------------------------------------------ + */ + +$IN =& load_class('Input'); +$LANG =& load_class('Language'); + +/* + * ------------------------------------------------------ + * Load the app controller and local controller + * ------------------------------------------------------ + * + * Note: Due to the poor object handling in PHP 4 we'll + * conditionally load different versions of the base + * class. Retaining PHP 4 compatibility requires a bit of a hack. + * + * Note: The Loader class needs to be included first + * + */ +if ( ! is_php('5.0.0')) +{ + load_class('Loader', FALSE); + require(BASEPATH.'codeigniter/Base4'.EXT); +} +else +{ + require(BASEPATH.'codeigniter/Base5'.EXT); +} + +// Load the base controller class +load_class('Controller', FALSE); + +// Load the local application controller +// Note: The Router class automatically validates the controller path. If this include fails it +// means that the default controller in the Routes.php file is not resolving to something valid. +if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) +{ + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); +} + +include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); + +// Set a mark point for benchmarking +$BM->mark('loading_time_base_classes_end'); + + +/* + * ------------------------------------------------------ + * Security check + * ------------------------------------------------------ + * + * None of the functions in the app controller or the + * loader class can be called via the URI, nor can + * controller functions that begin with an underscore + */ +$class = $RTR->fetch_class(); +$method = $RTR->fetch_method(); + +if ( ! class_exists($class) + OR $method == 'controller' + OR strncmp($method, '_', 1) == 0 + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) + ) +{ + show_404("{$class}/{$method}"); +} + +/* + * ------------------------------------------------------ + * Is there a "pre_controller" hook? + * ------------------------------------------------------ + */ +$EXT->_call_hook('pre_controller'); + +/* + * ------------------------------------------------------ + * Instantiate the controller and call requested method + * ------------------------------------------------------ + */ + +// Mark a start point so we can benchmark the controller +$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); + +$CI = new $class(); + +// Is this a scaffolding request? +if ($RTR->scaffolding_request === TRUE) +{ + if ($EXT->_call_hook('scaffolding_override') === FALSE) + { + $CI->_ci_scaffolding(); + } +} +else +{ + /* + * ------------------------------------------------------ + * Is there a "post_controller_constructor" hook? + * ------------------------------------------------------ + */ + $EXT->_call_hook('post_controller_constructor'); + + // Is there a "remap" function? + if (method_exists($CI, '_remap')) + { + $CI->_remap($method); + } + else + { + // is_callable() returns TRUE on some versions of PHP 5 for private and protected + // 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}"); + } + + // Call the requested method. + // Any URI segments present (besides the class/function) will be passed to the method for convenience + call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); + } +} + +// Mark a benchmark end point +$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); + +/* + * ------------------------------------------------------ + * Is there a "post_controller" hook? + * ------------------------------------------------------ + */ +$EXT->_call_hook('post_controller'); + +/* + * ------------------------------------------------------ + * Send the final rendered output to the browser + * ------------------------------------------------------ + */ + +if ($EXT->_call_hook('display_override') === FALSE) +{ + $OUT->_display(); +} + +/* + * ------------------------------------------------------ + * Is there a "post_system" hook? + * ------------------------------------------------------ + */ +$EXT->_call_hook('post_system'); + +/* + * ------------------------------------------------------ + * Close the DB connection if one exists + * ------------------------------------------------------ + */ +if (class_exists('CI_DB') AND isset($CI->db)) +{ + $CI->db->close(); +} + + +/* End of file CodeIgniter.php */ +/* Location: ./system/codeigniter/CodeIgniter.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From c68dfbf9df1bd76f608307185ec16f5be4b550f1 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 2 Mar 2010 12:59:23 -0600 Subject: fixed EOF code comment file locations --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 5d5bb144b..65c75a6c4 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -277,4 +277,4 @@ if (class_exists('CI_DB') AND isset($CI->db)) /* End of file CodeIgniter.php */ -/* Location: ./system/codeigniter/CodeIgniter.php */ \ No newline at end of file +/* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 218876c55d9d3f56c20675c4444f19433880878f Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 2 Mar 2010 13:11:00 -0600 Subject: updating CodeIgniter.php init file --- system/core/CodeIgniter.php | 292 +++++++++++++++++++++++++++----------------- 1 file changed, 180 insertions(+), 112 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 65c75a6c4..90cce1c6e 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -16,7 +16,7 @@ // ------------------------------------------------------------------------ /** - * System Front Controller + * System Initialization File * * Loads the base classes and executes the request. * @@ -27,100 +27,177 @@ * @link http://codeigniter.com/user_guide/ */ -// CI Version -define('CI_VERSION', '1.7.2'); +/* + * ------------------------------------------------------ + * Define the CodeIgniter Version + * ------------------------------------------------------ + */ + define('CI_VERSION', '2.0'); /* * ------------------------------------------------------ * Load the global functions * ------------------------------------------------------ */ -require(BASEPATH.'codeigniter/Common'.EXT); + require(BASEPATH.'core/Common'.EXT); /* * ------------------------------------------------------ * Load the compatibility override functions * ------------------------------------------------------ */ -require(BASEPATH.'codeigniter/Compat'.EXT); + require(BASEPATH.'core/Compat'.EXT); /* * ------------------------------------------------------ * Load the framework constants * ------------------------------------------------------ */ -require(APPPATH.'config/constants'.EXT); + require(APPPATH.'config/constants'.EXT); /* * ------------------------------------------------------ * Define a custom error handler so we can log PHP errors * ------------------------------------------------------ */ -set_error_handler('_exception_handler'); + set_error_handler('_exception_handler'); + + if ( ! is_php('5.3')) + { + @set_magic_quotes_runtime(0); // Kill magic quotes + } -if ( ! is_php('5.3')) -{ - @set_magic_quotes_runtime(0); // Kill magic quotes -} + // Set a liberal script execution time limit + if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) + { + @set_time_limit(300); + } /* * ------------------------------------------------------ - * Start the timer... tick tock tick tock... + * Set the subclass_prefix * ------------------------------------------------------ + * + * Normally the "subclass_prefix" is set in the config file. + * The subclass prefix allows CI to know if a core class is + * being extended via a library in the local application + * "libraries" folder. Since CI allows config items to be + * overriden via data set in the main index. php file, + * before proceeding we need to know if a subclass_prefix + * override exists. If so, we will set this value now, + * before any classes are loaded + * Note: Since the config file data is cached it doesn't + * hurt to load it here. */ + if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '') + { + get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); + } -$BM =& load_class('Benchmark'); -$BM->mark('total_execution_time_start'); -$BM->mark('loading_time_base_classes_start'); +/* + * ------------------------------------------------------ + * Start the timer... tick tock tick tock... + * ------------------------------------------------------ + */ + $BM =& load_class('Benchmark', 'core'); + $BM->mark('total_execution_time_start'); + $BM->mark('loading_time:_base_classes_start'); /* * ------------------------------------------------------ * Instantiate the hooks class * ------------------------------------------------------ */ - -$EXT =& load_class('Hooks'); + $EXT =& load_class('Hooks', 'core'); /* * ------------------------------------------------------ * Is there a "pre_system" hook? * ------------------------------------------------------ */ -$EXT->_call_hook('pre_system'); + $EXT->_call_hook('pre_system'); + +/* + * ------------------------------------------------------ + * Instantiate the config class + * ------------------------------------------------------ + */ + $CFG =& load_class('Config', 'core'); + + // Do we have any manually set config items in the index.php file? + if (isset($assign_to_config)) + { + $CFG->_assign_to_config($assign_to_config); + } + +/* + * ------------------------------------------------------ + * Instantiate the Unicode class + * ------------------------------------------------------ + * + * Note: Order here is rather important as the Unicode + * class needs to be used very early on, but it cannot + * properly determine if UTf-8 can be supported until + * after the Config class is instantiated. + * + */ + $UNI =& load_class('Unicode', 'core'); + /* * ------------------------------------------------------ - * Instantiate the base classes + * Instantiate the URI class * ------------------------------------------------------ */ + $URI =& load_class('URI', 'core'); -$CFG =& load_class('Config'); -$URI =& load_class('URI'); -$RTR =& load_class('Router'); -$OUT =& load_class('Output'); +/* + * ------------------------------------------------------ + * Instantiate the routing class and set the routing + * ------------------------------------------------------ + */ + $RTR =& load_class('Router', 'core'); + $RTR->_set_routing(); + + // Set any routing overrides that may exist in the main index file + if (isset($routing)) + { + $RTR->_set_overrides($routing); + } /* * ------------------------------------------------------ - * Is there a valid cache file? If so, we're done... + * Instantiate the output class * ------------------------------------------------------ */ + $OUT =& load_class('Output', 'core'); -if ($EXT->_call_hook('cache_override') === FALSE) -{ - if ($OUT->_display_cache($CFG, $URI) == TRUE) +/* + * ------------------------------------------------------ + * Is there a valid cache file? If so, we're done... + * ------------------------------------------------------ + */ + if ($EXT->_call_hook('cache_override') === FALSE) { - exit; + if ($OUT->_display_cache($CFG, $URI) == TRUE) + { + exit; + } } -} /* * ------------------------------------------------------ - * Load the remaining base classes + * Load the Input class and sanitize globals * ------------------------------------------------------ */ + $IN =& load_class('Input', 'core'); -$IN =& load_class('Input'); -$LANG =& load_class('Language'); +/* + * ------------------------------------------------------ + * Load the Language class + * ------------------------------------------------------ + */ + $LANG =& load_class('Lang', 'core'); /* * ------------------------------------------------------ @@ -131,35 +208,33 @@ $LANG =& load_class('Language'); * conditionally load different versions of the base * class. Retaining PHP 4 compatibility requires a bit of a hack. * - * Note: The Loader class needs to be included first - * */ -if ( ! is_php('5.0.0')) -{ - load_class('Loader', FALSE); - require(BASEPATH.'codeigniter/Base4'.EXT); -} -else -{ - require(BASEPATH.'codeigniter/Base5'.EXT); -} - -// Load the base controller class -load_class('Controller', FALSE); - -// Load the local application controller -// Note: The Router class automatically validates the controller path. If this include fails it -// means that the default controller in the Routes.php file is not resolving to something valid. -if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) -{ - show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); -} - -include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); - -// Set a mark point for benchmarking -$BM->mark('loading_time_base_classes_end'); - + if (is_php('5.0.0') == TRUE) + { + require(BASEPATH.'core/Base5'.EXT); + } + else + { + // The Loader class needs to be included first when running PHP 4.x + load_class('Loader', 'core'); + require(BASEPATH.'core/Base4'.EXT); + } + + // Load the base controller class + require BASEPATH.'core/Controller'.EXT; + + // Load the local application controller + // Note: The Router class automatically validates the controller path using the router->_validate_request(). + // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. + if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) + { + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); + } + + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); + + // Set a mark point for benchmarking + $BM->mark('loading_time:_base_classes_end'); /* * ------------------------------------------------------ @@ -170,54 +245,48 @@ $BM->mark('loading_time_base_classes_end'); * loader class can be called via the URI, nor can * controller functions that begin with an underscore */ -$class = $RTR->fetch_class(); -$method = $RTR->fetch_method(); - -if ( ! class_exists($class) - OR $method == 'controller' - OR strncmp($method, '_', 1) == 0 - OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) - ) -{ - show_404("{$class}/{$method}"); -} + $class = $RTR->fetch_class(); + $method = $RTR->fetch_method(); + + if ( ! class_exists($class) + OR $method == 'controller' + OR strncmp($method, '_', 1) == 0 + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) + ) + { + show_404("{$class}/{$method}"); + } /* * ------------------------------------------------------ * Is there a "pre_controller" hook? * ------------------------------------------------------ */ -$EXT->_call_hook('pre_controller'); + $EXT->_call_hook('pre_controller'); /* * ------------------------------------------------------ - * Instantiate the controller and call requested method + * Instantiate the requested controller * ------------------------------------------------------ */ + // Mark a start point so we can benchmark the controller + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); + + $CI = new $class(); -// Mark a start point so we can benchmark the controller -$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); - -$CI = new $class(); - -// Is this a scaffolding request? -if ($RTR->scaffolding_request === TRUE) -{ - if ($EXT->_call_hook('scaffolding_override') === FALSE) - { - $CI->_ci_scaffolding(); - } -} -else -{ - /* - * ------------------------------------------------------ - * Is there a "post_controller_constructor" hook? - * ------------------------------------------------------ - */ +/* + * ------------------------------------------------------ + * Is there a "post_controller_constructor" hook? + * ------------------------------------------------------ + */ $EXT->_call_hook('post_controller_constructor'); - - // Is there a "remap" function? + +/* + * ------------------------------------------------------ + * Call the requested method + * ------------------------------------------------------ + */ + // Is there a "remap" function? If so, we call it instead if (method_exists($CI, '_remap')) { $CI->_remap($method); @@ -232,48 +301,47 @@ else } // Call the requested method. - // Any URI segments present (besides the class/function) will be passed to the method for convenience - call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); + // Any URI segments present (besides the class/function) will be passed to the method for convenience + call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); } -} -// Mark a benchmark end point -$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); + + // Mark a benchmark end point + $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); /* * ------------------------------------------------------ * Is there a "post_controller" hook? * ------------------------------------------------------ */ -$EXT->_call_hook('post_controller'); + $EXT->_call_hook('post_controller'); /* * ------------------------------------------------------ * Send the final rendered output to the browser * ------------------------------------------------------ */ - -if ($EXT->_call_hook('display_override') === FALSE) -{ - $OUT->_display(); -} - + if ($EXT->_call_hook('display_override') === FALSE) + { + $OUT->_display(); + } + /* * ------------------------------------------------------ * Is there a "post_system" hook? * ------------------------------------------------------ */ -$EXT->_call_hook('post_system'); + $EXT->_call_hook('post_system'); /* * ------------------------------------------------------ * Close the DB connection if one exists * ------------------------------------------------------ */ -if (class_exists('CI_DB') AND isset($CI->db)) -{ - $CI->db->close(); -} + if (class_exists('CI_DB') AND isset($CI->db)) + { + $CI->db->close(); + } /* End of file CodeIgniter.php */ -- cgit v1.2.3-24-g4f1b From 1efda7bc21582c6d0b6409e1f9a37d58e2d79571 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 2 Mar 2010 13:30:20 -0600 Subject: @PHP4 tags to CodeIgniter.php --- system/core/CodeIgniter.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 90cce1c6e..488f9f3ce 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -207,7 +207,8 @@ * Note: Due to the poor object handling in PHP 4 we'll * conditionally load different versions of the base * class. Retaining PHP 4 compatibility requires a bit of a hack. - * + * @PHP4 + * */ if (is_php('5.0.0') == TRUE) { -- cgit v1.2.3-24-g4f1b From fa281354b37feead98ab71cc4e6d68f9748a7b6c Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Mon, 22 Mar 2010 14:41:27 -0500 Subject: Fix #10 , extending the CodeIgniter controller with MY_Controller will lead to a fatal PHP error. --- system/core/CodeIgniter.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 488f9f3ce..295917c92 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -224,6 +224,11 @@ // Load the base controller class require BASEPATH.'core/Controller'.EXT; + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT)) + { + require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT; + } + // Load the local application controller // Note: The Router class automatically validates the controller path using the router->_validate_request(). // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. -- cgit v1.2.3-24-g4f1b From dd6719738936be31cdaa1758ca86d5eb14dcab3d Mon Sep 17 00:00:00 2001 From: Barry Mieny Date: Mon, 4 Oct 2010 16:33:58 +0200 Subject: Cleanup of stray spaces and tabs --- system/core/CodeIgniter.php | 64 ++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 32 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 295917c92..f67bb8c10 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -61,10 +61,10 @@ * ------------------------------------------------------ */ set_error_handler('_exception_handler'); - + if ( ! is_php('5.3')) { - @set_magic_quotes_runtime(0); // Kill magic quotes + @set_magic_quotes_runtime(0); // Kill magic quotes } // Set a liberal script execution time limit @@ -78,18 +78,18 @@ * Set the subclass_prefix * ------------------------------------------------------ * - * Normally the "subclass_prefix" is set in the config file. - * The subclass prefix allows CI to know if a core class is + * Normally the "subclass_prefix" is set in the config file. + * The subclass prefix allows CI to know if a core class is * being extended via a library in the local application - * "libraries" folder. Since CI allows config items to be - * overriden via data set in the main index. php file, - * before proceeding we need to know if a subclass_prefix + * "libraries" folder. Since CI allows config items to be + * overriden via data set in the main index. php file, + * before proceeding we need to know if a subclass_prefix * override exists. If so, we will set this value now, * before any classes are loaded - * Note: Since the config file data is cached it doesn't + * Note: Since the config file data is cached it doesn't * hurt to load it here. */ - if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '') + if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '') { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } @@ -121,12 +121,12 @@ * ------------------------------------------------------ * Instantiate the config class * ------------------------------------------------------ - */ + */ $CFG =& load_class('Config', 'core'); // Do we have any manually set config items in the index.php file? if (isset($assign_to_config)) - { + { $CFG->_assign_to_config($assign_to_config); } @@ -134,16 +134,16 @@ * ------------------------------------------------------ * Instantiate the Unicode class * ------------------------------------------------------ - * + * * Note: Order here is rather important as the Unicode * class needs to be used very early on, but it cannot - * properly determine if UTf-8 can be supported until + * properly determine if UTf-8 can be supported until * after the Config class is instantiated. - * + * */ $UNI =& load_class('Unicode', 'core'); - + /* * ------------------------------------------------------ * Instantiate the URI class @@ -155,10 +155,10 @@ * ------------------------------------------------------ * Instantiate the routing class and set the routing * ------------------------------------------------------ - */ + */ $RTR =& load_class('Router', 'core'); $RTR->_set_routing(); - + // Set any routing overrides that may exist in the main index file if (isset($routing)) { @@ -190,7 +190,7 @@ * Load the Input class and sanitize globals * ------------------------------------------------------ */ - $IN =& load_class('Input', 'core'); + $IN =& load_class('Input', 'core'); /* * ------------------------------------------------------ @@ -208,9 +208,9 @@ * conditionally load different versions of the base * class. Retaining PHP 4 compatibility requires a bit of a hack. * @PHP4 - * + * */ - if (is_php('5.0.0') == TRUE) + if (is_php('5.0.0') == TRUE) { require(BASEPATH.'core/Base5'.EXT); } @@ -220,25 +220,25 @@ load_class('Loader', 'core'); require(BASEPATH.'core/Base4'.EXT); } - + // Load the base controller class require BASEPATH.'core/Controller'.EXT; - + if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT)) { require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT; } - + // Load the local application controller - // Note: The Router class automatically validates the controller path using the router->_validate_request(). + // Note: The Router class automatically validates the controller path using the router->_validate_request(). // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) { show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); } - + include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); - + // Set a mark point for benchmarking $BM->mark('loading_time:_base_classes_end'); @@ -253,7 +253,7 @@ */ $class = $RTR->fetch_class(); $method = $RTR->fetch_method(); - + if ( ! class_exists($class) OR $method == 'controller' OR strncmp($method, '_', 1) == 0 @@ -277,7 +277,7 @@ */ // Mark a start point so we can benchmark the controller $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start'); - + $CI = new $class(); /* @@ -307,11 +307,11 @@ } // Call the requested method. - // Any URI segments present (besides the class/function) will be passed to the method for convenience - call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); + // Any URI segments present (besides the class/function) will be passed to the method for convenience + call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2)); } - + // Mark a benchmark end point $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end'); @@ -331,7 +331,7 @@ { $OUT->_display(); } - + /* * ------------------------------------------------------ * Is there a "post_system" hook? -- cgit v1.2.3-24-g4f1b From f566af5ffb8f2e8d49bd0b206c6ee29c8bc35a78 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Tue, 9 Nov 2010 13:03:26 -0500 Subject: Fixed a bug where silently failed to override if set_time_limit was in Suhosin's function blacklist. Simply moved the set_time_limit call down a bit. --- system/core/CodeIgniter.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index f67bb8c10..e701cc323 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -67,12 +67,6 @@ @set_magic_quotes_runtime(0); // Kill magic quotes } - // Set a liberal script execution time limit - if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) - { - @set_time_limit(300); - } - /* * ------------------------------------------------------ * Set the subclass_prefix @@ -93,6 +87,16 @@ { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } + +/* + * ------------------------------------------------------ + * Set a liberal script execution time limit + * ------------------------------------------------------ + */ + if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0) + { + @set_time_limit(300); + } /* * ------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 63277b81edde11b77ff94cbf1c3e5db16c97c4bf Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Tue, 9 Nov 2010 13:46:13 -0600 Subject: Fix #62 Adding CI_ prefix to Controller. --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index e701cc323..3dfefc2ef 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -261,7 +261,7 @@ if ( ! class_exists($class) OR $method == 'controller' OR strncmp($method, '_', 1) == 0 - OR in_array(strtolower($method), array_map('strtolower', get_class_methods('Controller'))) + OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) ) { show_404("{$class}/{$method}"); -- cgit v1.2.3-24-g4f1b From 3431ae375f7e9283ccfe7e165f39bfc84d79f694 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Tue, 9 Nov 2010 15:19:50 -0500 Subject: Adding a second parameter to _remap that contains an array of the leftover segments. --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index e701cc323..b52281918 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -299,7 +299,7 @@ // Is there a "remap" function? If so, we call it instead if (method_exists($CI, '_remap')) { - $CI->_remap($method); + $CI->_remap($method, array_slice($URI->rsegments, 2)); } else { -- cgit v1.2.3-24-g4f1b From 4abfa686ca53177b7dbbb7e1bac3febbbe27ec0f Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 10 Nov 2010 14:44:26 -0600 Subject: Blasting the Base4/5 files. Updating Controller.php to inherit bits from the old Base5. If a constructor is needed in a controller, call parent::__contruct() --- system/core/CodeIgniter.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index bf412b21d..c50ae6d2b 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -208,25 +208,15 @@ * Load the app controller and local controller * ------------------------------------------------------ * - * Note: Due to the poor object handling in PHP 4 we'll - * conditionally load different versions of the base - * class. Retaining PHP 4 compatibility requires a bit of a hack. - * @PHP4 - * */ - if (is_php('5.0.0') == TRUE) - { - require(BASEPATH.'core/Base5'.EXT); - } - else + // Load the base controller class + require BASEPATH.'core/Controller'.EXT; + + function &get_instance() { - // The Loader class needs to be included first when running PHP 4.x - load_class('Loader', 'core'); - require(BASEPATH.'core/Base4'.EXT); + return CI_Controller::get_instance(); } - // Load the base controller class - require BASEPATH.'core/Controller'.EXT; if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller'.EXT)) { -- cgit v1.2.3-24-g4f1b From 741de1c1319dd13de75348863cca591713dd46ce Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 10 Nov 2010 14:52:57 -0600 Subject: Updating PHP requirements in files 5.1.6 --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index c50ae6d2b..be5a27120 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -2,7 +2,7 @@ /** * CodeIgniter * - * An open source application development framework for PHP 4.3.2 or newer + * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team -- cgit v1.2.3-24-g4f1b From 2893f00bf042057b73435d65814906e1f5d2380d Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 10 Nov 2010 14:55:46 -0600 Subject: Removing require Compat.php in CodeIgniter.php --- system/core/CodeIgniter.php | 7 ------- 1 file changed, 7 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index be5a27120..fc334f050 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -41,13 +41,6 @@ */ require(BASEPATH.'core/Common'.EXT); -/* - * ------------------------------------------------------ - * Load the compatibility override functions - * ------------------------------------------------------ - */ - require(BASEPATH.'core/Compat'.EXT); - /* * ------------------------------------------------------ * Load the framework constants -- cgit v1.2.3-24-g4f1b From ebb6f4bf664747d3649d622b98abc78f2da397f7 Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Wed, 10 Nov 2010 17:09:21 -0500 Subject: Some simple tweaking --- system/core/CodeIgniter.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index fc334f050..595e00f27 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -221,7 +221,7 @@ // If this include fails it means that the default controller in the Routes.php file is not resolving to something valid. if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT)) { - show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); + show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.'); } include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().EXT); @@ -242,7 +242,6 @@ $method = $RTR->fetch_method(); if ( ! class_exists($class) - OR $method == 'controller' OR strncmp($method, '_', 1) == 0 OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller'))) ) -- cgit v1.2.3-24-g4f1b From 0711dc87d98ce20d3a87f7ac43d78af8fba1dca7 Mon Sep 17 00:00:00 2001 From: Greg Aker Date: Wed, 5 Jan 2011 10:49:40 -0600 Subject: Hey look, it's 2011 --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 595e00f27..742903653 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008 - 2010, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 -- cgit v1.2.3-24-g4f1b From aaec1e491f99e9d733b06b721d8d4d1ae778135a Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Thu, 20 Jan 2011 00:01:21 -0500 Subject: Renaming the unicode class to utf8 so we don't run the risk of violating the Unicode Consortium's trademark. --- system/core/CodeIgniter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 742903653..2d3f24958 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -129,17 +129,17 @@ /* * ------------------------------------------------------ - * Instantiate the Unicode class + * Instantiate the UTF-8 class * ------------------------------------------------------ * - * Note: Order here is rather important as the Unicode + * Note: Order here is rather important as the UTF-8 * class needs to be used very early on, but it cannot * properly determine if UTf-8 can be supported until * after the Config class is instantiated. * */ - $UNI =& load_class('Unicode', 'core'); + $UNI =& load_class('Utf8', 'core'); /* * ------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From c5bf616c68ab4d18777ba77d5eaf07384b392f78 Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Sun, 30 Jan 2011 21:17:11 -0500 Subject: Added 404_override to Codeigniter file to catch the 404 if the controller is available but no method. Fixes #19 --- system/core/CodeIgniter.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 2d3f24958..0414ffbf1 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -80,7 +80,7 @@ { get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix'])); } - + /* * ------------------------------------------------------ * Set a liberal script execution time limit @@ -289,7 +289,17 @@ // 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'); + } + else + { + show_404("{$class}/{$method}"); + } } // Call the requested method. -- cgit v1.2.3-24-g4f1b From 5519e3d5d3311275a6fb2aa4962f9cea1626996c Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Tue, 1 Feb 2011 13:07:37 -0500 Subject: Better logic handling for 404 override --- system/core/CodeIgniter.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 0414ffbf1..567e67f65 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -295,6 +295,17 @@ $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 { -- cgit v1.2.3-24-g4f1b From babfb29332501d63a7be59d1dbed864d128ffdae Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 8 Mar 2011 21:56:08 +0000 Subject: Added the constant CI_CORE to help differentiate between Core: TRUE and Reactor: FALSE. --- system/core/CodeIgniter.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 2d3f24958..1c06488f0 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -34,6 +34,13 @@ */ define('CI_VERSION', '2.0'); +/* + * ------------------------------------------------------ + * Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE) + * ------------------------------------------------------ + */ + define('CI_CORE', FALSE); + /* * ------------------------------------------------------ * Load the global functions -- cgit v1.2.3-24-g4f1b From 2f8b27efeb0a39c24eddf89cf31ea0fd113a6b71 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 8 Mar 2011 21:56:08 +0000 Subject: Added the constant CI_CORE to help differentiate between Core: TRUE and Reactor: FALSE. --- system/core/CodeIgniter.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 567e67f65..b91ed3896 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -34,6 +34,13 @@ */ define('CI_VERSION', '2.0'); +/* + * ------------------------------------------------------ + * Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE) + * ------------------------------------------------------ + */ + define('CI_CORE', FALSE); + /* * ------------------------------------------------------ * Load the global functions -- cgit v1.2.3-24-g4f1b From 1e85af54ffc3e31938ec85987849a93c28bb988d Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Tue, 8 Mar 2011 23:01:12 -0500 Subject: Flipping Phil's IS_CORE to true. --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 1c06488f0..0d0fffbe1 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -39,7 +39,7 @@ * Define the CodeIgniter Branch (Core = TRUE, Reactor = FALSE) * ------------------------------------------------------ */ - define('CI_CORE', FALSE); + define('CI_CORE', TRUE); /* * ------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 09380594534d4dd2669e2894aa390582a2bc121d Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 9 Mar 2011 16:42:07 +0000 Subject: Added 2.0.1 upgrade guide and changed the constants ready. --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 6ac333a52..99c261e74 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -32,7 +32,7 @@ * Define the CodeIgniter Version * ------------------------------------------------------ */ - define('CI_VERSION', '2.0'); + define('CI_VERSION', '2.0.1'); /* * ------------------------------------------------------ -- cgit v1.2.3-24-g4f1b From 35f6491450d8564b26cbfab90aedcd0e592a81d4 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Tue, 15 Mar 2011 21:01:39 +0000 Subject: constants.php will be loaded from the environment specific config folder if available. --- system/core/CodeIgniter.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 99c261e74..39a4d7ffd 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -53,7 +53,14 @@ * Load the framework constants * ------------------------------------------------------ */ - require(APPPATH.'config/constants'.EXT); + if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT)) + { + require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT); + } + else + { + require(APPPATH.'config/constants'.EXT); + } /* * ------------------------------------------------------ @@ -365,4 +372,4 @@ /* End of file CodeIgniter.php */ -/* Location: ./system/core/CodeIgniter.php */ +/* Location: ./system/core/CodeIgniter.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b From 14a0ac63a9dfb72e4681c37f7727cd48882152bd Mon Sep 17 00:00:00 2001 From: Pascal Kriete Date: Tue, 5 Apr 2011 14:55:56 -0400 Subject: Moving security to core. --- system/core/CodeIgniter.php | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 39a4d7ffd..7f4595e68 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -196,6 +196,13 @@ } } +/* + * ----------------------------------------------------- + * Load the security class for xss and csrf support + * ----------------------------------------------------- + */ + $SEC =& load_class('Security', 'core'); + /* * ------------------------------------------------------ * Load the Input class and sanitize globals -- cgit v1.2.3-24-g4f1b From 05fa61144667c85b0463f7e8baa6af00aa195dc6 Mon Sep 17 00:00:00 2001 From: Phil Sturgeon Date: Wed, 6 Apr 2011 22:57:43 +0100 Subject: Made Environment Support optional. Comment out or delete the constant to stop environment checks. --- system/core/CodeIgniter.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/core/CodeIgniter.php') diff --git a/system/core/CodeIgniter.php b/system/core/CodeIgniter.php index 39a4d7ffd..143faec15 100644 --- a/system/core/CodeIgniter.php +++ b/system/core/CodeIgniter.php @@ -53,7 +53,7 @@ * Load the framework constants * ------------------------------------------------------ */ - if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT)) + if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT)) { require(APPPATH.'config/'.ENVIRONMENT.'/constants'.EXT); } -- cgit v1.2.3-24-g4f1b