private function read() { try { $this->initialized = true; if (isset($_COOKIE[self::COOKIE_SELECTOR]) && $_COOKIE[self::COOKIE_SELECTOR]) { $base = base64_decode($_COOKIE[self::COOKIE_SELECTOR]); $decrypted = Dfi_Crypt_MCrypt::decode($base); $unserialized = unserialize($decrypted); $this->setValues($unserialized); } } catch (Exception $e) { } }
/** * Returns the contents of storage * * Behavior is undefined when storage is empty. * * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible * @return mixed */ public function read() { $request = Zend_Controller_Front::getInstance()->getRequest(); if ($request) { $controller = Zend_Controller_Front::getInstance()->getRequest()->getParam('controller'); } else { $controller = ''; } try { $this->initialized = true; if (isset($_COOKIE['_u']) && $_COOKIE['_u'] && $_COOKIE['_u'] != 'deleted') { $base = base64_decode($_COOKIE['_u']); $decrypted = Dfi_Crypt_MCrypt::decode($base); list($userId, $token) = explode('-', $decrypted); $time = time(); if ($token + 20 * 60 >= $time) { $queryClass = ucfirst($this->model) . 'Peer'; $user = $queryClass::retrieveByPK($userId); /** @var $user SysUser */ if ($user) { $this->userId = $user->getPrimaryKey(); $this->user = $user; return $user; } else { if (!in_array($controller, array('login', 'logout'))) { Dfi_Controller_Action_Helper_Messages::getInstance()->addMessage(Dfi_Controller_Action_Helper_Messages::TYPE_DEBUG, 'bad cookie user'); } } } else { if (!in_array($controller, array('login', 'logout'))) { Dfi_Controller_Action_Helper_Messages::getInstance()->addMessage(Dfi_Controller_Action_Helper_Messages::TYPE_DEBUG, 'cookie expired: ' . $base . ' dec: ' . $decrypted . ' token:' . $token . ' diff:' . ($time - $token) / 60); } } } else { if (!in_array($controller, array('login', 'logout'))) { //Dfi_Controller_Action_Helper_Messages::getInstance()->addMessage(Dfi_Controller_Action_Helper_Messages::TYPE_DEBUG, 'cookie auth not set'); } } } catch (Exception $e) { throw new Zend_Auth_Storage_Exception($e->getMessage()); } return false; }