当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Session::getOptions方法代码示例

本文整理汇总了PHP中Zend_Session::getOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Session::getOptions方法的具体用法?PHP Zend_Session::getOptions怎么用?PHP Zend_Session::getOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Session的用法示例。


在下文中一共展示了Zend_Session::getOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOverride

 /**
  * @depends testDestroy
  */
 public function testOverride()
 {
     // Initialize session
     $result = $this->_handler->write($this->_id, $this->_data);
     $this->assertEquals(true, $result);
     $sess = $this->_findSession($this->_id);
     // No update
     $this->_handler->read($this->_id);
     $this->_handler->write($this->_id, $this->_data);
     $sess1 = $this->_findSession($this->_id);
     $this->assertEquals($sess, $sess1);
     // Wait
     sleep(1);
     // Update
     $this->_handler->read($this->_id);
     $this->_handler->write($this->_id, $this->_data . '3839');
     $sess2 = $this->_findSession($this->_id);
     $this->assertNotEquals($sess, $sess2);
     $this->assertNotEquals($sess['metadata']['created'], $sess2['metadata']['created']);
     $this->assertEquals($sess['metadata']['expire'], $sess2['metadata']['expire']);
     // Wait
     sleep(Zend_Session::getOptions('gc_maxlifetime') + 1);
     // New one due to max lifetime
     $this->_handler->read($this->_id);
     $this->_handler->write($this->_id, $this->_data);
     $sess3 = $this->_findSession($this->_id);
     $this->assertNotEquals($sess, $sess3);
     $this->assertNotEquals($sess['metadata']['created'], $sess3['metadata']['created']);
     $this->assertNotEquals($sess['metadata']['expire'], $sess3['metadata']['expire']);
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:33,代码来源:MongoTest.php

示例2: perioddialogAction

 public function perioddialogAction()
 {
     $yearList = new Model_Year_List();
     $this->view->assign("yearList", $yearList->getListView());
     $this->view->assign("yearCurrent", Zend_Session::getOptions("yearId"));
     $this->view->assign("filter", new Model_Abstract_Filter());
 }
开发者ID:nikita-prikazchikov,项目名称:academic_load,代码行数:7,代码来源:IndexController.php

示例3: __construct

 /**
  *
  */
 public function __construct($config = array())
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     } else {
         if (!is_array($config)) {
             /**
              * @see Zend_Session_SaveHandler_Exception
              */
             require_once 'Zend/Session/SaveHandler/Exception.php';
             throw new Zend_Session_SaveHandler_Exception('$config must be an instance of Zend_Config or array of key/value pairs containing ' . 'configuration options for App_Session_SaveHandler_Cache.');
         }
     }
     if (!isset($config['cache'])) {
         throw new Zend_Session_SaveHandler_Exception('$config have to indicate the cachename.');
     }
     if (is_string($config['cache'])) {
         $cacheMgr = isset($config['cacheManager']) ? $config['cacheManager'] : App::get('cacheManager');
         $this->_cache = $cacheMgr->getCache($config['cache']);
     } else {
         $this->_cache = $config['cache'];
     }
     if (isset($config['prefix'])) {
         $this->_prefix = (string) $config['prefix'];
     }
     $this->_maxLifeTime = Zend_Session::getOptions('gc_maxlifetime');
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:30,代码来源:Cache.php

