本文整理汇总了PHP中CI_Session_driver::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP CI_Session_driver::__construct方法的具体用法?PHP CI_Session_driver::__construct怎么用?PHP CI_Session_driver::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CI_Session_driver
的用法示例。
在下文中一共展示了CI_Session_driver::__construct方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (empty($this->_config['save_path'])) {
log_message('error', 'Session: No Redis save path configured.');
} elseif (preg_match('#^unix://([^\\?]+)(?<options>\\?.+)?$#', $this->_config['save_path'], $matches)) {
$save_path = array('path' => $matches[1]);
} elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\\:(\\d+))?(?<options>\\?.+)?#', $this->_config['save_path'], $matches)) {
$save_path = array('host' => $matches[1], 'port' => empty($matches[2]) ? NULL : $matches[2]);
} else {
log_message('error', 'Session: Invalid Redis save path format: ' . $this->_config['save_path']);
}
if (isset($save_path)) {
if (isset($matches['options'])) {
$save_path['password'] = preg_match('#auth=([^\\s&]+)#', $matches['options'], $match) ? $match[1] : NULL;
$save_path['database'] = preg_match('#database=(\\d+)#', $matches['options'], $match) ? (int) $match[1] : NULL;
$save_path['timeout'] = preg_match('#timeout=(\\d+\\.\\d+)#', $matches['options'], $match) ? (double) $match[1] : NULL;
preg_match('#prefix=([^\\s&]+)#', $matches['options'], $match) && ($this->_key_prefix = $match[1]);
}
$this->_config['save_path'] = $save_path;
if ($this->_config['match_ip'] === TRUE) {
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'] . ':';
}
}
}
示例2: __construct
/**
* Session Constructor
*
* The constructor runs the session routines automatically
* whenever the class is instantiated.
*
* For MongoDB, this loads custom config and MongoDB active record lib
*/
public function __construct(&$params)
{
parent::__construct($params);
// Set the super object to a local variable for use throughout the class
$this->CI =& get_instance();
$this->CI->benchmark->mark('SESSION_start');
// Load config directives
$this->CI->config->load($this->_config_file);
$config = $this->CI->config->item('default');
$this->_config['sess_use_mongodb'] = $config['sess_use_mongodb'];
$this->_config['sess_collection_name'] = $config['sess_collection_name'];
$this->_use_mongodb = TRUE;
// Set all the session preferences, which can either be set
// manually via the $params array above or via the config file
foreach (array('sess_encrypt_cookie', 'sess_use_database', 'sess_table_name', 'sess_expiration', 'sess_expire_on_close', 'sess_match_ip', 'sess_match_useragent', 'sess_cookie_name', 'cookie_path', 'cookie_domain', 'cookie_secure', 'sess_time_to_update', 'time_reference', 'cookie_prefix', 'encryption_key') as $key) {
$this->{$key} = isset($params[$key]) ? $params[$key] : $this->CI->config->item($key);
}
$this->CI->load->library('mongo_db');
// Set the "now" time. Can either be GMT or server time, based on the
// config prefs. We use this to set the "last activity" time
$this->now = time();
// Set the session length. If the session expiration is
// set to zero we'll set the expiration two years from now.
if ($this->sess_expiration == 0) {
$this->sess_expiration = 60 * 60 * 24 * 365 * 2;
}
// Set the cookie name
$this->sess_cookie_name = $this->cookie_prefix . $this->sess_cookie_name;
}
示例3: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (empty($this->_config['save_path'])) {
}
if ($this->_config['match_ip'] === TRUE) {
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'] . ':';
}
}
示例4: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (empty($this->_config['save_path'])) {
log_message('error', 'Session: No Memcached save path configured.');
}
if ($this->_config['match_ip'] === TRUE) {
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'] . ':';
}
}
示例5: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (isset($this->_config['save_path'])) {
$this->_config['save_path'] = rtrim($this->_config['save_path'], '/\\');
ini_set('session.save_path', $this->_config['save_path']);
} else {
$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
}
}
示例6: __construct
/**
* Class constructor.
*
* @param array $params Configuration parameters
*
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (isset($this->_config['save_path'])) {
$this->_config['save_path'] = rtrim($this->_config['save_path'], '/\\');
ini_set('session.save_path', $this->_config['save_path']);
} else {
log_message('debug', 'Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.');
$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
}
}
示例7: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
// DO NOT forget this
parent::__construct($params);
//mongo PECL driver loaded ??
if (!class_exists('Mongo') && !class_exists('MongoClient')) {
show_error("The MongoDB PECL extension has not been installed or enabled", 500);
}
// Configuration & other initializations
$CI =& get_instance();
$CI->config->load('session_mongo');
$this->_build_config($CI);
}
示例8: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (empty($this->_config['save_path'])) {
} elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\\:(\\d+))?(\\?.+)?#', $this->_config['save_path'], $matches)) {
isset($matches[3]) or $matches[3] = '';
// Just to avoid undefined index notices below
$this->_config['save_path'] = array('host' => $matches[1], 'port' => empty($matches[2]) ? NULL : $matches[2], 'password' => preg_match('#auth=([^\\s&]+)#', $matches[3], $match) ? $match[1] : NULL, 'database' => preg_match('#database=(\\d+)#', $matches[3], $match) ? (int) $match[1] : NULL, 'timeout' => preg_match('#timeout=(\\d+\\.\\d+)#', $matches[3], $match) ? (double) $match[1] : NULL);
preg_match('#prefix=([^\\s&]+)#', $matches[3], $match) && ($this->_key_prefix = $match[1]);
} else {
}
if ($this->_config['match_ip'] === TRUE) {
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'] . ':';
}
}
示例9: __construct
/**
* Class constructor.
*
* @param array $params Configuration parameters
*
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (empty($this->_config['save_path'])) {
log_message('error', 'Session: No Redis save path configured.');
} elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\\:(\\d+))?(\\?.+)?#', $this->_config['save_path'], $matches)) {
isset($matches[3]) or $matches[3] = '';
// Just to avoid undefined index notices below
$this->_config['save_path'] = ['host' => $matches[1], 'port' => empty($matches[2]) ? null : $matches[2], 'password' => preg_match('#auth=([^\\s&]+)#', $matches[3], $match) ? $match[1] : null, 'database' => preg_match('#database=(\\d+)#', $matches[3], $match) ? (int) $match[1] : null, 'timeout' => preg_match('#timeout=(\\d+\\.\\d+)#', $matches[3], $match) ? (double) $match[1] : null];
preg_match('#prefix=([^\\s&]+)#', $matches[3], $match) && ($this->_key_prefix = $match[1]);
} else {
log_message('error', 'Session: Invalid Redis save path format: ' . $this->_config['save_path']);
}
if ($this->_config['match_ip'] === true) {
$this->_key_prefix .= $_SERVER['REMOTE_ADDR'] . ':';
}
}
示例10: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
$CI =& get_instance();
isset($CI->db) or $CI->load->database();
$this->_db = $CI->db;
if (!$this->_db instanceof CI_DB_query_builder) {
throw new Exception('Query Builder not enabled for the configured database. Aborting.');
} elseif ($this->_db->pconnect) {
throw new Exception('Configured database connection is persistent. Aborting.');
}
$db_driver = $this->_db->dbdriver . (empty($this->_db->subdriver) ? '' : '_' . $this->_db->subdriver);
if (strpos($db_driver, 'mysql') !== FALSE) {
$this->_platform = 'mysql';
} elseif (in_array($db_driver, array('postgre', 'pdo_pgsql'), TRUE)) {
$this->_platform = 'postgre';
}
// Note: BC work-around for the old 'sess_table_name' setting, should be removed in the future.
isset($this->_config['save_path']) or $this->_config['save_path'] = config_item('sess_table_name');
}
示例11: __construct
/**
* Class constructor.
*
* @param array $params Configuration parameters
*
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
$CI =& get_instance();
isset($CI->db) or $CI->load->database();
$this->_db = $CI->db;
if (!$this->_db instanceof CI_DB_query_builder) {
throw new Exception('Query Builder not enabled for the configured database. Aborting.');
} elseif ($this->_db->pconnect) {
throw new Exception('Configured database connection is persistent. Aborting.');
} elseif ($this->_db->cache_on) {
throw new Exception('Configured database connection has cache enabled. Aborting.');
}
$db_driver = $this->_db->dbdriver . (empty($this->_db->subdriver) ? '' : '_' . $this->_db->subdriver);
if (strpos($db_driver, 'mysql') !== false) {
$this->_platform = 'mysql';
} elseif (in_array($db_driver, ['postgre', 'pdo_pgsql'], true)) {
$this->_platform = 'postgre';
}
// Note: BC work-around for the old 'sess_table_name' setting, should be removed in the future.
if (!isset($this->_config['save_path']) && ($this->_config['save_path'] = config_item('sess_table_name'))) {
log_message('debug', 'Session: "sess_save_path" is empty; using BC fallback to "sess_table_name".');
}
}
示例12: __construct
/**
* Class constructor
*
* @param array $params Configuration parameters
* @return void
*/
public function __construct(&$params)
{
parent::__construct($params);
if (isset($this->_config['save_path'])) {
$this->_config['save_path'] = rtrim($this->_config['save_path'], '/\\');
ini_set('session.save_path', $this->_config['save_path']);
} else {
log_message('debug', 'Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.');
$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
}
$this->_sid_regexp = $this->_config['_sid_regexp'];
isset(self::$func_override) or self::$func_override = extension_loaded('mbstring') && ini_get('mbstring.func_override');
}