summaryrefslogtreecommitdiffstats
path: root/system/libraries/Session
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries/Session')
-rw-r--r--system/libraries/Session/Session.php2
-rw-r--r--system/libraries/Session/SessionHandlerInterface.php60
-rw-r--r--system/libraries/Session/drivers/Session_redis_driver.php70
-rw-r--r--system/libraries/Session/drivers/index.html2
-rw-r--r--system/libraries/Session/index.html2
5 files changed, 50 insertions, 86 deletions
diff --git a/system/libraries/Session/Session.php b/system/libraries/Session/Session.php
index a211ce31b..2d55f822a 100644
--- a/system/libraries/Session/Session.php
+++ b/system/libraries/Session/Session.php
@@ -205,8 +205,6 @@ class CI_Session {
*/
protected function _ci_load_classes($driver)
{
- // PHP 5.4 compatibility
- interface_exists('SessionHandlerInterface', FALSE) OR require_once(BASEPATH.'libraries/Session/SessionHandlerInterface.php');
// PHP 7 compatibility
interface_exists('SessionUpdateTimestampHandlerInterface', FALSE) OR require_once(BASEPATH.'libraries/Session/SessionUpdateTimestampHandlerInterface.php');
diff --git a/system/libraries/Session/SessionHandlerInterface.php b/system/libraries/Session/SessionHandlerInterface.php
deleted file mode 100644
index eadb63c1a..000000000
--- a/system/libraries/Session/SessionHandlerInterface.php
+++ /dev/null
@@ -1,60 +0,0 @@
-<?php
-/**
- * CodeIgniter
- *
- * An open source application development framework for PHP
- *
- * This content is released under the MIT License (MIT)
- *
- * Copyright (c) 2019 - 2022, CodeIgniter Foundation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- * @package CodeIgniter
- * @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
- * @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (https://bcit.ca/)
- * @copyright Copyright (c) 2019 - 2022, CodeIgniter Foundation (https://codeigniter.com/)
- * @license https://opensource.org/licenses/MIT MIT License
- * @link https://codeigniter.com
- * @since Version 3.0.0
- * @filesource
- */
-defined('BASEPATH') OR exit('No direct script access allowed');
-
-/**
- * SessionHandlerInterface
- *
- * PHP 5.4 compatibility interface
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Sessions
- * @author Andrey Andreev
- * @link https://codeigniter.com/userguide3/libraries/sessions.html
- */
-interface SessionHandlerInterface {
-
- public function open($save_path, $name);
- public function close();
- public function read($session_id);
- public function write($session_id, $session_data);
- public function destroy($session_id);
- public function gc($maxlifetime);
-}
diff --git a/system/libraries/Session/drivers/Session_redis_driver.php b/system/libraries/Session/drivers/Session_redis_driver.php
index 269dfcd64..4d822d585 100644
--- a/system/libraries/Session/drivers/Session_redis_driver.php
+++ b/system/libraries/Session/drivers/Session_redis_driver.php
@@ -134,27 +134,40 @@ class CI_Session_redis_driver extends CI_Session_driver implements CI_Session_dr
{
log_message('error', 'Session: No Redis save path configured.');
}
- elseif (preg_match('#(?:tcp://)?([^:?]+)(?:\:(\d+))?(\?.+)?#', $this->_config['save_path'], $matches))
+ elseif (preg_match('#^unix://([^\?]+)(?<options>\?.+)?$#', $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) ? (float) $match[1] : NULL
+ $save_path = array('path' => $matches[1]);
+ }
+ elseif (preg_match('#(?:(?:tcp|tls)://)?([^:?]+)(?:\:(\d+))?(?<options>\?.+)?#', $this->_config['save_path'], $matches))
+ {
+ $save_path = array(
+ 'host' => $matches[1],
+ 'port' => empty($matches[2]) ? NULL : $matches[2],
+ 'timeout' => 0.0 // We always pass this to Redis::connect(), so it needs to exist
);
-
- 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)
+ if (isset($save_path))
{
- $this->_key_prefix .= $_SERVER['REMOTE_ADDR'].':';
+ 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) ? (float) $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'].':';
+ }
}
}
@@ -177,17 +190,30 @@ class CI_Session_redis_driver extends CI_Session_driver implements CI_Session_dr
}
$redis = new Redis();
- if ( ! $redis->connect($this->_config['save_path']['host'], $this->_config['save_path']['port'], $this->_config['save_path']['timeout']))
- {
- log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
- }
- elseif (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
- {
- log_message('error', 'Session: Unable to authenticate to Redis instance.');
- }
- elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
+ $connected = isset($this->_config['save_path']['path'])
+ ? $redis->connect($this->_config['save_path']['path'])
+ : $redis->connect(
+ $this->_config['save_path']['host'],
+ $this->_config['save_path']['port'],
+ $this->_config['save_path']['timeout']
+ );
+
+ if ($connected)
{
- log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
+ if (isset($this->_config['save_path']['password']) && ! $redis->auth($this->_config['save_path']['password']))
+ {
+ log_message('error', 'Session: Unable to authenticate to Redis instance.');
+ }
+ elseif (isset($this->_config['save_path']['database']) && ! $redis->select($this->_config['save_path']['database']))
+ {
+ log_message('error', 'Session: Unable to select Redis database with index '.$this->_config['save_path']['database']);
+ }
+ else
+ {
+ $this->_redis = $redis;
+ $this->php5_validate_id();
+ return $this->_success;
+ }
}
else
{
diff --git a/system/libraries/Session/drivers/index.html b/system/libraries/Session/drivers/index.html
index b702fbc39..bcb7cae34 100644
--- a/system/libraries/Session/drivers/index.html
+++ b/system/libraries/Session/drivers/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html lang="en">
<head>
<title>403 Forbidden</title>
</head>
diff --git a/system/libraries/Session/index.html b/system/libraries/Session/index.html
index b702fbc39..bcb7cae34 100644
--- a/system/libraries/Session/index.html
+++ b/system/libraries/Session/index.html
@@ -1,5 +1,5 @@
<!DOCTYPE html>
-<html>
+<html lang="en">
<head>
<title>403 Forbidden</title>
</head>