1
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
5
* An open source application development framework for PHP 5.1.6 or newer
8
* @author ExpressionEngine Dev Team
9
* @copyright Copyright (c) 2008 - 2011, EllisLab, Inc.
10
* @license http://codeigniter.com/user_guide/license.html
11
* @link http://codeigniter.com
16
// ------------------------------------------------------------------------
19
* System Initialization File
21
* Loads the base classes and executes the request.
23
* @package CodeIgniter
24
* @subpackage codeigniter
25
* @category Front-controller
26
* @author ExpressionEngine Dev Team
27
* @link http://codeigniter.com/user_guide/
36
define('CI_VERSION', '2.1.3');
39
* CodeIgniter Branch (Core = TRUE, Reactor = FALSE)
44
define('CI_CORE', FALSE);
47
* ------------------------------------------------------
48
* Load the global functions
49
* ------------------------------------------------------
51
require(BASEPATH.'core/Common.php');
54
* ------------------------------------------------------
55
* Load the framework constants
56
* ------------------------------------------------------
58
if (defined('ENVIRONMENT') AND file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
60
require(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
64
require(APPPATH.'config/constants.php');
68
* ------------------------------------------------------
69
* Define a custom error handler so we can log PHP errors
70
* ------------------------------------------------------
72
set_error_handler('_exception_handler');
76
@set_magic_quotes_runtime(0); // Kill magic quotes
80
* ------------------------------------------------------
81
* Set the subclass_prefix
82
* ------------------------------------------------------
84
* Normally the "subclass_prefix" is set in the config file.
85
* The subclass prefix allows CI to know if a core class is
86
* being extended via a library in the local application
87
* "libraries" folder. Since CI allows config items to be
88
* overriden via data set in the main index. php file,
89
* before proceeding we need to know if a subclass_prefix
90
* override exists. If so, we will set this value now,
91
* before any classes are loaded
92
* Note: Since the config file data is cached it doesn't
93
* hurt to load it here.
95
if (isset($assign_to_config['subclass_prefix']) AND $assign_to_config['subclass_prefix'] != '')
97
get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
101
* ------------------------------------------------------
102
* Set a liberal script execution time limit
103
* ------------------------------------------------------
105
if (function_exists("set_time_limit") == TRUE AND @ini_get("safe_mode") == 0)
107
@set_time_limit(300);
111
* ------------------------------------------------------
112
* Start the timer... tick tock tick tock...
113
* ------------------------------------------------------
115
$BM =& load_class('Benchmark', 'core');
116
$BM->mark('total_execution_time_start');
117
$BM->mark('loading_time:_base_classes_start');
120
* ------------------------------------------------------
121
* Instantiate the hooks class
122
* ------------------------------------------------------
124
$EXT =& load_class('Hooks', 'core');
127
* ------------------------------------------------------
128
* Is there a "pre_system" hook?
129
* ------------------------------------------------------
131
$EXT->_call_hook('pre_system');
134
* ------------------------------------------------------
135
* Instantiate the config class
136
* ------------------------------------------------------
138
$CFG =& load_class('Config', 'core');
140
// Do we have any manually set config items in the index.php file?
141
if (isset($assign_to_config))
143
$CFG->_assign_to_config($assign_to_config);
147
* ------------------------------------------------------
148
* Instantiate the UTF-8 class
149
* ------------------------------------------------------
151
* Note: Order here is rather important as the UTF-8
152
* class needs to be used very early on, but it cannot
153
* properly determine if UTf-8 can be supported until
154
* after the Config class is instantiated.
158
$UNI =& load_class('Utf8', 'core');
161
* ------------------------------------------------------
162
* Instantiate the URI class
163
* ------------------------------------------------------
165
$URI =& load_class('URI', 'core');
168
* ------------------------------------------------------
169
* Instantiate the routing class and set the routing
170
* ------------------------------------------------------
172
$RTR =& load_class('Router', 'core');
173
$RTR->_set_routing();
175
// Set any routing overrides that may exist in the main index file
178
$RTR->_set_overrides($routing);
182
* ------------------------------------------------------
183
* Instantiate the output class
184
* ------------------------------------------------------
186
$OUT =& load_class('Output', 'core');
189
* ------------------------------------------------------
190
* Is there a valid cache file? If so, we're done...
191
* ------------------------------------------------------
193
if ($EXT->_call_hook('cache_override') === FALSE)
195
if ($OUT->_display_cache($CFG, $URI) == TRUE)
202
* -----------------------------------------------------
203
* Load the security class for xss and csrf support
204
* -----------------------------------------------------
206
$SEC =& load_class('Security', 'core');
209
* ------------------------------------------------------
210
* Load the Input class and sanitize globals
211
* ------------------------------------------------------
213
$IN =& load_class('Input', 'core');
216
* ------------------------------------------------------
217
* Load the Language class
218
* ------------------------------------------------------
220
$LANG =& load_class('Lang', 'core');
223
* ------------------------------------------------------
224
* Load the app controller and local controller
225
* ------------------------------------------------------
228
// Load the base controller class
229
require BASEPATH.'core/Controller.php';
231
function &get_instance()
233
return CI_Controller::get_instance();
237
if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
239
require APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
242
// Load the local application controller
243
// Note: The Router class automatically validates the controller path using the router->_validate_request().
244
// If this include fails it means that the default controller in the Routes.php file is not resolving to something valid.
245
if ( ! file_exists(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php'))
247
show_error('Unable to load your default controller. Please make sure the controller specified in your Routes.php file is valid.');
250
include(APPPATH.'controllers/'.$RTR->fetch_directory().$RTR->fetch_class().'.php');
252
// Set a mark point for benchmarking
253
$BM->mark('loading_time:_base_classes_end');
256
* ------------------------------------------------------
258
* ------------------------------------------------------
260
* None of the functions in the app controller or the
261
* loader class can be called via the URI, nor can
262
* controller functions that begin with an underscore
264
$class = $RTR->fetch_class();
265
$method = $RTR->fetch_method();
267
if ( ! class_exists($class)
268
OR strncmp($method, '_', 1) == 0
269
OR in_array(strtolower($method), array_map('strtolower', get_class_methods('CI_Controller')))
272
if ( ! empty($RTR->routes['404_override']))
274
$x = explode('/', $RTR->routes['404_override']);
276
$method = (isset($x[1]) ? $x[1] : 'index');
277
if ( ! class_exists($class))
279
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
281
show_404("{$class}/{$method}");
284
include_once(APPPATH.'controllers/'.$class.'.php');
289
show_404("{$class}/{$method}");
294
* ------------------------------------------------------
295
* Is there a "pre_controller" hook?
296
* ------------------------------------------------------
298
$EXT->_call_hook('pre_controller');
301
* ------------------------------------------------------
302
* Instantiate the requested controller
303
* ------------------------------------------------------
305
// Mark a start point so we can benchmark the controller
306
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
311
* ------------------------------------------------------
312
* Is there a "post_controller_constructor" hook?
313
* ------------------------------------------------------
315
$EXT->_call_hook('post_controller_constructor');
318
* ------------------------------------------------------
319
* Call the requested method
320
* ------------------------------------------------------
322
// Is there a "remap" function? If so, we call it instead
323
if (method_exists($CI, '_remap'))
325
$CI->_remap($method, array_slice($URI->rsegments, 2));
329
// is_callable() returns TRUE on some versions of PHP 5 for private and protected
330
// methods, so we'll use this workaround for consistent behavior
331
if ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($CI))))
333
// Check and see if we are using a 404 override and use it.
334
if ( ! empty($RTR->routes['404_override']))
336
$x = explode('/', $RTR->routes['404_override']);
338
$method = (isset($x[1]) ? $x[1] : 'index');
339
if ( ! class_exists($class))
341
if ( ! file_exists(APPPATH.'controllers/'.$class.'.php'))
343
show_404("{$class}/{$method}");
346
include_once(APPPATH.'controllers/'.$class.'.php');
353
show_404("{$class}/{$method}");
357
// Call the requested method.
358
// Any URI segments present (besides the class/function) will be passed to the method for convenience
359
call_user_func_array(array(&$CI, $method), array_slice($URI->rsegments, 2));
363
// Mark a benchmark end point
364
$BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
367
* ------------------------------------------------------
368
* Is there a "post_controller" hook?
369
* ------------------------------------------------------
371
$EXT->_call_hook('post_controller');
374
* ------------------------------------------------------
375
* Send the final rendered output to the browser
376
* ------------------------------------------------------
378
if ($EXT->_call_hook('display_override') === FALSE)
384
* ------------------------------------------------------
385
* Is there a "post_system" hook?
386
* ------------------------------------------------------
388
$EXT->_call_hook('post_system');
391
* ------------------------------------------------------
392
* Close the DB connection if one exists
393
* ------------------------------------------------------
395
if (class_exists('CI_DB') AND isset($CI->db))
401
/* End of file CodeIgniter.php */
402
/* Location: ./system/core/CodeIgniter.php */
b'\\ No newline at end of file'