Пример #1
0
 /**
  * @return Enlight_Components_Session_Namespace
  */
 public function initSession()
 {
     $configSession = array_merge(array('name' => 'ENLIGHTSID', 'cookie_lifetime' => 0, 'use_trans_sid' => 0, 'gc_probability' => 1), (array) $this->Application()->getOption('session'));
     Enlight_Components_Session::start($configSession);
     $this->registerResource('SessionId', Enlight_Components_Session::getId());
     $namespace = new Enlight_Components_Session_Namespace('Default');
     return $namespace;
 }
Пример #2
0
 /**
  * Set some properties only available at runtime
  */
 public function __construct()
 {
     parent::__construct();
     // Add conditions to user queries
     foreach ($this->conditions as $condition) {
         $this->addCondition($condition);
     }
     $this->setSessionId(Enlight_Components_Session::getId());
 }
Пример #3
0
 /**
  * @param Enlight_Controller_Request_Request $request
  */
 public function refreshBasket($request)
 {
     $currentController = $request->getParam('requestController', $request->getControllerName());
     $sessionId = (string) Enlight_Components_Session::getId();
     if (!empty($currentController) && !empty($sessionId)) {
         $userId = (int) Shopware()->Session()->sUserId;
         $userAgent = (string) $request->getServer("HTTP_USER_AGENT");
         $sql = "\n                UPDATE s_order_basket\n                SET lastviewport = ?,\n                    useragent = ?,\n                    userID = ?\n                WHERE sessionID=?\n            ";
         Shopware()->Db()->query($sql, array($currentController, $userAgent, $userId, $sessionId));
     }
 }
Пример #4
0
 /**
  * authenticate() - defined by Zend_Auth_Adapter_Interface.  This method is called to
  * attempt an authentication.  Previous to this call, this adapter would have already
  * been configured with all necessary information to successfully connect to a database
  * table and attempt to find a record matching the provided identity.
  *
  * @throws Zend_Auth_Adapter_Exception if answering the authentication query is impossible
  * @return Zend_Auth_Result
  */
 public function authenticate()
 {
     $result = parent::authenticate();
     $select = $this->_zendDb->select();
     $select->from($this->_tableName);
     $select->where($this->_zendDb->quoteIdentifier($this->_identityColumn, true) . ' = ?', $this->_identity);
     $user = $this->_zendDb->fetchRow($select, array(), Zend_Db::FETCH_OBJ);
     if ($result->isValid()) {
         // Check if user role is active
         $sql = 'SELECT enabled FROM s_core_auth_roles WHERE id = ?';
         if ($this->_zendDb->fetchOne($sql, array($user->roleID)) == false) {
             return new Zend_Auth_Result(Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND, $this->_identity, array());
         }
         Enlight_Components_Session::regenerateId();
         // close and restart session to make sure the db session handler writes updates.
         session_write_close();
         session_start();
         $this->setSessionId(Enlight_Components_Session::getId());
         $this->updateExpiry();
         $this->updateSessionId();
         //reset failed login count
         $this->setFailedLogins(0);
     } else {
         // If more then 4 previous failed logins lock account for n * failedlogins seconds
         if ($user->failedlogins >= 4) {
             $lockedUntil = new Zend_Date();
             $lockedUntil->addSecond($this->lockSeconds * $user->failedlogins);
             $this->setLockedUntil($lockedUntil);
         }
         // Increase number of failed logins
         $this->setFailedLogins($user->failedlogins + 1);
         if (isset($lockedUntil)) {
             return new Zend_Auth_Result(-4, $this->_identity, array('lockedUntil' => $lockedUntil));
         }
     }
     return $result;
 }
Пример #5
0
    /**
     * Init session method
     *
     * @return Enlight_Components_Session_Namespace
     */
    protected function initSession()
    {
        $sessionOptions = $this->Application()->getOption('session', array());

        if (!empty($sessionOptions['unitTestEnabled'])) {
            Enlight_Components_Session::$_unitTestEnabled = true;
        }
        unset($sessionOptions['unitTestEnabled']);

        if (Enlight_Components_Session::isStarted()) {
            Enlight_Components_Session::writeClose();
        }

        /** @var $shop \Shopware\Models\Shop\Shop */
        $shop = $this->getResource('Shop');

        $name = 'session-' . $shop->getId();
        //$path = rtrim($shop->getBasePath(), '/') . '/';
        //$host = $shop->getHost();
        //$host = $host === 'localhost' ? null : $host;

        $sessionOptions['name'] = $name;
        //$sessionOptions['cookie_path'] = $path;
        //$sessionOptions['cookie_domain'] = $host;

        if (!isset($sessionOptions['save_handler']) || $sessionOptions['save_handler'] == 'db') {
            $config_save_handler = array(
                'db'			 => $this->getResource('Db'),
                'name'           => 's_core_sessions',
                'primary'        => 'id',
                'modifiedColumn' => 'modified',
                'dataColumn'     => 'data',
                'lifetimeColumn' => 'expiry'
            );
            Enlight_Components_Session::setSaveHandler(
                new Enlight_Components_Session_SaveHandler_DbTable($config_save_handler)
            );
            unset($sessionOptions['save_handler']);
        }

        Enlight_Components_Session::start($sessionOptions);

        $this->registerResource('SessionID', Enlight_Components_Session::getId());

        $namespace = new Enlight_Components_Session_Namespace('Shopware');

        return $namespace;
    }
Пример #6
-1
 /**
  * @param Container $container
  * @return \Enlight_Components_Session_Namespace
  */
 public function factory(Container $container)
 {
     $sessionOptions = Shopware()->getOption('session', array());
     if (!empty($sessionOptions['unitTestEnabled'])) {
         \Enlight_Components_Session::$_unitTestEnabled = true;
     }
     unset($sessionOptions['unitTestEnabled']);
     if (\Enlight_Components_Session::isStarted()) {
         \Enlight_Components_Session::writeClose();
     }
     /** @var $shop \Shopware\Models\Shop\Shop */
     $shop = $container->get('Shop');
     $name = 'session-' . $shop->getId();
     $sessionOptions['name'] = $name;
     if (!isset($sessionOptions['save_handler']) || $sessionOptions['save_handler'] == 'db') {
         $config_save_handler = array('db' => $container->get('Db'), 'name' => 's_core_sessions', 'primary' => 'id', 'modifiedColumn' => 'modified', 'dataColumn' => 'data', 'lifetimeColumn' => 'expiry');
         \Enlight_Components_Session::setSaveHandler(new \Enlight_Components_Session_SaveHandler_DbTable($config_save_handler));
         unset($sessionOptions['save_handler']);
     }
     \Enlight_Components_Session::start($sessionOptions);
     $container->set('SessionID', \Enlight_Components_Session::getId());
     $namespace = new \Enlight_Components_Session_Namespace('Shopware');
     $namespace->offsetSet('sessionId', \Enlight_Components_Session::getId());
     return $namespace;
 }