Author: Michael Slusarz (slusarz@horde.org)
示例#1
0
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  * collection: (string) The collection to store data in.
  * mongo_db: (Horde_Mongo_Client) [REQUIRED] The Mongo client object.
  * </pre>
  */
 public function __construct(array $params = array())
 {
     if (!isset($params['mongo_db'])) {
         throw new InvalidArgumentException('Missing mongo_db parameter.');
     }
     parent::__construct(array_merge(array('collection' => 'horde_sessionhandler'), $params));
     $this->_db = $this->_params['mongo_db']->selectCollection(null, $this->_params['collection']);
 }
示例#2
0
文件: Builtin.php 项目: horde/horde
 /**
  */
 public function __construct(array $params = array())
 {
     parent::__construct($params);
     $this->_path = session_save_path();
     if (!$this->_path) {
         $this->_path = sys_get_temp_dir();
     }
 }
示例#3
0
文件: File.php 项目: raz0rsdge/horde
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  * path - (string) [REQUIRED] The path to save the files.
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     if (!isset($params['path'])) {
         throw new InvalidArgumentException('Missing path parameter.');
     }
     $params['path'] = rtrim($params['path'], '/');
     parent::__construct($params);
 }
示例#4
0
文件: Sql.php 项目: raz0rsdge/horde
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  * 'db' - (Horde_Db_Adapter) [REQUIRED] The DB instance.
  * 'table' - (string) The name of the sessions table.
  *           DEFAULT: 'horde_sessionhandler'
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     if (!isset($params['db'])) {
         throw new InvalidArgumentException('Missing db parameter.');
     }
     $this->_db = $params['db'];
     unset($params['db']);
     parent::__construct(array_merge(array('table' => 'horde_sessionhandler'), $params));
 }
示例#5
0
 /**
  * Constructor.
  *
  * @param array $params  Required parameters:
  * <pre>
  * close - (callback) See session_set_save_handler().
  * destroy - (callback) See session_set_save_handler().
  * gc - (callback) See session_set_save_handler().
  * open - (callback) See session_set_save_handler().
  * read - (callback) See session_set_save_handler().
  * write - (callback) See session_set_save_handler().
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     foreach (array('open', 'close', 'read', 'write', 'destroy', 'gc') as $val) {
         if (!isset($params[$val])) {
             throw new InvalidArgumentException('Missing parameter: ' . $val);
         }
     }
     parent::__construct($params);
 }
示例#6
0
文件: Stack.php 项目: horde/horde
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  * stack - (array) [REQUIRED] A list of storage objects to loop
  *         through, in order of priority. The last entry is considered
  *         the "master" server.
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     if (!isset($params['stack'])) {
         throw new InvalidArgumentException('Missing stack parameter.');
     }
     $this->_stack = $params['stack'];
     unset($params['stack']);
     parent::__construct($params);
 }
示例#7
0
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  *   - hashtable: (Horde_HashTable) [REQUIRED] A Horde_HashTable object.
  *   - track: (boolean) Track active sessions?
  * </pre>
  */
 public function __construct(array $params = array())
 {
     if (empty($params['hashtable'])) {
         throw new InvalidArgumentException('Missing hashtable parameter.');
     }
     if (!$params['hashtable']->locking) {
         throw new InvalidArgumentException('HashTable object must support locking.');
     }
     $this->_hash = $params['hashtable'];
     unset($params['hashtable']);
     parent::__construct($params);
     if (!empty($this->_params['track']) && !rand(0, 999)) {
         register_shutdown_function(array($this, 'trackGC'));
     }
 }
示例#8
0
文件: Memcache.php 项目: horde/horde
 /**
  * Constructor.
  *
  * @param array $params  Parameters:
  * <pre>
  * 'memcache' - (Horde_Memcache) [REQUIRED] A memcache object.
  * 'track' - (boolean) Track active sessions?
  * 'track_lifetime' - (integer) The number of seconds after which tracked
  *                    sessions will be treated as expired.
  * </pre>
  *
  * @throws InvalidArgumentException
  */
 public function __construct(array $params = array())
 {
     if (empty($params['memcache'])) {
         throw new InvalidArgumentException('Missing memcache argument.');
     }
     $this->_memcache = $params['memcache'];
     unset($params['memcache']);
     parent::__construct($params);
     if (empty($this->_params['track_lifetime'])) {
         $this->_params['track_lifetime'] = ini_get('session.gc_maxlifetime');
     }
     if (!empty($this->_params['track']) && substr(time(), -3) === '000') {
         register_shutdown_function(array($this, 'trackGC'));
     }
 }
示例#9
0
 /**
  * Get a list of the valid session identifiers.
  *
  * @return array  A list of valid session identifiers.
  * @throws Horde_SessionHandler_Exception
  */
 public function getSessionIDs()
 {
     return $this->_storage->getSessionIDs();
 }