private function loadLibraries()
 {
     $loaded_libraries =& is_loaded();
     return array_map(function ($item) {
         return array('name' => $item);
     }, $loaded_libraries);
 }
示例#2
0
/**
 * Reset CodeIgniter instance
 */
function reset_instance()
{
    // Reset loaded classes
    load_class('', '', NULL, TRUE);
    is_loaded('', TRUE);
    // Close db connection
    $CI =& get_instance();
    if (isset($CI->db)) {
        if ($CI->db->dsn !== 'sqlite::memory:' && $CI->db->database !== ':memory:') {
            $CI->db->close();
            $CI->db = null;
        } else {
            // Don't close if SQLite in-memory database
            // If we close it, all tables and stored data will be gone
            load_class_instance('db', $CI->db);
        }
    }
    // Load core classes
    load_class('Benchmark', 'core');
    load_class('Hooks', 'core');
    load_class('Config', 'core');
    //	load_class('Utf8', 'core');
    load_class('URI', 'core');
    load_class('Router', 'core');
    load_class('Output', 'core');
    load_class('Security', 'core');
    load_class('Input', 'core');
    load_class('Lang', 'core');
    CIPHPUnitTest::loadLoader();
    // Remove CodeIgniter instance
    $CI = new CIPHPUnitTestNullCodeIgniter();
}
 function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
 {
     static $_classes = array();
     if (isset($_classes[$class])) {
         return $_classes[$class];
     }
     $name = FALSE;
     foreach (array(APPPATH, BASEPATH) as $path) {
         if (file_exists($path . $directory . '/' . $class . '.php')) {
             $name = $prefix . $class;
             if (class_exists($name) === FALSE) {
                 require $path . $directory . '/' . $class . '.php';
             }
             break;
         }
     }
     if (file_exists(APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php')) {
         $name = config_item('subclass_prefix') . $class;
         if (class_exists($name) === FALSE) {
             require APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php';
         }
     }
     if ($name === FALSE) {
         exit('Unable to locate the specified class: ' . $class . '.php');
     }
     is_loaded($class);
     $_classes[$class] = new $name();
     return $_classes[$class];
 }
示例#4
0
	/**
	 * Class constructor
	 *
	 * @return	void
	 */
	public function __construct()
	{
		self::$instance =& $this;

		// Assign all the class objects that were instantiated by the
		// bootstrap file (CodeIgniter.php) to local class variables
		// so that CI can run as one big super object.
		foreach (is_loaded() as $var => $class)
		{
			$this->$var =& load_class($class);
		}

		$this->load =& load_class('Loader', 'core');
		$this->load->initialize();
		log_message('info', 'Controller Class Initialized');
                user_logged_in();
                //echo $user_type = $this->session->userdata['department'];
                $valid_method = get_restricted_department();
                $user_type = strtolower($this->session->userdata['department']);
                if(in_array($user_type, $valid_method)) {
					user_authentication($user_type);
                }
                
               
	}
示例#5
0
 /**
  * Constructor
  *
  * Calls the initialize() function
  */
 function Controller()
 {
     parent::CI_Base();
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     // In PHP 5 the Loader class is run as a discreet
     // class.  In PHP 4 it extends the Controller @PHP4
     if (is_php('5.0.0') == TRUE) {
         $this->load =& load_class('Loader', 'core');
         $this->load->_base_classes =& is_loaded();
         $this->load->_ci_autoloader();
     } else {
         $this->_ci_autoloader();
         // sync up the objects since PHP4 was working from a copy
         foreach (array_keys(get_object_vars($this)) as $attribute) {
             if (is_object($this->{$attribute})) {
                 $this->load->{$attribute} =& $this->{$attribute};
             }
         }
     }
     log_message('debug', "Controller Class Initialized");
 }
示例#6
0
 function &load_class($class, $directory = 'libraries', $prefix = 'CI_')
 {
     static $_classes = array();
     // Does the class exist?  If so, we're done...
     if (isset($_classes[$class])) {
         return $_classes[$class];
     }
     $name = false;
     // Look for the class first in the local application/libraries folder
     // then in the native system/libraries folder
     foreach (array(APPPATH, STACKCIEXTPATH, BASEPATH) as $path) {
         if (file_exists($path . $directory . '/' . $class . '.php')) {
             $name = $prefix . $class;
             if (class_exists($name) === false) {
                 require $path . $directory . '/' . $class . '.php';
             }
             break;
         }
     }
     // Is the request a class extension?  If so we load it too
     if (file_exists(APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php')) {
         $name = config_item('subclass_prefix') . $class;
         if (class_exists($name) === false) {
             require APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php';
         }
     }
     // Did we find the class?
     if ($name === false) {
         throw new Exception(sprintf('Unable to locate the specified class: %s.php', $class));
     }
     // Keep track of what we just loaded
     is_loaded($class);
     $_classes[$class] = new $name();
     return $_classes[$class];
 }
示例#7
0
function &__load($class, $directory = 'core', $prefix = TF_PREFIX, $from_child = FALSE)
{
    static $_classes = array();
    $class = strtoupper($class);
    $class_name = '';
    $the_path = $from_child === TRUE ? TFUSE_CHILD : TFUSE;
    #check to see if class is already loaded. if true, return class instance from memory
    if (isset($_classes[$class])) {
        return $_classes[$class];
    }
    #look in the classes directory and attempt to load
    $class_name = $prefix . $class;
    if (file_exists($the_path . '/' . $directory . '/' . $class . '.php')) {
        if (class_exists($class_name, FALSE) === FALSE) {
            require_once $the_path . '/' . $directory . '/' . $class . '.php';
        }
    }
    #check if the class has been found, else die
    if (class_exists($class_name, FALSE) === FALSE) {
        exit('Class not found: ' . $class_name);
    }
    #load the class
    is_loaded($class);
    #load the class in the memory array
    $_classes[$class] = new $class_name();
    #finally return the object instance
    return $_classes[$class];
}
示例#8
0
/**
 * Turns a plugin on and creates the row to show loading
 * @global resource
 * @param string $name name of plugin
 * @return boolean|string
 */
function load_plugin($name)
{
    global $database;
    if ($name == "") {
        return 'error_plugin_no_name';
    } else {
        if (!alpha($name, 'alpha-underscore')) {
            return 'error_plugin_name';
        } else {
            if (!is_loaded($name)) {
                // Insert plugin
                $database->query("INSERT INTO `plugins` SET `name` = '{$name}'");
                // That plugin has been loaded.
                plugin_loaded($name);
                // Include
                include BASEPATH . '../plugins/' . $name . '.php';
                // Install plugin
                if (function_exists('install_' . $name)) {
                    // set it up
                    $function = 'install_' . $name;
                    // initiate it
                    $function();
                }
                // Return true
                return true;
            }
        }
    }
    return 'error_already_loaded';
}
示例#9
0
function load_class_inc($class, $directory = 'libraries')
{
    static $_classes = array();
    // Does the class exist?  If so, we're done...
    if (isset($_classes[$class])) {
        return $_classes[$class];
    }
    $name = FALSE;
    // Look for the class first in the local application/libraries folder
    // then in the native system/libraries folder
    foreach (array(APPPATH, LIBS_PATH, BASEPATH) as $path) {
        if (file_exists($path . $directory . '/' . $class . '.php')) {
            $name = $prefix . $class;
            if (class_exists($name) === FALSE) {
                require $path . $directory . '/' . $class . '.php';
            }
            break;
        }
    }
    // Did we find the class?
    if ($name === FALSE) {
        exit('Unable to locate the specified class: ' . $class . '.php');
    }
    // Keep track of what we just loaded
    is_loaded($class);
}
示例#10
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     if ($this->input->get('lang')) {
         $lang = $this->input->get('lang');
         if ($lang == 'en') {
             $this->session->set_userdata('lang', 'en');
         } else {
             $this->session->set_userdata('lang', 'fr');
         }
     }
     $this->language = 'french';
     if ($this->session->userdata('lang') == 'en') {
         $this->language = 'english';
     } else {
         $this->language = 'french';
     }
     $this->lang->load('site', $this->language);
     log_message('debug', "Controller Class Initialized");
 }
示例#11
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('debug', "Controller Class Initialized");
     //add by Chaiphet S. Check Authorization
     $authorize = $this->session->userdata('userSession');
     if ($this->authorization->checkAuthorize(get_class($this))) {
         if ($authorize == null) {
             $msg = 'Status 501: You have no authentication or your session is time out to access ' . get_class($this);
             $msg .= '<br>Please <a href="' . site_url('authentication') . '">log in</a>';
             show_error($msg, 501);
         } else {
             if (!isset($authorize['controller']) || $authorize['controller'] == null || !in_array(get_class($this), $authorize['controller'])) {
                 show_error('Status 502: You have no authorize to access ' . get_class($this), 502);
             }
         }
     }
 }