示例4: _getData

 /**
  * Returns the data to show in the index action
  *
  * Allows to easily add or modifiy the information at project level
  *
  * @return array
  */
 protected function _getData()
 {
     $versions = $this->loader->getVersions();
     $data[$this->_('Project name')] = $this->project->getName();
     $data[$this->_('Project version')] = $versions->getProjectVersion();
     $data[$this->_('Gems version')] = $versions->getGemsVersion();
     $data[$this->_('Gems build')] = $versions->getBuild();
     $data[$this->_('Gems project')] = GEMS_PROJECT_NAME;
     $data[$this->_('Gems web directory')] = $this->getDirInfo(GEMS_WEB_DIR);
     $data[$this->_('Gems root directory')] = $this->getDirInfo(GEMS_ROOT_DIR);
     $data[$this->_('Gems code directory')] = $this->getDirInfo(GEMS_LIBRARY_DIR);
     $data[$this->_('Gems variable directory')] = $this->getDirInfo(GEMS_ROOT_DIR . '/var');
     $data[$this->_('MUtil version')] = \MUtil_Version::get();
     $data[$this->_('Zend version')] = \Zend_Version::VERSION;
     $data[$this->_('Application environment')] = APPLICATION_ENV;
     $data[$this->_('Application baseuri')] = $this->loader->getUtil()->getCurrentURI();
     $data[$this->_('Application directory')] = $this->getDirInfo(APPLICATION_PATH);
     $data[$this->_('Application encoding')] = APPLICATION_ENCODING;
     $data[$this->_('PHP version')] = phpversion();
     $data[$this->_('Server Hostname')] = php_uname('n');
     $data[$this->_('Server OS')] = php_uname('s');
     $data[$this->_('Time on server')] = date('r');
     $driveVars = array($this->_('Session directory') => \Zend_Session::getOptions('save_path'), $this->_('Temporary files directory') => realpath(getenv('TMP')));
     if ($system = getenv('SystemDrive')) {
         $driveVars[$this->_('System Drive')] = realpath($system);
     }
     foreach ($driveVars as $name => $drive) {
         $data[$name] = $this->getDirInfo($drive);
     }
     return $data;
 }
开发者ID:GemsTracker,项目名称:gemstracker-library,代码行数:38,代码来源:ProjectInformationAction.php

示例5: __construct

 /**
  *
  */
 public function __construct($config = array())
 {
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     } else {
         if (!is_array($config)) {
             /**
              * @see Zend_Session_SaveHandler_Exception
              */
             require_once 'Zend/Session/SaveHandler/Exception.php';
             throw new Zend_Session_SaveHandler_Exception('$config must be an instance of Zend_Config or array of key/value pairs containing ' . 'configuration options for App_Session_SaveHandler_Cache.');
         }
     }
     if (!isset($config['collection'])) {
         throw new Zend_Session_SaveHandler_Exception('$config have to indicate the collection.');
     }
     try {
         if (is_string($config['collection'])) {
             $this->_connection = \App::get('mongo');
             $this->_collection = $this->_connection->{$config['collection']};
         } else {
             $this->_collection = $config['collection'];
         }
     } catch (\Exception $e) {
         if ($this->_connection) {
             $this->_connection->close();
         }
         throw $e;
     }
     $this->_maxLifeTime = Zend_Session::getOptions('gc_maxlifetime');
 }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:34,代码来源:Mongo.php

