protected function __construct() { $this->config = Hayate_Config::load('session'); $driver = isset($this->config->session->driver) ? $this->config->session->driver : 'native'; switch ($driver) { case 'database': // can we get a db connection ? if (null === Hayate_Database::getInstance()) { throw new Hayate_Exception(sprintf(_('%s cannot use "database" driver as it is unable' . ' to retrieve a valid database connection.'), __CLASS__)); } $ses = Hayate_Session_Database::getInstance(); session_set_save_handler(array($ses, 'open'), array($ses, 'close'), array($ses, 'read'), array($ses, 'write'), array($ses, 'destroy'), array($ses, 'gc')); break; case 'native': break; default: throw new Hayate_Exception(sprintf(_('Session driver: "%s" not supported.'), $driver)); } // @see http://php.net/manual/en/function.session-write-close.php Hayate_Event::add('hayate.shutdown', 'session_write_close'); ini_set('session.use_only_cookies', true); ini_set('session.use_trans_sid', 0); session_name($this->config->get('session.name', 'HayateSession')); // session will not work with a domain without top level $domain = $this->config->get('session.domain', $_SERVER['SERVER_NAME']); if (preg_match('/^\\.?.+\\.[a-z]{2,4}$/i', $domain) != 1) { $domain = ''; } session_set_cookie_params((int) $this->config->get('session.lifetime', 0), $this->config->get('session.path', '/'), $domain, $this->config->get('session.secure', false), $this->config->get('session.httponly', false)); session_start(); Hayate_Log::info(sprintf(_('%s initialized.'), __CLASS__)); }
protected function __construct() { $this->config = Hayate_Config::load('session'); $connName = $this->config->get('session.connection', 'default'); $this->db = Hayate_Database::getInstance($connName); $this->crypto = null; // if we want the session encrypted, and the cookie does not // encrypt then we encrypt here otherwise we let the cookie class encrypt if ($this->config->get('session.encrypt', false)) { $this->crypto = Hayate_Crypto::getInstance(); } }
public function __construct($id = null) { if (!isset($this->table_name)) { $this->table_name = strtolower(str_ireplace('_model', '', get_class($this))); } if (!isset($this->class_name)) { $this->class_name = strtolower(str_ireplace('_model', '', get_class($this))); } $this->setFields(); $this->db = Hayate_Database::getInstance($this->dbconfig); $this->loaded = false; if (null !== $id) { $this->load($id); } }
protected function __construct() { $this->session = Hayate_Session::getInstance(); $this->cookie = Hayate_Cookie::getInstance(); $this->db = Hayate_Database::getInstance(); if ($this->session->exists(self::AUTHID)) { $this->identity = $this->session->get(self::AUTHID); $this->status = self::SUCCESS; } else { if ($this->cookie->exists(self::AUTHID)) { $this->identity = $this->cookie->get(self::AUTHID); $this->session->set(self::AUTHID, $this->identity); $this->status = self::SUCCESS; } else { $this->status = FALSE; $this->identity = NULL; } } }