示例#12
0
 /**
  * FA_Controller constructor.
  */
 public function __construct()
 {
     self::$instance =& $this;
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     /**
      * **************************************
      *  Hook "pre_init_controller"
      * **************************************
      */
     $this->hook->action(FA, 'pre_init_controller');
     $this->module = $this->router->module();
     $this->controller = $this->router->controller();
     $this->action = $this->router->action();
     /**
      * Loader class
      */
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     /**
      * Declare model object
      */
     $this->model = new \stdClass();
     /**
      * Declare lib object
      */
     $this->lib = new \stdClass();
     /**
      * Log info
      */
     log_message(MSG_INFO, 'Controller Class Initialized');
 }
示例#13
0
 /**
  * Initialize the Loader
  *
  * This method is called once in CI_Controller.
  *
  * @param 	array
  * @return 	object
  */
 public function initialize()
 {
     $this->_ci_classes = array();
     $this->_ci_loaded_files = array();
     $this->_ci_models = array();
     $this->_base_classes =& is_loaded();
     $this->_ci_autoloader();
     return $this;
 }
示例#14
0
 public function __construct()
 {
     self::$instance =& $this;
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('debug', "Controller Class Initialized");
 }
示例#15
0
 /**
  * Initialize the Loader
  *
  * This method is called once in CI_Controller.
  *
  * @param   array
  * @return  object
  */
 public function initialize()
 {
     // 必须在子类中做如下初始化,不可直接 parent::initialize()
     $this->_ci_classes = array();
     $this->_ci_loaded_files = array();
     $this->_ci_models = array();
     $this->_base_classes =& is_loaded();
     $this->_ci_autoloader();
     return $this;
 }