示例6: testSetOptions

 public function testSetOptions()
 {
     Zend_Session::setOptions(array('use_only_cookies' => false, 'remember_me_seconds' => 3600));
     $this->resource->setOptions(array('use_only_cookies' => true, 'remember_me_seconds' => 7200));
     $this->resource->init();
     $this->assertEquals(1, Zend_Session::getOptions('use_only_cookies'));
     $this->assertEquals(7200, Zend_Session::getOptions('remember_me_seconds'));
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:8,代码来源:SessionTest.php

示例7: __construct

 public function __construct($namespace = self::NAMESPACE_DEFAULT, $member = self::MEMBER_DEFAULT)
 {
     $this->_namespace = $namespace;
     $this->_member = $member;
     $sessName = Zend_Session::getOptions('name');
     if (isset($_COOKIE[$sessName])) {
         $this->_session = new Zend_Session_Namespace($namespace);
     }
 }
开发者ID:shevron,项目名称:stoa,代码行数:9,代码来源:LazySession.php

示例8: initSession

 /**
  * @static
  * @return void
  */
 public static function initSession()
 {
     Zend_Session::setOptions(array("throw_startup_exceptions" => false, "gc_maxlifetime" => 7200, "name" => "pimcore_admin_sid", "strict" => false, "use_only_cookies" => false));
     try {
         try {
             if (!Zend_Session::isStarted()) {
                 $sName = Zend_Session::getOptions("name");
                 // only set the session id if the cookie isn't present, otherwise Set-Cookie is always in the headers
                 if (array_key_exists($sName, $_REQUEST) && !empty($_REQUEST[$sName]) && (!array_key_exists($sName, $_COOKIE) || empty($_COOKIE[$sName]))) {
                     // get zend_session work with session-id via get (since SwfUpload doesn't support cookies)
                     Zend_Session::setId($_REQUEST[$sName]);
                 }
                 // register session
                 Zend_Session::start();
             }
         } catch (Exception $e) {
             Logger::error("Problem while starting session");
             Logger::error($e);
         }
     } catch (Exception $e) {
         Logger::emergency("there is a problem with admin session");
         die;
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:28,代码来源:Authentication.php

示例9: loginAction


//.........这里部分代码省略.........
                 $user->password = $password;
                 $user->save();
                 Engine_Api::_()->user()->getAuth()->getStorage()->write($user->getIdentity());
                 // @todo should we delete the old migration row?
             } else {
                 $this->view->status = false;
                 $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid credentials');
                 $form->addError(Zend_Registry::get('Zend_Translate')->_('Invalid credentials supplied'));
                 return;
             }
             // End Version 3 authentication
         } else {
             $form->addError('There appears to be a problem logging in. Please reset your password with the Forgot Password link.');
             // Register login
             Engine_Api::_()->getDbtable('logins', 'user')->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'v3-migration'));
             return;
         }
     } else {
         $authResult = Engine_Api::_()->user()->authenticate($email, $password);
         $authCode = $authResult->getCode();
         Engine_Api::_()->user()->setViewer();
         if ($authCode != Zend_Auth_Result::SUCCESS) {
             $this->view->status = false;
             $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid credentials');
             $form->addError(Zend_Registry::get('Zend_Translate')->_('Invalid credentials supplied'));
             // Register login
             Engine_Api::_()->getDbtable('logins', 'user')->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'bad-password'));
             return;
         }
     }
     // -- Success! --
     // Register login
     $loginTable = Engine_Api::_()->getDbtable('logins', 'user');
     $loginTable->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'success', 'active' => true));
     $_SESSION['login_id'] = $login_id = $loginTable->getAdapter()->lastInsertId();
     // Remember
     if ($remember) {
         $lifetime = 1209600;
         // Two weeks
         Zend_Session::getSaveHandler()->setLifetime($lifetime, true);
         Zend_Session::rememberMe($lifetime);
     }
     // Increment sign-in count
     Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.logins');
     // Test activity @todo remove
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $viewer->lastlogin_date = date("Y-m-d H:i:s");
         if ('cli' !== PHP_SAPI) {
             $viewer->lastlogin_ip = $ipExpr;
         }
         $viewer->save();
         Engine_Api::_()->getDbtable('actions', 'activity')->addActivity($viewer, $viewer, 'login');
     }
     // Assign sid to view for json context
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Login successful');
     $this->view->sid = Zend_Session::getId();
     $this->view->sname = Zend_Session::getOptions('name');
     // Run post login hook
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('onUserLoginAfter', $viewer);
     // Do redirection only if normal context
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         // Redirect by form
         $uri = $form->getValue('return_url');
         if ($uri) {
             if (substr($uri, 0, 3) == '64-') {
                 $uri = base64_decode(substr($uri, 3));
             }
             return $this->_redirect($uri, array('prependBase' => false));
         }
         // Redirect by session
         $session = new Zend_Session_Namespace('Redirect');
         if (isset($session->uri)) {
             $uri = $session->uri;
             $opts = $session->options;
             $session->unsetAll();
             return $this->_redirect($uri, $opts);
         } else {
             if (isset($session->route)) {
                 $session->unsetAll();
                 return $this->_helper->redirector->gotoRoute($session->params, $session->route, $session->reset);
             }
         }
         // Redirect by hook
         foreach ((array) $event->getResponses() as $response) {
             if (is_array($response)) {
                 if (!empty($response['error']) && !empty($response['message'])) {
                     return $form->addError($response['message']);
                 } else {
                     if (!empty($response['redirect'])) {
                         return $this->_helper->redirector->gotoUrl($response['redirect'], array('prependBase' => false));
                     }
                 }
             }
         }
         // Just redirect to home
         return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general', true);
     }
 }
开发者ID:HiLeo1610,项目名称:tumlumsach,代码行数:101,代码来源:AuthController.php

