CodeIgniter 3.1.11 -> 3.4.5 (pocketarc fork) en PHP 8.3-fixes
- system/ vervangen door CodeIgniter 3.4.5 (pocketarc/codeigniter, PHP 8.2-8.5 compatibel) - config.php, mimes.php, user_agents.php en error-views bijgewerkt naar 3.4.5 - composer.json: php-constraint "^7.4 || ^8.0" zodat composer install op 8.3 werkt - PHP 8-fatals opgelost: count()/array-functies op FALSE/null, rekenen met lege strings, delen door nul, property zetten op FALSE, curly-brace string offsets, ongedefinieerde constanten, foute curl_setopt in Phantom_model::create_img - dynamic properties gedeclareerd in libraries, optionele parameters voor verplichte opgelost - vergelijkingen waar '' == 0 in PHP 8 anders uitvalt gecast naar (int) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+9
-8
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 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
|
||||
@@ -28,9 +28,8 @@
|
||||
*
|
||||
* @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 (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @copyright Copyright (c) 2022, CodeIgniter Foundation (https://codeigniter.com/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -38,17 +37,17 @@
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* SessionHandlerInterface
|
||||
* CI_Session_driver_interface
|
||||
*
|
||||
* PHP 5.4 compatibility interface
|
||||
* A compatibility typeless SessionHandlerInterface alias
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
interface SessionHandlerInterface {
|
||||
interface CI_Session_driver_interface {
|
||||
|
||||
public function open($save_path, $name);
|
||||
public function close();
|
||||
@@ -56,4 +55,6 @@ interface SessionHandlerInterface {
|
||||
public function write($session_id, $session_data);
|
||||
public function destroy($session_id);
|
||||
public function gc($maxlifetime);
|
||||
public function updateTimestamp($session_id, $data);
|
||||
public function validateId($session_id);
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 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) 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');
|
||||
|
||||
/**
|
||||
* OldSessionWrapper
|
||||
*
|
||||
* PHP 8 Session handler compatibility wrapper, pre-PHP8 version
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_SessionWrapper implements SessionHandlerInterface, SessionUpdateTimestampHandlerInterface {
|
||||
|
||||
protected $driver;
|
||||
|
||||
public function __construct(CI_Session_driver_interface $driver)
|
||||
{
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
public function open($save_path, $name)
|
||||
{
|
||||
return $this->driver->open($save_path, $name);
|
||||
}
|
||||
|
||||
public function close()
|
||||
{
|
||||
return $this->driver->close();
|
||||
}
|
||||
|
||||
public function read($id)
|
||||
{
|
||||
return $this->driver->read($id);
|
||||
}
|
||||
|
||||
public function write($id, $data)
|
||||
{
|
||||
return $this->driver->write($id, $data);
|
||||
}
|
||||
|
||||
public function destroy($id)
|
||||
{
|
||||
return $this->driver->destroy($id);
|
||||
}
|
||||
|
||||
public function gc($maxlifetime)
|
||||
{
|
||||
return $this->driver->gc($maxlifetime);
|
||||
}
|
||||
|
||||
public function updateTimestamp($id, $data)
|
||||
{
|
||||
return $this->driver->updateTimestamp($id, $data);
|
||||
}
|
||||
|
||||
public function validateId($id)
|
||||
{
|
||||
return $this->driver->validateId($id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 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) 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');
|
||||
|
||||
/**
|
||||
* PHP8SessionWrapper
|
||||
*
|
||||
* PHP 8 Session handler compatibility wrapper
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_SessionWrapper implements SessionHandlerInterface, SessionUpdateTimestampHandlerInterface {
|
||||
|
||||
protected CI_Session_driver_interface $driver;
|
||||
|
||||
public function __construct(CI_Session_driver_interface $driver)
|
||||
{
|
||||
$this->driver = $driver;
|
||||
}
|
||||
|
||||
public function open(string $save_path, string $name): bool
|
||||
{
|
||||
return $this->driver->open($save_path, $name);
|
||||
}
|
||||
|
||||
public function close(): bool
|
||||
{
|
||||
return $this->driver->close();
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function read(string $id): mixed
|
||||
{
|
||||
return $this->driver->read($id);
|
||||
}
|
||||
|
||||
public function write(string $id, string $data): bool
|
||||
{
|
||||
return $this->driver->write($id, $data);
|
||||
}
|
||||
|
||||
public function destroy(string $id): bool
|
||||
{
|
||||
return $this->driver->destroy($id);
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function gc(int $maxlifetime): mixed
|
||||
{
|
||||
return $this->driver->gc($maxlifetime);
|
||||
}
|
||||
|
||||
public function updateTimestamp(string $id, string $data): bool
|
||||
{
|
||||
return $this->driver->updateTimestamp($id, $data);
|
||||
}
|
||||
|
||||
public function validateId(string $id): bool
|
||||
{
|
||||
return $this->driver->validateId($id);
|
||||
}
|
||||
|
||||
public function create_sid(): string
|
||||
{
|
||||
return session_create_id();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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 2.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session {
|
||||
|
||||
@@ -102,31 +103,24 @@ class CI_Session {
|
||||
$this->_configure($params);
|
||||
$this->_config['_sid_regexp'] = $this->_sid_regexp;
|
||||
|
||||
$class = new $class($this->_config);
|
||||
if ($class instanceof SessionHandlerInterface)
|
||||
$class = new $class($this->_config);
|
||||
$wrapper = new CI_SessionWrapper($class);
|
||||
if (is_php('5.4'))
|
||||
{
|
||||
if (is_php('5.4'))
|
||||
{
|
||||
session_set_save_handler($class, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
session_set_save_handler(
|
||||
array($class, 'open'),
|
||||
array($class, 'close'),
|
||||
array($class, 'read'),
|
||||
array($class, 'write'),
|
||||
array($class, 'destroy'),
|
||||
array($class, 'gc')
|
||||
);
|
||||
|
||||
register_shutdown_function('session_write_close');
|
||||
}
|
||||
session_set_save_handler($wrapper, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('error', "Session: Driver '".$this->_driver."' doesn't implement SessionHandlerInterface. Aborting.");
|
||||
return;
|
||||
session_set_save_handler(
|
||||
array($wrapper, 'open'),
|
||||
array($wrapper, 'close'),
|
||||
array($wrapper, 'read'),
|
||||
array($wrapper, 'write'),
|
||||
array($wrapper, 'destroy'),
|
||||
array($wrapper, 'gc')
|
||||
);
|
||||
|
||||
register_shutdown_function('session_write_close');
|
||||
}
|
||||
|
||||
// Sanitize the cookie, because apparently PHP doesn't do that for userspace handlers
|
||||
@@ -160,15 +154,36 @@ class CI_Session {
|
||||
// unless it is being currently created or regenerated
|
||||
elseif (isset($_COOKIE[$this->_config['cookie_name']]) && $_COOKIE[$this->_config['cookie_name']] === session_id())
|
||||
{
|
||||
setcookie(
|
||||
$this->_config['cookie_name'],
|
||||
session_id(),
|
||||
(empty($this->_config['cookie_lifetime']) ? 0 : time() + $this->_config['cookie_lifetime']),
|
||||
$this->_config['cookie_path'],
|
||||
$this->_config['cookie_domain'],
|
||||
$this->_config['cookie_secure'],
|
||||
TRUE
|
||||
);
|
||||
$expires = empty($this->_config['cookie_lifetime']) ? 0 : time() + $this->_config['cookie_lifetime'];
|
||||
if (is_php('7.3'))
|
||||
{
|
||||
setcookie(
|
||||
$this->_config['cookie_name'],
|
||||
session_id(),
|
||||
array(
|
||||
'expires' => $expires,
|
||||
'path' => $this->_config['cookie_path'],
|
||||
'domain' => $this->_config['cookie_domain'],
|
||||
'secure' => $this->_config['cookie_secure'],
|
||||
'httponly' => TRUE,
|
||||
'samesite' => $this->_config['cookie_samesite']
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$header = 'Set-Cookie: '.$this->_config['cookie_name'].'='.session_id();
|
||||
$header .= empty($expires) ? '' : '; Expires='.gmdate('D, d-M-Y H:i:s T', $expires).'; Max-Age='.$this->_config['cookie_lifetime'];
|
||||
$header .= '; Path='.$this->_config['cookie_path'];
|
||||
$header .= ($this->_config['cookie_domain'] !== '' ? '; Domain='.$this->_config['cookie_domain'] : '');
|
||||
$header .= ($this->_config['cookie_secure'] ? '; Secure' : '').'; HttpOnly; SameSite='.$this->_config['cookie_samesite'];
|
||||
header($header);
|
||||
}
|
||||
|
||||
if ( ! $this->_config['cookie_secure'] && $this->_config['cookie_samesite'] === 'None')
|
||||
{
|
||||
log_message('error', "Session: '".$this->_config['cookie_name']."' cookie sent with SameSite=None, but without Secure attribute.'");
|
||||
}
|
||||
}
|
||||
|
||||
$this->_ci_init_vars();
|
||||
@@ -190,8 +205,12 @@ 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');
|
||||
|
||||
require_once(BASEPATH.'libraries/Session/CI_Session_driver_interface.php');
|
||||
$wrapper = is_php('8.0') ? 'PHP8SessionWrapper' : 'OldSessionWrapper';
|
||||
require_once(BASEPATH.'libraries/Session/'.$wrapper.'.php');
|
||||
|
||||
$prefix = config_item('subclass_prefix');
|
||||
|
||||
@@ -286,13 +305,43 @@ class CI_Session {
|
||||
isset($params['cookie_domain']) OR $params['cookie_domain'] = config_item('cookie_domain');
|
||||
isset($params['cookie_secure']) OR $params['cookie_secure'] = (bool) config_item('cookie_secure');
|
||||
|
||||
session_set_cookie_params(
|
||||
$params['cookie_lifetime'],
|
||||
$params['cookie_path'],
|
||||
$params['cookie_domain'],
|
||||
$params['cookie_secure'],
|
||||
TRUE // HttpOnly; Yes, this is intentional and not configurable for security reasons
|
||||
);
|
||||
isset($params['cookie_samesite']) OR $params['cookie_samesite'] = config_item('sess_samesite');
|
||||
if ( ! isset($params['cookie_samesite']) && is_php('7.3'))
|
||||
{
|
||||
$params['cookie_samesite'] = ini_get('session.cookie_samesite');
|
||||
}
|
||||
|
||||
if (isset($params['cookie_samesite']))
|
||||
{
|
||||
$params['cookie_samesite'] = ucfirst(strtolower($params['cookie_samesite']));
|
||||
in_array($params['cookie_samesite'], array('Lax', 'Strict', 'None'), TRUE) OR $params['cookie_samesite'] = 'Lax';
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['cookie_samesite'] = 'Lax';
|
||||
}
|
||||
|
||||
if (is_php('7.3'))
|
||||
{
|
||||
session_set_cookie_params(array(
|
||||
'lifetime' => $params['cookie_lifetime'],
|
||||
'path' => $params['cookie_path'],
|
||||
'domain' => $params['cookie_domain'],
|
||||
'secure' => $params['cookie_secure'],
|
||||
'httponly' => TRUE,
|
||||
'samesite' => $params['cookie_samesite']
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
session_set_cookie_params(
|
||||
$params['cookie_lifetime'],
|
||||
$params['cookie_path'].'; SameSite='.$params['cookie_samesite'],
|
||||
$params['cookie_domain'],
|
||||
$params['cookie_secure'],
|
||||
TRUE // HttpOnly; Yes, this is intentional and not configurable for security reasons
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($expiration))
|
||||
{
|
||||
@@ -368,7 +417,7 @@ class CI_Session {
|
||||
{
|
||||
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
|
||||
$sid_length = (int) ini_get('session.sid_length');
|
||||
if (($bits = $sid_length * $bits_per_character) < 160)
|
||||
if (($bits = $sid_length * $bits_per_character) < 160 && version_compare(PHP_VERSION, '8.4', '<'))
|
||||
{
|
||||
// Add as many more characters as necessary to reach at least 160 bits
|
||||
$sid_length += (int) ceil((160 % $bits) / $bits_per_character);
|
||||
@@ -415,9 +464,7 @@ class CI_Session {
|
||||
{
|
||||
$_SESSION['__ci_vars'][$key] = 'old';
|
||||
}
|
||||
// Hacky, but 'old' will (implicitly) always be less than time() ;)
|
||||
// DO NOT move this above the 'new' check!
|
||||
elseif ($value < $current_time)
|
||||
elseif ($value === 'old' || $value < $current_time)
|
||||
{
|
||||
unset($_SESSION[$key], $_SESSION['__ci_vars'][$key]);
|
||||
}
|
||||
@@ -725,7 +772,7 @@ class CI_Session {
|
||||
*
|
||||
* Legacy CI_Session compatibility method
|
||||
*
|
||||
* @returns array
|
||||
* @return array
|
||||
*/
|
||||
public function &get_userdata()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
<?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');
|
||||
|
||||
/**
|
||||
* SessionUpdateTimestampHandlerInterface
|
||||
*
|
||||
* PHP 7 compatibility interface
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
interface SessionUpdateTimestampHandlerInterface {
|
||||
|
||||
public function updateTimestamp($session_id, $data);
|
||||
public function validateId($session_id);
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
abstract class CI_Session_driver {
|
||||
|
||||
protected $_config;
|
||||
|
||||
@@ -121,7 +122,7 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
*/
|
||||
public function php5_validate_id()
|
||||
{
|
||||
if (isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateSessionId($_COOKIE[$this->_config['cookie_name']]))
|
||||
if ($this->_success === 0 && isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateId($_COOKIE[$this->_config['cookie_name']]))
|
||||
{
|
||||
unset($_COOKIE[$this->_config['cookie_name']]);
|
||||
}
|
||||
@@ -139,14 +140,28 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
*/
|
||||
protected function _cookie_destroy()
|
||||
{
|
||||
if ( ! is_php('7.3'))
|
||||
{
|
||||
$header = 'Set-Cookie: '.$this->_config['cookie_name'].'=';
|
||||
$header .= '; Expires='.gmdate('D, d-M-Y H:i:s T', 1).'; Max-Age=-1';
|
||||
$header .= '; Path='.$this->_config['cookie_path'];
|
||||
$header .= ($this->_config['cookie_domain'] !== '' ? '; Domain='.$this->_config['cookie_domain'] : '');
|
||||
$header .= ($this->_config['cookie_secure'] ? '; Secure' : '').'; HttpOnly; SameSite='.$this->_config['cookie_samesite'];
|
||||
header($header);
|
||||
return;
|
||||
}
|
||||
|
||||
return setcookie(
|
||||
$this->_config['cookie_name'],
|
||||
NULL,
|
||||
1,
|
||||
$this->_config['cookie_path'],
|
||||
$this->_config['cookie_domain'],
|
||||
$this->_config['cookie_secure'],
|
||||
TRUE
|
||||
'',
|
||||
array(
|
||||
'expires' => 1,
|
||||
'path' => $this->_config['cookie_path'],
|
||||
'domain' => $this->_config['cookie_domain'],
|
||||
'secure' => $this->_config['cookie_secure'],
|
||||
'httponly' => TRUE,
|
||||
'samesite' => $this->_config['cookie_samesite']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session_database_driver extends CI_Session_driver implements SessionHandlerInterface {
|
||||
class CI_Session_database_driver extends CI_Session_driver implements CI_Session_driver_interface {
|
||||
|
||||
/**
|
||||
* DB object
|
||||
@@ -343,16 +344,41 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update Timestamp
|
||||
*
|
||||
* Update session timestamp without modifying data
|
||||
*
|
||||
* @param string $id Session ID
|
||||
* @param string $data Unknown & unused
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTimestamp($id, $unknown)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
$this->_db->where('id', $id);
|
||||
if ($this->_config['match_ip'])
|
||||
{
|
||||
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
return (bool) $this->_db->update($this->_config['save_path'], array('timestamp' => time()));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
public function validateId($id)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,11 +30,12 @@
|
||||
* @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');
|
||||
|
||||
/**
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session_files_driver extends CI_Session_driver implements SessionHandlerInterface {
|
||||
class CI_Session_files_driver extends CI_Session_driver implements CI_Session_driver_interface {
|
||||
|
||||
/**
|
||||
* Save path
|
||||
@@ -115,7 +116,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
|
||||
$this->_sid_regexp = $this->_config['_sid_regexp'];
|
||||
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
isset(self::$func_overload) OR self::$func_overload = ( ! is_php('8.0') && extension_loaded('mbstring') && @ini_get('mbstring.func_overload'));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -196,6 +197,10 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
}
|
||||
|
||||
// Prevent possible data corruption
|
||||
// See https://github.com/bcit-ci/CodeIgniter/issues/5857
|
||||
clearstatcache(TRUE, $this->_file_path.$session_id);
|
||||
}
|
||||
// We shouldn't need this, but apparently we do ...
|
||||
// See https://github.com/bcit-ci/CodeIgniter/issues/4039
|
||||
@@ -395,16 +400,32 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update Timestamp
|
||||
*
|
||||
* Update session timestamp without modifying data
|
||||
*
|
||||
* @param string $id Session ID
|
||||
* @param string $data Unknown & unused
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTimestamp($id, $unknown)
|
||||
{
|
||||
return touch($this->_file_path.$id);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
public function validateId($id)
|
||||
{
|
||||
$result = is_file($this->_file_path.$id);
|
||||
clearstatcache(TRUE, $this->_file_path.$id);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session_memcached_driver extends CI_Session_driver implements SessionHandlerInterface {
|
||||
class CI_Session_memcached_driver extends CI_Session_driver implements CI_Session_driver_interface {
|
||||
|
||||
/**
|
||||
* Memcached instance
|
||||
@@ -294,16 +295,32 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update Timestamp
|
||||
*
|
||||
* Update session timestamp without modifying data
|
||||
*
|
||||
* @param string $id Session ID
|
||||
* @param string $data Unknown & unused
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTimestamp($id, $unknown)
|
||||
{
|
||||
return $this->_memcached->touch($this->_key_prefix.$id, $this->_config['expiration']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
public function validateId($id)
|
||||
{
|
||||
$this->_memcached->get($this->_key_prefix.$id);
|
||||
return ($this->_memcached->getResultCode() === Memcached::RES_SUCCESS);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* 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
|
||||
@@ -30,6 +30,7 @@
|
||||
* @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
|
||||
@@ -44,9 +45,9 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Sessions
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/sessions.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/sessions.html
|
||||
*/
|
||||
class CI_Session_redis_driver extends CI_Session_driver implements SessionHandlerInterface {
|
||||
class CI_Session_redis_driver extends CI_Session_driver implements CI_Session_driver_interface {
|
||||
|
||||
/**
|
||||
* phpRedis instance
|
||||
@@ -133,27 +134,40 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
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] : 0.0;
|
||||
|
||||
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'].':';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,23 +190,34 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
}
|
||||
|
||||
$redis = new Redis();
|
||||
if ( ! $redis->connect($this->_config['save_path']['host'], $this->_config['save_path']['port'], $this->_config['save_path']['timeout']))
|
||||
$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 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']))
|
||||
{
|
||||
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
|
||||
{
|
||||
$this->_redis = $redis;
|
||||
$this->php5_validate_id();
|
||||
return $this->_success;
|
||||
log_message('error', 'Session: Unable to connect to Redis with the configured settings.');
|
||||
}
|
||||
|
||||
return $this->_failure;
|
||||
@@ -354,16 +379,32 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Update Timestamp
|
||||
*
|
||||
* Update session timestamp without modifying data
|
||||
*
|
||||
* @param string $id Session ID
|
||||
* @param string $data Unknown & unused
|
||||
* @return bool
|
||||
*/
|
||||
public function updateTimestamp($id, $unknown)
|
||||
{
|
||||
return $this->_redis->{$this->_setTimeout_name}($this->_key_prefix.$id, $this->_config['expiration']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @param string $id Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
public function validateId($id)
|
||||
{
|
||||
return (bool) $this->_redis->exists($this->_key_prefix.$id);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user