示例#16
0
/**
 * Class registry
 * 
 * @staticvar array $_classes
 * 
 * @param string $class
 * @param string $directory
 * @param array  $param
 * @param bool   $reset
 * @param object $obj
 * 
 * @return object
 */
function &load_class($class, $directory = 'libraries', $param = NULL, $reset = FALSE, $obj = NULL)
{
    static $_classes = array();
    if ($reset) {
        // If Utf8 is instantiated twice,
        // error "Constant UTF8_ENABLED already defined" occurs
        $UTF8 = $_classes['Utf8'];
        $_classes = array('Utf8' => $UTF8);
        $obj = new stdClass();
        return $obj;
    }
    // Register object directly
    if ($obj) {
        is_loaded($class);
        $_classes[$class] = $obj;
        return $_classes[$class];
    }
    // Does the class exist? If so, we're done...
    if (isset($_classes[$class])) {
        return $_classes[$class];
    }
    $name = FALSE;
    // Look for the class first in the local application/libraries folder
    // then in the native system/libraries folder
    foreach (array(APPPATH, BASEPATH) as $path) {
        if (file_exists($path . $directory . '/' . $class . '.php')) {
            $name = 'CI_' . $class;
            if (class_exists($name, FALSE) === FALSE) {
                require_once $path . $directory . '/' . $class . '.php';
            }
            break;
        }
    }
    // Is the request a class extension? If so we load it too
    if (file_exists(APPPATH . $directory . '/' . config_item('subclass_prefix') . $class . '.php')) {
        $name = config_item('subclass_prefix') . $class;
        if (class_exists($name, FALSE) === FALSE) {
            require_once APPPATH . $directory . '/' . $name . '.php';
        }
    }
    // Did we find the class?
    if ($name === FALSE) {
        // Note: We use exit() rather then show_error() in order to avoid a
        // self-referencing loop with the Exceptions class
        set_status_header(503);
        // changed by ci-phpunit-test
        $msg = 'Unable to locate the specified class: ' . $class . '.php';
        //		exit(5); // EXIT_UNK_CLASS
        throw new CIPHPUnitTestExitException($msg);
    }
    // Keep track of what we just loaded
    is_loaded($class);
    $_classes[$class] = isset($param) ? new $name($param) : new $name();
    return $_classes[$class];
}
示例#17
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->set_base_classes()->ci_autoloader();
     $this->load->model('login_model', '', TRUE);
     //////CODE EDITED BY JIJI---FROM HERE---///////for language selector
     $lang_arr = $this->session->userdata('lang_arr');
     if (strlen($this->uri->segment(1)) == 2) {
         for ($i = 0; $i < count($lang_arr); $i++) {
             if ($this->uri->segment(1) == $lang_arr[$i]['lang_code']) {
                 $this->login_model->setDefaultLang($lang_arr[$i]['lang_id']);
                 $this->lang->load($lang_arr[$i]['lang_name_in_english'], $lang_arr[$i]['lang_name_in_english']);
                 $this->session->set_userdata('tran_language', $lang_arr[$i]['lang_name_in_english']);
             }
         }
     } else {
         if ($this->session->userdata('tran_language')) {
             if ($this->checkSession()) {
                 $controler_class = $this->router->class;
                 if ($controler_class != 'login') {
                     $user_type = $this->session->userdata['logged_in']['user_type'];
                     if ($user_type == "employee") {
                         $id = $this->login_model->getAdminid();
                         $lang_id = $this->login_model->getDefaultLang($id);
                         $language = $this->login_model->getLanguageName($lang_id);
                         $this->lang->load($language, $language);
                         $this->session->set_userdata('tran_language', $language);
                     } else {
                         $user_id = $this->session->userdata['logged_in']['user_id'];
                         $lang_id = $this->login_model->getDefaultLang($user_id);
                         $language = $this->login_model->getLanguageName($lang_id);
                         $this->lang->load($language, $language);
                         $this->session->set_userdata('tran_language', $language);
                     }
                 }
             } else {
                 $this->lang->load($this->session->userdata('tran_language'), $this->session->userdata('tran_language'));
                 $this->session->set_userdata('tran_language', $this->session->userdata('tran_language'));
             }
         } else {
             $this->lang->load('french', 'french');
             $this->session->set_userdata('tran_language', 'french');
         }
     }
     //////CODE EDITED BY JIJI---UPTO HERE---///////
     log_message('debug', "Controller Class Initialized");
 }
