Example #1
0
 /**
  * Session Constructor
  *
  * The constructor runs the session routines automatically
  * whenever the class is instantiated.
  */
 public function __construct()
 {
     // Set the super object to a local variable for use throughout the class
     $this->registry =& registry::instance();
     // Do we need use cookie? If so, load the input library
     $this->registry->load->library('input');
     // Do we need encryption? If so, load the encryption library
     if ($this->session_encrypt_cookie == true) {
         $this->registry->load->library('encrypt');
     }
     // Set the "now" time.  Can either be GMT or server time, based on the
     // config prefs.  We use this to set the "last activity" time
     $this->now = $this->_get_time();
     // Set the session length. If the session expiration is
     // set to zero we'll set the expiration two years from now.
     if ($this->session_expiration == 0) {
         $this->session_expiration = 60 * 60 * 24 * 365 * 2;
     }
     // Set the cookie name
     $this->session_cookie_name = $this->cookie_prefix . $this->session_cookie_name;
     // Run the Session routine. If a session doesn't exist we'll
     // create a new one.  If it does, we'll update it.
     if (!$this->session_read()) {
         $this->session_create();
     } else {
         $this->session_update();
     }
 }
Example #2
0
 /**
  * class constructor
  *
  * @access	public
  */
 public function __construct()
 {
     // set the class instance
     registry::instance($this);
     // instantiate loader engine
     $this->load = new AppLoader();
     // instantiate viewer engine
     $this->view = new AppViewer();
 }
Example #3
0
 /**
  * class constructor
  *
  * @access	public
  */
 public function __construct()
 {
     // global objects
     foreach (array_keys(get_object_vars(registry::instance())) as $object) {
         if (!isset($this->{$object})) {
             $this->{$object} = registry::instance()->{$object};
         }
     }
     // load database library
     $this->db = $this->load->database();
 }
Example #4
0
 public static function getInstance()
 {
     //there is no instance
     if (!self::$instance instanceof self) {
         //si el instance es una instancia de si mismo
         self::$instance = new self();
         return self::$instance;
     } else {
         return self::$instance;
     }
 }
Example #5
0
 /**
  * model
  *
  * load a model object
  *
  * @access	public
  * @param	string $model_name the name of the model class
  * @param	string $alias_name the property name alias
  * @param	string $filename the filename
  * @return	boolean
  */
 public function model($model_name, $alias_name = null, $filename = null)
 {
     // if no alias,  use the model name
     if (!isset($alias_name)) {
         $alias_name = $model_name;
     }
     // final check for model alias
     if (empty($alias_name)) {
         throw new Exception('Model name cannot be empty', 205);
     }
     // check valid alias name
     if (!preg_match('!^[a-zA-Z][a-zA-Z_]+$!', $alias_name)) {
         throw new Exception('Model name "' . $alias_name . '" is an invalid format', 206);
     }
     // check reserved alias name
     if (method_exists($this, $alias_name)) {
         throw new Exception('Model name "' . $alias_name . '" is an invalid (reserved) name', 207);
     }
     // model already loaded? skip
     if (isset($this->{$alias_name})) {
         return true;
     }
     // if no filename, use the lower-case model name
     if (!isset($filename)) {
         $filename = strtolower($model_name);
     }
     // assign application model path
     $filepath = APPDIR . 'models' . DS . $filename . '.php';
     // check application model path
     if (!file_exists($filepath)) {
         throw new Exception($model_name, 208);
     }
     // no problem, load application model class
     require_once $filepath;
     // class name must be the same as the model name
     if (!class_exists($model_name)) {
         throw new Exception($model_name, 209);
     }
     // get instance of registry object
     $registry = registry::instance();
     // instantiate the object as a property
     $registry->{$alias_name} = new $model_name();
     return true;
 }
Example #6
0
/**
 * get_instance
 *
 * set & get the registry object instance function
 *
 * @access public
 */
function &get_instance($new_instance = null)
{
    return registry::instance($new_instance);
}