示例10: indexAction

 public function indexAction()
 {
     // Already logged in
     $viewer = Khcn_Api::_()->getViewer();
     if ($viewer && $viewer->getIdentity()) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Bạn đã đăng nhập.');
         $this->_helper->redirector->gotoRoute(array(), 'default', true);
         return;
     }
     // Make form
     $this->view->form = $form = new Default_Form_Login();
     $form->setAction($this->view->url(array('return_url' => null)));
     $form->populate(array('return_url' => $this->_getParam('return_url')));
     // Not a post
     if (!$this->getRequest()->isPost()) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('No action taken');
         return;
     }
     // Form not valid
     if (!$form->isValid($this->getRequest()->getPost())) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid data');
         return;
     }
     // Check login creds
     extract($form->getValues());
     // $Username, $Password, $Remember
     $userTable = Khcn_Api::_()->getItemTable('default_nguoi_dung');
     $userSelect = $userTable->select()->where('ten_dang_nhap = ?', $Username);
     // If post exists
     $user = $userTable->fetchRow($userSelect);
     // Get ip address
     $db = Khcn_Db_Table::getDefaultAdapter();
     // Check if user exists
     if (empty($user)) {
         $this->view->status = false;
         $this->view->error = Zend_Registry::get('Zend_Translate')->_('Tên đăng nhập hoặc mật khẩu không đúng.');
         $form->addError(Zend_Registry::get('Zend_Translate')->_('Tên đăng nhập hoặc mật khẩu không đúng.'));
         return;
     }
     // Check if user is verified and enabled
     if (!$user->enabled) {
         if (!$user->verified) {
             $this->view->status = false;
             $translate = Zend_Registry::get('Zend_Translate');
             $error = $translate->translate('Vui lòng kích hoạt tài khoản thông qua email.');
             $form->getDecorator('errors')->setOption('escape', false);
             $form->addError($error);
             return;
         } else {
             if (!$user->approved) {
                 $this->view->status = false;
                 $translate = Zend_Registry::get('Zend_Translate');
                 $error = $translate->translate('Tài khoản của bạn cần được kích hoạt bởi admin.');
                 $form->getDecorator('errors')->setOption('escape', false);
                 $form->addError($error);
                 return;
             }
         }
         // Should be handled by hooks or payment
         //return;
     }
     // Version 3 Import compatibility
     if (empty($user->mat_khau)) {
         $form->addError('Mật khẩu không hợp lệ. Vui lòng reset lại mật khẩu.');
         return;
     } else {
         $authResult = Khcn_Api::_()->authenticate($Username, $Password);
         $authCode = $authResult->getCode();
         Khcn_Api::_()->setViewer();
         if ($authCode != Zend_Auth_Result::SUCCESS) {
             $this->view->status = false;
             $this->view->error = Zend_Registry::get('Zend_Translate')->_('Tên đăng nhập hoặc mật khẩu không đúng.');
             $form->addError(Zend_Registry::get('Zend_Translate')->_('Tên đăng nhập hoặc mật khẩu không đúng.'));
             return;
         }
     }
     // -- Success! --
     // Remember
     if (!empty($Remember)) {
         $lifetime = 1209600;
         // Two weeks
         Zend_Session::getSaveHandler()->setLifetime($lifetime, true);
         Zend_Session::rememberMe($lifetime);
     }
     // Test activity @todo remove
     $viewer = Khcn_Api::_()->getViewer();
     if ($viewer && $viewer->getIdentity()) {
         $viewer->lan_dang_nhap_cuoi = date("Y-m-d H:i:s");
         $viewer->save();
     }
     // Assign sid to view for json context
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Đăng nhập thành công');
     $this->view->sid = Zend_Session::getId();
     $this->view->sname = Zend_Session::getOptions('name');
     // Do redirection only if normal context
     // Redirect by form
//.........这里部分代码省略.........
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:101,代码来源:DangNhapController.php

示例11: loginAction


