From d21a5d89753e34dcbb7501ac625ec8c1a1dfad8d Mon Sep 17 00:00:00 2001 From: Rougin Gutib Date: Fri, 18 Sep 2015 22:26:34 +0800 Subject: [PATCH] Fixed issues on defined constants --- src/Instance.php | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/Instance.php b/src/Instance.php index 44c0c95..c04aabd 100644 --- a/src/Instance.php +++ b/src/Instance.php @@ -64,14 +64,17 @@ public function __construct() $slash = DIRECTORY_SEPARATOR; - foreach ($iterator as $path) { - $core = 'core' . $slash . 'CodeIgniter.php'; + if ( ! defined('BASEPATH')) { + foreach ($iterator as $path) { + $core = 'core' . $slash . 'CodeIgniter.php'; + + if (strpos($path->__toString(), $core) !== FALSE) { + $basepath = str_replace($core, '', $path->__toString()); - if (strpos($path->__toString(), $core) !== FALSE) { - $basepath = str_replace($core, '', $path->__toString()); - define('BASEPATH', $basepath); + define('BASEPATH', $basepath); - break; + break; + } } } @@ -83,16 +86,23 @@ public function __construct() // Load the Common and Base Controller class require BASEPATH . 'core/Common.php'; - require BASEPATH . 'core/Controller.php'; + + if ( ! class_exists('CI_Controller')) { + require BASEPATH . 'core/Controller.php'; + } /** * Load the framework constants */ - if (file_exists(APPPATH . 'config/' . ENVIRONMENT . '/constants.php')) { - require APPPATH . 'config/' . ENVIRONMENT . '/constants.php'; - } else { - require APPPATH . 'config/constants.php'; + if ( ! defined('FILE_READ_MODE')) { + $constants = APPPATH . 'config/' . ENVIRONMENT . '/constants.php'; + + if (file_exists($constants)) { + require $constants; + } else { + require APPPATH . 'config/constants.php'; + } } // Important charset-related stuff