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:
@@ -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
|
||||
@@ -55,6 +56,7 @@ class CI_Cache extends CI_Driver_Library {
|
||||
*/
|
||||
protected $valid_drivers = array(
|
||||
'apc',
|
||||
'apcu',
|
||||
'dummy',
|
||||
'file',
|
||||
'memcached',
|
||||
@@ -252,4 +254,16 @@ class CI_Cache extends CI_Driver_Library {
|
||||
|
||||
return $support[$driver];
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get currently loaded driver
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_loaded_driver()
|
||||
{
|
||||
return $this->_adapter;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -160,10 +161,10 @@ class CI_Cache_apc extends CI_Driver {
|
||||
* @param string user/filehits
|
||||
* @return mixed array on success, false on failure
|
||||
*/
|
||||
public function cache_info($type = NULL)
|
||||
{
|
||||
return apc_cache_info($type);
|
||||
}
|
||||
public function cache_info($type = NULL)
|
||||
{
|
||||
return apc_cache_info($type);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.2.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CodeIgniter APCu Caching Class
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Core
|
||||
* @author CodeIgniter Dev team
|
||||
*/
|
||||
class CI_Cache_apcu extends CI_Driver {
|
||||
|
||||
/**
|
||||
* Class constructor
|
||||
*
|
||||
* Only present so that an error message is logged
|
||||
* if APCu is not available.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if ( ! $this->is_supported())
|
||||
{
|
||||
log_message('error', 'Cache: Failed to initialize APCu; extension not loaded/enabled?');
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get
|
||||
*
|
||||
* Look for a value in the cache. If it exists, return the data
|
||||
* if not, return FALSE
|
||||
*
|
||||
* @param string
|
||||
* @return mixed value that is stored/FALSE on failure
|
||||
*/
|
||||
public function get($id)
|
||||
{
|
||||
$success = FALSE;
|
||||
$data = apcu_fetch($id, $success);
|
||||
|
||||
if ($success === TRUE)
|
||||
{
|
||||
return is_array($data)
|
||||
? $data[0]
|
||||
: $data;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Cache Save
|
||||
*
|
||||
* @param string $id Cache ID
|
||||
* @param mixed $data Data to store
|
||||
* @param int $ttl Length of time (in seconds) to cache the data
|
||||
* @param bool $raw Whether to store the raw value
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
public function save($id, $data, $ttl = 60, $raw = FALSE)
|
||||
{
|
||||
$ttl = (int) $ttl;
|
||||
|
||||
return apcu_store(
|
||||
$id,
|
||||
($raw === TRUE ? $data : array($data, time(), $ttl)),
|
||||
$ttl
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Delete from Cache
|
||||
*
|
||||
* @param mixed unique identifier of the item in the cache
|
||||
* @return bool true on success/false on failure
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return apcu_delete($id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Increment a raw value
|
||||
*
|
||||
* @param string $id Cache ID
|
||||
* @param int $offset Step/value to add
|
||||
* @return mixed New value on success or FALSE on failure
|
||||
*/
|
||||
public function increment($id, $offset = 1)
|
||||
{
|
||||
return apcu_inc($id, $offset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decrement a raw value
|
||||
*
|
||||
* @param string $id Cache ID
|
||||
* @param int $offset Step/value to reduce by
|
||||
* @return mixed New value on success or FALSE on failure
|
||||
*/
|
||||
public function decrement($id, $offset = 1)
|
||||
{
|
||||
return apcu_dec($id, $offset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Clean the cache
|
||||
*
|
||||
* @return bool false on failure/true on success
|
||||
*/
|
||||
public function clean()
|
||||
{
|
||||
return apcu_clear_cache();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Cache Info
|
||||
*
|
||||
* @return mixed array on success, false on failure
|
||||
*/
|
||||
public function cache_info()
|
||||
{
|
||||
return apcu_cache_info();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Cache Metadata
|
||||
*
|
||||
* @param mixed key to get cache metadata on
|
||||
* @return mixed array on success/false on failure
|
||||
*/
|
||||
public function get_metadata($id)
|
||||
{
|
||||
$success = FALSE;
|
||||
$stored = apcu_fetch($id, $success);
|
||||
|
||||
if ($success === FALSE OR count($stored) !== 3)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
list($data, $time, $ttl) = $stored;
|
||||
|
||||
return array(
|
||||
'expire' => $time + $ttl,
|
||||
'mtime' => $time,
|
||||
'data' => $data
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* is_supported()
|
||||
*
|
||||
* Check to see if APCu is available on this system, bail if it isn't.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function is_supported()
|
||||
{
|
||||
return (extension_loaded('apcu') && ini_get('apc.enabled'));
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -138,10 +139,10 @@ class CI_Cache_dummy extends CI_Driver {
|
||||
* @param string user/filehits
|
||||
* @return bool FALSE
|
||||
*/
|
||||
public function cache_info($type = NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
public function cache_info($type = NULL)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
@@ -102,10 +103,22 @@ class CI_Cache_memcached extends CI_Driver {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($this->_config as $cache_server)
|
||||
foreach ($this->_config as $cache_name => $cache_server)
|
||||
{
|
||||
isset($cache_server['hostname']) OR $cache_server['hostname'] = $defaults['host'];
|
||||
isset($cache_server['port']) OR $cache_server['port'] = $defaults['port'];
|
||||
if ( ! isset($cache_server['hostname']))
|
||||
{
|
||||
log_message('debug', 'Cache: Memcache(d) configuration "'.$cache_name.'" doesn\'t include a hostname; ignoring.');
|
||||
continue;
|
||||
}
|
||||
elseif ($cache_server['hostname'][0] === '/')
|
||||
{
|
||||
$cache_server['port'] = 0;
|
||||
}
|
||||
elseif (empty($cache_server['port']))
|
||||
{
|
||||
$cache_server['port'] = $defaults['port'];
|
||||
}
|
||||
|
||||
isset($cache_server['weight']) OR $cache_server['weight'] = $defaults['weight'];
|
||||
|
||||
if ($this->_memcached instanceof Memcache)
|
||||
|
||||
@@ -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
|
||||
@@ -55,11 +56,11 @@ class CI_Cache_redis extends CI_Driver
|
||||
* @var array
|
||||
*/
|
||||
protected static $_default_config = array(
|
||||
'socket_type' => 'tcp',
|
||||
'host' => '127.0.0.1',
|
||||
'password' => NULL,
|
||||
'port' => 6379,
|
||||
'timeout' => 0
|
||||
'timeout' => 0.0,
|
||||
'database' => 0
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -69,13 +70,6 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
protected $_redis;
|
||||
|
||||
/**
|
||||
* An internal cache for storing keys of serialized values.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_serialized = array();
|
||||
|
||||
/**
|
||||
* del()/delete() method name depending on phpRedis version
|
||||
*
|
||||
@@ -83,6 +77,13 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
protected static $_delete_name;
|
||||
|
||||
/**
|
||||
* sRem()/sRemove() method name depending on phpRedis version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_sRemove_name;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -94,6 +95,7 @@ class CI_Cache_redis extends CI_Driver
|
||||
* if a Redis connection can't be established.
|
||||
*
|
||||
* @return void
|
||||
* @throws RedisException
|
||||
* @see Redis::connect()
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -104,9 +106,19 @@ class CI_Cache_redis extends CI_Driver
|
||||
return;
|
||||
}
|
||||
|
||||
isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('phpredis'), '5', '>=')
|
||||
? 'del'
|
||||
: 'delete';
|
||||
if ( ! isset(static::$_delete_name, static::$_sRemove_name))
|
||||
{
|
||||
if (version_compare(phpversion('redis'), '5', '>='))
|
||||
{
|
||||
static::$_delete_name = 'del';
|
||||
static::$_sRemove_name = 'sRem';
|
||||
}
|
||||
else
|
||||
{
|
||||
static::$_delete_name = 'delete';
|
||||
static::$_sRemove_name = 'sRemove';
|
||||
}
|
||||
}
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
@@ -121,30 +133,21 @@ class CI_Cache_redis extends CI_Driver
|
||||
|
||||
$this->_redis = new Redis();
|
||||
|
||||
try
|
||||
// The following calls used to be wrapped in a try ... catch
|
||||
// and just log an error, but that only causes more errors later.
|
||||
if ( ! $this->_redis->connect($config['host'], ($config['host'][0] === '/' ? 0 : $config['port']), $config['timeout']))
|
||||
{
|
||||
if ($config['socket_type'] === 'unix')
|
||||
{
|
||||
$success = $this->_redis->connect($config['socket']);
|
||||
}
|
||||
else // tcp socket
|
||||
{
|
||||
$success = $this->_redis->connect($config['host'], $config['port'], $config['timeout']);
|
||||
}
|
||||
|
||||
if ( ! $success)
|
||||
{
|
||||
log_message('error', 'Cache: Redis connection failed. Check your configuration.');
|
||||
}
|
||||
|
||||
if (isset($config['password']) && ! $this->_redis->auth($config['password']))
|
||||
{
|
||||
log_message('error', 'Cache: Redis authentication failed.');
|
||||
}
|
||||
log_message('error', 'Cache: Redis connection failed. Check your configuration.');
|
||||
}
|
||||
catch (RedisException $e)
|
||||
|
||||
if (isset($config['password']) && ! $this->_redis->auth($config['password']))
|
||||
{
|
||||
log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')');
|
||||
log_message('error', 'Cache: Redis authentication failed.');
|
||||
}
|
||||
|
||||
if (isset($config['database']) && $config['database'] > 0 && ! $this->_redis->select($config['database']))
|
||||
{
|
||||
log_message('error', 'Cache: Redis select database failed.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,14 +161,30 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
public function get($key)
|
||||
{
|
||||
$value = $this->_redis->get($key);
|
||||
$data = $this->_redis->hMGet($key, array('__ci_type', '__ci_value'));
|
||||
|
||||
if ($value !== FALSE && $this->_redis->sIsMember('_ci_redis_serialized', $key))
|
||||
if ($data === FALSE || $this->_redis->sIsMember('_ci_redis_serialized', $key))
|
||||
{
|
||||
return unserialize($value);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $value;
|
||||
switch ($data['__ci_type'])
|
||||
{
|
||||
case 'array':
|
||||
case 'object':
|
||||
return unserialize($data['__ci_value']);
|
||||
case 'boolean':
|
||||
case 'integer':
|
||||
case 'double': // Yes, 'double' is returned and NOT 'float'
|
||||
case 'string':
|
||||
case 'NULL':
|
||||
return settype($data['__ci_value'], $data['__ci_type'])
|
||||
? $data['__ci_value']
|
||||
: FALSE;
|
||||
case 'resource':
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -181,22 +200,34 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
public function save($id, $data, $ttl = 60, $raw = FALSE)
|
||||
{
|
||||
if (is_array($data) OR is_object($data))
|
||||
switch ($data_type = gettype($data))
|
||||
{
|
||||
if ( ! $this->_redis->sIsMember('_ci_redis_serialized', $id) && ! $this->_redis->sAdd('_ci_redis_serialized', $id))
|
||||
{
|
||||
case 'array':
|
||||
case 'object':
|
||||
$data = serialize($data);
|
||||
break;
|
||||
case 'boolean':
|
||||
case 'integer':
|
||||
case 'double': // Yes, 'double' is returned and NOT 'float'
|
||||
case 'string':
|
||||
case 'NULL':
|
||||
break;
|
||||
case 'resource':
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
isset($this->_serialized[$id]) OR $this->_serialized[$id] = TRUE;
|
||||
$data = serialize($data);
|
||||
if ( ! $this->_redis->hMSet($id, array('__ci_type' => $data_type, '__ci_value' => $data)))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_redis->sRemove('_ci_redis_serialized', $id);
|
||||
$this->_redis->expireAt($id, time() + $ttl);
|
||||
$this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $id);
|
||||
}
|
||||
|
||||
return $this->_redis->set($id, $data, $ttl);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -214,7 +245,7 @@ class CI_Cache_redis extends CI_Driver
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_redis->sRemove('_ci_redis_serialized', $key);
|
||||
$this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $key);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -41,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* CodeIgniter Wincache Caching Class
|
||||
*
|
||||
* Read more about Wincache functions here:
|
||||
* http://www.php.net/manual/en/ref.wincache.php
|
||||
* https://www.php.net/manual/en/ref.wincache.php
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
@@ -169,10 +170,10 @@ class CI_Cache_wincache extends CI_Driver {
|
||||
*
|
||||
* @return mixed array on success, false on failure
|
||||
*/
|
||||
public function cache_info()
|
||||
{
|
||||
return wincache_ucache_info(TRUE);
|
||||
}
|
||||
public function cache_info()
|
||||
{
|
||||
return wincache_ucache_info(TRUE);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/calendar.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/calendar.html
|
||||
*/
|
||||
class CI_Calendar {
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -29,8 +29,9 @@
|
||||
* @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) 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 1.0.0
|
||||
* @filesource
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Shopping Cart
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/cart.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/cart.html
|
||||
* @deprecated 3.0.0 This class is too specific for CI.
|
||||
*/
|
||||
class CI_Cart {
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -49,6 +50,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @author EllisLab Dev Team
|
||||
* @link
|
||||
*/
|
||||
#[AllowDynamicProperties]
|
||||
class CI_Driver_Library {
|
||||
|
||||
/**
|
||||
|
||||
+91
-163
@@ -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 1.0.0
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/email.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/email.html
|
||||
*/
|
||||
class CI_Email {
|
||||
|
||||
@@ -147,7 +148,7 @@ class CI_Email {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $charset = 'UTF-8';
|
||||
public $charset = 'utf-8';
|
||||
|
||||
/**
|
||||
* Alternative message (for HTML messages only)
|
||||
@@ -161,7 +162,7 @@ class CI_Email {
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $validate = FALSE;
|
||||
public $validate = TRUE;
|
||||
|
||||
/**
|
||||
* X-Priority header value.
|
||||
@@ -174,7 +175,7 @@ class CI_Email {
|
||||
* Newline character sequence.
|
||||
* Use "\r\n" to comply with RFC 822.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc822.txt
|
||||
* @link https://www.ietf.org/rfc/rfc822.txt
|
||||
* @var string "\r\n" or "\n"
|
||||
*/
|
||||
public $newline = "\n"; // Default newline. "\r\n" or "\n" (Use "\r\n" to comply with RFC 822)
|
||||
@@ -188,7 +189,7 @@ class CI_Email {
|
||||
* switching to "\n", while improper, is the only solution
|
||||
* that seems to work for all environments.
|
||||
*
|
||||
* @link http://www.ietf.org/rfc/rfc822.txt
|
||||
* @link https://www.ietf.org/rfc/rfc822.txt
|
||||
* @var string
|
||||
*/
|
||||
public $crlf = "\n";
|
||||
@@ -225,13 +226,6 @@ class CI_Email {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Whether PHP is running in safe mode. Initialized by the class constructor.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_safe_mode = FALSE;
|
||||
|
||||
/**
|
||||
* Subject header
|
||||
*
|
||||
@@ -395,9 +389,8 @@ class CI_Email {
|
||||
{
|
||||
$this->charset = config_item('charset');
|
||||
$this->initialize($config);
|
||||
$this->_safe_mode = ( ! is_php('5.4') && ini_get('safe_mode'));
|
||||
|
||||
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'));
|
||||
|
||||
log_message('info', 'Email Class Initialized');
|
||||
}
|
||||
@@ -675,18 +668,6 @@ class CI_Email {
|
||||
public function message($body)
|
||||
{
|
||||
$this->_body = rtrim(str_replace("\r", '', $body));
|
||||
|
||||
/* strip slashes only if magic quotes is ON
|
||||
if we do it with magic quotes OFF, it strips real, user-inputted chars.
|
||||
|
||||
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
|
||||
it will probably not exist in future versions at all.
|
||||
*/
|
||||
if ( ! is_php('5.4') && get_magic_quotes_gpc())
|
||||
{
|
||||
$this->_body = stripslashes($this->_body);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -1032,16 +1013,15 @@ class CI_Email {
|
||||
*/
|
||||
public function valid_email($email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $email, $matches))
|
||||
{
|
||||
list($account, $domain) = explode('@', $email, 2);
|
||||
$domain = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
? idn_to_ascii($domain, 0, INTL_IDNA_VARIANT_UTS46)
|
||||
: idn_to_ascii($domain);
|
||||
? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46)
|
||||
: idn_to_ascii($matches[2]);
|
||||
|
||||
if ($domain !== FALSE)
|
||||
{
|
||||
$email = $account.'@'.$domain;
|
||||
$email = $matches[1].'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1261,7 +1241,7 @@ class CI_Email {
|
||||
/**
|
||||
* Build Final Body and attachments
|
||||
*
|
||||
* @return bool
|
||||
* @return void
|
||||
*/
|
||||
protected function _build_message()
|
||||
{
|
||||
@@ -1428,8 +1408,6 @@ class CI_Email {
|
||||
$this->_finalbody = ($this->_get_protocol() === 'mail')
|
||||
? $body
|
||||
: $hdr.$this->newline.$this->newline.$body;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1490,7 +1468,7 @@ class CI_Email {
|
||||
* Prep Quoted Printable
|
||||
*
|
||||
* Prepares string for Quoted-Printable Content-Transfer-Encoding
|
||||
* Refer to RFC 2045 http://www.ietf.org/rfc/rfc2045.txt
|
||||
* Refer to RFC 2045 https://www.ietf.org/rfc/rfc2045.txt
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
@@ -1499,7 +1477,7 @@ class CI_Email {
|
||||
{
|
||||
// ASCII code numbers for "safe" characters that can always be
|
||||
// used literally, without encoding, as described in RFC 2049.
|
||||
// http://www.ietf.org/rfc/rfc2049.txt
|
||||
// https://www.ietf.org/rfc/rfc2049.txt
|
||||
static $ascii_safe_chars = array(
|
||||
// ' ( ) + , - . / : = ?
|
||||
39, 40, 41, 43, 44, 45, 46, 47, 58, 61, 63,
|
||||
@@ -1691,8 +1669,8 @@ class CI_Email {
|
||||
$this->reply_to($this->_headers['From']);
|
||||
}
|
||||
|
||||
if ( ! isset($this->_recipients) && ! isset($this->_headers['To'])
|
||||
&& ! isset($this->_bcc_array) && ! isset($this->_headers['Bcc'])
|
||||
if (empty($this->_recipients) && ! isset($this->_headers['To'])
|
||||
&& empty($this->_bcc_array) && ! isset($this->_headers['Bcc'])
|
||||
&& ! isset($this->_headers['Cc']))
|
||||
{
|
||||
$this->_set_error_message('lang:email_no_recipients');
|
||||
@@ -1703,21 +1681,17 @@ class CI_Email {
|
||||
|
||||
if ($this->bcc_batch_mode && count($this->_bcc_array) > $this->bcc_batch_size)
|
||||
{
|
||||
$result = $this->batch_bcc_send();
|
||||
$this->batch_bcc_send();
|
||||
|
||||
if ($result && $auto_clear)
|
||||
if ($auto_clear)
|
||||
{
|
||||
$this->clear();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
if ($this->_build_message() === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
$this->_build_message();
|
||||
$result = $this->_spool_email();
|
||||
|
||||
if ($result && $auto_clear)
|
||||
@@ -1776,11 +1750,7 @@ class CI_Email {
|
||||
$this->_bcc_array = $bcc;
|
||||
}
|
||||
|
||||
if ($this->_build_message() === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_build_message();
|
||||
$this->_spool_email();
|
||||
}
|
||||
}
|
||||
@@ -1857,7 +1827,7 @@ class CI_Email {
|
||||
*/
|
||||
protected function _validate_email_for_shell(&$email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
|
||||
{
|
||||
list($account, $domain) = explode('@', $email, 2);
|
||||
$domain = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
@@ -1891,16 +1861,14 @@ class CI_Email {
|
||||
// so this needs to be assigned to a variable
|
||||
$from = $this->clean_email($this->_headers['Return-Path']);
|
||||
|
||||
if ($this->_safe_mode === TRUE || ! $this->_validate_email_for_shell($from))
|
||||
if ( ! $this->_validate_email_for_shell($from))
|
||||
{
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str);
|
||||
}
|
||||
else
|
||||
{
|
||||
// most documentation of sendmail using the "-f" flag lacks a space after it, however
|
||||
// we've encountered servers that seem to require it to be in place.
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$from);
|
||||
}
|
||||
|
||||
// most documentation of sendmail using the "-f" flag lacks a space after it, however
|
||||
// we've encountered servers that seem to require it to be in place.
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$from);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1981,27 +1949,21 @@ class CI_Email {
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->_cc_array) > 0)
|
||||
foreach ($this->_cc_array as $val)
|
||||
{
|
||||
foreach ($this->_cc_array as $val)
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($this->_bcc_array) > 0)
|
||||
foreach ($this->_bcc_array as $val)
|
||||
{
|
||||
foreach ($this->_bcc_array as $val)
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
if ($val !== '' && ! $this->_send_command('to', $val))
|
||||
{
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
$this->_smtp_end();
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2015,7 +1977,6 @@ class CI_Email {
|
||||
$this->_send_data($this->_header_str.preg_replace('/^\./m', '..$1', $this->_finalbody));
|
||||
|
||||
$this->_send_data('.');
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
$this->_set_error_message($reply);
|
||||
|
||||
@@ -2041,9 +2002,7 @@ class CI_Email {
|
||||
*/
|
||||
protected function _smtp_end()
|
||||
{
|
||||
($this->smtp_keepalive)
|
||||
? $this->_send_command('reset')
|
||||
: $this->_send_command('quit');
|
||||
$this->_send_command($this->smtp_keepalive ? 'reset' : 'quit');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -2062,11 +2021,13 @@ class CI_Email {
|
||||
|
||||
$ssl = ($this->smtp_crypto === 'ssl') ? 'ssl://' : '';
|
||||
|
||||
$this->_smtp_connect = fsockopen($ssl.$this->smtp_host,
|
||||
$this->smtp_port,
|
||||
$errno,
|
||||
$errstr,
|
||||
$this->smtp_timeout);
|
||||
$this->_smtp_connect = fsockopen(
|
||||
$ssl.$this->smtp_host,
|
||||
$this->smtp_port,
|
||||
$errno,
|
||||
$errstr,
|
||||
$this->smtp_timeout
|
||||
);
|
||||
|
||||
if ( ! is_resource($this->_smtp_connect))
|
||||
{
|
||||
@@ -2119,57 +2080,49 @@ class CI_Email {
|
||||
{
|
||||
switch ($cmd)
|
||||
{
|
||||
case 'hello' :
|
||||
case 'hello':
|
||||
if ($this->_smtp_auth OR $this->_get_encoding() === '8bit')
|
||||
{
|
||||
$this->_send_data('EHLO '.$this->_get_hostname());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('HELO '.$this->_get_hostname());
|
||||
}
|
||||
|
||||
if ($this->_smtp_auth OR $this->_get_encoding() === '8bit')
|
||||
{
|
||||
$this->_send_data('EHLO '.$this->_get_hostname());
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('HELO '.$this->_get_hostname());
|
||||
}
|
||||
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'starttls' :
|
||||
|
||||
$this->_send_data('STARTTLS');
|
||||
$resp = 220;
|
||||
break;
|
||||
case 'from' :
|
||||
|
||||
$this->_send_data('MAIL FROM:<'.$data.'>');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'to' :
|
||||
|
||||
if ($this->dsn)
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'>');
|
||||
}
|
||||
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'data' :
|
||||
|
||||
$this->_send_data('DATA');
|
||||
$resp = 354;
|
||||
break;
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'starttls':
|
||||
$this->_send_data('STARTTLS');
|
||||
$resp = 220;
|
||||
break;
|
||||
case 'from':
|
||||
$this->_send_data('MAIL FROM:<'.$data.'>');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'to':
|
||||
if ($this->dsn)
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'> NOTIFY=SUCCESS,DELAY,FAILURE ORCPT=rfc822;'.$data);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_send_data('RCPT TO:<'.$data.'>');
|
||||
}
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'data':
|
||||
$this->_send_data('DATA');
|
||||
$resp = 354;
|
||||
break;
|
||||
case 'reset':
|
||||
|
||||
$this->_send_data('RSET');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'quit' :
|
||||
|
||||
$this->_send_data('QUIT');
|
||||
$resp = 221;
|
||||
break;
|
||||
$this->_send_data('RSET');
|
||||
$resp = 250;
|
||||
break;
|
||||
case 'quit':
|
||||
$this->_send_data('QUIT');
|
||||
$resp = 221;
|
||||
break;
|
||||
}
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
@@ -2211,7 +2164,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data('AUTH LOGIN');
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '503') === 0) // Already authenticated
|
||||
@@ -2225,7 +2177,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data(base64_encode($this->smtp_user));
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '334') !== 0)
|
||||
@@ -2235,7 +2186,6 @@ class CI_Email {
|
||||
}
|
||||
|
||||
$this->_send_data(base64_encode($this->smtp_pass));
|
||||
|
||||
$reply = $this->_get_smtp_data();
|
||||
|
||||
if (strpos($reply, '235') !== 0)
|
||||
@@ -2269,7 +2219,7 @@ class CI_Email {
|
||||
{
|
||||
break;
|
||||
}
|
||||
// See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
|
||||
// See https://bugs.php.net/bug.php?id=39598 and https://secure.php.net/manual/en/function.fwrite.php#96951
|
||||
elseif ($result === 0)
|
||||
{
|
||||
if ($timestamp === 0)
|
||||
@@ -2332,7 +2282,7 @@ class CI_Email {
|
||||
* (eg: "[1.2.3.4]").
|
||||
*
|
||||
* @link https://tools.ietf.org/html/rfc5321#section-2.3.5
|
||||
* @link http://cbl.abuseat.org/namingproblems.html
|
||||
* @link https://cbl.abuseat.org/namingproblems.html
|
||||
* @return string
|
||||
*/
|
||||
protected function _get_hostname()
|
||||
@@ -2356,34 +2306,15 @@ class CI_Email {
|
||||
*/
|
||||
public function print_debugger($include = array('headers', 'subject', 'body'))
|
||||
{
|
||||
$msg = '';
|
||||
|
||||
if (count($this->_debug_msg) > 0)
|
||||
{
|
||||
foreach ($this->_debug_msg as $val)
|
||||
{
|
||||
$msg .= $val;
|
||||
}
|
||||
}
|
||||
$msg = implode('', $this->_debug_msg);
|
||||
|
||||
// Determine which parts of our raw data needs to be printed
|
||||
$raw_data = '';
|
||||
is_array($include) OR $include = array($include);
|
||||
|
||||
if (in_array('headers', $include, TRUE))
|
||||
{
|
||||
$raw_data = htmlspecialchars($this->_header_str)."\n";
|
||||
}
|
||||
|
||||
if (in_array('subject', $include, TRUE))
|
||||
{
|
||||
$raw_data .= htmlspecialchars($this->_subject)."\n";
|
||||
}
|
||||
|
||||
if (in_array('body', $include, TRUE))
|
||||
{
|
||||
$raw_data .= htmlspecialchars($this->_finalbody);
|
||||
}
|
||||
in_array('headers', $include, TRUE) && $raw_data = htmlspecialchars($this->_header_str)."\n";
|
||||
in_array('subject', $include, TRUE) && $raw_data .= htmlspecialchars($this->_subject)."\n";
|
||||
in_array('body', $include, TRUE) && $raw_data .= htmlspecialchars($this->_finalbody);
|
||||
|
||||
return $msg.($raw_data === '' ? '' : '<pre>'.$raw_data.'</pre>');
|
||||
}
|
||||
@@ -2477,9 +2408,6 @@ class CI_Email {
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,521 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* CodeIgniter
|
||||
*
|
||||
* An open source application development framework for PHP
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
*/
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
/**
|
||||
* CodeIgniter Encryption Class
|
||||
*
|
||||
* Provides two-way keyed encoding using Mcrypt
|
||||
*
|
||||
* @package CodeIgniter
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/encryption.html
|
||||
*/
|
||||
class CI_Encrypt {
|
||||
|
||||
/**
|
||||
* Reference to the user's encryption key
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $encryption_key = '';
|
||||
|
||||
/**
|
||||
* Type of hash operation
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_hash_type = 'sha1';
|
||||
|
||||
/**
|
||||
* Flag for the existence of mcrypt
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_mcrypt_exists = FALSE;
|
||||
|
||||
/**
|
||||
* Current cipher to be used with mcrypt
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_mcrypt_cipher;
|
||||
|
||||
/**
|
||||
* Method for encrypting/decrypting data
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $_mcrypt_mode;
|
||||
|
||||
/**
|
||||
* Initialize Encryption class
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
if (($this->_mcrypt_exists = function_exists('mcrypt_encrypt')) === FALSE)
|
||||
{
|
||||
show_error('The Encrypt library requires the Mcrypt extension.');
|
||||
}
|
||||
|
||||
log_message('info', 'Encrypt Class Initialized');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fetch the encryption key
|
||||
*
|
||||
* Returns it as MD5 in order to have an exact-length 128 bit key.
|
||||
* Mcrypt is sensitive to keys that are not the correct length
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function get_key($key = '')
|
||||
{
|
||||
if ($key === '')
|
||||
{
|
||||
if ($this->encryption_key !== '')
|
||||
{
|
||||
return $this->encryption_key;
|
||||
}
|
||||
|
||||
$key = config_item('encryption_key');
|
||||
|
||||
if ( ! self::strlen($key))
|
||||
{
|
||||
show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
|
||||
}
|
||||
}
|
||||
|
||||
return md5($key);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the encryption key
|
||||
*
|
||||
* @param string
|
||||
* @return CI_Encrypt
|
||||
*/
|
||||
public function set_key($key = '')
|
||||
{
|
||||
$this->encryption_key = $key;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Encode
|
||||
*
|
||||
* Encodes the message string using bitwise XOR encoding.
|
||||
* The key is combined with a random hash, and then it
|
||||
* too gets converted using XOR. The whole thing is then run
|
||||
* through mcrypt using the randomized key. The end result
|
||||
* is a double-encrypted message string that is randomized
|
||||
* with each call to this function, even if the supplied
|
||||
* message and key are the same.
|
||||
*
|
||||
* @param string the string to encode
|
||||
* @param string the key
|
||||
* @return string
|
||||
*/
|
||||
public function encode($string, $key = '')
|
||||
{
|
||||
return base64_encode($this->mcrypt_encode($string, $this->get_key($key)));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decode
|
||||
*
|
||||
* Reverses the above process
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function decode($string, $key = '')
|
||||
{
|
||||
if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string) OR base64_encode(base64_decode($string)) !== $string)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $this->mcrypt_decode(base64_decode($string), $this->get_key($key));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Encode from Legacy
|
||||
*
|
||||
* Takes an encoded string from the original Encryption class algorithms and
|
||||
* returns a newly encoded string using the improved method added in 2.0.0
|
||||
* This allows for backwards compatibility and a method to transition to the
|
||||
* new encryption algorithms.
|
||||
*
|
||||
* For more details, see https://codeigniter.com/user_guide/installation/upgrade_200.html#encryption
|
||||
*
|
||||
* @param string
|
||||
* @param int (mcrypt mode constant)
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function encode_from_legacy($string, $legacy_mode = MCRYPT_MODE_ECB, $key = '')
|
||||
{
|
||||
if (preg_match('/[^a-zA-Z0-9\/\+=]/', $string))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// decode it first
|
||||
// set mode temporarily to what it was when string was encoded with the legacy
|
||||
// algorithm - typically MCRYPT_MODE_ECB
|
||||
$current_mode = $this->_get_mode();
|
||||
$this->set_mode($legacy_mode);
|
||||
|
||||
$key = $this->get_key($key);
|
||||
$dec = base64_decode($string);
|
||||
if (($dec = $this->mcrypt_decode($dec, $key)) === FALSE)
|
||||
{
|
||||
$this->set_mode($current_mode);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$dec = $this->_xor_decode($dec, $key);
|
||||
|
||||
// set the mcrypt mode back to what it should be, typically MCRYPT_MODE_CBC
|
||||
$this->set_mode($current_mode);
|
||||
|
||||
// and re-encode
|
||||
return base64_encode($this->mcrypt_encode($dec, $key));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* XOR Decode
|
||||
*
|
||||
* Takes an encoded string and key as input and generates the
|
||||
* plain-text original message
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
protected function _xor_decode($string, $key)
|
||||
{
|
||||
$string = $this->_xor_merge($string, $key);
|
||||
|
||||
$dec = '';
|
||||
for ($i = 0, $l = self::strlen($string); $i < $l; $i++)
|
||||
{
|
||||
$dec .= ($string[$i++] ^ $string[$i]);
|
||||
}
|
||||
|
||||
return $dec;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* XOR key + string Combiner
|
||||
*
|
||||
* Takes a string and key as input and computes the difference using XOR
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
protected function _xor_merge($string, $key)
|
||||
{
|
||||
$hash = $this->hash($key);
|
||||
$str = '';
|
||||
|
||||
for ($i = 0, $ls = self::strlen($string), $lh = self::strlen($hash); $i < $ls; $i++)
|
||||
{
|
||||
$str .= $string[$i] ^ $hash[($i % $lh)];
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Encrypt using Mcrypt
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function mcrypt_encode($data, $key)
|
||||
{
|
||||
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
|
||||
$init_vect = mcrypt_create_iv($init_size, MCRYPT_DEV_URANDOM);
|
||||
return $this->_add_cipher_noise($init_vect.mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), $key);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decrypt using Mcrypt
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function mcrypt_decode($data, $key)
|
||||
{
|
||||
$data = $this->_remove_cipher_noise($data, $key);
|
||||
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
|
||||
|
||||
if ($init_size > self::strlen($data))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$init_vect = self::substr($data, 0, $init_size);
|
||||
$data = self::substr($data, $init_size);
|
||||
|
||||
return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Adds permuted noise to the IV + encrypted data to protect
|
||||
* against Man-in-the-middle attacks on CBC mode ciphers
|
||||
* http://www.ciphersbyritter.com/GLOSSARY.HTM#IV
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
protected function _add_cipher_noise($data, $key)
|
||||
{
|
||||
$key = $this->hash($key);
|
||||
$str = '';
|
||||
|
||||
for ($i = 0, $j = 0, $ld = self::strlen($data), $lk = self::strlen($key); $i < $ld; ++$i, ++$j)
|
||||
{
|
||||
if ($j >= $lk)
|
||||
{
|
||||
$j = 0;
|
||||
}
|
||||
|
||||
$str .= chr((ord($data[$i]) + ord($key[$j])) % 256);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Removes permuted noise from the IV + encrypted data, reversing
|
||||
* _add_cipher_noise()
|
||||
*
|
||||
* Function description
|
||||
*
|
||||
* @param string $data
|
||||
* @param string $key
|
||||
* @return string
|
||||
*/
|
||||
protected function _remove_cipher_noise($data, $key)
|
||||
{
|
||||
$key = $this->hash($key);
|
||||
$str = '';
|
||||
|
||||
for ($i = 0, $j = 0, $ld = self::strlen($data), $lk = self::strlen($key); $i < $ld; ++$i, ++$j)
|
||||
{
|
||||
if ($j >= $lk)
|
||||
{
|
||||
$j = 0;
|
||||
}
|
||||
|
||||
$temp = ord($data[$i]) - ord($key[$j]);
|
||||
|
||||
if ($temp < 0)
|
||||
{
|
||||
$temp += 256;
|
||||
}
|
||||
|
||||
$str .= chr($temp);
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the Mcrypt Cipher
|
||||
*
|
||||
* @param int
|
||||
* @return CI_Encrypt
|
||||
*/
|
||||
public function set_cipher($cipher)
|
||||
{
|
||||
$this->_mcrypt_cipher = $cipher;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the Mcrypt Mode
|
||||
*
|
||||
* @param int
|
||||
* @return CI_Encrypt
|
||||
*/
|
||||
public function set_mode($mode)
|
||||
{
|
||||
$this->_mcrypt_mode = $mode;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Mcrypt cipher Value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function _get_cipher()
|
||||
{
|
||||
if ($this->_mcrypt_cipher === NULL)
|
||||
{
|
||||
return $this->_mcrypt_cipher = MCRYPT_RIJNDAEL_256;
|
||||
}
|
||||
|
||||
return $this->_mcrypt_cipher;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get Mcrypt Mode Value
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
protected function _get_mode()
|
||||
{
|
||||
if ($this->_mcrypt_mode === NULL)
|
||||
{
|
||||
return $this->_mcrypt_mode = MCRYPT_MODE_CBC;
|
||||
}
|
||||
|
||||
return $this->_mcrypt_mode;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Set the Hash type
|
||||
*
|
||||
* @param string
|
||||
* @return void
|
||||
*/
|
||||
public function set_hash($type = 'sha1')
|
||||
{
|
||||
$this->_hash_type = in_array($type, hash_algos()) ? $type : 'sha1';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Hash encode a string
|
||||
*
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
public function hash($str)
|
||||
{
|
||||
return hash($this->_hash_type, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return defined('MB_OVERLOAD_STRING')
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe substr()
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
protected static function substr($str, $start, $length = NULL)
|
||||
{
|
||||
if (defined('MB_OVERLOAD_STRING'))
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
return isset($length)
|
||||
? substr($str, $start, $length)
|
||||
: substr($str, $start);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author Andrey Andreev
|
||||
* @link https://codeigniter.com/user_guide/libraries/encryption.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/encryption.html
|
||||
*/
|
||||
class CI_Encryption {
|
||||
|
||||
@@ -161,7 +162,7 @@ class CI_Encryption {
|
||||
show_error('Encryption: Unable to find an available encryption driver.');
|
||||
}
|
||||
|
||||
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'));
|
||||
$this->initialize($params);
|
||||
|
||||
if ( ! isset($this->_key) && self::strlen($key = config_item('encryption_key')) > 0)
|
||||
@@ -365,10 +366,10 @@ class CI_Encryption {
|
||||
* Encrypt
|
||||
*
|
||||
* @param string $data Input data
|
||||
* @param array $params Input parameters
|
||||
* @param array|null $params Input parameters
|
||||
* @return string
|
||||
*/
|
||||
public function encrypt($data, array $params = NULL)
|
||||
public function encrypt($data, $params = NULL)
|
||||
{
|
||||
if (($params = $this->_get_params($params)) === FALSE)
|
||||
{
|
||||
@@ -469,6 +470,11 @@ class CI_Encryption {
|
||||
*/
|
||||
protected function _openssl_encrypt($data, $params)
|
||||
{
|
||||
if ($data === NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (empty($params['handle']))
|
||||
{
|
||||
return FALSE;
|
||||
@@ -476,13 +482,13 @@ class CI_Encryption {
|
||||
|
||||
$iv = ($iv_size = openssl_cipher_iv_length($params['handle']))
|
||||
? $this->create_key($iv_size)
|
||||
: NULL;
|
||||
: '';
|
||||
|
||||
$data = openssl_encrypt(
|
||||
$data,
|
||||
$params['handle'],
|
||||
$params['key'],
|
||||
1, // DO NOT TOUCH!
|
||||
OPENSSL_RAW_DATA,
|
||||
$iv
|
||||
);
|
||||
|
||||
@@ -500,10 +506,10 @@ class CI_Encryption {
|
||||
* Decrypt
|
||||
*
|
||||
* @param string $data Encrypted data
|
||||
* @param array $params Input parameters
|
||||
* @param array|null $params Input parameters
|
||||
* @return string
|
||||
*/
|
||||
public function decrypt($data, array $params = NULL)
|
||||
public function decrypt($data, $params = NULL)
|
||||
{
|
||||
if (($params = $this->_get_params($params)) === FALSE)
|
||||
{
|
||||
@@ -585,7 +591,7 @@ class CI_Encryption {
|
||||
}
|
||||
else
|
||||
{
|
||||
$iv = NULL;
|
||||
$iv = '';
|
||||
}
|
||||
|
||||
if (mcrypt_generic_init($params['handle'], $params['key'], $iv) < 0)
|
||||
@@ -625,6 +631,11 @@ class CI_Encryption {
|
||||
*/
|
||||
protected function _openssl_decrypt($data, $params)
|
||||
{
|
||||
if ($data === NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ($iv_size = openssl_cipher_iv_length($params['handle']))
|
||||
{
|
||||
$iv = self::substr($data, 0, $iv_size);
|
||||
@@ -632,7 +643,7 @@ class CI_Encryption {
|
||||
}
|
||||
else
|
||||
{
|
||||
$iv = NULL;
|
||||
$iv = '';
|
||||
}
|
||||
|
||||
return empty($params['handle'])
|
||||
@@ -641,7 +652,7 @@ class CI_Encryption {
|
||||
$data,
|
||||
$params['handle'],
|
||||
$params['key'],
|
||||
1, // DO NOT TOUCH!
|
||||
OPENSSL_RAW_DATA,
|
||||
$iv
|
||||
);
|
||||
}
|
||||
@@ -910,8 +921,8 @@ class CI_Encryption {
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return (self::$func_overload)
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
? mb_strlen((string) $str, '8bit')
|
||||
: strlen((string) $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -928,9 +939,6 @@ class CI_Encryption {
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Validation
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/form_validation.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/form_validation.html
|
||||
*/
|
||||
class CI_Form_validation {
|
||||
|
||||
@@ -105,8 +106,9 @@ class CI_Form_validation {
|
||||
protected $error_string = '';
|
||||
|
||||
/**
|
||||
* Whether the form data has been validated as safe
|
||||
* Whether the form data has been through validation and had errors
|
||||
*
|
||||
* @deprecated 3.0.6
|
||||
* @var bool
|
||||
*/
|
||||
protected $_safe_form_data = FALSE;
|
||||
@@ -164,7 +166,7 @@ class CI_Form_validation {
|
||||
* @param array $errors
|
||||
* @return CI_Form_validation
|
||||
*/
|
||||
public function set_rules($field, $label = '', $rules = array(), $errors = array())
|
||||
public function set_rules($field, $label = null, $rules = null, $errors = array())
|
||||
{
|
||||
// No reason to set rules if we have no POST data
|
||||
// or a validation array has not been specified
|
||||
@@ -197,18 +199,22 @@ class CI_Form_validation {
|
||||
|
||||
return $this;
|
||||
}
|
||||
elseif ( ! isset($rules))
|
||||
{
|
||||
throw new BadMethodCallException('Form_validation: set_rules() called without a $rules parameter');
|
||||
}
|
||||
|
||||
// No fields or no rules? Nothing to do...
|
||||
if ( ! is_string($field) OR $field === '' OR empty($rules))
|
||||
{
|
||||
return $this;
|
||||
throw new RuntimeException('Form_validation: set_rules() called with an empty $rules parameter');
|
||||
}
|
||||
elseif ( ! is_array($rules))
|
||||
{
|
||||
// BC: Convert pipe-separated rules string to an array
|
||||
if ( ! is_string($rules))
|
||||
{
|
||||
return $this;
|
||||
throw new InvalidArgumentException('Form_validation: set_rules() expect $rules to be string or array; '.gettype($rules).' given');
|
||||
}
|
||||
|
||||
$rules = preg_split('/\|(?![^\[]*\])/', $rules);
|
||||
@@ -410,10 +416,11 @@ class CI_Form_validation {
|
||||
*
|
||||
* This function does all the work.
|
||||
*
|
||||
* @param string $group
|
||||
* @param string $config
|
||||
* @param array $data
|
||||
* @return bool
|
||||
*/
|
||||
public function run($group = '')
|
||||
public function run($config = NULL, &$data = NULL)
|
||||
{
|
||||
$validation_array = empty($this->validation_data)
|
||||
? $_POST
|
||||
@@ -424,19 +431,19 @@ class CI_Form_validation {
|
||||
if (count($this->_field_data) === 0)
|
||||
{
|
||||
// No validation rules? We're done...
|
||||
if (count($this->_config_rules) === 0)
|
||||
if (empty($this->_config_rules))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (empty($group))
|
||||
if (empty($config))
|
||||
{
|
||||
// Is there a validation rule for the particular URI being accessed?
|
||||
$group = trim($this->CI->uri->ruri_string(), '/');
|
||||
isset($this->_config_rules[$group]) OR $group = $this->CI->router->class.'/'.$this->CI->router->method;
|
||||
$config = trim($this->CI->uri->ruri_string(), '/');
|
||||
isset($this->_config_rules[$config]) OR $config = $this->CI->router->class.'/'.$this->CI->router->method;
|
||||
}
|
||||
|
||||
$this->set_rules(isset($this->_config_rules[$group]) ? $this->_config_rules[$group] : $this->_config_rules);
|
||||
$this->set_rules(isset($this->_config_rules[$config]) ? $this->_config_rules[$config] : $this->_config_rules);
|
||||
|
||||
// Were we able to set the rules correctly?
|
||||
if (count($this->_field_data) === 0)
|
||||
@@ -478,17 +485,23 @@ class CI_Form_validation {
|
||||
$this->_execute($row, $row['rules'], $row['postdata']);
|
||||
}
|
||||
|
||||
// Did we end up with any errors?
|
||||
$total_errors = count($this->_error_array);
|
||||
if ($total_errors > 0)
|
||||
if ( ! empty($this->_error_array))
|
||||
{
|
||||
$this->_safe_form_data = TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Now we need to re-set the POST data with the new, processed data
|
||||
empty($this->validation_data) && $this->_reset_post_array();
|
||||
// Fill $data if requested, otherwise modify $_POST, as long as
|
||||
// set_data() wasn't used (yea, I know it sounds confusing)
|
||||
if (func_num_args() >= 2)
|
||||
{
|
||||
$data = empty($this->validation_data) ? $_POST : $this->validation_data;
|
||||
$this->_reset_data_array($data);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return ($total_errors === 0);
|
||||
empty($this->validation_data) && $this->_reset_data_array($_POST);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -576,7 +589,7 @@ class CI_Form_validation {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _reset_post_array()
|
||||
protected function _reset_data_array(&$data)
|
||||
{
|
||||
foreach ($this->_field_data as $field => $row)
|
||||
{
|
||||
@@ -584,27 +597,26 @@ class CI_Form_validation {
|
||||
{
|
||||
if ($row['is_array'] === FALSE)
|
||||
{
|
||||
isset($_POST[$field]) && $_POST[$field] = is_array($row['postdata']) ? NULL : $row['postdata'];
|
||||
isset($data[$field]) && $data[$field] = is_array($row['postdata']) ? NULL : $row['postdata'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// start with a reference
|
||||
$post_ref =& $_POST;
|
||||
$data_ref =& $data;
|
||||
|
||||
// before we assign values, make a reference to the right POST key
|
||||
if (count($row['keys']) === 1)
|
||||
{
|
||||
$post_ref =& $post_ref[current($row['keys'])];
|
||||
$data_ref =& $data[current($row['keys'])];
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($row['keys'] as $val)
|
||||
{
|
||||
$post_ref =& $post_ref[$val];
|
||||
$data_ref =& $data_ref[$val];
|
||||
}
|
||||
}
|
||||
|
||||
$post_ref = $row['postdata'];
|
||||
$data_ref = $row['postdata'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -623,11 +635,13 @@ class CI_Form_validation {
|
||||
*/
|
||||
protected function _execute($row, $rules, $postdata = NULL, $cycles = 0)
|
||||
{
|
||||
$allow_arrays = in_array('is_array', $rules, TRUE);
|
||||
|
||||
// If the $_POST data is an array we will run a recursive call
|
||||
//
|
||||
// Note: We MUST check if the array is empty or not!
|
||||
// Otherwise empty arrays will always pass validation.
|
||||
if (is_array($postdata) && ! empty($postdata))
|
||||
if ($allow_arrays === FALSE && is_array($postdata) && ! empty($postdata))
|
||||
{
|
||||
foreach ($postdata as $key => $val)
|
||||
{
|
||||
@@ -656,14 +670,16 @@ class CI_Form_validation {
|
||||
$postdata = $this->_field_data[$row['field']]['postdata'][$cycles];
|
||||
$_in_array = TRUE;
|
||||
}
|
||||
// If we get an array field, but it's not expected - then it is most likely
|
||||
// somebody messing with the form on the client side, so we'll just consider
|
||||
// it an empty field
|
||||
elseif ($allow_arrays === FALSE && is_array($this->_field_data[$row['field']]['postdata']))
|
||||
{
|
||||
$postdata = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we get an array field, but it's not expected - then it is most likely
|
||||
// somebody messing with the form on the client side, so we'll just consider
|
||||
// it an empty field
|
||||
$postdata = is_array($this->_field_data[$row['field']]['postdata'])
|
||||
? NULL
|
||||
: $this->_field_data[$row['field']]['postdata'];
|
||||
$postdata = $this->_field_data[$row['field']]['postdata'];
|
||||
}
|
||||
|
||||
// Is the rule a callback?
|
||||
@@ -698,7 +714,7 @@ class CI_Form_validation {
|
||||
|
||||
// Ignore empty, non-required inputs with a few exceptions ...
|
||||
if (
|
||||
($postdata === NULL OR $postdata === '')
|
||||
($postdata === NULL OR ($allow_arrays === FALSE && $postdata === ''))
|
||||
&& $callback === FALSE
|
||||
&& $callable === FALSE
|
||||
&& ! in_array($rule, array('required', 'isset', 'matches'), TRUE)
|
||||
@@ -845,11 +861,6 @@ class CI_Form_validation {
|
||||
{
|
||||
return $line;
|
||||
}
|
||||
// DEPRECATED support for non-prefixed keys, lang file again
|
||||
elseif (FALSE !== ($line = $this->CI->lang->line($rule, FALSE)))
|
||||
{
|
||||
return $line;
|
||||
}
|
||||
|
||||
return $this->CI->lang->line('form_validation_error_message_not_set').'('.$rule.')';
|
||||
}
|
||||
@@ -1056,7 +1067,7 @@ class CI_Form_validation {
|
||||
{
|
||||
return is_array($str)
|
||||
? (empty($str) === FALSE)
|
||||
: (trim($str) !== '');
|
||||
: (trim((string) $str) !== '');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1293,6 +1304,31 @@ class CI_Form_validation {
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate MAC address
|
||||
*
|
||||
* @param string $mac
|
||||
* @return bool
|
||||
*/
|
||||
public function valid_mac($mac)
|
||||
{
|
||||
if ( ! is_php('5.5'))
|
||||
{
|
||||
// Most common format, with either dash or colon delimiters
|
||||
if (preg_match('#\A[0-9a-f]{2}(?<delimiter>[:-])([0-9a-f]{2}(?P=delimiter)){4}[0-9a-f]{2}\z#i', $mac))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// The less common format; e.g. 0123.4567.89ab
|
||||
return (bool) preg_match('#((\A|\.)[0-9a-f]{4}){3}\z#i', $mac);
|
||||
}
|
||||
|
||||
return (bool) filter_var($mac, FILTER_VALIDATE_MAC);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alpha
|
||||
*
|
||||
@@ -1537,12 +1573,7 @@ class CI_Form_validation {
|
||||
*/
|
||||
public function prep_url($str = '')
|
||||
{
|
||||
if ($str === 'http://' OR $str === '')
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
if (strpos($str, 'http://') !== 0 && strpos($str, 'https://') !== 0)
|
||||
if ($str !== '' && stripos($str, 'http://') !== 0 && stripos($str, 'https://') !== 0)
|
||||
{
|
||||
return 'http://'.$str;
|
||||
}
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/ftp.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/ftp.html
|
||||
*/
|
||||
class CI_FTP {
|
||||
|
||||
@@ -202,7 +203,7 @@ class CI_FTP {
|
||||
*/
|
||||
protected function _is_conn()
|
||||
{
|
||||
if ( ! is_resource($this->conn_id))
|
||||
if ($this->conn_id === FALSE)
|
||||
{
|
||||
if ($this->debug === TRUE)
|
||||
{
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Image_lib
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/image_lib.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/image_lib.html
|
||||
*/
|
||||
class CI_Image_lib {
|
||||
|
||||
@@ -84,6 +85,14 @@ class CI_Image_lib {
|
||||
*/
|
||||
public $new_image = '';
|
||||
|
||||
|
||||
/**
|
||||
* Path to destination image
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $dest_image = '';
|
||||
|
||||
/**
|
||||
* Image width
|
||||
*
|
||||
@@ -832,8 +841,11 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
// Kill the file handles
|
||||
imagedestroy($dst_img);
|
||||
imagedestroy($src_img);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
imagedestroy($dst_img);
|
||||
imagedestroy($src_img);
|
||||
}
|
||||
|
||||
if ($this->dynamic_output !== TRUE)
|
||||
{
|
||||
@@ -946,6 +958,10 @@ class CI_Image_lib {
|
||||
$cmd_in = 'pngtopnm';
|
||||
$cmd_out = 'ppmtopng';
|
||||
break;
|
||||
case 18 :
|
||||
$cmd_in = 'webptopnm';
|
||||
$cmd_out = 'ppmtowebp';
|
||||
break;
|
||||
}
|
||||
|
||||
if ($action === 'crop')
|
||||
@@ -1037,8 +1053,11 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
// Kill the file handles
|
||||
imagedestroy($dst_img);
|
||||
imagedestroy($src_img);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
imagedestroy($dst_img);
|
||||
imagedestroy($src_img);
|
||||
}
|
||||
|
||||
chmod($this->full_dst_path, $this->file_permissions);
|
||||
|
||||
@@ -1116,7 +1135,10 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
// Kill the file handles
|
||||
imagedestroy($src_img);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
imagedestroy($src_img);
|
||||
}
|
||||
|
||||
chmod($this->full_dst_path, $this->file_permissions);
|
||||
|
||||
@@ -1207,7 +1229,7 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
// Build the finalized image
|
||||
if ($wm_img_type === 3 && function_exists('imagealphablending'))
|
||||
if ($wm_img_type === 3)
|
||||
{
|
||||
@imagealphablending($src_img, TRUE);
|
||||
}
|
||||
@@ -1246,8 +1268,11 @@ class CI_Image_lib {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
imagedestroy($src_img);
|
||||
imagedestroy($wm_img);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
imagedestroy($src_img);
|
||||
imagedestroy($wm_img);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1417,7 +1442,10 @@ class CI_Image_lib {
|
||||
$this->image_save_gd($src_img);
|
||||
}
|
||||
|
||||
imagedestroy($src_img);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
imagedestroy($src_img);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1472,6 +1500,14 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
return imagecreatefrompng($path);
|
||||
case 18:
|
||||
if ( ! function_exists('imagecreatefromwebp'))
|
||||
{
|
||||
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_webp_not_supported'));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return imagecreatefromwebp($path);
|
||||
default:
|
||||
$this->set_error(array('imglib_unsupported_imagecreate'));
|
||||
return FALSE;
|
||||
@@ -1532,6 +1568,19 @@ class CI_Image_lib {
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
case 18:
|
||||
if ( ! function_exists('imagewebp'))
|
||||
{
|
||||
$this->set_error(array('imglib_unsupported_imagecreate', 'imglib_webp_not_supported'));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( ! @imagewebp($resource, $this->full_dst_path))
|
||||
{
|
||||
$this->set_error('imglib_save_failed');
|
||||
return FALSE;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
$this->set_error(array('imglib_unsupported_imagecreate'));
|
||||
return FALSE;
|
||||
@@ -1551,7 +1600,16 @@ class CI_Image_lib {
|
||||
*/
|
||||
public function image_display_gd($resource)
|
||||
{
|
||||
header('Content-Disposition: filename='.$this->source_image.';');
|
||||
// RFC 6266 allows for multibyte filenames, but only in UTF-8,
|
||||
// so we have to make it conditional ...
|
||||
$filename = basename(empty($this->new_image) ? $this->source_image : $this->new_image);
|
||||
$charset = strtoupper(config_item('charset'));
|
||||
$utf8_filename = ($charset !== 'UTF-8')
|
||||
? get_instance()->utf8->convert_to_utf8($filename, $charset)
|
||||
: $filename;
|
||||
isset($utf8_filename[0]) && $utf8_filename = " filename*=UTF-8''".rawurlencode($utf8_filename);
|
||||
|
||||
header('Content-Disposition: filename="'.$filename.'";'.$utf8_filename);
|
||||
header('Content-Type: '.$this->mime_type);
|
||||
header('Content-Transfer-Encoding: binary');
|
||||
header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
|
||||
@@ -1564,6 +1622,8 @@ class CI_Image_lib {
|
||||
break;
|
||||
case 3 : imagepng($resource);
|
||||
break;
|
||||
case 18 : imagewebp($resource);
|
||||
break;
|
||||
default: echo 'Unable to display the image';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @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/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
@@ -49,6 +49,20 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
*/
|
||||
class CI_Javascript {
|
||||
|
||||
/**
|
||||
* CI Singleton
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
protected $CI;
|
||||
|
||||
/**
|
||||
* JavaScript library driver instance
|
||||
*
|
||||
* @var object
|
||||
*/
|
||||
public $js;
|
||||
|
||||
/**
|
||||
* JavaScript location
|
||||
*
|
||||
@@ -650,11 +664,11 @@ class CI_Javascript {
|
||||
$this->_javascript_location = $this->CI->config->item('javascript_location');
|
||||
}
|
||||
|
||||
if ($relative === TRUE OR strpos($external_file, 'http://') === 0 OR strpos($external_file, 'https://') === 0)
|
||||
if ($relative === TRUE OR stripos($external_file, 'http://') === 0 OR stripos($external_file, 'https://') === 0)
|
||||
{
|
||||
$str = $this->_open_script($external_file);
|
||||
}
|
||||
elseif (strpos($this->_javascript_location, 'http://') !== FALSE)
|
||||
elseif (stripos($this->_javascript_location, 'http://') !== FALSE)
|
||||
{
|
||||
$str = $this->_open_script($this->_javascript_location.$external_file);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @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/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<p>Directory access is forbidden.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -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
|
||||
@@ -288,7 +289,7 @@ class CI_Migration {
|
||||
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
|
||||
return FALSE;
|
||||
}
|
||||
elseif ( ! is_callable(array($class, $method)))
|
||||
elseif ( ! method_exists($class, $method) OR ! (new ReflectionMethod($class, $method))->isPublic())
|
||||
{
|
||||
$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
|
||||
return FALSE;
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Pagination
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/pagination.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/pagination.html
|
||||
*/
|
||||
class CI_Pagination {
|
||||
|
||||
@@ -357,20 +358,18 @@ class CI_Pagination {
|
||||
*/
|
||||
public function initialize(array $params = array())
|
||||
{
|
||||
if (isset($params['anchor_class']))
|
||||
{
|
||||
empty($params['anchor_class']) OR $params['attributes']['class'] = $params['anchor_class'];
|
||||
unset($params['anchor_class']);
|
||||
}
|
||||
|
||||
if (isset($params['attributes']) && is_array($params['attributes']))
|
||||
{
|
||||
$this->_parse_attributes($params['attributes']);
|
||||
unset($params['attributes']);
|
||||
}
|
||||
|
||||
// Deprecated legacy support for the anchor_class option
|
||||
// Should be removed in CI 3.1+
|
||||
if (isset($params['anchor_class']))
|
||||
{
|
||||
empty($params['anchor_class']) OR $attributes['class'] = $params['anchor_class'];
|
||||
unset($params['anchor_class']);
|
||||
}
|
||||
|
||||
foreach ($params as $key => $val)
|
||||
{
|
||||
if (property_exists($this, $key))
|
||||
@@ -522,7 +521,7 @@ class CI_Pagination {
|
||||
}
|
||||
|
||||
// If something isn't quite right, back to the default base page.
|
||||
if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
|
||||
if ( ! ctype_digit((string) $this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0))
|
||||
{
|
||||
$this->cur_page = $base_page;
|
||||
}
|
||||
@@ -686,7 +685,7 @@ class CI_Pagination {
|
||||
/**
|
||||
* Add "rel" attribute
|
||||
*
|
||||
* @link http://www.w3.org/TR/html5/links.html#linkTypes
|
||||
* @link https://www.w3.org/TR/html5/links.html#linkTypes
|
||||
* @param string $type
|
||||
* @return string
|
||||
*/
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Parser
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/parser.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/parser.html
|
||||
*/
|
||||
class CI_Parser {
|
||||
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -50,7 +51,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Libraries
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/general/profiling.html
|
||||
* @link https://codeigniter.com/userguide3/general/profiling.html
|
||||
*/
|
||||
class CI_Profiler {
|
||||
|
||||
@@ -72,6 +73,76 @@ class CI_Profiler {
|
||||
'config'
|
||||
);
|
||||
|
||||
/**
|
||||
* Compile benchmarks
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_benchmarks;
|
||||
|
||||
/**
|
||||
* Compile GET data
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_get;
|
||||
|
||||
/**
|
||||
* Compile memory usage
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_memory_usage;
|
||||
|
||||
/**
|
||||
* Compile POST data
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_post;
|
||||
|
||||
/**
|
||||
* Compile URI string
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_uri_string;
|
||||
|
||||
/**
|
||||
* Compile controller info
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_controller_info;
|
||||
|
||||
/**
|
||||
* Compile queries
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_queries;
|
||||
|
||||
/**
|
||||
* Compile HTTP headers
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_http_headers;
|
||||
|
||||
/**
|
||||
* Compile session data
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_session_data;
|
||||
|
||||
/**
|
||||
* Compile config data
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $_compile_config;
|
||||
|
||||
/**
|
||||
* Number of queries to show before making the additional queries togglable
|
||||
*
|
||||
@@ -105,7 +176,7 @@ class CI_Profiler {
|
||||
{
|
||||
if ( ! isset($config[$section]))
|
||||
{
|
||||
$this->_compile_{$section} = TRUE;
|
||||
$this->{'_compile_'.$section} = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +206,7 @@ class CI_Profiler {
|
||||
{
|
||||
if (in_array($method, $this->_available_sections))
|
||||
{
|
||||
$this->_compile_{$method} = ($enable !== FALSE);
|
||||
$this->{'_compile_'.$method} = ($enable !== FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,17 +557,17 @@ class CI_Profiler {
|
||||
{
|
||||
$pre = '';
|
||||
$pre_close = '';
|
||||
|
||||
|
||||
if (is_array($val) OR is_object($val))
|
||||
{
|
||||
$val = print_r($val, TRUE);
|
||||
|
||||
|
||||
$pre = '<pre>' ;
|
||||
$pre_close = '</pre>';
|
||||
$pre_close = '</pre>';
|
||||
}
|
||||
|
||||
$output .= '<tr><td style="padding:5px;vertical-align:top;color:#900;background-color:#ddd;">'
|
||||
.$config.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
.$config.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars((string) $val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
}
|
||||
|
||||
return $output."</table>\n</fieldset>";
|
||||
@@ -524,17 +595,17 @@ class CI_Profiler {
|
||||
{
|
||||
$pre = '';
|
||||
$pre_close = '';
|
||||
|
||||
|
||||
if (is_array($val) OR is_object($val))
|
||||
{
|
||||
$val = print_r($val, TRUE);
|
||||
|
||||
|
||||
$pre = '<pre>' ;
|
||||
$pre_close = '</pre>';
|
||||
$pre_close = '</pre>';
|
||||
}
|
||||
|
||||
$output .= '<tr><td style="padding:5px;vertical-align:top;color:#900;background-color:#ddd;">'
|
||||
.$key.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
.$key.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars((string) $val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
}
|
||||
|
||||
return $output."</table>\n</fieldset>";
|
||||
@@ -554,7 +625,7 @@ class CI_Profiler {
|
||||
|
||||
foreach ($this->_available_sections as $section)
|
||||
{
|
||||
if ($this->_compile_{$section} !== FALSE)
|
||||
if ($this->{'_compile_'.$section} !== FALSE)
|
||||
{
|
||||
$func = '_compile_'.$section;
|
||||
$output .= $this->{$func}();
|
||||
|
||||
+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>
|
||||
|
||||
@@ -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 1.3.1
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category HTML Tables
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/table.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/table.html
|
||||
*/
|
||||
class CI_Table {
|
||||
|
||||
@@ -427,6 +428,7 @@ class CI_Table {
|
||||
$this->rows = array();
|
||||
$this->heading = array();
|
||||
$this->auto_heading = TRUE;
|
||||
$this->caption = NULL;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -488,12 +490,12 @@ class CI_Table {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->temp = $this->_default_template();
|
||||
$temp = $this->_default_template();
|
||||
foreach (array('table_open', 'thead_open', 'thead_close', 'heading_row_start', 'heading_row_end', 'heading_cell_start', 'heading_cell_end', 'tbody_open', 'tbody_close', 'row_start', 'row_end', 'cell_start', 'cell_end', 'row_alt_start', 'row_alt_end', 'cell_alt_start', 'cell_alt_end', 'table_close') as $val)
|
||||
{
|
||||
if ( ! isset($this->template[$val]))
|
||||
{
|
||||
$this->template[$val] = $this->temp[$val];
|
||||
$this->template[$val] = $temp[$val];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Trackbacks
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/trackback.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/trackback.html
|
||||
*/
|
||||
class CI_Trackback {
|
||||
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Helpers
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/typography.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/typography.html
|
||||
*/
|
||||
class CI_Typography {
|
||||
|
||||
|
||||
@@ -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 1.3.1
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category UnitTesting
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/unit_testing.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/unit_testing.html
|
||||
*/
|
||||
class CI_Unit_test {
|
||||
|
||||
|
||||
+13
-11
@@ -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 1.0.0
|
||||
@@ -44,7 +45,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Uploads
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/file_uploading.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/file_uploading.html
|
||||
*/
|
||||
class CI_Upload {
|
||||
|
||||
@@ -867,7 +868,7 @@ class CI_Upload {
|
||||
$this->file_type = 'image/jpeg';
|
||||
}
|
||||
|
||||
$img_mimes = array('image/gif', 'image/jpeg', 'image/png');
|
||||
$img_mimes = array('image/gif', 'image/jpeg', 'image/png', 'image/webp');
|
||||
|
||||
return in_array($this->file_type, $img_mimes, TRUE);
|
||||
}
|
||||
@@ -901,7 +902,7 @@ class CI_Upload {
|
||||
}
|
||||
|
||||
// Images get some additional checks
|
||||
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png'), TRUE) && @getimagesize($this->file_temp) === FALSE)
|
||||
if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png', 'webp'), TRUE) && @getimagesize($this->file_temp) === FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1183,7 +1184,7 @@ class CI_Upload {
|
||||
* Prevents possible script execution from Apache's handling
|
||||
* of files' multiple extensions.
|
||||
*
|
||||
* @link http://httpd.apache.org/docs/1.3/mod/mod_mime.html#multipleext
|
||||
* @link https://httpd.apache.org/docs/1.3/mod/mod_mime.html#multipleext
|
||||
*
|
||||
* @param string $filename
|
||||
* @return string
|
||||
@@ -1227,10 +1228,13 @@ class CI_Upload {
|
||||
if (function_exists('finfo_file'))
|
||||
{
|
||||
$finfo = @finfo_open(FILEINFO_MIME);
|
||||
if (is_resource($finfo)) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
|
||||
if ($finfo !== FALSE) // It is possible that a FALSE value is returned, if there is no magic MIME database file found on the system
|
||||
{
|
||||
$mime = @finfo_file($finfo, $file['tmp_name']);
|
||||
finfo_close($finfo);
|
||||
if (PHP_VERSION_ID < 80100)
|
||||
{
|
||||
finfo_close($finfo);
|
||||
}
|
||||
|
||||
/* According to the comments section of the PHP manual page,
|
||||
* it is possible that this function returns an empty string
|
||||
@@ -1257,9 +1261,7 @@ class CI_Upload {
|
||||
*/
|
||||
if (DIRECTORY_SEPARATOR !== '\\')
|
||||
{
|
||||
$cmd = function_exists('escapeshellarg')
|
||||
? 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1'
|
||||
: 'file --brief --mime '.$file['tmp_name'].' 2>&1';
|
||||
$cmd = 'file --brief --mime '.escapeshellarg($file['tmp_name']).' 2>&1';
|
||||
|
||||
if (function_usable('exec'))
|
||||
{
|
||||
@@ -1276,7 +1278,7 @@ class CI_Upload {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! ini_get('safe_mode') && function_usable('shell_exec'))
|
||||
if (function_usable('shell_exec'))
|
||||
{
|
||||
$mime = @shell_exec($cmd);
|
||||
if (strlen($mime) > 0)
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -46,7 +47,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category User Agent
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/user_agent.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/user_agent.html
|
||||
*/
|
||||
class CI_User_agent {
|
||||
|
||||
@@ -498,7 +499,7 @@ class CI_User_agent {
|
||||
else
|
||||
{
|
||||
$referer_host = @parse_url($_SERVER['HTTP_REFERER'], PHP_URL_HOST);
|
||||
$own_host = parse_url(config_item('base_url'), PHP_URL_HOST);
|
||||
$own_host = parse_url((string) config_item('base_url'), PHP_URL_HOST);
|
||||
|
||||
$this->referer = ($referer_host && $referer_host !== $own_host);
|
||||
}
|
||||
|
||||
+100
-102
@@ -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 1.0.0
|
||||
@@ -51,7 +52,7 @@ if ( ! function_exists('xml_parser_create'))
|
||||
* @subpackage Libraries
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class CI_Xmlrpc {
|
||||
|
||||
@@ -559,7 +560,7 @@ class CI_Xmlrpc {
|
||||
*
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class XML_RPC_Client extends CI_Xmlrpc
|
||||
{
|
||||
@@ -743,7 +744,7 @@ class XML_RPC_Client extends CI_Xmlrpc
|
||||
{
|
||||
break;
|
||||
}
|
||||
// See https://bugs.php.net/bug.php?id=39598 and http://php.net/manual/en/function.fwrite.php#96951
|
||||
// See https://bugs.php.net/bug.php?id=39598 and https://secure.php.net/manual/en/function.fwrite.php#96951
|
||||
elseif ($result === 0)
|
||||
{
|
||||
if ($timestamp === 0)
|
||||
@@ -780,7 +781,7 @@ class XML_RPC_Client extends CI_Xmlrpc
|
||||
*
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class XML_RPC_Response
|
||||
{
|
||||
@@ -836,9 +837,7 @@ class XML_RPC_Response
|
||||
{
|
||||
// error
|
||||
$this->errno = $code;
|
||||
$this->errstr = htmlspecialchars($fstr,
|
||||
(is_php('5.4') ? ENT_XML1 | ENT_NOQUOTES : ENT_NOQUOTES),
|
||||
'UTF-8');
|
||||
$this->errstr = htmlspecialchars($fstr, ENT_XML1 | ENT_NOQUOTES, 'UTF-8');
|
||||
}
|
||||
elseif ( ! is_object($val))
|
||||
{
|
||||
@@ -1030,7 +1029,7 @@ class XML_RPC_Response
|
||||
*
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class XML_RPC_Message extends CI_Xmlrpc
|
||||
{
|
||||
@@ -1152,8 +1151,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
//-------------------------------------
|
||||
|
||||
$parser = xml_parser_create($this->xmlrpc_defencoding);
|
||||
$pname = (string) $parser;
|
||||
$this->xh[$pname] = array(
|
||||
$this->xh = array(
|
||||
'isf' => 0,
|
||||
'ac' => '',
|
||||
'headers' => array(),
|
||||
@@ -1162,10 +1160,9 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
'isf_reason' => 0
|
||||
);
|
||||
|
||||
xml_set_object($parser, $this);
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, TRUE);
|
||||
xml_set_element_handler($parser, 'open_tag', 'closing_tag');
|
||||
xml_set_character_data_handler($parser, 'character_data');
|
||||
xml_set_element_handler($parser, [$this, 'open_tag'], [$this, 'closing_tag']);
|
||||
xml_set_character_data_handler($parser, [$this, 'character_data']);
|
||||
//xml_set_default_handler($parser, 'default_handler');
|
||||
|
||||
// Get headers
|
||||
@@ -1176,7 +1173,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
{
|
||||
break;
|
||||
}
|
||||
$this->xh[$pname]['headers'][] = $line;
|
||||
$this->xh['headers'][] = $line;
|
||||
}
|
||||
$data = implode("\r\n", $lines);
|
||||
|
||||
@@ -1188,24 +1185,31 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
xml_get_current_line_number($parser));
|
||||
|
||||
$r = new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
|
||||
xml_parser_free($parser);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
xml_parser_free($parser);
|
||||
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
|
||||
// Got ourselves some badness, it seems
|
||||
if ($this->xh[$pname]['isf'] > 1)
|
||||
if ($this->xh['isf'] > 1)
|
||||
{
|
||||
if ($this->debug === TRUE)
|
||||
{
|
||||
echo "---Invalid Return---\n".$this->xh[$pname]['isf_reason']."---Invalid Return---\n\n";
|
||||
echo "---Invalid Return---\n".$this->xh['isf_reason']."---Invalid Return---\n\n";
|
||||
}
|
||||
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$pname]['isf_reason']);
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh['isf_reason']);
|
||||
}
|
||||
elseif ( ! is_object($this->xh[$pname]['value']))
|
||||
elseif ( ! is_object($this->xh['value']))
|
||||
{
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh[$pname]['isf_reason']);
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return'].' '.$this->xh['isf_reason']);
|
||||
}
|
||||
|
||||
// Display XML content for debugging
|
||||
@@ -1213,10 +1217,10 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
{
|
||||
echo '<pre>';
|
||||
|
||||
if (count($this->xh[$pname]['headers']) > 0)
|
||||
if (count($this->xh['headers']) > 0)
|
||||
{
|
||||
echo "---HEADERS---\n";
|
||||
foreach ($this->xh[$pname]['headers'] as $header)
|
||||
foreach ($this->xh['headers'] as $header)
|
||||
{
|
||||
echo $header."\n";
|
||||
}
|
||||
@@ -1224,13 +1228,13 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
}
|
||||
|
||||
echo "---DATA---\n".htmlspecialchars($data)."\n---END DATA---\n\n---PARSED---\n";
|
||||
var_dump($this->xh[$pname]['value']);
|
||||
var_dump($this->xh['value']);
|
||||
echo "\n---END PARSED---</pre>";
|
||||
}
|
||||
|
||||
// Send response
|
||||
$v = $this->xh[$pname]['value'];
|
||||
if ($this->xh[$pname]['isf'])
|
||||
$v = $this->xh['value'];
|
||||
if ($this->xh['isf'])
|
||||
{
|
||||
$errno_v = $v->me['struct']['faultCode'];
|
||||
$errstr_v = $v->me['struct']['faultString'];
|
||||
@@ -1249,7 +1253,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
$r = new XML_RPC_Response($v);
|
||||
}
|
||||
|
||||
$r->headers = $this->xh[$pname]['headers'];
|
||||
$r->headers = $this->xh['headers'];
|
||||
return $r;
|
||||
}
|
||||
|
||||
@@ -1280,26 +1284,24 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
*/
|
||||
public function open_tag($the_parser, $name)
|
||||
{
|
||||
$the_parser = (string) $the_parser;
|
||||
|
||||
// If invalid nesting, then return
|
||||
if ($this->xh[$the_parser]['isf'] > 1) return;
|
||||
if ($this->xh['isf'] > 1) return;
|
||||
|
||||
// Evaluate and check for correct nesting of XML elements
|
||||
if (count($this->xh[$the_parser]['stack']) === 0)
|
||||
if (count($this->xh['stack']) === 0)
|
||||
{
|
||||
if ($name !== 'METHODRESPONSE' && $name !== 'METHODCALL')
|
||||
{
|
||||
$this->xh[$the_parser]['isf'] = 2;
|
||||
$this->xh[$the_parser]['isf_reason'] = 'Top level XML-RPC element is missing';
|
||||
$this->xh['isf'] = 2;
|
||||
$this->xh['isf_reason'] = 'Top level XML-RPC element is missing';
|
||||
return;
|
||||
}
|
||||
}
|
||||
// not top level element: see if parent is OK
|
||||
elseif ( ! in_array($this->xh[$the_parser]['stack'][0], $this->valid_parents[$name], TRUE))
|
||||
elseif ( ! in_array($this->xh['stack'][0], $this->valid_parents[$name], TRUE))
|
||||
{
|
||||
$this->xh[$the_parser]['isf'] = 2;
|
||||
$this->xh[$the_parser]['isf_reason'] = 'XML-RPC element '.$name.' cannot be child of '.$this->xh[$the_parser]['stack'][0];
|
||||
$this->xh['isf'] = 2;
|
||||
$this->xh['isf_reason'] = 'XML-RPC element '.$name.' cannot be child of '.$this->xh['stack'][0];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1309,22 +1311,22 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
case 'ARRAY':
|
||||
// Creates array for child elements
|
||||
$cur_val = array('value' => array(), 'type' => $name);
|
||||
array_unshift($this->xh[$the_parser]['valuestack'], $cur_val);
|
||||
array_unshift($this->xh['valuestack'], $cur_val);
|
||||
break;
|
||||
case 'METHODNAME':
|
||||
case 'NAME':
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh['ac'] = '';
|
||||
break;
|
||||
case 'FAULT':
|
||||
$this->xh[$the_parser]['isf'] = 1;
|
||||
$this->xh['isf'] = 1;
|
||||
break;
|
||||
case 'PARAM':
|
||||
$this->xh[$the_parser]['value'] = NULL;
|
||||
$this->xh['value'] = NULL;
|
||||
break;
|
||||
case 'VALUE':
|
||||
$this->xh[$the_parser]['vt'] = 'value';
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh[$the_parser]['lv'] = 1;
|
||||
$this->xh['vt'] = 'value';
|
||||
$this->xh['ac'] = '';
|
||||
$this->xh['lv'] = 1;
|
||||
break;
|
||||
case 'I4':
|
||||
case 'INT':
|
||||
@@ -1333,23 +1335,23 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
if ($this->xh[$the_parser]['vt'] !== 'value')
|
||||
if ($this->xh['vt'] !== 'value')
|
||||
{
|
||||
//two data elements inside a value: an error occurred!
|
||||
$this->xh[$the_parser]['isf'] = 2;
|
||||
$this->xh[$the_parser]['isf_reason'] = 'There is a '.$name.' element following a '
|
||||
.$this->xh[$the_parser]['vt'].' element inside a single value';
|
||||
$this->xh['isf'] = 2;
|
||||
$this->xh['isf_reason'] = 'There is a '.$name.' element following a '
|
||||
.$this->xh['vt'].' element inside a single value';
|
||||
return;
|
||||
}
|
||||
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh['ac'] = '';
|
||||
break;
|
||||
case 'MEMBER':
|
||||
// Set name of <member> to nothing to prevent errors later if no <name> is found
|
||||
$this->xh[$the_parser]['valuestack'][0]['name'] = '';
|
||||
$this->xh['valuestack'][0]['name'] = '';
|
||||
|
||||
// Set NULL value to check to see if value passed for this param/member
|
||||
$this->xh[$the_parser]['value'] = NULL;
|
||||
$this->xh['value'] = NULL;
|
||||
break;
|
||||
case 'DATA':
|
||||
case 'METHODCALL':
|
||||
@@ -1359,15 +1361,15 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
break;
|
||||
default:
|
||||
/// An Invalid Element is Found, so we have trouble
|
||||
$this->xh[$the_parser]['isf'] = 2;
|
||||
$this->xh[$the_parser]['isf_reason'] = 'Invalid XML-RPC element found: '.$name;
|
||||
$this->xh['isf'] = 2;
|
||||
$this->xh['isf_reason'] = 'Invalid XML-RPC element found: '.$name;
|
||||
break;
|
||||
}
|
||||
|
||||
// Add current element name to stack, to allow validation of nesting
|
||||
array_unshift($this->xh[$the_parser]['stack'], $name);
|
||||
array_unshift($this->xh['stack'], $name);
|
||||
|
||||
$name === 'VALUE' OR $this->xh[$the_parser]['lv'] = 0;
|
||||
$name === 'VALUE' OR $this->xh['lv'] = 0;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1381,27 +1383,25 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
*/
|
||||
public function closing_tag($the_parser, $name)
|
||||
{
|
||||
$the_parser = (string) $the_parser;
|
||||
|
||||
if ($this->xh[$the_parser]['isf'] > 1) return;
|
||||
if ($this->xh['isf'] > 1) return;
|
||||
|
||||
// Remove current element from stack and set variable
|
||||
// NOTE: If the XML validates, then we do not have to worry about
|
||||
// the opening and closing of elements. Nesting is checked on the opening
|
||||
// tag so we be safe there as well.
|
||||
|
||||
$curr_elem = array_shift($this->xh[$the_parser]['stack']);
|
||||
$curr_elem = array_shift($this->xh['stack']);
|
||||
|
||||
switch ($name)
|
||||
{
|
||||
case 'STRUCT':
|
||||
case 'ARRAY':
|
||||
$cur_val = array_shift($this->xh[$the_parser]['valuestack']);
|
||||
$this->xh[$the_parser]['value'] = isset($cur_val['values']) ? $cur_val['values'] : array();
|
||||
$this->xh[$the_parser]['vt'] = strtolower($name);
|
||||
$cur_val = array_shift($this->xh['valuestack']);
|
||||
$this->xh['value'] = isset($cur_val['values']) ? $cur_val['values'] : array();
|
||||
$this->xh['vt'] = strtolower($name);
|
||||
break;
|
||||
case 'NAME':
|
||||
$this->xh[$the_parser]['valuestack'][0]['name'] = $this->xh[$the_parser]['ac'];
|
||||
$this->xh['valuestack'][0]['name'] = $this->xh['ac'];
|
||||
break;
|
||||
case 'BOOLEAN':
|
||||
case 'I4':
|
||||
@@ -1410,87 +1410,87 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
$this->xh[$the_parser]['vt'] = strtolower($name);
|
||||
$this->xh['vt'] = strtolower($name);
|
||||
|
||||
if ($name === 'STRING')
|
||||
{
|
||||
$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
|
||||
$this->xh['value'] = $this->xh['ac'];
|
||||
}
|
||||
elseif ($name === 'DATETIME.ISO8601')
|
||||
{
|
||||
$this->xh[$the_parser]['vt'] = $this->xmlrpcDateTime;
|
||||
$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
|
||||
$this->xh['vt'] = $this->xmlrpcDateTime;
|
||||
$this->xh['value'] = $this->xh['ac'];
|
||||
}
|
||||
elseif ($name === 'BASE64')
|
||||
{
|
||||
$this->xh[$the_parser]['value'] = base64_decode($this->xh[$the_parser]['ac']);
|
||||
$this->xh['value'] = base64_decode($this->xh['ac']);
|
||||
}
|
||||
elseif ($name === 'BOOLEAN')
|
||||
{
|
||||
// Translated BOOLEAN values to TRUE AND FALSE
|
||||
$this->xh[$the_parser]['value'] = (bool) $this->xh[$the_parser]['ac'];
|
||||
$this->xh['value'] = (bool) $this->xh['ac'];
|
||||
}
|
||||
elseif ($name=='DOUBLE')
|
||||
{
|
||||
// we have a DOUBLE
|
||||
// we must check that only 0123456789-.<space> are characters here
|
||||
$this->xh[$the_parser]['value'] = preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh[$the_parser]['ac'])
|
||||
? (float) $this->xh[$the_parser]['ac']
|
||||
$this->xh['value'] = preg_match('/^[+-]?[eE0-9\t \.]+$/', $this->xh['ac'])
|
||||
? (float) $this->xh['ac']
|
||||
: 'ERROR_NON_NUMERIC_FOUND';
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have an I4/INT
|
||||
// we must check that only 0123456789-<space> are characters here
|
||||
$this->xh[$the_parser]['value'] = preg_match('/^[+-]?[0-9\t ]+$/', $this->xh[$the_parser]['ac'])
|
||||
? (int) $this->xh[$the_parser]['ac']
|
||||
$this->xh['value'] = preg_match('/^[+-]?[0-9\t ]+$/', $this->xh['ac'])
|
||||
? (int) $this->xh['ac']
|
||||
: 'ERROR_NON_NUMERIC_FOUND';
|
||||
}
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh[$the_parser]['lv'] = 3; // indicate we've found a value
|
||||
$this->xh['ac'] = '';
|
||||
$this->xh['lv'] = 3; // indicate we've found a value
|
||||
break;
|
||||
case 'VALUE':
|
||||
// This if() detects if no scalar was inside <VALUE></VALUE>
|
||||
if ($this->xh[$the_parser]['vt'] == 'value')
|
||||
if ($this->xh['vt'] == 'value')
|
||||
{
|
||||
$this->xh[$the_parser]['value'] = $this->xh[$the_parser]['ac'];
|
||||
$this->xh[$the_parser]['vt'] = $this->xmlrpcString;
|
||||
$this->xh['value'] = $this->xh['ac'];
|
||||
$this->xh['vt'] = $this->xmlrpcString;
|
||||
}
|
||||
|
||||
// build the XML-RPC value out of the data received, and substitute it
|
||||
$temp = new XML_RPC_Values($this->xh[$the_parser]['value'], $this->xh[$the_parser]['vt']);
|
||||
$temp = new XML_RPC_Values($this->xh['value'], $this->xh['vt']);
|
||||
|
||||
if (count($this->xh[$the_parser]['valuestack']) && $this->xh[$the_parser]['valuestack'][0]['type'] === 'ARRAY')
|
||||
if (count($this->xh['valuestack']) && $this->xh['valuestack'][0]['type'] === 'ARRAY')
|
||||
{
|
||||
// Array
|
||||
$this->xh[$the_parser]['valuestack'][0]['values'][] = $temp;
|
||||
$this->xh['valuestack'][0]['values'][] = $temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Struct
|
||||
$this->xh[$the_parser]['value'] = $temp;
|
||||
$this->xh['value'] = $temp;
|
||||
}
|
||||
break;
|
||||
case 'MEMBER':
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh['ac'] = '';
|
||||
|
||||
// If value add to array in the stack for the last element built
|
||||
if ($this->xh[$the_parser]['value'])
|
||||
if ($this->xh['value'])
|
||||
{
|
||||
$this->xh[$the_parser]['valuestack'][0]['values'][$this->xh[$the_parser]['valuestack'][0]['name']] = $this->xh[$the_parser]['value'];
|
||||
$this->xh['valuestack'][0]['values'][$this->xh['valuestack'][0]['name']] = $this->xh['value'];
|
||||
}
|
||||
break;
|
||||
case 'DATA':
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh['ac'] = '';
|
||||
break;
|
||||
case 'PARAM':
|
||||
if ($this->xh[$the_parser]['value'])
|
||||
if ($this->xh['value'])
|
||||
{
|
||||
$this->xh[$the_parser]['params'][] = $this->xh[$the_parser]['value'];
|
||||
$this->xh['params'][] = $this->xh['value'];
|
||||
}
|
||||
break;
|
||||
case 'METHODNAME':
|
||||
$this->xh[$the_parser]['method'] = ltrim($this->xh[$the_parser]['ac']);
|
||||
$this->xh['method'] = ltrim($this->xh['ac']);
|
||||
break;
|
||||
case 'PARAMS':
|
||||
case 'FAULT':
|
||||
@@ -1515,24 +1515,22 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
*/
|
||||
public function character_data($the_parser, $data)
|
||||
{
|
||||
$the_parser = (string) $the_parser;
|
||||
|
||||
if ($this->xh[$the_parser]['isf'] > 1) return; // XML Fault found already
|
||||
if ($this->xh['isf'] > 1) return; // XML Fault found already
|
||||
|
||||
// If a value has not been found
|
||||
if ($this->xh[$the_parser]['lv'] !== 3)
|
||||
if ($this->xh['lv'] !== 3)
|
||||
{
|
||||
if ($this->xh[$the_parser]['lv'] === 1)
|
||||
if ($this->xh['lv'] === 1)
|
||||
{
|
||||
$this->xh[$the_parser]['lv'] = 2; // Found a value
|
||||
$this->xh['lv'] = 2; // Found a value
|
||||
}
|
||||
|
||||
if ( ! isset($this->xh[$the_parser]['ac']))
|
||||
if ( ! isset($this->xh['ac']))
|
||||
{
|
||||
$this->xh[$the_parser]['ac'] = '';
|
||||
$this->xh['ac'] = '';
|
||||
}
|
||||
|
||||
$this->xh[$the_parser]['ac'] .= $data;
|
||||
$this->xh['ac'] .= $data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1649,7 +1647,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
*
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class XML_RPC_Values extends CI_Xmlrpc
|
||||
{
|
||||
@@ -1720,7 +1718,7 @@ class XML_RPC_Values extends CI_Xmlrpc
|
||||
|
||||
if ($typeof != 1)
|
||||
{
|
||||
echo '<strong>XML_RPC_Values</strong>: not a scalar type (${typeof})<br />';
|
||||
echo "<strong>XML_RPC_Values</strong>: not a scalar type ($typeof)<br />";
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1911,10 +1909,10 @@ class XML_RPC_Values extends CI_Xmlrpc
|
||||
* @param int unix timestamp
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
*/
|
||||
public function iso8601_encode($time, $utc = FALSE)
|
||||
{
|
||||
return ($utc) ? strftime('%Y%m%dT%H:%i:%s', $time) : gmstrftime('%Y%m%dT%H:%i:%s', $time);
|
||||
return ($utc) ? date('Ymd\TH:i:s', $time) : gmdate('Ymd\TH:i:s', $time);
|
||||
}
|
||||
|
||||
} // END XML_RPC_Values Class
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -56,7 +57,7 @@ if ( ! class_exists('CI_Xmlrpc', FALSE))
|
||||
* @subpackage Libraries
|
||||
* @category XML-RPC
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/xmlrpc.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/xmlrpc.html
|
||||
*/
|
||||
class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
|
||||
@@ -233,9 +234,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
|
||||
$parser = xml_parser_create($this->xmlrpc_defencoding);
|
||||
$parser_object = new XML_RPC_Message('filler');
|
||||
$pname = (string) $parser;
|
||||
|
||||
$parser_object->xh[$pname] = array(
|
||||
$parser_object->xh = array(
|
||||
'isf' => 0,
|
||||
'isf_reason' => '',
|
||||
'params' => array(),
|
||||
@@ -244,10 +244,9 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
'method' => ''
|
||||
);
|
||||
|
||||
xml_set_object($parser, $parser_object);
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, TRUE);
|
||||
xml_set_element_handler($parser, 'open_tag', 'closing_tag');
|
||||
xml_set_character_data_handler($parser, 'character_data');
|
||||
xml_set_element_handler($parser, [$parser_object, 'open_tag'], [$parser_object, 'closing_tag']);
|
||||
xml_set_character_data_handler($parser, [$parser_object, 'character_data']);
|
||||
//xml_set_default_handler($parser, 'default_handler');
|
||||
|
||||
//-------------------------------------
|
||||
@@ -262,27 +261,33 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
sprintf('XML error: %s at line %d',
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
xml_get_current_line_number($parser)));
|
||||
xml_parser_free($parser);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
}
|
||||
elseif ($parser_object->xh[$pname]['isf'])
|
||||
elseif ($parser_object->xh['isf'])
|
||||
{
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['invalid_return'], $this->xmlrpcstr['invalid_return']);
|
||||
}
|
||||
else
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
if (PHP_VERSION_ID < 80000)
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
}
|
||||
|
||||
$m = new XML_RPC_Message($parser_object->xh[$pname]['method']);
|
||||
$m = new XML_RPC_Message($parser_object->xh['method']);
|
||||
$plist = '';
|
||||
|
||||
for ($i = 0, $c = count($parser_object->xh[$pname]['params']); $i < $c; $i++)
|
||||
for ($i = 0, $c = count($parser_object->xh['params']); $i < $c; $i++)
|
||||
{
|
||||
if ($this->debug === TRUE)
|
||||
{
|
||||
$plist .= $i.' - '.print_r(get_object_vars($parser_object->xh[$pname]['params'][$i]), TRUE).";\n";
|
||||
$plist .= $i.' - '.print_r(get_object_vars($parser_object->xh['params'][$i]), TRUE).";\n";
|
||||
}
|
||||
|
||||
$m->addParam($parser_object->xh[$pname]['params'][$i]);
|
||||
$m->addParam($parser_object->xh['params'][$i]);
|
||||
}
|
||||
|
||||
if ($this->debug === TRUE)
|
||||
@@ -348,7 +353,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
|
||||
}
|
||||
}
|
||||
elseif (($objectCall && ! is_callable(array($method_parts[0], $method_parts[1])))
|
||||
elseif (($objectCall && ( ! method_exists($method_parts[0], $method_parts[1]) OR ! (new ReflectionMethod($method_parts[0], $method_parts[1]))->isPublic()))
|
||||
OR ( ! $objectCall && ! is_callable($this->methods[$methName]['function']))
|
||||
)
|
||||
{
|
||||
@@ -550,8 +555,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
*/
|
||||
public function multicall_error($err)
|
||||
{
|
||||
$str = is_string($err) ? $this->xmlrpcstr["multicall_${err}"] : $err->faultString();
|
||||
$code = is_string($err) ? $this->xmlrpcerr["multicall_${err}"] : $err->faultCode();
|
||||
$str = is_string($err) ? $this->xmlrpcstr["multicall_$err"] : $err->faultString();
|
||||
$code = is_string($err) ? $this->xmlrpcerr["multicall_$err"] : $err->faultCode();
|
||||
|
||||
$struct['faultCode'] = new XML_RPC_Values($code, 'int');
|
||||
$struct['faultString'] = new XML_RPC_Values($str, 'string');
|
||||
|
||||
@@ -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 1.0.0
|
||||
@@ -41,7 +42,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* Zip Compression Class
|
||||
*
|
||||
* This class is based on a library I found at Zend:
|
||||
* http://www.zend.com/codex.php?id=696&single=1
|
||||
* https://www.zend.com/codex.php?id=696&single=1
|
||||
*
|
||||
* The original library is a little rough around the edges so I
|
||||
* refactored it and added several additional methods -- Rick Ellis
|
||||
@@ -50,7 +51,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
* @subpackage Libraries
|
||||
* @category Encryption
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/zip.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/zip.html
|
||||
*/
|
||||
class CI_Zip {
|
||||
|
||||
@@ -119,7 +120,7 @@ class CI_Zip {
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
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'));
|
||||
|
||||
$this->now = time();
|
||||
log_message('info', 'Zip Compression Class Initialized');
|
||||
@@ -366,7 +367,7 @@ class CI_Zip {
|
||||
|
||||
while (FALSE !== ($file = readdir($fp)))
|
||||
{
|
||||
if ($file[0] === '.')
|
||||
if ($file === '.' OR $file === '..')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -406,13 +407,14 @@ class CI_Zip {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $this->zipdata
|
||||
.$this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"
|
||||
// @see https://github.com/bcit-ci/CodeIgniter/issues/5864
|
||||
$footer = $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00"
|
||||
.pack('v', $this->entries) // total # of entries "on this disk"
|
||||
.pack('v', $this->entries) // total # of entries overall
|
||||
.pack('V', self::strlen($this->directory)) // size of central dir
|
||||
.pack('V', self::strlen($this->zipdata)) // offset to start of central dir
|
||||
."\x00\x00"; // .zip file comment length
|
||||
return $this->zipdata.$footer;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -519,9 +521,6 @@ class CI_Zip {
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>403 Forbidden</title>
|
||||
</head>
|
||||
|
||||
Reference in New Issue
Block a user