//.........这里部分代码省略.........
                 $this->view->error = $error = $translate->translate('This account still requires admin approval.');
                 $form->getDecorator('errors')->setOption('escape', false);
                 $form->addError($error);
                 // Register login
                 Engine_Api::_()->getDbtable('logins', 'user')->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'disabled'));
                 return;
             }
         }
         // Should be handled by hooks or payment
     }
     // Handle subscriptions
     if (Engine_Api::_()->hasModuleBootstrap('payment')) {
         // Check for the user's plan
         $subscriptionsTable = Engine_Api::_()->getDbtable('subscriptions', 'payment');
         if (!$subscriptionsTable->check($user)) {
             // Register login
             Engine_Api::_()->getDbtable('logins', 'user')->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'unpaid'));
             // Redirect to subscription page
             $subscriptionSession = new Zend_Session_Namespace('Payment_Subscription');
             $subscriptionSession->unsetAll();
             $subscriptionSession->user_id = $user->getIdentity();
             return $this->_helper->redirector->gotoRoute(array('module' => 'payment', 'controller' => 'subscription', 'action' => 'index'), 'default', true);
         }
     }
     // Register login
     $auth = Zend_Auth::getInstance();
     $auth->getStorage()->write($user->getIdentity());
     // Run pre login hook
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('onUserLoginBefore', $user);
     foreach ((array) $event->getResponses() as $response) {
         if (is_array($response)) {
             if (!empty($response['error']) && !empty($response['message'])) {
                 $form->addError($response['message']);
             } else {
                 if (!empty($response['redirect'])) {
                     $this->_helper->redirector->gotoUrl($response['redirect'], array('prependBase' => false));
                 } else {
                     continue;
                 }
             }
             // Register login
             Engine_Api::_()->getDbtable('logins', 'user')->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'third-party'));
             // Return
             return;
         }
     }
     // Register login
     $loginTable = Engine_Api::_()->getDbtable('logins', 'user');
     $loginTable->insert(array('user_id' => $user->getIdentity(), 'email' => $email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'success', 'active' => true));
     $_SESSION['login_id'] = $login_id = $loginTable->getAdapter()->lastInsertId();
     // Increment sign-in count
     Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.logins');
     // Test activity @todo remove
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $viewer->lastlogin_date = date("Y-m-d H:i:s");
         if ('cli' !== PHP_SAPI) {
             $viewer->lastlogin_ip = $ipExpr;
         }
         $viewer->save();
         Engine_Api::_()->getDbtable('actions', 'activity')->addActivity($viewer, $viewer, 'login');
     }
     // Assign sid to view for json context
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Login successful');
     $this->view->sid = Zend_Session::getId();
     $this->view->sname = Zend_Session::getOptions('name');
     // Run post login hook
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('onUserLoginAfter', $viewer);
     // Do redirection only if normal context
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         // Redirect by session
         $session = new Zend_Session_Namespace('Redirect');
         if (isset($session->uri)) {
             $uri = $session->uri;
             $opts = $session->options;
             $session->unsetAll();
             return $this->_redirect($uri, $opts);
         } else {
             if (isset($session->route)) {
                 $session->unsetAll();
                 return $this->_helper->redirector->gotoRoute($session->params, $session->route, $session->reset);
             }
         }
         // Redirect by hook
         foreach ((array) $event->getResponses() as $response) {
             if (is_array($response)) {
                 if (!empty($response['error']) && !empty($response['message'])) {
                     return $form->addError($response['message']);
                 } else {
                     if (!empty($response['redirect'])) {
                         return $this->_helper->redirector->gotoUrl($response['redirect'], array('prependBase' => false));
                     }
                 }
             }
         }
         // Just redirect to home
         return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general', true);
     }
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:101,代码来源:IndexController.php

