Update database and helper functionality in CodeIgniter
Revised database drivers, query builder, and file/inflector helpers for improved consistency and functionality. Updated copyrights, links, and standardized function names including deprecating `is_countable` in favor of `word_is_countable`. Added support for new SQL features and optimized query handling.
This commit is contained in:
Executable → Regular
+4
-3
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0.0
|
||||
* @filesource
|
||||
|
||||
Executable → Regular
+8
-7
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0.0
|
||||
* @filesource
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
Executable → Regular
+8
-7
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0
|
||||
* @filesource
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0
|
||||
* @filesource
|
||||
@@ -276,7 +277,7 @@ class CI_Cache_file extends CI_Driver {
|
||||
|
||||
if ($data['ttl'] > 0 && time() > $data['time'] + $data['ttl'])
|
||||
{
|
||||
unlink($this->_cache_path.$id);
|
||||
file_exists($this->_cache_path.$id) && unlink($this->_cache_path.$id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+16
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0
|
||||
* @filesource
|
||||
@@ -198,7 +199,12 @@ class CI_Cache_memcached extends CI_Driver {
|
||||
*/
|
||||
public function increment($id, $offset = 1)
|
||||
{
|
||||
return $this->_memcached->increment($id, $offset);
|
||||
if (($result = $this->_memcached->increment($id, $offset)) === FALSE)
|
||||
{
|
||||
return $this->_memcached->add($id, $offset) ? $offset : FALSE;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -212,7 +218,12 @@ class CI_Cache_memcached extends CI_Driver {
|
||||
*/
|
||||
public function decrement($id, $offset = 1)
|
||||
{
|
||||
return $this->_memcached->decrement($id, $offset);
|
||||
if (($result = $this->_memcached->decrement($id, $offset)) === FALSE)
|
||||
{
|
||||
return $this->_memcached->add($id, 0) ? 0 : FALSE;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
+39
-19
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -76,6 +77,20 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
protected $_serialized = array();
|
||||
|
||||
/**
|
||||
* del()/delete() method name depending on phpRedis version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_delete_name;
|
||||
|
||||
/**
|
||||
* sRem()/sRemove() method name depending on phpRedis version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_sRemove_name;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -97,6 +112,20 @@ class CI_Cache_redis extends CI_Driver
|
||||
return;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if ($CI->config->load('redis', TRUE, TRUE))
|
||||
@@ -135,10 +164,6 @@ class CI_Cache_redis extends CI_Driver
|
||||
{
|
||||
log_message('error', 'Cache: Redis connection refused ('.$e->getMessage().')');
|
||||
}
|
||||
|
||||
// Initialize the index of serialized values.
|
||||
$serialized = $this->_redis->sMembers('_ci_redis_serialized');
|
||||
empty($serialized) OR $this->_serialized = array_flip($serialized);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -153,7 +178,7 @@ class CI_Cache_redis extends CI_Driver
|
||||
{
|
||||
$value = $this->_redis->get($key);
|
||||
|
||||
if ($value !== FALSE && isset($this->_serialized[$key]))
|
||||
if ($value !== FALSE && $this->_redis->sIsMember('_ci_redis_serialized', $key))
|
||||
{
|
||||
return unserialize($value);
|
||||
}
|
||||
@@ -184,10 +209,9 @@ class CI_Cache_redis extends CI_Driver
|
||||
isset($this->_serialized[$id]) OR $this->_serialized[$id] = TRUE;
|
||||
$data = serialize($data);
|
||||
}
|
||||
elseif (isset($this->_serialized[$id]))
|
||||
else
|
||||
{
|
||||
$this->_serialized[$id] = NULL;
|
||||
$this->_redis->sRemove('_ci_redis_serialized', $id);
|
||||
$this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $id);
|
||||
}
|
||||
|
||||
return $this->_redis->set($id, $data, $ttl);
|
||||
@@ -203,16 +227,12 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
public function delete($key)
|
||||
{
|
||||
if ($this->_redis->delete($key) !== 1)
|
||||
if ($this->_redis->{static::$_delete_name}($key) !== 1)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (isset($this->_serialized[$key]))
|
||||
{
|
||||
$this->_serialized[$key] = NULL;
|
||||
$this->_redis->sRemove('_ci_redis_serialized', $key);
|
||||
}
|
||||
$this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $key);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -228,7 +248,7 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
public function increment($id, $offset = 1)
|
||||
{
|
||||
return $this->_redis->incr($id, $offset);
|
||||
return $this->_redis->incrBy($id, $offset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -242,7 +262,7 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
public function decrement($id, $offset = 1)
|
||||
{
|
||||
return $this->_redis->decr($id, $offset);
|
||||
return $this->_redis->decrBy($id, $offset);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
+9
-8
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 {
|
||||
|
||||
Executable → Regular
+4
-3
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
|
||||
Executable → Regular
+43
-18
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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 {
|
||||
|
||||
@@ -397,7 +398,7 @@ class CI_Email {
|
||||
$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');
|
||||
}
|
||||
@@ -961,10 +962,8 @@ class CI_Email {
|
||||
{
|
||||
return 'plain-attach';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'plain';
|
||||
}
|
||||
|
||||
return 'plain';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1034,9 +1033,17 @@ class CI_Email {
|
||||
*/
|
||||
public function valid_email($email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
{
|
||||
$email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos));
|
||||
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);
|
||||
|
||||
if ($domain !== FALSE)
|
||||
{
|
||||
$email = $account.'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||
@@ -1851,9 +1858,17 @@ class CI_Email {
|
||||
*/
|
||||
protected function _validate_email_for_shell(&$email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && $atpos = strpos($email, '@'))
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
{
|
||||
$email = self::substr($email, 0, ++$atpos).idn_to_ascii(self::substr($email, $atpos));
|
||||
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);
|
||||
|
||||
if ($domain !== FALSE)
|
||||
{
|
||||
$email = $account.'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email && preg_match('#\A[a-z0-9._+-]+@[a-z0-9.-]{1,253}\z#i', $email));
|
||||
@@ -2068,7 +2083,19 @@ class CI_Email {
|
||||
$this->_send_command('hello');
|
||||
$this->_send_command('starttls');
|
||||
|
||||
$crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, STREAM_CRYPTO_METHOD_TLS_CLIENT);
|
||||
/**
|
||||
* STREAM_CRYPTO_METHOD_TLS_CLIENT is quite the mess ...
|
||||
*
|
||||
* - On PHP <5.6 it doesn't even mean TLS, but SSL 2.0, and there's no option to use actual TLS
|
||||
* - On PHP 5.6.0-5.6.6, >=7.2 it means negotiation with any of TLS 1.0, 1.1, 1.2
|
||||
* - On PHP 5.6.7-7.1.* it means only TLS 1.0
|
||||
*
|
||||
* We want the negotiation, so we'll force it below ...
|
||||
*/
|
||||
$method = is_php('5.6')
|
||||
? STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
|
||||
: STREAM_CRYPTO_METHOD_TLS_CLIENT;
|
||||
$crypto = stream_socket_enable_crypto($this->_smtp_connect, TRUE, $method);
|
||||
|
||||
if ($crypto !== TRUE)
|
||||
{
|
||||
@@ -2259,10 +2286,8 @@ class CI_Email {
|
||||
usleep(250000);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$timestamp = 0;
|
||||
}
|
||||
|
||||
$timestamp = 0;
|
||||
}
|
||||
|
||||
if ($result === FALSE)
|
||||
|
||||
Executable → Regular
+6
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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/encryption.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/encryption.html
|
||||
*/
|
||||
class CI_Encrypt {
|
||||
|
||||
@@ -198,7 +199,7 @@ class CI_Encrypt {
|
||||
* 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
|
||||
* For more details, see https://codeigniter.com/userguide3/installation/upgrade_200.html#encryption
|
||||
*
|
||||
* @param string
|
||||
* @param int (mcrypt mode constant)
|
||||
|
||||
Executable → Regular
+13
-14
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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)
|
||||
@@ -476,7 +477,7 @@ class CI_Encryption {
|
||||
|
||||
$iv = ($iv_size = openssl_cipher_iv_length($params['handle']))
|
||||
? $this->create_key($iv_size)
|
||||
: NULL;
|
||||
: '';
|
||||
|
||||
$data = openssl_encrypt(
|
||||
$data,
|
||||
@@ -585,7 +586,7 @@ class CI_Encryption {
|
||||
}
|
||||
else
|
||||
{
|
||||
$iv = NULL;
|
||||
$iv = '';
|
||||
}
|
||||
|
||||
if (mcrypt_generic_init($params['handle'], $params['key'], $iv) < 0)
|
||||
@@ -632,7 +633,7 @@ class CI_Encryption {
|
||||
}
|
||||
else
|
||||
{
|
||||
$iv = NULL;
|
||||
$iv = '';
|
||||
}
|
||||
|
||||
return empty($params['handle'])
|
||||
@@ -682,10 +683,8 @@ class CI_Encryption {
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$params['mode'] = $this->_modes[$this->_driver][$params['mode']];
|
||||
}
|
||||
|
||||
$params['mode'] = $this->_modes[$this->_driver][$params['mode']];
|
||||
}
|
||||
|
||||
if (isset($params['hmac']) && $params['hmac'] === FALSE)
|
||||
@@ -912,8 +911,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);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
+22
-7
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
@@ -584,7 +585,7 @@ class CI_Form_validation {
|
||||
{
|
||||
if ($row['is_array'] === FALSE)
|
||||
{
|
||||
isset($_POST[$field]) && $_POST[$field] = $row['postdata'];
|
||||
isset($_POST[$field]) && $_POST[$field] = is_array($row['postdata']) ? NULL : $row['postdata'];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1056,7 +1057,7 @@ class CI_Form_validation {
|
||||
{
|
||||
return is_array($str)
|
||||
? (empty($str) === FALSE)
|
||||
: (trim($str) !== '');
|
||||
: (trim((string) $str) !== '');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1208,6 +1209,13 @@ class CI_Form_validation {
|
||||
$str = $matches[2];
|
||||
}
|
||||
|
||||
// Apparently, FILTER_VALIDATE_URL doesn't reject digit-only names for some reason ...
|
||||
// See https://github.com/bcit-ci/CodeIgniter/issues/5755
|
||||
if (ctype_digit($str))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// PHP 7 accepts IPv6 addresses within square brackets as hostnames,
|
||||
// but it appears that the PR that came in with https://bugs.php.net/bug.php?id=68039
|
||||
// was never merged into a PHP 5 branch ... https://3v4l.org/8PsSN
|
||||
@@ -1231,7 +1239,14 @@ class CI_Form_validation {
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches))
|
||||
{
|
||||
$str = $matches[1].'@'.idn_to_ascii($matches[2]);
|
||||
$domain = defined('INTL_IDNA_VARIANT_UTS46')
|
||||
? idn_to_ascii($matches[2], 0, INTL_IDNA_VARIANT_UTS46)
|
||||
: idn_to_ascii($matches[2]);
|
||||
|
||||
if ($domain !== FALSE)
|
||||
{
|
||||
$str = $matches[1].'@'.$domain;
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) filter_var($str, FILTER_VALIDATE_EMAIL);
|
||||
|
||||
Executable → Regular
+6
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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)
|
||||
{
|
||||
|
||||
Executable → Regular
+9
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
@@ -835,7 +836,10 @@ class CI_Image_lib {
|
||||
imagedestroy($dst_img);
|
||||
imagedestroy($src_img);
|
||||
|
||||
chmod($this->full_dst_path, $this->file_permissions);
|
||||
if ($this->dynamic_output !== TRUE)
|
||||
{
|
||||
chmod($this->full_dst_path, $this->file_permissions);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 Javascript
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/javascript.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/javascript.html
|
||||
* @deprecated 3.0.0 This was never a good idea in the first place.
|
||||
*/
|
||||
class CI_Javascript {
|
||||
|
||||
Executable → Regular
+6
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 Loader
|
||||
* @author EllisLab Dev Team
|
||||
* @link https://codeigniter.com/user_guide/libraries/javascript.html
|
||||
* @link https://codeigniter.com/userguide3/libraries/javascript.html
|
||||
*/
|
||||
class CI_Jquery extends CI_Javascript {
|
||||
|
||||
@@ -789,7 +790,7 @@ class CI_Jquery extends CI_Javascript {
|
||||
/**
|
||||
* Corner Plugin
|
||||
*
|
||||
* @link http://www.malsup.com/jquery/corner/
|
||||
* @link https://www.malsup.com/jquery/corner/
|
||||
* @param string $element
|
||||
* @param string $corner_style
|
||||
* @return string
|
||||
|
||||
Executable → Regular
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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;
|
||||
|
||||
Executable → Regular
+11
-7
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
@@ -339,6 +340,10 @@ class CI_Pagination {
|
||||
}
|
||||
}
|
||||
|
||||
// _parse_attributes(), called by initialize(), needs to run at least once
|
||||
// in order to enable "rel" attributes, and this triggers it.
|
||||
isset($params['attributes']) OR $params['attributes'] = array();
|
||||
|
||||
$this->initialize($params);
|
||||
log_message('info', 'Pagination Class Initialized');
|
||||
}
|
||||
@@ -353,8 +358,7 @@ class CI_Pagination {
|
||||
*/
|
||||
public function initialize(array $params = array())
|
||||
{
|
||||
isset($params['attributes']) OR $params['attributes'] = array();
|
||||
if (is_array($params['attributes']))
|
||||
if (isset($params['attributes']) && is_array($params['attributes']))
|
||||
{
|
||||
$this->_parse_attributes($params['attributes']);
|
||||
unset($params['attributes']);
|
||||
@@ -683,7 +687,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
|
||||
*/
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
|
||||
Executable → Regular
+16
-15
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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 {
|
||||
|
||||
@@ -105,7 +106,7 @@ class CI_Profiler {
|
||||
{
|
||||
if ( ! isset($config[$section]))
|
||||
{
|
||||
$this->_compile_{$section} = TRUE;
|
||||
$this->{'_compile_'.$section} = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ class CI_Profiler {
|
||||
{
|
||||
if (in_array($method, $this->_available_sections))
|
||||
{
|
||||
$this->_compile_{$method} = ($enable !== FALSE);
|
||||
$this->{'_compile_'.$method} = ($enable !== FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,17 +487,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 +525,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 +555,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}();
|
||||
|
||||
Executable → Regular
+97
-50
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 2.0.0
|
||||
* @filesource
|
||||
@@ -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();
|
||||
@@ -192,6 +207,12 @@ class CI_Session {
|
||||
{
|
||||
// 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');
|
||||
|
||||
@@ -241,10 +262,8 @@ class CI_Session {
|
||||
{
|
||||
return $prefix.$class;
|
||||
}
|
||||
else
|
||||
{
|
||||
log_message('debug', 'Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.');
|
||||
}
|
||||
|
||||
log_message('debug', 'Session: '.$prefix.$class.".php found but it doesn't declare class ".$prefix.$class.'.');
|
||||
}
|
||||
|
||||
return 'CI_'.$class;
|
||||
@@ -288,13 +307,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))
|
||||
{
|
||||
@@ -417,9 +466,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]);
|
||||
}
|
||||
@@ -606,7 +653,7 @@ class CI_Session {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unmark flash
|
||||
* Unmark temp
|
||||
*
|
||||
* @param mixed $key Session data key(s)
|
||||
* @return void
|
||||
@@ -727,7 +774,7 @@ class CI_Session {
|
||||
*
|
||||
* Legacy CI_Session compatibility method
|
||||
*
|
||||
* @returns array
|
||||
* @return array
|
||||
*/
|
||||
public function &get_userdata()
|
||||
{
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -46,7 +47,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
|
||||
*/
|
||||
interface SessionHandlerInterface {
|
||||
|
||||
|
||||
Executable → Regular
+43
-32
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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;
|
||||
|
||||
@@ -112,6 +113,23 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* PHP 5.x validate ID
|
||||
*
|
||||
* Enforces session.use_strict_mode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function php5_validate_id()
|
||||
{
|
||||
if ($this->_success === 0 && isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateId($_COOKIE[$this->_config['cookie_name']]))
|
||||
{
|
||||
unset($_COOKIE[$this->_config['cookie_name']]);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Cookie destroy
|
||||
*
|
||||
@@ -122,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']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -167,25 +199,4 @@ abstract class CI_Session_driver implements SessionHandlerInterface {
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Fail
|
||||
*
|
||||
* Drivers other than the 'files' one don't (need to) use the
|
||||
* session.save_path INI setting, but that leads to confusing
|
||||
* error messages emitted by PHP when open() or write() fail,
|
||||
* as the message contains session.save_path ...
|
||||
* To work around the problem, the drivers will call this method
|
||||
* so that the INI is set just in time for the error message to
|
||||
* be properly generated.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _fail()
|
||||
{
|
||||
ini_set('session.save_path', config_item('sess_save_path'));
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
|
||||
Executable → Regular
+104
-53
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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
|
||||
@@ -130,9 +131,11 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
{
|
||||
if (empty($this->_db->conn_id) && ! $this->_db->db_connect())
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->php5_validate_id();
|
||||
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
@@ -148,48 +151,47 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
*/
|
||||
public function read($session_id)
|
||||
{
|
||||
if ($this->_get_lock($session_id) !== FALSE)
|
||||
if ($this->_get_lock($session_id) === FALSE)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
$this->_session_id = $session_id;
|
||||
|
||||
$this->_db
|
||||
->select('data')
|
||||
->from($this->_config['save_path'])
|
||||
->where('id', $session_id);
|
||||
|
||||
if ($this->_config['match_ip'])
|
||||
{
|
||||
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
|
||||
{
|
||||
// PHP7 will reuse the same SessionHandler object after
|
||||
// ID regeneration, so we need to explicitly set this to
|
||||
// FALSE instead of relying on the default ...
|
||||
$this->_row_exists = FALSE;
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
}
|
||||
|
||||
// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
|
||||
// PITA to work with, so we use base64-encoded data in a TEXT
|
||||
// field instead.
|
||||
$result = ($this->_platform === 'postgre')
|
||||
? base64_decode(rtrim($result->data))
|
||||
: $result->data;
|
||||
|
||||
$this->_fingerprint = md5($result);
|
||||
$this->_row_exists = TRUE;
|
||||
return $result;
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
// Needed by write() to detect session_regenerate_id() calls
|
||||
$this->_session_id = $session_id;
|
||||
|
||||
$this->_db
|
||||
->select('data')
|
||||
->from($this->_config['save_path'])
|
||||
->where('id', $session_id);
|
||||
|
||||
if ($this->_config['match_ip'])
|
||||
{
|
||||
$this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
if ( ! ($result = $this->_db->get()) OR ($result = $result->row()) === NULL)
|
||||
{
|
||||
// PHP7 will reuse the same SessionHandler object after
|
||||
// ID regeneration, so we need to explicitly set this to
|
||||
// FALSE instead of relying on the default ...
|
||||
$this->_row_exists = FALSE;
|
||||
$this->_fingerprint = md5('');
|
||||
return '';
|
||||
}
|
||||
|
||||
// PostgreSQL's variant of a BLOB datatype is Bytea, which is a
|
||||
// PITA to work with, so we use base64-encoded data in a TEXT
|
||||
// field instead.
|
||||
$result = ($this->_platform === 'postgre')
|
||||
? base64_decode(rtrim($result->data))
|
||||
: $result->data;
|
||||
|
||||
$this->_fingerprint = md5($result);
|
||||
$this->_row_exists = TRUE;
|
||||
return $result;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -213,7 +215,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
{
|
||||
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_row_exists = FALSE;
|
||||
@@ -221,7 +223,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
}
|
||||
elseif ($this->_lock === FALSE)
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
if ($this->_row_exists === FALSE)
|
||||
@@ -240,7 +242,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_db->where('id', $session_id);
|
||||
@@ -263,7 +265,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -278,7 +280,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
public function close()
|
||||
{
|
||||
return ($this->_lock && ! $this->_release_lock())
|
||||
? $this->_fail()
|
||||
? $this->_failure
|
||||
: $this->_success;
|
||||
}
|
||||
|
||||
@@ -307,7 +309,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
if ( ! $this->_db->delete($this->_config['save_path']))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,7 +319,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -337,7 +339,56 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
return ($this->_db->delete($this->_config['save_path'], 'timestamp < '.(time() - $maxlifetime)))
|
||||
? $this->_success
|
||||
: $this->_fail();
|
||||
: $this->_failure;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 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 Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
{
|
||||
// Prevent previous QB calls from messing with our queries
|
||||
$this->_db->reset_query();
|
||||
|
||||
$this->_db->select('1')->from($this->_config['save_path'])->where('id', $id);
|
||||
empty($this->_config['match_ip']) OR $this->_db->where('ip_address', $_SERVER['REMOTE_ADDR']);
|
||||
$result = $this->_db->get();
|
||||
empty($result) OR $result = $result->row();
|
||||
|
||||
return ! empty($result);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
+52
-9
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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,12 +29,13 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2017, 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 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'));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -135,12 +136,14 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if ( ! mkdir($save_path, 0700, TRUE))
|
||||
{
|
||||
throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not a directory, doesn't exist or cannot be created.");
|
||||
log_message('error', "Session: Configured save path '".$this->_config['save_path']."' is not a directory, doesn't exist or cannot be created.");
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
elseif ( ! is_writable($save_path))
|
||||
{
|
||||
throw new Exception("Session: Configured save path '".$this->_config['save_path']."' is not writable by the PHP process.");
|
||||
log_message('error', "Session: Configured save path '".$this->_config['save_path']."' is not writable by the PHP process.");
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_config['save_path'] = $save_path;
|
||||
@@ -148,6 +151,8 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
.$name // we'll use the session cookie name as a prefix to avoid collisions
|
||||
.($this->_config['match_ip'] ? md5($_SERVER['REMOTE_ADDR']) : '');
|
||||
|
||||
$this->php5_validate_id();
|
||||
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
@@ -192,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
|
||||
@@ -391,6 +400,40 @@ 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 Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
{
|
||||
$result = is_file($this->_file_path.$id);
|
||||
clearstatcache(TRUE, $this->_file_path.$id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
|
||||
Executable → Regular
+53
-15
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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
|
||||
@@ -117,7 +118,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
{
|
||||
$this->_memcached = NULL;
|
||||
log_message('error', 'Session: Invalid Memcached save path format: '.$this->_config['save_path']);
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
foreach ($matches as $match)
|
||||
@@ -142,9 +143,11 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
if (empty($server_list))
|
||||
{
|
||||
log_message('error', 'Session: Memcached server pool is empty.');
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->php5_validate_id();
|
||||
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
@@ -170,7 +173,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $session_data;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -188,14 +191,14 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
{
|
||||
if ( ! isset($this->_memcached, $this->_lock_key))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
// Was the ID regenerated?
|
||||
elseif ($session_id !== $this->_session_id)
|
||||
{
|
||||
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_fingerprint = md5('');
|
||||
@@ -213,7 +216,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
elseif (
|
||||
$this->_memcached->touch($key, $this->_config['expiration'])
|
||||
@@ -223,7 +226,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -242,14 +245,14 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
$this->_release_lock();
|
||||
if ( ! $this->_memcached->quit())
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_memcached = NULL;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -271,7 +274,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -290,6 +293,39 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 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 Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
{
|
||||
$this->_memcached->get($this->_key_prefix.$id);
|
||||
return ($this->_memcached->getResultCode() === Memcached::RES_SUCCESS);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -313,6 +349,8 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
? $this->_memcached->add($this->_lock_key, time(), 300)
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// 30 attempts to obtain a lock, in case another request already has it
|
||||
|
||||
Executable → Regular
+103
-26
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 3.0.0
|
||||
* @filesource
|
||||
@@ -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
|
||||
@@ -76,6 +77,33 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
*/
|
||||
protected $_key_exists = FALSE;
|
||||
|
||||
/**
|
||||
* Name of setTimeout() method in phpRedis
|
||||
*
|
||||
* Due to some deprecated methods in phpRedis, we need to call the
|
||||
* specific methods depending on the version of phpRedis.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_setTimeout_name;
|
||||
|
||||
/**
|
||||
* Name of delete() method in phpRedis
|
||||
*
|
||||
* Due to some deprecated methods in phpRedis, we need to call the
|
||||
* specific methods depending on the version of phpRedis.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_delete_name;
|
||||
|
||||
/**
|
||||
* Success return value of ping() method in phpRedis
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $_ping_success;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -88,6 +116,20 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
parent::__construct($params);
|
||||
|
||||
// Detect the names of some methods in phpRedis instance
|
||||
if (version_compare(phpversion('redis'), '5', '>='))
|
||||
{
|
||||
$this->_setTimeout_name = 'expire';
|
||||
$this->_delete_name = 'del';
|
||||
$this->_ping_success = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_setTimeout_name = 'setTimeout';
|
||||
$this->_delete_name = 'delete';
|
||||
$this->_ping_success = '+PONG';
|
||||
}
|
||||
|
||||
if (empty($this->_config['save_path']))
|
||||
{
|
||||
log_message('error', 'Session: No Redis save path configured.');
|
||||
@@ -131,7 +173,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if (empty($this->_config['save_path']))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$redis = new Redis();
|
||||
@@ -150,10 +192,11 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
else
|
||||
{
|
||||
$this->_redis = $redis;
|
||||
$this->php5_validate_id();
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -183,7 +226,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
return $session_data;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -201,21 +244,21 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if ( ! isset($this->_redis, $this->_lock_key))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
// Was the ID regenerated?
|
||||
elseif ($session_id !== $this->_session_id)
|
||||
{
|
||||
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_key_exists = FALSE;
|
||||
$this->_session_id = $session_id;
|
||||
}
|
||||
|
||||
$this->_redis->setTimeout($this->_lock_key, 300);
|
||||
$this->_redis->{$this->_setTimeout_name}($this->_lock_key, 300);
|
||||
if ($this->_fingerprint !== ($fingerprint = md5($session_data)) OR $this->_key_exists === FALSE)
|
||||
{
|
||||
if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
|
||||
@@ -225,12 +268,12 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
|
||||
return ($this->_redis->{$this->_setTimeout_name}($this->_key_prefix.$session_id, $this->_config['expiration']))
|
||||
? $this->_success
|
||||
: $this->_fail();
|
||||
: $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -247,12 +290,12 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
if (isset($this->_redis))
|
||||
{
|
||||
try {
|
||||
if ($this->_redis->ping() === '+PONG')
|
||||
if ($this->_redis->ping() === $this->_ping_success)
|
||||
{
|
||||
$this->_release_lock();
|
||||
if ($this->_redis->close() === FALSE)
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -282,16 +325,16 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if (isset($this->_redis, $this->_lock_key))
|
||||
{
|
||||
if (($result = $this->_redis->delete($this->_key_prefix.$session_id)) !== 1)
|
||||
if (($result = $this->_redis->{$this->_delete_name}($this->_key_prefix.$session_id)) !== 1)
|
||||
{
|
||||
log_message('debug', 'Session: Redis::delete() expected to return 1, got '.var_export($result, TRUE).' instead.');
|
||||
log_message('debug', 'Session: Redis::'.$this->_delete_name.'() expected to return 1, got '.var_export($result, TRUE).' instead.');
|
||||
}
|
||||
|
||||
$this->_cookie_destroy();
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -310,6 +353,38 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* 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 Session ID
|
||||
* @return bool
|
||||
*/
|
||||
public function validateId($id)
|
||||
{
|
||||
return (bool) $this->_redis->exists($this->_key_prefix.$id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -327,7 +402,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
// correct session ID.
|
||||
if ($this->_lock_key === $this->_key_prefix.$session_id.':lock')
|
||||
{
|
||||
return $this->_redis->setTimeout($this->_lock_key, 300);
|
||||
return $this->_redis->{$this->_setTimeout_name}($this->_lock_key, 300);
|
||||
}
|
||||
|
||||
// 30 attempts to obtain a lock, in case another request already has it
|
||||
@@ -341,11 +416,13 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
continue;
|
||||
}
|
||||
|
||||
$result = ($ttl === -2)
|
||||
? $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300))
|
||||
: $this->_redis->setex($lock_key, 300, time());
|
||||
|
||||
if ( ! $result)
|
||||
if ($ttl === -2 && ! $this->_redis->set($lock_key, time(), array('nx', 'ex' => 300)))
|
||||
{
|
||||
// Sleep for 1s to wait for lock releases.
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
elseif ( ! $this->_redis->setex($lock_key, 300, time()))
|
||||
{
|
||||
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
|
||||
return FALSE;
|
||||
@@ -383,7 +460,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
{
|
||||
if (isset($this->_redis, $this->_lock_key) && $this->_lock)
|
||||
{
|
||||
if ( ! $this->_redis->delete($this->_lock_key))
|
||||
if ( ! $this->_redis->{$this->_delete_name}($this->_lock_key))
|
||||
{
|
||||
log_message('error', 'Session: Error while trying to free lock for '.$this->_lock_key);
|
||||
return FALSE;
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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.3.1
|
||||
* @filesource
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
|
||||
Executable → Regular
+5
-4
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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.3.1
|
||||
* @filesource
|
||||
@@ -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 {
|
||||
|
||||
|
||||
Executable → Regular
+10
-11
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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 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 {
|
||||
|
||||
@@ -678,10 +679,8 @@ class CI_Upload {
|
||||
$this->set_error('upload_bad_filename', 'debug');
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $new_filename;
|
||||
}
|
||||
|
||||
return $new_filename;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -869,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);
|
||||
}
|
||||
@@ -903,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;
|
||||
}
|
||||
@@ -1229,7 +1228,7 @@ 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);
|
||||
|
||||
Executable → Regular
+6
-5
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Executable → Regular
+13
-12
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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
|
||||
{
|
||||
@@ -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
|
||||
{
|
||||
@@ -1030,7 +1031,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
|
||||
{
|
||||
@@ -1181,7 +1182,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
$data = implode("\r\n", $lines);
|
||||
|
||||
// Parse XML data
|
||||
if ( ! xml_parse($parser, $data, count($data)))
|
||||
if ( ! xml_parse($parser, $data, TRUE))
|
||||
{
|
||||
$errstr = sprintf('XML error: %s at line %d',
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
@@ -1213,7 +1214,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
{
|
||||
echo '<pre>';
|
||||
|
||||
if (count($this->xh[$pname]['headers'] > 0))
|
||||
if (count($this->xh[$pname]['headers']) > 0)
|
||||
{
|
||||
echo "---HEADERS---\n";
|
||||
foreach ($this->xh[$pname]['headers'] as $header)
|
||||
@@ -1649,7 +1650,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
|
||||
{
|
||||
@@ -1911,10 +1912,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
|
||||
|
||||
Executable → Regular
+12
-17
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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 {
|
||||
|
||||
@@ -348,7 +349,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']))
|
||||
)
|
||||
{
|
||||
@@ -402,15 +403,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
{
|
||||
return get_instance()->{$method_parts[1]}($m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->object->{$method_parts[1]}($m);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return call_user_func($this->methods[$methName]['function'], $m);
|
||||
|
||||
return $this->object->{$method_parts[1]}($m);
|
||||
}
|
||||
|
||||
return call_user_func($this->methods[$methName]['function'], $m);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -499,10 +496,8 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
|
||||
return new XML_RPC_Response(new XML_RPC_Values($docstring, 'string'));
|
||||
}
|
||||
else
|
||||
{
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['introspect_unknown'], $this->xmlrpcstr['introspect_unknown']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
+9
-7
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2017, 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 - 2017, 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
|
||||
@@ -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');
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
Executable → Regular
Reference in New Issue
Block a user