Example #1
0
 public static function getInstance()
 {
     if (null === self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Example #2
0
 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();
     }
 }
Example #3
0
 /**
  * @param string $name The name of the cookie
  * @param mixed $default If $name is not set this value is returned
  * @param bool $xss_clean If boolean it will overwrite the configuration settings (prevent xss attacts)
  * @return mixed The value of the cookie
  */
 public function get($name, $default = null, $xss_clean = null)
 {
     if (!$this->exists($name)) {
         return $default;
     }
     $ans = $_COOKIE[$name];
     if ($this->encrypt) {
         $crypto = Hayate_Crypto::getInstance();
         $ans = $crypto->decrypt($ans);
     }
     $xss = Hayate_Config::getInstance()->get('xss_clean', false);
     if (is_bool($xss_clean)) {
         $xss = $xss_clean;
     }
     return $xss ? htmlentities($ans, ENT_QUOTES, 'utf-8') : $ans;
 }
Example #4
0
 /**
  * @param string $name The name of the cookie
  * @param mixed $default If $name is not set this value is returned
  * @param bool $xss_clean If boolean it will overwrite the configuration settings (prevent xss attacts)
  * @return mixed The value of the cookie
  */
 public function get($name, $default = null, $xss_clean = null)
 {
     if (!array_key_exists($name, $_COOKIE)) {
         return $default;
     }
     $ans = $_COOKIE[$name];
     if ($this->encrypt) {
         $crypto = Hayate_Crypto::getInstance();
         $ans = $crypto->decrypt($ans);
     }
     $xss = Hayate_Config::getInstance()->get('xss_clean', false);
     if (is_bool($xss_clean)) {
         $xss = $xss_clean;
     }
     $ans = unserialize($ans);
     return is_string($ans) && $xss ? htmlspecialchars($ans, ENT_QUOTES, Hayate_Config::getInstance()->get('charset', 'UTF-8')) : $ans;
 }