示例12: _initSession

 protected function _initSession()
 {
     // Get session configuration
     $file = APPLICATION_PATH . '/application/settings/session.php';
     $config = array();
     if (file_exists($file)) {
         $config = (include $file);
     }
     // Get default session configuration
     if (empty($config)) {
         $config = array('options' => array('save_path' => 'session', 'use_only_cookies' => true, 'remember_me_seconds' => 864000, 'gc_maxlifetime' => 86400, 'cookie_httponly' => false), 'saveHandler' => array('class' => 'Core_Model_DbTable_Session', 'params' => array('lifetime' => 86400)));
     }
     // Remove httponly unless forced in config
     if (!isset($config['options']['cookie_httponly'])) {
         $config['options']['cookie_httponly'] = false;
     }
     // Set session options
     Zend_Session::setOptions($config['options']);
     $saveHandler = $config['saveHandler']['class'];
     Zend_Session::setSaveHandler(new $saveHandler($config['saveHandler']['params']));
     // Session hack for fancy upload
     //if( !isset($_COOKIE[session_name()]) )
     //{
     $sessionName = Zend_Session::getOptions('name');
     if (isset($_POST[$sessionName])) {
         Zend_Session::setId($_POST[$sessionName]);
     } else {
         if (isset($_POST['PHPSESSID'])) {
             Zend_Session::setId($_POST['PHPSESSID']);
         }
     }
     //}
     //Zend_Session::start();
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:34,代码来源:Bootstrap.php

示例13: write

 /**
  * Write session data
  *
  * @param string $id
  * @param string $data
  * @return boolean
  */
 public function write($id, $data)
 {
     return $this->getCache()->save($data, $this->normalizeId($id), array(), \Zend_Session::getOptions('gc_maxlifetime'));
 }
开发者ID:lciolecki,项目名称:zf-extensions-library,代码行数:11,代码来源:Cache.php

示例14: loginAction


//.........这里部分代码省略.........
             $resend_url = $this->_helper->url->url(array('action' => 'resend', 'email' => $email), 'user_signup', true);
             $error .= ' ';
             $error .= sprintf($translate->translate('Click <a href="%s">here</a> to resend the email.'), $resend_url);
         }
         $form->getDecorator('errors')->setOption('escape', false);
         $form->addError($error);
         return;
     }
     // Version 3 Import compatibility
     if (empty($user->password)) {
         $compat = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.compatibility.password');
         $migration = null;
         try {
             $migration = Engine_Db_Table::getDefaultAdapter()->select()->from('engine4_user_migration')->where('user_id = ?', $user->getIdentity())->limit(1)->query()->fetch();
         } catch (Exception $e) {
             $migration = null;
             $compat = null;
         }
         if (!$migration) {
             $compat = null;
         }
         if ($compat == 'import-version-3') {
             // Version 3 authentication
             $cryptedPassword = self::_version3PasswordCrypt($migration['user_password_method'], $migration['user_code'], $password);
             if ($cryptedPassword === $migration['user_password']) {
                 // Regenerate the user password using the given password
                 $user->salt = (string) rand(1000000, 9999999);
                 $user->password = $password;
                 $user->save();
                 Engine_Api::_()->user()->getAuth()->getStorage()->write($user->getIdentity());
                 // @todo should we delete the old migration row?
             } else {
                 $this->view->status = false;
                 $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid credentials');
                 $form->addError(Zend_Registry::get('Zend_Translate')->_('Invalid credentials supplied'));
                 return;
             }
             // End Version 3 authentication
         } else {
             $form->addError('There appears to be a problem logging in. Please reset your password with the Forgot Password link.');
             return;
         }
     } else {
         $authResult = Engine_Api::_()->user()->authenticate($email, $password);
         $authCode = $authResult->getCode();
         Engine_Api::_()->user()->setViewer();
         if ($authCode != Zend_Auth_Result::SUCCESS) {
             $this->view->status = false;
             $this->view->error = Zend_Registry::get('Zend_Translate')->_('Invalid credentials');
             $form->addError(Zend_Registry::get('Zend_Translate')->_('Invalid credentials supplied'));
             return;
         }
     }
     // -- Success! --
     // Remember
     if ($remember) {
         $lifetime = 1209600;
         // Two weeks
         Zend_Session::getSaveHandler()->setLifetime($lifetime, true);
         Zend_Session::rememberMe($lifetime);
     }
     // Increment sign-in count
     Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.logins');
     // Test activity @todo remove
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $viewer->lastlogin_date = date("Y-m-d H:i:s");
         $viewer->lastlogin_ip = $_SERVER['REMOTE_ADDR'];
         $viewer->save();
         Engine_Api::_()->getDbtable('actions', 'activity')->addActivity($viewer, $viewer, 'login');
     }
     // Assign sid to view for json context
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Login successful');
     $this->view->sid = Zend_Session::getId();
     $this->view->sname = Zend_Session::getOptions('name');
     // Do redirection only if normal context
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         // Redirect by form
         $uri = $form->getValue('return_url');
         if ($uri) {
             return $this->_redirect($uri, array('prependBase' => false));
         }
         // Redirect by session
         $session = new Zend_Session_Namespace('Redirect');
         if (isset($session->uri)) {
             $uri = $session->uri;
             $opts = $session->options;
             $session->unsetAll();
             return $this->_redirect($uri, $opts);
         } else {
             if (isset($session->route)) {
                 $session->unsetAll();
                 return $this->_helper->redirector->gotoRoute($session->params, $session->route, $session->reset);
             } else {
                 return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general');
             }
         }
     }
 }
