/**
* 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'] . ':';
}
}
}