public function set($key, $value) { parent::set($key, $value); if ($value instanceof Model) { // TODO: throw new AjdeException('It is not allowed to store a Model directly in the session, use Ajde_Session::setModel() instead.'); } $_SESSION[$this->_namespace][$key] = $value; Cache::getInstance()->updateHash($this->hash()); }
/** * CSRF prevention token */ public static function getFormToken() { static $token; if (!isset($token)) { Cache::getInstance()->disable(); $token = md5(uniqid(rand(), true)); $session = new Session('AC.Form'); $tokenDictionary = self::_getTokenDictionary($session); $tokenDictionary[$token] = self::_tokenHash($token); $session->set('formTokens', $tokenDictionary); } self::markFormTime(); return $token; }
public function getContents() { ob_start(); $filename = $this->getFilename(); Cache::getInstance()->addFile($filename); if (is_file($filename)) { include $filename; } $contents = ob_get_contents(); ob_end_clean(); return $contents; }
/** * * @param Ajde_Model|Ajde_Collection $object */ public function touchCache($object = null) { Cache::getInstance()->updateHash(isset($object) ? $object->hash() : time()); }
public function getContents() { if (!isset($this->_contents)) { Dispatcher::trigger($this, 'beforeGetContents'); Cache::getInstance()->addFile($this->getFilename()); $contents = $this->getParser()->parse($this); $this->setContents($contents); Dispatcher::trigger($this, 'afterGetContents'); } return $this->_contents; }
public static function includeFileOnce($filename) { Cache::getInstance()->addFile($filename); include_once $filename; }
public function render() { Cache::getInstance()->disable(); Ajde::app()->getDocument()->setLayout(new Layout('empty')); return parent::render(); }
public function verifyCookie($includeDomain = true) { $cookie = new Cookie(Config::get('ident') . '_user', true); if (!$cookie->has('auth')) { return false; } $auth = $cookie->get('auth'); list($uid, $hash) = explode(':', $auth); if (!$this->loadByPK($uid)) { return false; } if ($this->getCookieHash($includeDomain) === $hash) { $this->login(); Flash::alert(sprintf(__('Welcome back %s'), $this->getFullname())); Cache::getInstance()->disable(); } else { return false; } }
public function addResource(Resource $resource, $position = self::RESOURCE_POSITION_DEFAULT) { if ($position == self::RESOURCE_POSITION_TOP) { $resource->setPosition(self::RESOURCE_POSITION_FIRST); } else { $resource->setPosition($position); } // Check for duplicates // TODO: another option, replace current resource foreach ($this->_resources as $positionArray) { foreach ($positionArray as $item) { if ((string) $item == (string) $resource) { return false; } } } if ($position === self::RESOURCE_POSITION_TOP) { array_unshift($this->_resources[self::RESOURCE_POSITION_FIRST], $resource); } else { $this->_resources[$position][] = $resource; } // Add to cache if ($resource instanceof Local) { Cache::getInstance()->addFile($resource->getFilename()); } return true; }