示例#18
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
 }
示例#19
0
 public function __construct()
 {
     //把CI的全局this赋给instance,这样可以在外部调用CI全局的this
     self::$instance =& $this;
     //必须先加载了CodeIgniter.php文件才能使用下面方法
     //is_load()存储了很多需要实例化的类
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('info', 'Controller Class Initialized');
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->set_base_classes()->ci_autoloader();
     log_message('debug', "Controller Class Initialized");
 }
示例#21
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('info', 'Controller Class Initialized');
     //ENVIRONMENT != 'development' || $this->output->enable_profiler(TRUE);
 }
示例#22
0
 function load_class($class, $dir = "libs")
 {
     static $_classes = array();
     $filePath = BASEPATH . $dir . '/' . $class . '.php';
     if (isset($_classes[$class])) {
         return $_classes[$class];
     }
     if (file_exists($filePath)) {
         require $filePath;
         is_loaded($class);
         $_classes[$class] = new $class();
         return $_classes[$class];
     }
 }
示例#23
0
 /**
  * Class constructor
  *类构造器  构造函数
  * @return	void
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     //分配所有的类对象实例化的引导文件(CodeIgniter.php)本地类变量,以便CI可以运行作为一个大的超级对象。
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('info', 'Controller Class Initialized');
 }
示例#24
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     date_default_timezone_set('America/Sao_Paulo');
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('info', 'Controller Class Initialized');
 }
示例#25
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     self::$instance =& $this;
     global $GLOBAL_VARS;
     $this->GLOBAL_VARS = $GLOBAL_VARS;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('info', 'Controller Class Initialized');
 }
示例#26
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class adress that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('debug', "Controller Class Initialized");
     $this->load->model('user_model');
     $this->data['user_token'] = $this->user_model->login_in();
 }
示例#27
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     $this->load->library('sr_user');
     $this->load->library('sr_auth');
     $this->config->set_item('app_id', hash('sha1', $this->config->item('app_id')));
     log_message('info', 'App Class Initialized');
 }
示例#28
0
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (Bootstrap.php) to local class variables
     // so that ING can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader');
     $this->load->initialize();
     $this->load->helper('url');
     $this->load->helper('template');
     $this->path = site_url(THM_PATH) . '/';
     log_message('debug', "Controller Class Initialized");
 }
示例#29
0
 /**
  * Constructor
  */
 public function __construct()
 {
     //error_reporting(0);
     //ini_set('display_errors', 0);
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     log_message('debug', "Controller Class Initialized");
     //$this->output->enable_profiler(TRUE);
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     self::$instance =& $this;
     // Assign all the class objects that were instantiated by the
     // bootstrap file (CodeIgniter.php) to local class variables
     // so that CI can run as one big super object.
     foreach (is_loaded() as $var => $class) {
         $this->{$var} =& load_class($class);
     }
     $this->load =& load_class('Loader', 'core');
     $this->load->initialize();
     $this->output->enable_profiler(FALSE);
     log_message('debug', "Controller Class Initialized");
     $this->load->model('page_model');
     $this->load->library('functions');
 }