开发者ID:robeendey,项目名称:ce,代码行数:101,代码来源:AuthController.php

示例15: activateAction

 public function activateAction()
 {
     $this->_helper->layout->setLayout('default-simple');
     $user = Engine_Api::_()->core()->getSubject();
     if (!$user->deactive) {
         return $this->_forward('success', 'utility', 'core', array('messages' => array(Zend_Registry::get('Zend_Translate')->_('Your request is invalid.')), 'redirect' => $this->getFrontController()->getRouter()->assemble(array('action' => 'home'), 'user_general', true)));
     }
     // Form
     $this->view->form = $form = new User_Form_Settings_Active();
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     // Process
     $db = Engine_Api::_()->getDbtable('users', 'user')->getAdapter();
     $db->beginTransaction();
     try {
         $user->user_id = $user->deactive;
         $user->deactive = 0;
         $user->save();
         $db->commit();
     } catch (Exception $e) {
         $db->rollBack();
         throw $e;
     }
     Zend_Auth::getInstance()->getStorage()->write($user->user_id);
     Engine_Api::_()->user()->setViewer();
     // Register login
     $loginTable = Engine_Api::_()->getDbtable('logins', 'user');
     $ipObj = new Engine_IP();
     $ipExpr = new Zend_Db_Expr($db->quoteInto('UNHEX(?)', bin2hex($ipObj->toBinary())));
     $loginTable->insert(array('user_id' => $user->getIdentity(), 'email' => $user->email, 'ip' => $ipExpr, 'timestamp' => new Zend_Db_Expr('NOW()'), 'state' => 'success', 'active' => true));
     $_SESSION['login_id'] = $login_id = $loginTable->getAdapter()->lastInsertId();
     // Increment sign-in count
     Engine_Api::_()->getDbtable('statistics', 'core')->increment('user.logins');
     // Test activity @todo remove
     $viewer = Engine_Api::_()->user()->getViewer();
     if ($viewer->getIdentity()) {
         $viewer->lastlogin_date = date("Y-m-d H:i:s");
         if ('cli' !== PHP_SAPI) {
             $viewer->lastlogin_ip = $ipExpr;
         }
         $viewer->save();
         Engine_Api::_()->getDbtable('actions', 'activity')->addActivity($viewer, $viewer, 'login');
     }
     // Assign sid to view for json context
     $this->view->status = true;
     $this->view->message = Zend_Registry::get('Zend_Translate')->_('Login successful');
     $this->view->sid = Zend_Session::getId();
     $this->view->sname = Zend_Session::getOptions('name');
     // Run post login hook
     $event = Engine_Hooks_Dispatcher::getInstance()->callEvent('onUserLoginAfter', $viewer);
     // Do redirection only if normal context
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         // Redirect by form
         $uri = $form->getValue('return_url');
         if ($uri) {
             if (substr($uri, 0, 3) == '64-') {
                 $uri = base64_decode(substr($uri, 3));
             }
             return $this->_redirect($uri, array('prependBase' => false));
         }
         // Redirect by session
         $session = new Zend_Session_Namespace('Redirect');
         if (isset($session->uri)) {
             $uri = $session->uri;
             $opts = $session->options;
             $session->unsetAll();
             return $this->_redirect($uri, $opts);
         } else {
             if (isset($session->route)) {
                 $session->unsetAll();
                 return $this->_helper->redirector->gotoRoute($session->params, $session->route, $session->reset);
             }
         }
         // Redirect by hook
         foreach ((array) $event->getResponses() as $response) {
             if (is_array($response)) {
                 if (!empty($response['error']) && !empty($response['message'])) {
                     return $form->addError($response['message']);
                 } else {
                     if (!empty($response['redirect'])) {
                         return $this->_helper->redirector->gotoUrl($response['redirect'], array('prependBase' => false));
                     }
                 }
             }
         }
         // Just redirect to home
         return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general', true);
     }
 }
开发者ID:hoalangoc,项目名称:ftf,代码行数:93,代码来源:SettingsController.php


注:本文中的Zend_Session::getOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。