123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556 |
- <?php
- defined('BASEPATH') OR exit('No direct script access allowed');
- const CI_VERSION = '3.1.2';
- if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/constants.php'))
- {
- require_once(APPPATH.'config/'.ENVIRONMENT.'/constants.php');
- }
- require_once(APPPATH.'config/constants.php');
- require_once(BASEPATH.'core/Common.php');
- if ( ! is_php('5.4'))
- {
- ini_set('magic_quotes_runtime', 0);
- if ((bool) ini_get('register_globals'))
- {
- $_protected = array(
- '_SERVER',
- '_GET',
- '_POST',
- '_FILES',
- '_REQUEST',
- '_SESSION',
- '_ENV',
- '_COOKIE',
- 'GLOBALS',
- 'HTTP_RAW_POST_DATA',
- 'system_path',
- 'application_folder',
- 'view_folder',
- '_protected',
- '_registered'
- );
- $_registered = ini_get('variables_order');
- foreach (array('E' => '_ENV', 'G' => '_GET', 'P' => '_POST', 'C' => '_COOKIE', 'S' => '_SERVER') as $key => $superglobal)
- {
- if (strpos($_registered, $key) === FALSE)
- {
- continue;
- }
- foreach (array_keys($$superglobal) as $var)
- {
- if (isset($GLOBALS[$var]) && ! in_array($var, $_protected, TRUE))
- {
- $GLOBALS[$var] = NULL;
- }
- }
- }
- }
- }
- set_error_handler('_error_handler');
- set_exception_handler('_exception_handler');
- register_shutdown_function('_shutdown_handler');
- if ( ! empty($assign_to_config['subclass_prefix']))
- {
- get_config(array('subclass_prefix' => $assign_to_config['subclass_prefix']));
- }
- if ($composer_autoload = config_item('composer_autoload'))
- {
- if ($composer_autoload === TRUE)
- {
- file_exists(APPPATH.'vendor/autoload.php')
- ? require_once(APPPATH.'vendor/autoload.php')
- : log_message('error', '$config[\'composer_autoload\'] is set to TRUE but '.APPPATH.'vendor/autoload.php was not found.');
- }
- elseif (file_exists($composer_autoload))
- {
- require_once($composer_autoload);
- }
- else
- {
- log_message('error', 'Could not find the specified $config[\'composer_autoload\'] path: '.$composer_autoload);
- }
- }
- $BM =& load_class('Benchmark', 'core');
- $BM->mark('total_execution_time_start');
- $BM->mark('loading_time:_base_classes_start');
- $EXT =& load_class('Hooks', 'core');
- $EXT->call_hook('pre_system');
- $CFG =& load_class('Config', 'core');
-
- if (isset($assign_to_config) && is_array($assign_to_config))
- {
- foreach ($assign_to_config as $key => $value)
- {
- $CFG->set_item($key, $value);
- }
- }
- $charset = strtoupper(config_item('charset'));
- ini_set('default_charset', $charset);
- if (extension_loaded('mbstring'))
- {
- define('MB_ENABLED', TRUE);
-
-
- @ini_set('mbstring.internal_encoding', $charset);
-
-
- mb_substitute_character('none');
- }
- else
- {
- define('MB_ENABLED', FALSE);
- }
-
-
- if (extension_loaded('iconv'))
- {
- define('ICONV_ENABLED', TRUE);
-
-
- @ini_set('iconv.internal_encoding', $charset);
- }
- else
- {
- define('ICONV_ENABLED', FALSE);
- }
- if (is_php('5.6'))
- {
- ini_set('php.internal_encoding', $charset);
- }
- require_once(BASEPATH.'core/compat/mbstring.php');
- require_once(BASEPATH.'core/compat/hash.php');
- require_once(BASEPATH.'core/compat/password.php');
- require_once(BASEPATH.'core/compat/standard.php');
- $UNI =& load_class('Utf8', 'core');
- $URI =& load_class('URI', 'core');
- $RTR =& load_class('Router', 'core', isset($routing) ? $routing : NULL);
- $OUT =& load_class('Output', 'core');
- if ($EXT->call_hook('cache_override') === FALSE && $OUT->_display_cache($CFG, $URI) === TRUE)
- {
- exit;
- }
- $SEC =& load_class('Security', 'core');
- $IN =& load_class('Input', 'core');
- $LANG =& load_class('Lang', 'core');
-
- require_once BASEPATH.'core/Controller.php';
-
- function &get_instance()
- {
- return CI_Controller::get_instance();
- }
- if (file_exists(APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php'))
- {
- require_once APPPATH.'core/'.$CFG->config['subclass_prefix'].'Controller.php';
- }
-
- $BM->mark('loading_time:_base_classes_end');
- $e404 = FALSE;
- $class = ucfirst($RTR->class);
- $method = $RTR->method;
- if (empty($class) OR ! file_exists(APPPATH.'controllers/'.$RTR->directory.$class.'.php'))
- {
- $e404 = TRUE;
- }
- else
- {
- require_once(APPPATH.'controllers/'.$RTR->directory.$class.'.php');
- if ( ! class_exists($class, FALSE) OR $method[0] === '_' OR method_exists('CI_Controller', $method))
- {
- $e404 = TRUE;
- }
- elseif (method_exists($class, '_remap'))
- {
- $params = array($method, array_slice($URI->rsegments, 2));
- $method = '_remap';
- }
- elseif ( ! method_exists($class, $method))
- {
- $e404 = TRUE;
- }
-
- elseif ( ! is_callable(array($class, $method)) && strcasecmp($class, $method) === 0)
- {
- $reflection = new ReflectionMethod($class, $method);
- if ( ! $reflection->isPublic() OR $reflection->isConstructor())
- {
- $e404 = TRUE;
- }
- }
- }
- if ($e404)
- {
- if ( ! empty($RTR->routes['404_override']))
- {
- if (sscanf($RTR->routes['404_override'], '%[^/]/%s', $error_class, $error_method) !== 2)
- {
- $error_method = 'index';
- }
- $error_class = ucfirst($error_class);
- if ( ! class_exists($error_class, FALSE))
- {
- if (file_exists(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php'))
- {
- require_once(APPPATH.'controllers/'.$RTR->directory.$error_class.'.php');
- $e404 = ! class_exists($error_class, FALSE);
- }
-
- elseif ( ! empty($RTR->directory) && file_exists(APPPATH.'controllers/'.$error_class.'.php'))
- {
- require_once(APPPATH.'controllers/'.$error_class.'.php');
- if (($e404 = ! class_exists($error_class, FALSE)) === FALSE)
- {
- $RTR->directory = '';
- }
- }
- }
- else
- {
- $e404 = FALSE;
- }
- }
-
- if ( ! $e404)
- {
- $class = $error_class;
- $method = $error_method;
- $URI->rsegments = array(
- 1 => $class,
- 2 => $method
- );
- }
- else
- {
- show_404($RTR->directory.$class.'/'.$method);
- }
- }
- if ($method !== '_remap')
- {
- $params = array_slice($URI->rsegments, 2);
- }
- $EXT->call_hook('pre_controller');
-
- $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_start');
- $CI = new $class();
- $EXT->call_hook('post_controller_constructor');
- call_user_func_array(array(&$CI, $method), $params);
-
- $BM->mark('controller_execution_time_( '.$class.' / '.$method.' )_end');
- $EXT->call_hook('post_controller');
- if ($EXT->call_hook('display_override') === FALSE)
- {
- $OUT->_display();
- }
- $EXT->call_hook('post_system');
|