blob: 4f625b143599d21e27f8f94a2cc9dd13648bc417 [file] [log] [blame]
Andrey Andreevc5536aa2012-11-01 17:33:58 +02001<?php
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev9c5c24a2012-01-07 18:51:21 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev9c5c24a2012-01-07 18:51:21 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
darwinel871754a2014-02-11 17:34:57 +010021 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
Andrey Andreevc5536aa2012-11-01 17:33:58 +020027defined('BASEPATH') OR exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +000028
Derek Allard2067d1a2008-11-13 22:59:24 +000029/**
Derek Jones218876c2010-03-02 13:11:00 -060030 * System Initialization File
Derek Allard2067d1a2008-11-13 22:59:24 +000031 *
32 * Loads the base classes and executes the request.
33 *
34 * @package CodeIgniter
Andrey Andreev92ebfb62012-05-17 12:49:24 +030035 * @subpackage CodeIgniter
Derek Allard2067d1a2008-11-13 22:59:24 +000036 * @category Front-controller
Derek Jonesf4a4bd82011-10-20 12:18:42 -050037 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000038 * @link http://codeigniter.com/user_guide/
39 */
40
Phil Sturgeond8ef6302011-08-14 12:10:55 -060041/**
42 * CodeIgniter Version
43 *
Timothy Warren48a7fbb2012-04-23 11:58:16 -040044 * @var string
Phil Sturgeond8ef6302011-08-14 12:10:55 -060045 *
Derek Jones218876c2010-03-02 13:11:00 -060046 */
Derek Jonesf4a4bd82011-10-20 12:18:42 -050047 define('CI_VERSION', '3.0-dev');
Andrey Andreevb6fbcbe2013-11-17 18:06:18 +020048
Derek Allard2067d1a2008-11-13 22:59:24 +000049/*
50 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -050051 * Load the framework constants
Derek Allard2067d1a2008-11-13 22:59:24 +000052 * ------------------------------------------------------
53 */
Andrey Andreevdb529ca2013-01-28 11:00:02 +020054 if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
Greg Akerd96f8822011-12-27 16:23:47 -060055 {
Andrey Andreev30d53242014-01-16 14:41:46 +020056 require_once(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
Greg Akerd96f8822011-12-27 16:23:47 -060057 }
Andrey Andreevb6fbcbe2013-11-17 18:06:18 +020058
Andrey Andreev30d53242014-01-16 14:41:46 +020059 require_once(APPPATH.'config/constants.php');
Derek Allard2067d1a2008-11-13 22:59:24 +000060
61/*
62 * ------------------------------------------------------
josephok1095d112013-11-16 09:33:37 +080063 * Load the global functions
64 * ------------------------------------------------------
65 */
66 require_once(BASEPATH.'core/Common.php');
67
Andrey Andreevb78a8c72014-04-15 17:21:16 +030068
69/*
70 * ------------------------------------------------------
71 * Security procedures
72 * ------------------------------------------------------
73 */
74
75if ( ! is_php('5.4'))
76{
77 ini_set('magic_quotes_runtime', 0);
78
79 if ((bool) ini_get('register_globals'))
80 {
81 $_protected = array(
82 '_SERVER',
83 '_GET',
84 '_POST',
85 '_FILES',
86 '_REQUEST',
87 '_SESSION',
88 '_ENV',
89 '_COOKIE',
90 'GLOBALS',
91 'HTTP_RAW_POST_DATA',
92 'system_folder',
93 'application_folder',
94 'view_folder',
95 '_protected',
96 '_registered'
97 );
98
99 $_registered = ini_get('variables_order');
100 foreach (array('E' => '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal)
101 {
102 if (strpos($_registered, $key) === FALSE)
103 {
104 continue;
105 }
106
107 foreach (array_keys($$superglobal) as $var)
108 {
109 if (isset($GLOBALS[$var]) && ! in_array($var, $_protected, TRUE))
110 {
111 $GLOBALS[$var] = NULL;
112 }
113 }
114 }
115 }
116}
117
118
josephok1095d112013-11-16 09:33:37 +0800119/*
120 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500121 * Define a custom error handler so we can log PHP errors
Derek Allard2067d1a2008-11-13 22:59:24 +0000122 * ------------------------------------------------------
123 */
Derek Jones218876c2010-03-02 13:11:00 -0600124 set_error_handler('_exception_handler');
Kaiwang Chen21fe9da2013-09-11 13:09:41 +0800125 register_shutdown_function('_shutdown_handler');
Barry Mienydd671972010-10-04 16:33:58 +0200126
Derek Jones218876c2010-03-02 13:11:00 -0600127/*
128 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500129 * Set the subclass_prefix
Derek Jones218876c2010-03-02 13:11:00 -0600130 * ------------------------------------------------------
131 *
Barry Mienydd671972010-10-04 16:33:58 +0200132 * Normally the "subclass_prefix" is set in the config file.
133 * The subclass prefix allows CI to know if a core class is
Derek Jones218876c2010-03-02 13:11:00 -0600134 * being extended via a library in the local application
Barry Mienydd671972010-10-04 16:33:58 +0200135 * "libraries" folder. Since CI allows config items to be
vlakoff8d70c0a2013-08-17 07:31:29 +0200136 * overriden via data set in the main index.php file,
Barry Mienydd671972010-10-04 16:33:58 +0200137 * before proceeding we need to know if a subclass_prefix
Andrey Andreev9c5c24a2012-01-07 18:51:21 +0200138 * override exists. If so, we will set this value now,
Derek Jones218876c2010-03-02 13:11:00 -0600139 * before any classes are loaded
Barry Mienydd671972010-10-04 16:33:58 +0200140 * Note: Since the config file data is cached it doesn't
Derek Jones218876c2010-03-02 13:11:00 -0600141 * hurt to load it here.
142 */
Andrey Andreev9ba661b2012-06-04 14:44:34 +0300143 if ( ! empty($assign_to_config['subclass_prefix']))
Derek Jones218876c2010-03-02 13:11:00 -0600144 {
145 get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
146 }
Eric Barnesc5bf6162011-01-30 21:17:11 -0500147
Pascal Krietef566af52010-11-09 13:03:26 -0500148/*
149 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500150 * Start the timer... tick tock tick tock...
Derek Allard2067d1a2008-11-13 22:59:24 +0000151 * ------------------------------------------------------
152 */
Derek Jones218876c2010-03-02 13:11:00 -0600153 $BM =& load_class('Benchmark', 'core');
154 $BM->mark('total_execution_time_start');
155 $BM->mark('loading_time:_base_classes_start');
Derek Allard2067d1a2008-11-13 22:59:24 +0000156
157/*
158 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500159 * Instantiate the hooks class
Derek Allard2067d1a2008-11-13 22:59:24 +0000160 * ------------------------------------------------------
161 */
Derek Jones218876c2010-03-02 13:11:00 -0600162 $EXT =& load_class('Hooks', 'core');
Derek Allard2067d1a2008-11-13 22:59:24 +0000163
164/*
165 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500166 * Is there a "pre_system" hook?
Derek Allard2067d1a2008-11-13 22:59:24 +0000167 * ------------------------------------------------------
168 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300169 $EXT->call_hook('pre_system');
Derek Allard2067d1a2008-11-13 22:59:24 +0000170
171/*
172 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500173 * Instantiate the config class
Derek Allard2067d1a2008-11-13 22:59:24 +0000174 * ------------------------------------------------------
Andrey Andreeveb555ed2014-02-12 19:25:01 +0200175 *
176 * Note: It is important that Config is loaded first as
177 * most other classes depend on it either directly or by
178 * depending on another class that uses it.
179 *
Barry Mienydd671972010-10-04 16:33:58 +0200180 */
Derek Jones218876c2010-03-02 13:11:00 -0600181 $CFG =& load_class('Config', 'core');
182
183 // Do we have any manually set config items in the index.php file?
Andrey Andreev5232ba02012-10-27 15:25:05 +0300184 if (isset($assign_to_config) && is_array($assign_to_config))
Barry Mienydd671972010-10-04 16:33:58 +0200185 {
Andrey Andreev5232ba02012-10-27 15:25:05 +0300186 foreach ($assign_to_config as $key => $value)
187 {
188 $CFG->set_item($key, $value);
189 }
Derek Jones218876c2010-03-02 13:11:00 -0600190 }
191
192/*
193 * ------------------------------------------------------
Andrey Andreeveb555ed2014-02-12 19:25:01 +0200194 * Important charset-related stuff
Derek Jones218876c2010-03-02 13:11:00 -0600195 * ------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200196 *
Andrey Andreeveb555ed2014-02-12 19:25:01 +0200197 * Configure mbstring and/or iconv if they are enabled
198 * and set MB_ENABLED and ICONV_ENABLED constants, so
199 * that we don't repeatedly do extension_loaded() or
200 * function_exists() calls.
Barry Mienydd671972010-10-04 16:33:58 +0200201 *
Andrey Andreeveb555ed2014-02-12 19:25:01 +0200202 * Note: UTF-8 class depends on this. It used to be done
203 * in it's constructor, but it's _not_ class-specific.
204 *
205 */
206 $charset = strtoupper(config_item('charset'));
207
208 if (extension_loaded('mbstring'))
209 {
210 define('MB_ENABLED', TRUE);
211 mb_internal_encoding($charset);
212 // This is required for mb_convert_encoding() to strip invalid characters.
213 // That's utilized by CI_Utf8, but it's also done for consistency with iconv.
214 mb_substitute_character('none');
215 }
216 else
217 {
218 define('MB_ENABLED', FALSE);
219 }
220
221 // There's an ICONV_IMPL constant, but the PHP manual says that using
222 // iconv's predefined constants is "strongly discouraged".
223 if (extension_loaded('iconv'))
224 {
225 define('ICONV_ENABLED', TRUE);
226 iconv_set_encoding('internal_encoding', $charset);
227 }
228 else
229 {
230 define('ICONV_ENABLED', FALSE);
231 }
232
233/*
234 * ------------------------------------------------------
Andrey Andreev3fd1b382014-02-13 03:01:31 +0200235 * Load compatibility features
236 * ------------------------------------------------------
237 */
238
Andrey Andreev376b2152014-02-13 12:35:52 +0200239 require_once(BASEPATH.'core/compat/mbstring.php');
Andrey Andreev9a152a92014-02-18 16:29:53 +0200240 require_once(BASEPATH.'core/compat/hash.php');
Andrey Andreev376b2152014-02-13 12:35:52 +0200241 require_once(BASEPATH.'core/compat/password.php');
Andrey Andreev02545892014-02-19 23:49:31 +0200242 require_once(BASEPATH.'core/compat/array.php');
Andrey Andreev3fd1b382014-02-13 03:01:31 +0200243
244/*
245 * ------------------------------------------------------
Andrey Andreeveb555ed2014-02-12 19:25:01 +0200246 * Instantiate the UTF-8 class
247 * ------------------------------------------------------
Derek Allard2067d1a2008-11-13 22:59:24 +0000248 */
Pascal Krieteaaec1e42011-01-20 00:01:21 -0500249 $UNI =& load_class('Utf8', 'core');
Barry Mienydd671972010-10-04 16:33:58 +0200250
Derek Jones218876c2010-03-02 13:11:00 -0600251/*
252 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500253 * Instantiate the URI class
Derek Jones218876c2010-03-02 13:11:00 -0600254 * ------------------------------------------------------
255 */
256 $URI =& load_class('URI', 'core');
257
258/*
259 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500260 * Instantiate the routing class and set the routing
Derek Jones218876c2010-03-02 13:11:00 -0600261 * ------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200262 */
Andrey Andreevc26b9eb2014-02-24 11:31:36 +0200263 $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
Barry Mienydd671972010-10-04 16:33:58 +0200264
Derek Jones218876c2010-03-02 13:11:00 -0600265/*
266 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500267 * Instantiate the output class
Derek Jones218876c2010-03-02 13:11:00 -0600268 * ------------------------------------------------------
269 */
270 $OUT =& load_class('Output', 'core');
Derek Allard2067d1a2008-11-13 22:59:24 +0000271
272/*
273 * ------------------------------------------------------
Andrey Andreev9c5c24a2012-01-07 18:51:21 +0200274 * Is there a valid cache file? If so, we're done...
Derek Allard2067d1a2008-11-13 22:59:24 +0000275 * ------------------------------------------------------
276 */
Andrey Andreevc26b9eb2014-02-24 11:31:36 +0200277 if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000278 {
Andrey Andreev9c5c24a2012-01-07 18:51:21 +0200279 exit;
Derek Allard2067d1a2008-11-13 22:59:24 +0000280 }
Derek Allard2067d1a2008-11-13 22:59:24 +0000281
282/*
Pascal Kriete14a0ac62011-04-05 14:55:56 -0400283 * -----------------------------------------------------
284 * Load the security class for xss and csrf support
285 * -----------------------------------------------------
286 */
287 $SEC =& load_class('Security', 'core');
288
289/*
Derek Allard2067d1a2008-11-13 22:59:24 +0000290 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500291 * Load the Input class and sanitize globals
Derek Allard2067d1a2008-11-13 22:59:24 +0000292 * ------------------------------------------------------
293 */
Barry Mienydd671972010-10-04 16:33:58 +0200294 $IN =& load_class('Input', 'core');
Derek Allard2067d1a2008-11-13 22:59:24 +0000295
Derek Jones218876c2010-03-02 13:11:00 -0600296/*
297 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500298 * Load the Language class
Derek Jones218876c2010-03-02 13:11:00 -0600299 * ------------------------------------------------------
300 */
301 $LANG =& load_class('Lang', 'core');
Derek Allard2067d1a2008-11-13 22:59:24 +0000302
303/*
304 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500305 * Load the app controller and local controller
Derek Allard2067d1a2008-11-13 22:59:24 +0000306 * ------------------------------------------------------
307 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000308 */
Derek Jones218876c2010-03-02 13:11:00 -0600309 // Load the base controller class
Andrey Andreev30d53242014-01-16 14:41:46 +0200310 require_once BASEPATH.'core/Controller.php';
Barry Mienydd671972010-10-04 16:33:58 +0200311
Timothy Warrenad475052012-04-19 13:21:06 -0400312 /**
313 * Reference to the CI_Controller method.
314 *
315 * Returns current CI instance object
316 *
317 * @return object
318 */
Greg Aker4abfa682010-11-10 14:44:26 -0600319 function &get_instance()
320 {
321 return CI_Controller::get_instance();
322 }
323
Greg Aker3a746652011-04-19 10:59:47 -0500324 if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
Greg Akerfa281352010-03-22 14:41:27 -0500325 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200326 require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
Greg Akerfa281352010-03-22 14:41:27 -0500327 }
Barry Mienydd671972010-10-04 16:33:58 +0200328
Derek Jones218876c2010-03-02 13:11:00 -0600329 // Set a mark point for benchmarking
330 $BM->mark('loading_time:_base_classes_end');
Derek Allard2067d1a2008-11-13 22:59:24 +0000331
332/*
333 * ------------------------------------------------------
Andrey Andreev30d53242014-01-16 14:41:46 +0200334 * Sanity checks
Derek Allard2067d1a2008-11-13 22:59:24 +0000335 * ------------------------------------------------------
336 *
Andrey Andreev30d53242014-01-16 14:41:46 +0200337 * The Router class has already validated the request,
338 * leaving us with 3 options here:
339 *
340 * 1) an empty class name, if we reached the default
341 * controller, but it didn't exist;
342 * 2) a query string which doesn't go through a
343 * file_exists() check
344 * 3) a regular request for a non-existing page
345 *
346 * We handle all of these as a 404 error.
347 *
348 * Furthermore, none of the methods in the app controller
349 * or the loader class can be called via the URI, nor can
Andrey Andreev20292312013-07-22 14:29:10 +0300350 * controller methods that begin with an underscore.
Derek Allard2067d1a2008-11-13 22:59:24 +0000351 */
Barry Mienydd671972010-10-04 16:33:58 +0200352
Andrey Andreev30d53242014-01-16 14:41:46 +0200353 $e404 = FALSE;
354 $class = ucfirst($RTR->class);
355 $method = $RTR->method;
356
357 if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
Derek Jones218876c2010-03-02 13:11:00 -0600358 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200359 $e404 = TRUE;
Andrey Andreev38e32f62012-11-03 00:16:47 +0200360 }
361 else
362 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200363 require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
364
365 if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
366 {
367 $e404 = TRUE;
368 }
369 elseif (method_exists($class, '_remap'))
370 {
371 $params = array($method, array_slice($URI->rsegments, 2));
372 $method = '_remap';
373 }
Andrey Andreev522c7362012-11-05 16:40:32 +0200374 // WARNING: It appears that there are issues with is_callable() even in PHP 5.2!
375 // Furthermore, there are bug reports and feature/change requests related to it
376 // that make it unreliable to use in this context. Please, DO NOT change this
377 // work-around until a better alternative is available.
Andrey Andreev30d53242014-01-16 14:41:46 +0200378 elseif ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE))
Andrey Andreev38e32f62012-11-03 00:16:47 +0200379 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200380 $e404 = TRUE;
381 }
382 }
383
384 if ($e404)
385 {
386 if ( ! empty($RTR->routes['404_override']))
387 {
388 if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
Andrey Andreev38e32f62012-11-03 00:16:47 +0200389 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200390 $error_method = 'index';
Andrey Andreev38e32f62012-11-03 00:16:47 +0200391 }
392
Andrey Andreev30d53242014-01-16 14:41:46 +0200393 $error_class = ucfirst($error_class);
Andrey Andreev20292312013-07-22 14:29:10 +0300394
Andrey Andreev30d53242014-01-16 14:41:46 +0200395 if ( ! class_exists($error_class, FALSE))
Andrey Andreev38e32f62012-11-03 00:16:47 +0200396 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200397 if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'))
Andrey Andreev38e32f62012-11-03 00:16:47 +0200398 {
Andrey Andreev30d53242014-01-16 14:41:46 +0200399 require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php');
400 $e404 = ! class_exists($error_class, FALSE);
Andrey Andreev38e32f62012-11-03 00:16:47 +0200401 }
Andrey Andreev30d53242014-01-16 14:41:46 +0200402 // Were we in a directory? If so, check for a global override
403 elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php'))
404 {
405 require_once(APPPATH.'controllers/'.$error_class.'.php');
406 if (($e404 = ! class_exists($error_class, FALSE)) === FALSE)
407 {
408 $RTR->directory = '';
409 }
410 }
411 }
412 else
413 {
414 $e404 = FALSE;
Andrey Andreev38e32f62012-11-03 00:16:47 +0200415 }
416 }
417
Andrey Andreev30d53242014-01-16 14:41:46 +0200418 // Did we reset the $e404 flag? If so, set the rsegments, starting from index 1
419 if ( ! $e404)
420 {
421 $class = $error_class;
422 $method = $error_method;
423
424 $URI->rsegments = array(
425 1 => $class,
426 2 => $method
427 );
428 }
429 else
430 {
431 show_404($RTR->directory.$class.'/'.$method);
432 }
433 }
434
435 if ($method !== '_remap')
436 {
Andrey Andreev38e32f62012-11-03 00:16:47 +0200437 $params = array_slice($URI->rsegments, 2);
438 }
439
Derek Allard2067d1a2008-11-13 22:59:24 +0000440/*
441 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500442 * Is there a "pre_controller" hook?
Derek Allard2067d1a2008-11-13 22:59:24 +0000443 * ------------------------------------------------------
444 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300445 $EXT->call_hook('pre_controller');
Derek Allard2067d1a2008-11-13 22:59:24 +0000446
447/*
448 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500449 * Instantiate the requested controller
Derek Allard2067d1a2008-11-13 22:59:24 +0000450 * ------------------------------------------------------
451 */
Derek Jones218876c2010-03-02 13:11:00 -0600452 // Mark a start point so we can benchmark the controller
453 $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
Barry Mienydd671972010-10-04 16:33:58 +0200454
Derek Jones218876c2010-03-02 13:11:00 -0600455 $CI = new $class();
456
457/*
458 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500459 * Is there a "post_controller_constructor" hook?
Derek Jones218876c2010-03-02 13:11:00 -0600460 * ------------------------------------------------------
461 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300462 $EXT->call_hook('post_controller_constructor');
Derek Jones218876c2010-03-02 13:11:00 -0600463
464/*
465 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500466 * Call the requested method
Derek Jones218876c2010-03-02 13:11:00 -0600467 * ------------------------------------------------------
468 */
Andrey Andreev38e32f62012-11-03 00:16:47 +0200469 call_user_func_array(array(&$CI, $method), $params);
Derek Allard2067d1a2008-11-13 22:59:24 +0000470
Derek Jones218876c2010-03-02 13:11:00 -0600471 // Mark a benchmark end point
472 $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
Derek Allard2067d1a2008-11-13 22:59:24 +0000473
474/*
475 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500476 * Is there a "post_controller" hook?
Derek Allard2067d1a2008-11-13 22:59:24 +0000477 * ------------------------------------------------------
478 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300479 $EXT->call_hook('post_controller');
Derek Allard2067d1a2008-11-13 22:59:24 +0000480
481/*
482 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500483 * Send the final rendered output to the browser
Derek Allard2067d1a2008-11-13 22:59:24 +0000484 * ------------------------------------------------------
485 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300486 if ($EXT->call_hook('display_override') === FALSE)
Derek Jones218876c2010-03-02 13:11:00 -0600487 {
488 $OUT->_display();
489 }
Barry Mienydd671972010-10-04 16:33:58 +0200490
Derek Allard2067d1a2008-11-13 22:59:24 +0000491/*
492 * ------------------------------------------------------
Derek Jones37f4b9c2011-07-01 17:56:50 -0500493 * Is there a "post_system" hook?
Derek Allard2067d1a2008-11-13 22:59:24 +0000494 * ------------------------------------------------------
495 */
Andrey Andreeva5dd2972012-03-26 14:43:01 +0300496 $EXT->call_hook('post_system');
Derek Allard2067d1a2008-11-13 22:59:24 +0000497
Derek Allard2067d1a2008-11-13 22:59:24 +0000498/* End of file CodeIgniter.php */
Andrey Andreevb6fbcbe2013-11-17 18:06:18 +0200499/* Location: ./system/core/CodeIgniter.php */