Update CodeIgniter system 3.1.0 => 3.1.16
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0.0
|
||||
* @filesource
|
||||
@@ -80,14 +80,7 @@ class CI_Cache_apc extends CI_Driver {
|
||||
$success = FALSE;
|
||||
$data = apc_fetch($id, $success);
|
||||
|
||||
if ($success === TRUE)
|
||||
{
|
||||
return is_array($data)
|
||||
? unserialize($data[0])
|
||||
: $data;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return ($success === TRUE) ? $data : FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -98,18 +91,12 @@ class CI_Cache_apc extends CI_Driver {
|
||||
* @param string $id Cache ID
|
||||
* @param mixed $data Data to store
|
||||
* @param int $ttl Length of time (in seconds) to cache the data
|
||||
* @param bool $raw Whether to store the raw value
|
||||
* @param bool $raw Whether to store the raw value (unused)
|
||||
* @return bool TRUE on success, FALSE on failure
|
||||
*/
|
||||
public function save($id, $data, $ttl = 60, $raw = FALSE)
|
||||
{
|
||||
$ttl = (int) $ttl;
|
||||
|
||||
return apc_store(
|
||||
$id,
|
||||
($raw === TRUE ? $data : array(serialize($data), time(), $ttl)),
|
||||
$ttl
|
||||
);
|
||||
return apc_store($id, $data, (int) $ttl);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -188,21 +175,30 @@ class CI_Cache_apc extends CI_Driver {
|
||||
*/
|
||||
public function get_metadata($id)
|
||||
{
|
||||
$success = FALSE;
|
||||
$stored = apc_fetch($id, $success);
|
||||
|
||||
if ($success === FALSE OR count($stored) !== 3)
|
||||
$cache_info = apc_cache_info('user', FALSE);
|
||||
if (empty($cache_info) OR empty($cache_info['cache_list']))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
list($data, $time, $ttl) = $stored;
|
||||
foreach ($cache_info['cache_list'] as &$entry)
|
||||
{
|
||||
if ($entry['info'] !== $id)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return array(
|
||||
'expire' => $time + $ttl,
|
||||
'mtime' => $time,
|
||||
'data' => unserialize($data)
|
||||
);
|
||||
$success = FALSE;
|
||||
$metadata = array(
|
||||
'expire' => ($entry['ttl'] ? $entry['mtime'] + $entry['ttl'] : 0),
|
||||
'mtime' => $entry['ttl'],
|
||||
'data' => apc_fetch($id, $success)
|
||||
);
|
||||
|
||||
return ($success === TRUE) ? $metadata : FALSE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0
|
||||
* @filesource
|
||||
@@ -120,7 +120,7 @@ class CI_Cache_file extends CI_Driver {
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return file_exists($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE;
|
||||
return is_file($this->_cache_path.$id) ? unlink($this->_cache_path.$id) : FALSE;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -216,7 +216,7 @@ class CI_Cache_file extends CI_Driver {
|
||||
*/
|
||||
public function get_metadata($id)
|
||||
{
|
||||
if ( ! file_exists($this->_cache_path.$id))
|
||||
if ( ! is_file($this->_cache_path.$id))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -227,13 +227,13 @@ class CI_Cache_file extends CI_Driver {
|
||||
{
|
||||
$mtime = filemtime($this->_cache_path.$id);
|
||||
|
||||
if ( ! isset($data['ttl']))
|
||||
if ( ! isset($data['ttl'], $data['time']))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return array(
|
||||
'expire' => $mtime + $data['ttl'],
|
||||
'expire' => $data['time'] + $data['ttl'],
|
||||
'mtime' => $mtime
|
||||
);
|
||||
}
|
||||
@@ -276,7 +276,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0
|
||||
* @filesource
|
||||
@@ -110,7 +110,7 @@ class CI_Cache_memcached extends CI_Driver {
|
||||
|
||||
if ($this->_memcached instanceof Memcache)
|
||||
{
|
||||
// Third parameter is persistance and defaults to TRUE.
|
||||
// Third parameter is persistence and defaults to TRUE.
|
||||
$this->_memcached->addServer(
|
||||
$cache_server['hostname'],
|
||||
$cache_server['port'],
|
||||
@@ -198,7 +198,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 +217,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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -76,6 +76,13 @@ class CI_Cache_redis extends CI_Driver
|
||||
*/
|
||||
protected $_serialized = array();
|
||||
|
||||
/**
|
||||
* del()/delete() method name depending on phpRedis version
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $_delete_name;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -97,6 +104,10 @@ class CI_Cache_redis extends CI_Driver
|
||||
return;
|
||||
}
|
||||
|
||||
isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('phpredis'), '5', '>=')
|
||||
? 'del'
|
||||
: 'delete';
|
||||
|
||||
$CI =& get_instance();
|
||||
|
||||
if ($CI->config->load('redis', TRUE, TRUE))
|
||||
@@ -135,10 +146,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 +160,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,9 +191,8 @@ 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);
|
||||
}
|
||||
|
||||
@@ -203,16 +209,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->sRemove('_ci_redis_serialized', $key);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -228,7 +230,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 +244,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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
|
||||
+168
-69
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -374,6 +374,13 @@ class CI_Email {
|
||||
5 => '5 (Lowest)'
|
||||
);
|
||||
|
||||
/**
|
||||
* mbstring.func_overload flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $func_overload;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -390,6 +397,8 @@ 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'));
|
||||
|
||||
log_message('info', 'Email Class Initialized');
|
||||
}
|
||||
|
||||
@@ -449,7 +458,6 @@ class CI_Email {
|
||||
$this->_headers = array();
|
||||
$this->_debug_msg = array();
|
||||
|
||||
$this->set_header('User-Agent', $this->useragent);
|
||||
$this->set_header('Date', $this->_set_date());
|
||||
|
||||
if ($clear_attachments !== FALSE)
|
||||
@@ -905,18 +913,13 @@ class CI_Email {
|
||||
/**
|
||||
* Get Mail Protocol
|
||||
*
|
||||
* @param bool
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _get_protocol($return = TRUE)
|
||||
protected function _get_protocol()
|
||||
{
|
||||
$this->protocol = strtolower($this->protocol);
|
||||
in_array($this->protocol, $this->_protocols, TRUE) OR $this->protocol = 'mail';
|
||||
|
||||
if ($return === TRUE)
|
||||
{
|
||||
return $this->protocol;
|
||||
}
|
||||
return $this->protocol;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -924,25 +927,21 @@ class CI_Email {
|
||||
/**
|
||||
* Get Mail Encoding
|
||||
*
|
||||
* @param bool
|
||||
* @return string
|
||||
*/
|
||||
protected function _get_encoding($return = TRUE)
|
||||
protected function _get_encoding()
|
||||
{
|
||||
in_array($this->_encoding, $this->_bit_depths) OR $this->_encoding = '8bit';
|
||||
|
||||
foreach ($this->_base_charsets as $charset)
|
||||
{
|
||||
if (strpos($charset, $this->charset) === 0)
|
||||
if (strpos($this->charset, $charset) === 0)
|
||||
{
|
||||
$this->_encoding = '7bit';
|
||||
}
|
||||
}
|
||||
|
||||
if ($return === TRUE)
|
||||
{
|
||||
return $this->_encoding;
|
||||
}
|
||||
return $this->_encoding;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -962,10 +961,8 @@ class CI_Email {
|
||||
{
|
||||
return 'plain-attach';
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'plain';
|
||||
}
|
||||
|
||||
return 'plain';
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1035,9 +1032,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 = substr($email, 0, ++$atpos).idn_to_ascii(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);
|
||||
@@ -1154,7 +1159,7 @@ class CI_Email {
|
||||
{
|
||||
// Is the line within the allowed character count?
|
||||
// If so we'll join it to the output and continue
|
||||
if (mb_strlen($line) <= $charlim)
|
||||
if (self::strlen($line) <= $charlim)
|
||||
{
|
||||
$output .= $line.$this->newline;
|
||||
continue;
|
||||
@@ -1170,10 +1175,10 @@ class CI_Email {
|
||||
}
|
||||
|
||||
// Trim the word down
|
||||
$temp .= mb_substr($line, 0, $charlim - 1);
|
||||
$line = mb_substr($line, $charlim - 1);
|
||||
$temp .= self::substr($line, 0, $charlim - 1);
|
||||
$line = self::substr($line, $charlim - 1);
|
||||
}
|
||||
while (mb_strlen($line) > $charlim);
|
||||
while (self::strlen($line) > $charlim);
|
||||
|
||||
// If $temp contains data it means we had to split up an over-length
|
||||
// word into smaller chunks so we'll add it back to our current line
|
||||
@@ -1202,10 +1207,11 @@ class CI_Email {
|
||||
/**
|
||||
* Build final headers
|
||||
*
|
||||
* @return string
|
||||
* @return void
|
||||
*/
|
||||
protected function _build_headers()
|
||||
{
|
||||
$this->set_header('User-Agent', $this->useragent);
|
||||
$this->set_header('X-Sender', $this->clean_email($this->_headers['From']));
|
||||
$this->set_header('X-Mailer', $this->useragent);
|
||||
$this->set_header('X-Priority', $this->_priorities[$this->priority]);
|
||||
@@ -1385,7 +1391,7 @@ class CI_Email {
|
||||
$this->_header_str .= $hdr;
|
||||
}
|
||||
|
||||
strlen($body) && $body .= $this->newline.$this->newline;
|
||||
self::strlen($body) && $body .= $this->newline.$this->newline;
|
||||
$body .= $this->_get_mime_message().$this->newline.$this->newline
|
||||
.'--'.$last_boundary.$this->newline
|
||||
|
||||
@@ -1468,7 +1474,8 @@ class CI_Email {
|
||||
.'Content-Type: '.$this->_attachments[$i]['type'].'; name="'.$name.'"'.$this->newline
|
||||
.'Content-Disposition: '.$this->_attachments[$i]['disposition'].';'.$this->newline
|
||||
.'Content-Transfer-Encoding: base64'.$this->newline
|
||||
.(empty($this->_attachments[$i]['cid']) ? '' : 'Content-ID: <'.$this->_attachments[$i]['cid'].'>'.$this->newline.$this->newline)
|
||||
.(empty($this->_attachments[$i]['cid']) ? '' : 'Content-ID: <'.$this->_attachments[$i]['cid'].'>'.$this->newline)
|
||||
.$this->newline
|
||||
.$this->_attachments[$i]['content'].$this->newline;
|
||||
}
|
||||
|
||||
@@ -1514,14 +1521,7 @@ class CI_Email {
|
||||
// which only works with "\n".
|
||||
if ($this->crlf === "\r\n")
|
||||
{
|
||||
if (is_php('5.3'))
|
||||
{
|
||||
return quoted_printable_encode($str);
|
||||
}
|
||||
elseif (function_exists('imap_8bit'))
|
||||
{
|
||||
return imap_8bit($str);
|
||||
}
|
||||
return quoted_printable_encode($str);
|
||||
}
|
||||
|
||||
// Reduce multiple spaces & remove nulls
|
||||
@@ -1538,7 +1538,7 @@ class CI_Email {
|
||||
|
||||
foreach (explode("\n", $str) as $line)
|
||||
{
|
||||
$length = strlen($line);
|
||||
$length = self::strlen($line);
|
||||
$temp = '';
|
||||
|
||||
// Loop through each character in the line to add soft-wrap
|
||||
@@ -1573,7 +1573,7 @@ class CI_Email {
|
||||
|
||||
// If we're at the character limit, add the line to the output,
|
||||
// reset our temp variable, and keep on chuggin'
|
||||
if ((strlen($temp) + strlen($char)) >= 76)
|
||||
if ((self::strlen($temp) + self::strlen($char)) >= 76)
|
||||
{
|
||||
$output .= $temp.$escape.$this->crlf;
|
||||
$temp = '';
|
||||
@@ -1588,7 +1588,7 @@ class CI_Email {
|
||||
}
|
||||
|
||||
// get rid of extra CRLF tacked onto the end
|
||||
return substr($output, 0, strlen($this->crlf) * -1);
|
||||
return self::substr($output, 0, self::strlen($this->crlf) * -1);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1630,7 +1630,7 @@ class CI_Email {
|
||||
// iconv_mime_encode() will always put a header field name.
|
||||
// We've passed it an empty one, but it still prepends our
|
||||
// encoded string with ': ', so we need to strip it.
|
||||
return substr($output, 2);
|
||||
return self::substr($output, 2);
|
||||
}
|
||||
|
||||
$chars = iconv_strlen($str, 'UTF-8');
|
||||
@@ -1642,10 +1642,10 @@ class CI_Email {
|
||||
}
|
||||
|
||||
// We might already have this set for UTF-8
|
||||
isset($chars) OR $chars = strlen($str);
|
||||
isset($chars) OR $chars = self::strlen($str);
|
||||
|
||||
$output = '=?'.$this->charset.'?Q?';
|
||||
for ($i = 0, $length = strlen($output); $i < $chars; $i++)
|
||||
for ($i = 0, $length = self::strlen($output); $i < $chars; $i++)
|
||||
{
|
||||
$chr = ($this->charset === 'UTF-8' && ICONV_ENABLED === TRUE)
|
||||
? '='.implode('=', str_split(strtoupper(bin2hex(iconv_substr($str, $i, 1, $this->charset))), 2))
|
||||
@@ -1653,11 +1653,11 @@ class CI_Email {
|
||||
|
||||
// RFC 2045 sets a limit of 76 characters per line.
|
||||
// We'll append ?= to the end of each line though.
|
||||
if ($length + ($l = strlen($chr)) > 74)
|
||||
if ($length + ($l = self::strlen($chr)) > 74)
|
||||
{
|
||||
$output .= '?='.$this->crlf // EOL
|
||||
.' =?'.$this->charset.'?Q?'.$chr; // New line
|
||||
$length = 6 + strlen($this->charset) + $l; // Reset the length for the new line
|
||||
$length = 6 + self::strlen($this->charset) + $l; // Reset the length for the new line
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1750,14 +1750,14 @@ class CI_Email {
|
||||
|
||||
if ($i === $float)
|
||||
{
|
||||
$chunk[] = substr($set, 1);
|
||||
$chunk[] = self::substr($set, 1);
|
||||
$float += $this->bcc_batch_size;
|
||||
$set = '';
|
||||
}
|
||||
|
||||
if ($i === $c-1)
|
||||
{
|
||||
$chunk[] = substr($set, 1);
|
||||
$chunk[] = self::substr($set, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1826,19 +1826,55 @@ class CI_Email {
|
||||
{
|
||||
$this->_unwrap_specials();
|
||||
|
||||
$method = '_send_with_'.$this->_get_protocol();
|
||||
$protocol = $this->_get_protocol();
|
||||
$method = '_send_with_'.$protocol;
|
||||
if ( ! $this->$method())
|
||||
{
|
||||
$this->_set_error_message('lang:email_send_failure_'.($this->_get_protocol() === 'mail' ? 'phpmail' : $this->_get_protocol()));
|
||||
$this->_set_error_message('lang:email_send_failure_'.($protocol === 'mail' ? 'phpmail' : $protocol));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->_set_error_message('lang:email_sent', $this->_get_protocol());
|
||||
$this->_set_error_message('lang:email_sent', $protocol);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate email for shell
|
||||
*
|
||||
* Applies stricter, shell-safe validation to email addresses.
|
||||
* Introduced to prevent RCE via sendmail's -f option.
|
||||
*
|
||||
* @see https://github.com/bcit-ci/CodeIgniter/issues/4963
|
||||
* @see https://gist.github.com/Zenexer/40d02da5e07f151adeaeeaa11af9ab36
|
||||
* @license https://creativecommons.org/publicdomain/zero/1.0/ CC0 1.0, Public Domain
|
||||
*
|
||||
* Credits for the base concept go to Paul Buonopane <paul@namepros.com>
|
||||
*
|
||||
* @param string $email
|
||||
* @return bool
|
||||
*/
|
||||
protected function _validate_email_for_shell(&$email)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && strpos($email, '@'))
|
||||
{
|
||||
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));
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Send using mail()
|
||||
*
|
||||
@@ -1851,7 +1887,11 @@ class CI_Email {
|
||||
$this->_recipients = implode(', ', $this->_recipients);
|
||||
}
|
||||
|
||||
if ($this->_safe_mode === TRUE)
|
||||
// _validate_email_for_shell() below accepts by reference,
|
||||
// so this needs to be assigned to a variable
|
||||
$from = $this->clean_email($this->_headers['Return-Path']);
|
||||
|
||||
if ($this->_safe_mode === TRUE || ! $this->_validate_email_for_shell($from))
|
||||
{
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str);
|
||||
}
|
||||
@@ -1859,7 +1899,7 @@ class CI_Email {
|
||||
{
|
||||
// most documentation of sendmail using the "-f" flag lacks a space after it, however
|
||||
// we've encountered servers that seem to require it to be in place.
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$this->clean_email($this->_headers['Return-Path']));
|
||||
return mail($this->_recipients, $this->_subject, $this->_finalbody, $this->_header_str, '-f '.$from);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1872,13 +1912,22 @@ class CI_Email {
|
||||
*/
|
||||
protected function _send_with_sendmail()
|
||||
{
|
||||
// is popen() enabled?
|
||||
if ( ! function_usable('popen')
|
||||
OR FALSE === ($fp = @popen(
|
||||
$this->mailpath.' -oi -f '.$this->clean_email($this->_headers['From']).' -t'
|
||||
, 'w'))
|
||||
) // server probably has popen disabled, so nothing we can do to get a verbose error.
|
||||
// _validate_email_for_shell() below accepts by reference,
|
||||
// so this needs to be assigned to a variable
|
||||
$from = $this->clean_email($this->_headers['From']);
|
||||
if ($this->_validate_email_for_shell($from))
|
||||
{
|
||||
$from = '-f '.$from;
|
||||
}
|
||||
else
|
||||
{
|
||||
$from = '';
|
||||
}
|
||||
|
||||
// is popen() enabled?
|
||||
if ( ! function_usable('popen') OR FALSE === ($fp = @popen($this->mailpath.' -oi '.$from.' -t', 'w')))
|
||||
{
|
||||
// server probably has popen disabled, so nothing we can do to get a verbose error.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -2033,7 +2082,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)
|
||||
{
|
||||
@@ -2052,7 +2113,7 @@ class CI_Email {
|
||||
*
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
protected function _send_command($cmd, $data = '')
|
||||
{
|
||||
@@ -2115,7 +2176,7 @@ class CI_Email {
|
||||
|
||||
$this->_debug_msg[] = '<pre>'.$cmd.': '.$reply.'</pre>';
|
||||
|
||||
if ((int) substr($reply, 0, 3) !== $resp)
|
||||
if ((int) self::substr($reply, 0, 3) !== $resp)
|
||||
{
|
||||
$this->_set_error_message('lang:email_smtp_error', $reply);
|
||||
return FALSE;
|
||||
@@ -2202,9 +2263,9 @@ class CI_Email {
|
||||
protected function _send_data($data)
|
||||
{
|
||||
$data .= $this->newline;
|
||||
for ($written = $timestamp = 0, $length = strlen($data); $written < $length; $written += $result)
|
||||
for ($written = $timestamp = 0, $length = self::strlen($data); $written < $length; $written += $result)
|
||||
{
|
||||
if (($result = fwrite($this->_smtp_connect, substr($data, $written))) === FALSE)
|
||||
if (($result = fwrite($this->_smtp_connect, self::substr($data, $written))) === FALSE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2224,10 +2285,8 @@ class CI_Email {
|
||||
usleep(250000);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
$timestamp = 0;
|
||||
}
|
||||
|
||||
$timestamp = 0;
|
||||
}
|
||||
|
||||
if ($result === FALSE)
|
||||
@@ -2388,4 +2447,44 @@ class CI_Email {
|
||||
{
|
||||
is_resource($this->_smtp_connect) && $this->_send_command('quit');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return (self::$func_overload)
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe substr()
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
protected static function substr($str, $start, $length = NULL)
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
return isset($length)
|
||||
? substr($str, $start, $length)
|
||||
: substr($str, $start);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -122,7 +122,7 @@ class CI_Encrypt {
|
||||
|
||||
$key = config_item('encryption_key');
|
||||
|
||||
if ( ! strlen($key))
|
||||
if ( ! self::strlen($key))
|
||||
{
|
||||
show_error('In order to use the encryption class requires that you set an encryption key in your config file.');
|
||||
}
|
||||
@@ -252,7 +252,7 @@ class CI_Encrypt {
|
||||
$string = $this->_xor_merge($string, $key);
|
||||
|
||||
$dec = '';
|
||||
for ($i = 0, $l = strlen($string); $i < $l; $i++)
|
||||
for ($i = 0, $l = self::strlen($string); $i < $l; $i++)
|
||||
{
|
||||
$dec .= ($string[$i++] ^ $string[$i]);
|
||||
}
|
||||
@@ -275,7 +275,8 @@ class CI_Encrypt {
|
||||
{
|
||||
$hash = $this->hash($key);
|
||||
$str = '';
|
||||
for ($i = 0, $ls = strlen($string), $lh = strlen($hash); $i < $ls; $i++)
|
||||
|
||||
for ($i = 0, $ls = self::strlen($string), $lh = self::strlen($hash); $i < $ls; $i++)
|
||||
{
|
||||
$str .= $string[$i] ^ $hash[($i % $lh)];
|
||||
}
|
||||
@@ -295,7 +296,7 @@ class CI_Encrypt {
|
||||
public function mcrypt_encode($data, $key)
|
||||
{
|
||||
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
|
||||
$init_vect = mcrypt_create_iv($init_size, MCRYPT_RAND);
|
||||
$init_vect = mcrypt_create_iv($init_size, MCRYPT_DEV_URANDOM);
|
||||
return $this->_add_cipher_noise($init_vect.mcrypt_encrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), $key);
|
||||
}
|
||||
|
||||
@@ -313,13 +314,14 @@ class CI_Encrypt {
|
||||
$data = $this->_remove_cipher_noise($data, $key);
|
||||
$init_size = mcrypt_get_iv_size($this->_get_cipher(), $this->_get_mode());
|
||||
|
||||
if ($init_size > strlen($data))
|
||||
if ($init_size > self::strlen($data))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$init_vect = substr($data, 0, $init_size);
|
||||
$data = substr($data, $init_size);
|
||||
$init_vect = self::substr($data, 0, $init_size);
|
||||
$data = self::substr($data, $init_size);
|
||||
|
||||
return rtrim(mcrypt_decrypt($this->_get_cipher(), $key, $data, $this->_get_mode(), $init_vect), "\0");
|
||||
}
|
||||
|
||||
@@ -339,7 +341,7 @@ class CI_Encrypt {
|
||||
$key = $this->hash($key);
|
||||
$str = '';
|
||||
|
||||
for ($i = 0, $j = 0, $ld = strlen($data), $lk = strlen($key); $i < $ld; ++$i, ++$j)
|
||||
for ($i = 0, $j = 0, $ld = self::strlen($data), $lk = self::strlen($key); $i < $ld; ++$i, ++$j)
|
||||
{
|
||||
if ($j >= $lk)
|
||||
{
|
||||
@@ -369,7 +371,7 @@ class CI_Encrypt {
|
||||
$key = $this->hash($key);
|
||||
$str = '';
|
||||
|
||||
for ($i = 0, $j = 0, $ld = strlen($data), $lk = strlen($key); $i < $ld; ++$i, ++$j)
|
||||
for ($i = 0, $j = 0, $ld = self::strlen($data), $lk = self::strlen($key); $i < $ld; ++$i, ++$j)
|
||||
{
|
||||
if ($j >= $lk)
|
||||
{
|
||||
@@ -477,4 +479,43 @@ class CI_Encrypt {
|
||||
return hash($this->_hash_type, $str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return defined('MB_OVERLOAD_STRING')
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe substr()
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
protected static function substr($str, $start, $length = NULL)
|
||||
{
|
||||
if (defined('MB_OVERLOAD_STRING'))
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
return isset($length)
|
||||
? substr($str, $start, $length)
|
||||
: substr($str, $start);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -135,11 +135,11 @@ class CI_Encryption {
|
||||
);
|
||||
|
||||
/**
|
||||
* mbstring.func_override flag
|
||||
* mbstring.func_overload flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $func_override;
|
||||
protected static $func_overload;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -152,10 +152,8 @@ class CI_Encryption {
|
||||
public function __construct(array $params = array())
|
||||
{
|
||||
$this->_drivers = array(
|
||||
'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
|
||||
// While OpenSSL is available for PHP 5.3.0, an IV parameter
|
||||
// for the encrypt/decrypt functions is only available since 5.3.3
|
||||
'openssl' => (is_php('5.3.3') && extension_loaded('openssl'))
|
||||
'mcrypt' => defined('MCRYPT_DEV_URANDOM'),
|
||||
'openssl' => extension_loaded('openssl')
|
||||
);
|
||||
|
||||
if ( ! $this->_drivers['mcrypt'] && ! $this->_drivers['openssl'])
|
||||
@@ -163,7 +161,7 @@ class CI_Encryption {
|
||||
show_error('Encryption: Unable to find an available encryption driver.');
|
||||
}
|
||||
|
||||
isset(self::$func_override) OR self::$func_override = (extension_loaded('mbstring') && ini_get('mbstring.func_override'));
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
$this->initialize($params);
|
||||
|
||||
if ( ! isset($this->_key) && self::strlen($key = config_item('encryption_key')) > 0)
|
||||
@@ -684,10 +682,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)
|
||||
@@ -909,11 +905,11 @@ class CI_Encryption {
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return integer
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return (self::$func_override)
|
||||
return (self::$func_overload)
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
@@ -930,7 +926,7 @@ class CI_Encryption {
|
||||
*/
|
||||
protected static function substr($str, $start, $length = NULL)
|
||||
{
|
||||
if (self::$func_override)
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -584,7 +584,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
|
||||
{
|
||||
@@ -1200,7 +1200,7 @@ class CI_Form_validation {
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
elseif ( ! in_array($matches[1], array('http', 'https'), TRUE))
|
||||
elseif ( ! in_array(strtolower($matches[1]), array('http', 'https'), TRUE))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -1208,6 +1208,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
|
||||
@@ -1216,18 +1223,7 @@ class CI_Form_validation {
|
||||
$str = 'ipv6.host'.substr($str, strlen($matches[1]) + 2);
|
||||
}
|
||||
|
||||
$str = 'http://'.$str;
|
||||
|
||||
// There's a bug affecting PHP 5.2.13, 5.3.2 that considers the
|
||||
// underscore to be a valid hostname character instead of a dash.
|
||||
// Reference: https://bugs.php.net/bug.php?id=51192
|
||||
if (version_compare(PHP_VERSION, '5.2.13', '==') OR version_compare(PHP_VERSION, '5.3.2', '=='))
|
||||
{
|
||||
sscanf($str, 'http://%[^/]', $host);
|
||||
$str = substr_replace($str, strtr($host, array('_' => '-', '-' => '_')), 7, strlen($host));
|
||||
}
|
||||
|
||||
return (filter_var($str, FILTER_VALIDATE_URL) !== FALSE);
|
||||
return (filter_var('http://'.$str, FILTER_VALIDATE_URL) !== FALSE);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1240,9 +1236,16 @@ class CI_Form_validation {
|
||||
*/
|
||||
public function valid_email($str)
|
||||
{
|
||||
if (function_exists('idn_to_ascii') && $atpos = strpos($str, '@'))
|
||||
if (function_exists('idn_to_ascii') && preg_match('#\A([^@]+)@(.+)\z#', $str, $matches))
|
||||
{
|
||||
$str = substr($str, 0, ++$atpos).idn_to_ascii(substr($str, $atpos));
|
||||
$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);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -486,7 +486,7 @@ class CI_FTP {
|
||||
{
|
||||
for ($i = 0, $c = count($list); $i < $c; $i++)
|
||||
{
|
||||
// If we can't delete the item it's probaly a directory,
|
||||
// If we can't delete the item it's probably a directory,
|
||||
// so we'll recursively call delete_dir()
|
||||
if ( ! preg_match('#/\.\.?$#', $list[$i]) && ! @ftp_delete($this->conn_id, $list[$i]))
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -392,6 +392,16 @@ class CI_Image_lib {
|
||||
$this->initialize($props);
|
||||
}
|
||||
|
||||
/**
|
||||
* A work-around for some improperly formatted, but
|
||||
* usable JPEGs; known to be produced by Samsung
|
||||
* smartphones' front-facing cameras.
|
||||
*
|
||||
* @see https://github.com/bcit-ci/CodeIgniter/issues/4967
|
||||
* @see https://bugs.php.net/bug.php?id=72404
|
||||
*/
|
||||
ini_set('gd.jpeg_ignore_warning', 1);
|
||||
|
||||
log_message('info', 'Image Lib Class Initialized');
|
||||
}
|
||||
|
||||
@@ -544,37 +554,30 @@ class CI_Image_lib {
|
||||
*/
|
||||
if ($this->new_image === '')
|
||||
{
|
||||
$this->dest_image = $this->source_image;
|
||||
$this->dest_image = $this->source_image;
|
||||
$this->dest_folder = $this->source_folder;
|
||||
}
|
||||
elseif (strpos($this->new_image, '/') === FALSE)
|
||||
elseif (strpos($this->new_image, '/') === FALSE && strpos($this->new_image, '\\') === FALSE)
|
||||
{
|
||||
$this->dest_image = $this->new_image;
|
||||
$this->dest_folder = $this->source_folder;
|
||||
$this->dest_image = $this->new_image;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strpos($this->new_image, '/') === FALSE && strpos($this->new_image, '\\') === FALSE)
|
||||
// Is there a file name?
|
||||
if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $this->new_image))
|
||||
{
|
||||
$full_dest_path = str_replace('\\', '/', realpath($this->new_image));
|
||||
$this->dest_image = $this->source_image;
|
||||
$this->dest_folder = $this->new_image;
|
||||
}
|
||||
else
|
||||
{
|
||||
$full_dest_path = $this->new_image;
|
||||
$x = explode('/', str_replace('\\', '/', $this->new_image));
|
||||
$this->dest_image = end($x);
|
||||
$this->dest_folder = str_replace($this->dest_image, '', $this->new_image);
|
||||
}
|
||||
|
||||
// Is there a file name?
|
||||
if ( ! preg_match('#\.(jpg|jpeg|gif|png)$#i', $full_dest_path))
|
||||
{
|
||||
$this->dest_folder = $full_dest_path.'/';
|
||||
$this->dest_image = $this->source_image;
|
||||
}
|
||||
else
|
||||
{
|
||||
$x = explode('/', $full_dest_path);
|
||||
$this->dest_image = end($x);
|
||||
$this->dest_folder = str_replace($this->dest_image, '', $full_dest_path);
|
||||
}
|
||||
$this->dest_folder = realpath($this->dest_folder).'/';
|
||||
}
|
||||
|
||||
/* Compile the finalized filenames/paths
|
||||
@@ -832,7 +835,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;
|
||||
}
|
||||
@@ -886,7 +892,7 @@ class CI_Image_lib {
|
||||
}
|
||||
}
|
||||
|
||||
$cmd .= ' "'.escapeshellarg($this->full_src_path).'" "'.escapeshellarg($this->full_dst_path).'" 2>&1';
|
||||
$cmd .= ' '.escapeshellarg($this->full_src_path).' '.escapeshellarg($this->full_dst_path).' 2>&1';
|
||||
|
||||
$retval = 1;
|
||||
// exec() might be disabled
|
||||
@@ -969,7 +975,7 @@ class CI_Image_lib {
|
||||
$cmd_inner = 'pnmscale -xysize '.$this->width.' '.$this->height;
|
||||
}
|
||||
|
||||
$cmd = $this->library_path.$cmd_in.' '.$this->full_src_path.' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
|
||||
$cmd = $this->library_path.$cmd_in.' '.escapeshellarg($this->full_src_path).' | '.$cmd_inner.' | '.$cmd_out.' > '.$this->dest_folder.'netpbm.tmp';
|
||||
|
||||
$retval = 1;
|
||||
// exec() might be disabled
|
||||
@@ -1646,25 +1652,31 @@ class CI_Image_lib {
|
||||
}
|
||||
|
||||
$vals = getimagesize($path);
|
||||
if ($vals === FALSE)
|
||||
{
|
||||
$this->set_error('imglib_invalid_image');
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$types = array(1 => 'gif', 2 => 'jpeg', 3 => 'png');
|
||||
$mime = (isset($types[$vals[2]])) ? 'image/'.$types[$vals[2]] : 'image/jpg';
|
||||
$mime = isset($types[$vals[2]]) ? 'image/'.$types[$vals[2]] : 'image/jpg';
|
||||
|
||||
if ($return === TRUE)
|
||||
{
|
||||
return array(
|
||||
'width' => $vals[0],
|
||||
'height' => $vals[1],
|
||||
'image_type' => $vals[2],
|
||||
'size_str' => $vals[3],
|
||||
'mime_type' => $mime
|
||||
);
|
||||
'width' => $vals[0],
|
||||
'height' => $vals[1],
|
||||
'image_type' => $vals[2],
|
||||
'size_str' => $vals[3],
|
||||
'mime_type' => $mime
|
||||
);
|
||||
}
|
||||
|
||||
$this->orig_width = $vals[0];
|
||||
$this->orig_height = $vals[1];
|
||||
$this->image_type = $vals[2];
|
||||
$this->size_str = $vals[3];
|
||||
$this->mime_type = $mime;
|
||||
$this->orig_width = $vals[0];
|
||||
$this->orig_height = $vals[1];
|
||||
$this->image_type = $vals[2];
|
||||
$this->size_str = $vals[3];
|
||||
$this->mime_type = $mime;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -288,10 +288,7 @@ class CI_Migration {
|
||||
$this->_error_string = sprintf($this->lang->line('migration_class_doesnt_exist'), $class);
|
||||
return FALSE;
|
||||
}
|
||||
// method_exists() returns true for non-public methods,
|
||||
// while is_callable() can't be used without instantiating.
|
||||
// Only get_class_methods() satisfies both conditions.
|
||||
elseif ( ! in_array($method, array_map('strtolower', get_class_methods($class))))
|
||||
elseif ( ! is_callable(array($class, $method)))
|
||||
{
|
||||
$this->_error_string = sprintf($this->lang->line('migration_missing_'.$method.'_method'), $class);
|
||||
return FALSE;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -339,6 +339,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 +357,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']);
|
||||
@@ -428,7 +431,7 @@ class CI_Pagination {
|
||||
{
|
||||
$get = $this->CI->input->get();
|
||||
|
||||
// Unset the controll, method, old-school routing options
|
||||
// Unset the control, method, old-school routing options
|
||||
unset($get['c'], $get['m'], $get[$this->query_string_segment]);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -316,7 +316,7 @@ class CI_Profiler {
|
||||
{
|
||||
is_int($key) OR $key = "'".htmlspecialchars($key, ENT_QUOTES, config_item('charset'))."'";
|
||||
$val = (is_array($val) OR is_object($val))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset'))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset')).'</pre>'
|
||||
: htmlspecialchars($val, ENT_QUOTES, config_item('charset'));
|
||||
|
||||
$output .= '<tr><td style="width:50%;color:#000;background-color:#ddd;padding:5px;">$_GET['
|
||||
@@ -356,7 +356,7 @@ class CI_Profiler {
|
||||
{
|
||||
is_int($key) OR $key = "'".htmlspecialchars($key, ENT_QUOTES, config_item('charset'))."'";
|
||||
$val = (is_array($val) OR is_object($val))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset'))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset')).'</pre>'
|
||||
: htmlspecialchars($val, ENT_QUOTES, config_item('charset'));
|
||||
|
||||
$output .= '<tr><td style="width:50%;padding:5px;color:#000;background-color:#ddd;">$_POST['
|
||||
@@ -368,7 +368,7 @@ class CI_Profiler {
|
||||
{
|
||||
is_int($key) OR $key = "'".htmlspecialchars($key, ENT_QUOTES, config_item('charset'))."'";
|
||||
$val = (is_array($val) OR is_object($val))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset'))
|
||||
? '<pre>'.htmlspecialchars(print_r($val, TRUE), ENT_QUOTES, config_item('charset')).'</pre>'
|
||||
: htmlspecialchars($val, ENT_QUOTES, config_item('charset'));
|
||||
|
||||
$output .= '<tr><td style="width:50%;padding:5px;color:#000;background-color:#ddd;">$_FILES['
|
||||
@@ -484,13 +484,19 @@ class CI_Profiler {
|
||||
|
||||
foreach ($this->CI->config->config as $config => $val)
|
||||
{
|
||||
$pre = '';
|
||||
$pre_close = '';
|
||||
|
||||
if (is_array($val) OR is_object($val))
|
||||
{
|
||||
$val = print_r($val, TRUE);
|
||||
|
||||
$pre = '<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;">'.htmlspecialchars($val)."</td></tr>\n";
|
||||
.$config.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
}
|
||||
|
||||
return $output."</table>\n</fieldset>";
|
||||
@@ -516,13 +522,19 @@ class CI_Profiler {
|
||||
|
||||
foreach ($this->CI->session->userdata() as $key => $val)
|
||||
{
|
||||
$pre = '';
|
||||
$pre_close = '';
|
||||
|
||||
if (is_array($val) OR is_object($val))
|
||||
{
|
||||
$val = print_r($val, TRUE);
|
||||
|
||||
$pre = '<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;">'.htmlspecialchars($val)."</td></tr>\n";
|
||||
.$key.' </td><td style="padding:5px;color:#000;background-color:#ddd;">'.$pre.htmlspecialchars($val, ENT_QUOTES, config_item('charset')).$pre_close."</td></tr>\n";
|
||||
}
|
||||
|
||||
return $output."</table>\n</fieldset>";
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 2.0.0
|
||||
* @filesource
|
||||
@@ -57,6 +57,7 @@ class CI_Session {
|
||||
|
||||
protected $_driver = 'files';
|
||||
protected $_config;
|
||||
protected $_sid_regexp;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
@@ -99,6 +100,7 @@ class CI_Session {
|
||||
|
||||
// Configuration ...
|
||||
$this->_configure($params);
|
||||
$this->_config['_sid_regexp'] = $this->_sid_regexp;
|
||||
|
||||
$class = new $class($this->_config);
|
||||
if ($class instanceof SessionHandlerInterface)
|
||||
@@ -131,7 +133,7 @@ class CI_Session {
|
||||
if (isset($_COOKIE[$this->_config['cookie_name']])
|
||||
&& (
|
||||
! is_string($_COOKIE[$this->_config['cookie_name']])
|
||||
OR ! preg_match('/^[0-9a-f]{40}$/', $_COOKIE[$this->_config['cookie_name']])
|
||||
OR ! preg_match('#\A'.$this->_sid_regexp.'\z#', $_COOKIE[$this->_config['cookie_name']])
|
||||
)
|
||||
)
|
||||
{
|
||||
@@ -239,10 +241,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;
|
||||
@@ -315,8 +315,82 @@ class CI_Session {
|
||||
ini_set('session.use_strict_mode', 1);
|
||||
ini_set('session.use_cookies', 1);
|
||||
ini_set('session.use_only_cookies', 1);
|
||||
ini_set('session.hash_function', 1);
|
||||
ini_set('session.hash_bits_per_character', 4);
|
||||
|
||||
$this->_configure_sid_length();
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Configure session ID length
|
||||
*
|
||||
* To make life easier, we used to force SHA-1 and 4 bits per
|
||||
* character on everyone. And of course, someone was unhappy.
|
||||
*
|
||||
* Then PHP 7.1 broke backwards-compatibility because ext/session
|
||||
* is such a mess that nobody wants to touch it with a pole stick,
|
||||
* and the one guy who does, nobody has the energy to argue with.
|
||||
*
|
||||
* So we were forced to make changes, and OF COURSE something was
|
||||
* going to break and now we have this pile of shit. -- Narf
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _configure_sid_length()
|
||||
{
|
||||
if (PHP_VERSION_ID < 70100)
|
||||
{
|
||||
$hash_function = ini_get('session.hash_function');
|
||||
if (ctype_digit($hash_function))
|
||||
{
|
||||
if ($hash_function !== '1')
|
||||
{
|
||||
ini_set('session.hash_function', 1);
|
||||
}
|
||||
|
||||
$bits = 160;
|
||||
}
|
||||
elseif ( ! in_array($hash_function, hash_algos(), TRUE))
|
||||
{
|
||||
ini_set('session.hash_function', 1);
|
||||
$bits = 160;
|
||||
}
|
||||
elseif (($bits = strlen(hash($hash_function, 'dummy', false)) * 4) < 160)
|
||||
{
|
||||
ini_set('session.hash_function', 1);
|
||||
$bits = 160;
|
||||
}
|
||||
|
||||
$bits_per_character = (int) ini_get('session.hash_bits_per_character');
|
||||
$sid_length = (int) ceil($bits / $bits_per_character);
|
||||
}
|
||||
else
|
||||
{
|
||||
$bits_per_character = (int) ini_get('session.sid_bits_per_character');
|
||||
$sid_length = (int) ini_get('session.sid_length');
|
||||
if (($bits = $sid_length * $bits_per_character) < 160)
|
||||
{
|
||||
// Add as many more characters as necessary to reach at least 160 bits
|
||||
$sid_length += (int) ceil((160 % $bits) / $bits_per_character);
|
||||
ini_set('session.sid_length', $sid_length);
|
||||
}
|
||||
}
|
||||
|
||||
// Yes, 4,5,6 are the only known possible values as of 2016-10-27
|
||||
switch ($bits_per_character)
|
||||
{
|
||||
case 4:
|
||||
$this->_sid_regexp = '[0-9a-f]';
|
||||
break;
|
||||
case 5:
|
||||
$this->_sid_regexp = '[0-9a-v]';
|
||||
break;
|
||||
case 6:
|
||||
$this->_sid_regexp = '[0-9a-zA-Z,-]';
|
||||
break;
|
||||
}
|
||||
|
||||
$this->_sid_regexp .= '{'.$sid_length.'}';
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -530,7 +604,7 @@ class CI_Session {
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Unmark flash
|
||||
* Unmark temp
|
||||
*
|
||||
* @param mixed $key Session data key(s)
|
||||
* @return void
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,7 +29,7 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
|
||||
* @license http://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -112,6 +112,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 (isset($_COOKIE[$this->_config['cookie_name']]) && ! $this->validateSessionId($_COOKIE[$this->_config['cookie_name']]))
|
||||
{
|
||||
unset($_COOKIE[$this->_config['cookie_name']]);
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Cookie destroy
|
||||
*
|
||||
@@ -167,25 +184,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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -130,9 +130,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 +150,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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -209,11 +210,11 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
$this->_db->reset_query();
|
||||
|
||||
// Was the ID regenerated?
|
||||
if ($session_id !== $this->_session_id)
|
||||
if (isset($this->_session_id) && $session_id !== $this->_session_id)
|
||||
{
|
||||
if ( ! $this->_release_lock() OR ! $this->_get_lock($session_id))
|
||||
{
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
$this->_row_exists = FALSE;
|
||||
@@ -221,7 +222,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 +241,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 +264,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -278,7 +279,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 +308,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 +318,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -337,7 +338,31 @@ 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;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($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);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -354,7 +379,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
{
|
||||
if ($this->_platform === 'mysql')
|
||||
{
|
||||
$arg = $session_id.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : '');
|
||||
$arg = md5($session_id.($this->_config['match_ip'] ? '_'.$_SERVER['REMOTE_ADDR'] : ''));
|
||||
if ($this->_db->query("SELECT GET_LOCK('".$arg."', 300) AS ci_session_lock")->row()->ci_session_lock)
|
||||
{
|
||||
$this->_lock = $arg;
|
||||
@@ -417,4 +442,4 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan
|
||||
|
||||
return parent::_release_lock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -76,6 +76,20 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
*/
|
||||
protected $_file_new;
|
||||
|
||||
/**
|
||||
* Validate SID regular expression
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_sid_regexp;
|
||||
|
||||
/**
|
||||
* mbstring.func_overload flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $func_overload;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -98,6 +112,10 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
log_message('debug', 'Session: "sess_save_path" is empty; using "session.save_path" value from php.ini.');
|
||||
$this->_config['save_path'] = rtrim(ini_get('session.save_path'), '/\\');
|
||||
}
|
||||
|
||||
$this->_sid_regexp = $this->_config['_sid_regexp'];
|
||||
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -117,12 +135,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;
|
||||
@@ -130,6 +150,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;
|
||||
}
|
||||
|
||||
@@ -149,18 +171,9 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
// which re-reads session data
|
||||
if ($this->_file_handle === NULL)
|
||||
{
|
||||
// Just using fopen() with 'c+b' mode would be perfect, but it is only
|
||||
// available since PHP 5.2.6 and we have to set permissions for new files,
|
||||
// so we'd have to hack around this ...
|
||||
if (($this->_file_new = ! file_exists($this->_file_path.$session_id)) === TRUE)
|
||||
{
|
||||
if (($this->_file_handle = fopen($this->_file_path.$session_id, 'w+b')) === FALSE)
|
||||
{
|
||||
log_message('error', "Session: File '".$this->_file_path.$session_id."' doesn't exist and cannot be created.");
|
||||
return $this->_failure;
|
||||
}
|
||||
}
|
||||
elseif (($this->_file_handle = fopen($this->_file_path.$session_id, 'r+b')) === FALSE)
|
||||
$this->_file_new = ! file_exists($this->_file_path.$session_id);
|
||||
|
||||
if (($this->_file_handle = fopen($this->_file_path.$session_id, 'c+b')) === FALSE)
|
||||
{
|
||||
log_message('error', "Session: Unable to open file '".$this->_file_path.$session_id."'.");
|
||||
return $this->_failure;
|
||||
@@ -196,7 +209,7 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
}
|
||||
|
||||
$session_data = '';
|
||||
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += strlen($buffer))
|
||||
for ($read = 0, $length = filesize($this->_file_path.$session_id); $read < $length; $read += self::strlen($buffer))
|
||||
{
|
||||
if (($buffer = fread($this->_file_handle, $length - $read)) === FALSE)
|
||||
{
|
||||
@@ -352,10 +365,13 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
|
||||
$ts = time() - $maxlifetime;
|
||||
|
||||
$pattern = ($this->_config['match_ip'] === TRUE)
|
||||
? '[0-9a-f]{32}'
|
||||
: '';
|
||||
|
||||
$pattern = sprintf(
|
||||
'/^%s[0-9a-f]{%d}$/',
|
||||
preg_quote($this->_config['cookie_name'], '/'),
|
||||
($this->_config['match_ip'] === TRUE ? 72 : 40)
|
||||
'#\A%s'.$pattern.$this->_sid_regexp.'\z#',
|
||||
preg_quote($this->_config['cookie_name'])
|
||||
);
|
||||
|
||||
while (($file = readdir($directory)) !== FALSE)
|
||||
@@ -377,4 +393,36 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
}
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
$result = is_file($this->_file_path.$id);
|
||||
clearstatcache(TRUE, $this->_file_path.$id);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return (self::$func_overload)
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -117,7 +117,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 +142,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 +172,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $session_data;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -186,51 +188,44 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
*/
|
||||
public function write($session_id, $session_data)
|
||||
{
|
||||
if ( ! isset($this->_memcached))
|
||||
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('');
|
||||
$this->_session_id = $session_id;
|
||||
}
|
||||
|
||||
if (isset($this->_lock_key))
|
||||
$key = $this->_key_prefix.$session_id;
|
||||
|
||||
$this->_memcached->replace($this->_lock_key, time(), 300);
|
||||
if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
|
||||
{
|
||||
$key = $this->_key_prefix.$session_id;
|
||||
|
||||
$this->_memcached->replace($this->_lock_key, time(), 300);
|
||||
if ($this->_fingerprint !== ($fingerprint = md5($session_data)))
|
||||
{
|
||||
if (
|
||||
$this->_memcached->replace($key, $session_data, $this->_config['expiration'])
|
||||
OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
|
||||
)
|
||||
{
|
||||
$this->_fingerprint = $fingerprint;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
}
|
||||
|
||||
if (
|
||||
$this->_memcached->touch($key, $this->_config['expiration'])
|
||||
OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
|
||||
)
|
||||
if ($this->_memcached->set($key, $session_data, $this->_config['expiration']))
|
||||
{
|
||||
$this->_fingerprint = $fingerprint;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_failure;
|
||||
}
|
||||
elseif (
|
||||
$this->_memcached->touch($key, $this->_config['expiration'])
|
||||
OR ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND && $this->_memcached->set($key, $session_data, $this->_config['expiration']))
|
||||
)
|
||||
{
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -249,14 +244,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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -278,7 +273,7 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -297,6 +292,23 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
$this->_memcached->get($this->_key_prefix.$id);
|
||||
return ($this->_memcached->getResultCode() === Memcached::RES_SUCCESS);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -317,9 +329,11 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
if ( ! $this->_memcached->replace($this->_lock_key, time(), 300))
|
||||
{
|
||||
return ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND)
|
||||
? $this->_memcached->set($this->_lock_key, time(), 300)
|
||||
? $this->_memcached->add($this->_lock_key, time(), 300)
|
||||
: FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// 30 attempts to obtain a lock, in case another request already has it
|
||||
@@ -333,7 +347,8 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! $this->_memcached->set($lock_key, time(), 300))
|
||||
$method = ($this->_memcached->getResultCode() === Memcached::RES_NOTFOUND) ? 'add' : 'set';
|
||||
if ( ! $this->_memcached->$method($lock_key, time(), 300))
|
||||
{
|
||||
log_message('error', 'Session: Error while trying to obtain lock for '.$this->_key_prefix.$session_id);
|
||||
return FALSE;
|
||||
@@ -379,4 +394,4 @@ class CI_Session_memcached_driver extends CI_Session_driver implements SessionHa
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 3.0.0
|
||||
* @filesource
|
||||
@@ -51,7 +51,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
/**
|
||||
* phpRedis instance
|
||||
*
|
||||
* @var resource
|
||||
* @var Redis
|
||||
*/
|
||||
protected $_redis;
|
||||
|
||||
@@ -76,6 +76,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 +115,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 +172,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 +191,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 +225,7 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
return $session_data;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -199,43 +241,38 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
*/
|
||||
public function write($session_id, $session_data)
|
||||
{
|
||||
if ( ! isset($this->_redis))
|
||||
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;
|
||||
}
|
||||
|
||||
if (isset($this->_lock_key))
|
||||
$this->_redis->{$this->_setTimeout_name}($this->_lock_key, 300);
|
||||
if ($this->_fingerprint !== ($fingerprint = md5($session_data)) OR $this->_key_exists === FALSE)
|
||||
{
|
||||
$this->_redis->setTimeout($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']))
|
||||
{
|
||||
if ($this->_redis->set($this->_key_prefix.$session_id, $session_data, $this->_config['expiration']))
|
||||
{
|
||||
$this->_fingerprint = $fingerprint;
|
||||
$this->_key_exists = TRUE;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
$this->_fingerprint = $fingerprint;
|
||||
$this->_key_exists = TRUE;
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
return ($this->_redis->setTimeout($this->_key_prefix.$session_id, $this->_config['expiration']))
|
||||
? $this->_success
|
||||
: $this->_fail();
|
||||
return $this->_failure;
|
||||
}
|
||||
|
||||
return $this->_fail();
|
||||
return ($this->_redis->{$this->_setTimeout_name}($this->_key_prefix.$session_id, $this->_config['expiration']))
|
||||
? $this->_success
|
||||
: $this->_failure;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -252,12 +289,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -287,16 +324,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;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
@@ -315,6 +352,22 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
return $this->_success;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Validate ID
|
||||
*
|
||||
* Checks whether a session ID record exists server-side,
|
||||
* to enforce session.use_strict_mode.
|
||||
*
|
||||
* @param string $id
|
||||
* @return bool
|
||||
*/
|
||||
public function validateSessionId($id)
|
||||
{
|
||||
return (bool) $this->_redis->exists($this->_key_prefix.$id);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -332,7 +385,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
|
||||
@@ -346,7 +399,13 @@ class CI_Session_redis_driver extends CI_Session_driver implements SessionHandle
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! $this->_redis->setex($lock_key, 300, time()))
|
||||
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;
|
||||
@@ -384,7 +443,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;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.1
|
||||
* @filesource
|
||||
@@ -277,6 +277,7 @@ class CI_Table {
|
||||
public function set_caption($caption)
|
||||
{
|
||||
$this->caption = $caption;
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -434,7 +435,7 @@ class CI_Table {
|
||||
/**
|
||||
* Set table data from a database result object
|
||||
*
|
||||
* @param CI_DB_result $db_result Database result object
|
||||
* @param CI_DB_result $object Database result object
|
||||
* @return void
|
||||
*/
|
||||
protected function _set_from_db_result($object)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -370,7 +370,7 @@ class CI_Trackback {
|
||||
{
|
||||
$url = trim($url);
|
||||
|
||||
if (strpos($url, 'http') !== 0)
|
||||
if (stripos($url, 'http') !== 0)
|
||||
{
|
||||
$url = 'http://'.$url;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -241,7 +241,7 @@ class CI_Typography {
|
||||
// Clean up stray paragraph tags that appear before block level elements
|
||||
'#<p></p><('.$this->block_elements.')#' => '<$1',
|
||||
|
||||
// Clean up stray non-breaking spaces preceeding block elements
|
||||
// Clean up stray non-breaking spaces preceding block elements
|
||||
'#( \s*)+<('.$this->block_elements.')#' => ' <$2',
|
||||
|
||||
// Replace the temporary markers we added earlier
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.3.1
|
||||
* @filesource
|
||||
@@ -154,7 +154,6 @@ class CI_Unit_test {
|
||||
|
||||
if (in_array($expected, array('is_object', 'is_string', 'is_bool', 'is_true', 'is_false', 'is_int', 'is_numeric', 'is_float', 'is_double', 'is_array', 'is_null', 'is_resource'), TRUE))
|
||||
{
|
||||
$expected = str_replace('is_double', 'is_float', $expected);
|
||||
$result = $expected($test);
|
||||
$extype = str_replace(array('true', 'false'), 'bool', str_replace('is_', '', $expected));
|
||||
}
|
||||
@@ -291,7 +290,7 @@ class CI_Unit_test {
|
||||
{
|
||||
continue;
|
||||
}
|
||||
elseif (in_array($key, array('test_name', 'test_datatype', 'test_res_datatype', 'result'), TRUE))
|
||||
elseif (in_array($key, array('test_name', 'test_datatype', 'res_datatype', 'result'), TRUE))
|
||||
{
|
||||
if (FALSE !== ($line = $CI->lang->line(strtolower('ut_'.$val), FALSE)))
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -678,10 +678,8 @@ class CI_Upload {
|
||||
$this->set_error('upload_bad_filename', 'debug');
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $new_filename;
|
||||
}
|
||||
|
||||
return $new_filename;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1083,16 +1081,27 @@ class CI_Upload {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')))
|
||||
if (memory_get_usage() && ($memory_limit = ini_get('memory_limit')) > 0)
|
||||
{
|
||||
$memory_limit *= 1024 * 1024;
|
||||
|
||||
// There was a bug/behavioural change in PHP 5.2, where numbers over one million get output
|
||||
// into scientific notation. number_format() ensures this number is an integer
|
||||
// http://bugs.php.net/bug.php?id=43053
|
||||
|
||||
$memory_limit = number_format(ceil(filesize($file) + $memory_limit), 0, '.', '');
|
||||
$memory_limit = str_split($memory_limit, strspn($memory_limit, '1234567890'));
|
||||
if ( ! empty($memory_limit[1]))
|
||||
{
|
||||
switch ($memory_limit[1][0])
|
||||
{
|
||||
case 'g':
|
||||
case 'G':
|
||||
$memory_limit[0] *= 1024 * 1024 * 1024;
|
||||
break;
|
||||
case 'm':
|
||||
case 'M':
|
||||
$memory_limit[0] *= 1024 * 1024;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$memory_limit = (int) ceil(filesize($file) + $memory_limit[0]);
|
||||
ini_set('memory_limit', $memory_limit); // When an integer is used, the value is measured in bytes. - PHP.net
|
||||
}
|
||||
|
||||
@@ -1207,10 +1216,13 @@ class CI_Upload {
|
||||
// We'll need this to validate the MIME info string (e.g. text/plain; charset=us-ascii)
|
||||
$regexp = '/^([a-z\-]+\/[a-z0-9\-\.\+]+)(;\s.+)?$/';
|
||||
|
||||
/* Fileinfo extension - most reliable method
|
||||
/**
|
||||
* Fileinfo extension - most reliable method
|
||||
*
|
||||
* Unfortunately, prior to PHP 5.3 - it's only available as a PECL extension and the
|
||||
* more convenient FILEINFO_MIME_TYPE flag doesn't exist.
|
||||
* Apparently XAMPP, CentOS, cPanel and who knows what
|
||||
* other PHP distribution channels EXPLICITLY DISABLE
|
||||
* ext/fileinfo, which is otherwise enabled by default
|
||||
* since PHP 5.3 ...
|
||||
*/
|
||||
if (function_exists('finfo_file'))
|
||||
{
|
||||
@@ -1298,7 +1310,7 @@ class CI_Upload {
|
||||
}
|
||||
}
|
||||
|
||||
// Fall back to the deprecated mime_content_type(), if available (still better than $_FILES[$field]['type'])
|
||||
// Fall back to mime_content_type(), if available (still better than $_FILES[$field]['type'])
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
$this->file_type = @mime_content_type($file['tmp_name']);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -238,7 +238,7 @@ class CI_Xmlrpc {
|
||||
public $result;
|
||||
|
||||
/**
|
||||
* XML-RPC Reponse
|
||||
* XML-RPC Response
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
@@ -352,7 +352,7 @@ class CI_Xmlrpc {
|
||||
*/
|
||||
public function server($url, $port = 80, $proxy = FALSE, $proxy_port = 8080)
|
||||
{
|
||||
if (strpos($url, 'http') !== 0)
|
||||
if (stripos($url, 'http') !== 0)
|
||||
{
|
||||
$url = 'http://'.$url;
|
||||
}
|
||||
@@ -460,7 +460,7 @@ class CI_Xmlrpc {
|
||||
{
|
||||
if (is_array($value[0]) && ($value[1] === 'struct' OR $value[1] === 'array'))
|
||||
{
|
||||
while (list($k) = each($value[0]))
|
||||
foreach (array_keys($value[0]) as $k)
|
||||
{
|
||||
$value[0][$k] = $this->values_parsing($value[0][$k]);
|
||||
}
|
||||
@@ -735,6 +735,8 @@ class XML_RPC_Client extends CI_Xmlrpc
|
||||
.'Content-Length: '.strlen($msg->payload).$r.$r
|
||||
.$msg->payload;
|
||||
|
||||
stream_set_timeout($fp, $this->timeout); // set timeout for subsequent operations
|
||||
|
||||
for ($written = $timestamp = 0, $length = strlen($op); $written < $length; $written += $result)
|
||||
{
|
||||
if (($result = fwrite($fp, substr($op, $written))) === FALSE)
|
||||
@@ -753,9 +755,6 @@ class XML_RPC_Client extends CI_Xmlrpc
|
||||
$result = FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
usleep(250000);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -932,15 +931,15 @@ class XML_RPC_Response
|
||||
|
||||
if (is_array($array))
|
||||
{
|
||||
while (list($key) = each($array))
|
||||
foreach ($array as $key => &$value)
|
||||
{
|
||||
if (is_array($array[$key]))
|
||||
if (is_array($value))
|
||||
{
|
||||
$array[$key] = $this->decode($array[$key]);
|
||||
$array[$key] = $this->decode($value);
|
||||
}
|
||||
elseif ($this->xss_clean)
|
||||
{
|
||||
$array[$key] = $CI->security->xss_clean($array[$key]);
|
||||
$array[$key] = $CI->security->xss_clean($value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -994,10 +993,11 @@ class XML_RPC_Response
|
||||
reset($xmlrpc_val->me['struct']);
|
||||
$arr = array();
|
||||
|
||||
while (list($key,$value) = each($xmlrpc_val->me['struct']))
|
||||
foreach ($xmlrpc_val->me['struct'] as $key => &$value)
|
||||
{
|
||||
$arr[$key] = $this->xmlrpc_decoder($value);
|
||||
}
|
||||
|
||||
return $arr;
|
||||
}
|
||||
}
|
||||
@@ -1181,7 +1181,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 +1213,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)
|
||||
@@ -1563,17 +1563,17 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
|
||||
if ( ! empty($array))
|
||||
{
|
||||
while (list($key) = each($array))
|
||||
foreach ($array as $key => &$value)
|
||||
{
|
||||
if (is_array($array[$key]))
|
||||
if (is_array($value))
|
||||
{
|
||||
$array[$key] = $this->output_parameters($array[$key]);
|
||||
$array[$key] = $this->output_parameters($value);
|
||||
}
|
||||
elseif ($key !== 'bits' && $this->xss_clean)
|
||||
{
|
||||
// 'bits' is for the MetaWeblog API image bits
|
||||
// @todo - this needs to be made more general purpose
|
||||
$array[$key] = $CI->security->xss_clean($array[$key]);
|
||||
$array[$key] = $CI->security->xss_clean($value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1633,7 +1633,7 @@ class XML_RPC_Message extends CI_Xmlrpc
|
||||
reset($param->me['struct']);
|
||||
$arr = array();
|
||||
|
||||
while (list($key,$value) = each($param->me['struct']))
|
||||
foreach ($param->me['struct'] as $key => &$value)
|
||||
{
|
||||
$arr[$key] = $this->decode_message($value);
|
||||
}
|
||||
@@ -1824,7 +1824,7 @@ class XML_RPC_Values extends CI_Xmlrpc
|
||||
// struct
|
||||
$rs .= "<struct>\n";
|
||||
reset($val);
|
||||
while (list($key2, $val2) = each($val))
|
||||
foreach ($val as $key2 => &$val2)
|
||||
{
|
||||
$rs .= "<member>\n<name>{$key2}</name>\n".$this->serializeval($val2)."</member>\n";
|
||||
}
|
||||
@@ -1885,11 +1885,9 @@ class XML_RPC_Values extends CI_Xmlrpc
|
||||
*/
|
||||
public function serializeval($o)
|
||||
{
|
||||
$ar = $o->me;
|
||||
reset($ar);
|
||||
|
||||
list($typ, $val) = each($ar);
|
||||
return "<value>\n".$this->serializedata($typ, $val)."</value>\n";
|
||||
$array = $o->me;
|
||||
list($value, $type) = array(reset($array), key($array));
|
||||
return "<value>\n".$this->serializedata($type, $value)."</value>\n";
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -1901,8 +1899,7 @@ class XML_RPC_Values extends CI_Xmlrpc
|
||||
*/
|
||||
public function scalarval()
|
||||
{
|
||||
reset($this->me);
|
||||
return current($this->me);
|
||||
return reset($this->me);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -339,11 +339,11 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
//-------------------------------------
|
||||
|
||||
$method_parts = explode('.', $this->methods[$methName]['function']);
|
||||
$objectCall = (isset($method_parts[1]) && $method_parts[1] !== '');
|
||||
$objectCall = ! empty($method_parts[1]);
|
||||
|
||||
if ($system_call === TRUE)
|
||||
{
|
||||
if ( ! is_callable(array($this,$method_parts[1])))
|
||||
if ( ! is_callable(array($this, $method_parts[1])))
|
||||
{
|
||||
return new XML_RPC_Response(0, $this->xmlrpcerr['unknown_method'], $this->xmlrpcstr['unknown_method']);
|
||||
}
|
||||
@@ -400,17 +400,13 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
}
|
||||
elseif ($this->object === FALSE)
|
||||
{
|
||||
return get_instance()->$method_parts[1]($m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return $this->object->$method_parts[1]($m);
|
||||
return get_instance()->{$method_parts[1]}($m);
|
||||
}
|
||||
|
||||
return $this->object->{$method_parts[1]}($m);
|
||||
}
|
||||
else
|
||||
{
|
||||
return call_user_func($this->methods[$methName]['function'], $m);
|
||||
}
|
||||
|
||||
return call_user_func($this->methods[$methName]['function'], $m);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -499,10 +495,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']);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
@@ -584,7 +578,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
return $this->multicall_error('nomethod');
|
||||
}
|
||||
|
||||
list($scalar_type, $scalar_value) = each($methName->me);
|
||||
list($scalar_value, $scalar_type) = array(reset($methName->me), key($methName->me));
|
||||
$scalar_type = $scalar_type === $this->xmlrpcI4 ? $this->xmlrpcInt : $scalar_type;
|
||||
|
||||
if ($methName->kindOf() !== 'scalar' OR $scalar_type !== 'string')
|
||||
@@ -604,7 +598,7 @@ class CI_Xmlrpcs extends CI_Xmlrpc {
|
||||
return $this->multicall_error('notarray');
|
||||
}
|
||||
|
||||
list($a, $b) = each($params->me);
|
||||
list($b, $a) = array(reset($params->me), key($params->me));
|
||||
|
||||
$msg = new XML_RPC_Message($scalar_value);
|
||||
for ($i = 0, $numParams = count($b); $i < $numParams; $i++)
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*
|
||||
* This content is released under the MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
|
||||
* Copyright (c) 2014 - 2019, British Columbia Institute of Technology
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -29,8 +29,8 @@
|
||||
* @package CodeIgniter
|
||||
* @author EllisLab Dev Team
|
||||
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
|
||||
* @copyright Copyright (c) 2014 - 2016, 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/)
|
||||
* @license https://opensource.org/licenses/MIT MIT License
|
||||
* @link https://codeigniter.com
|
||||
* @since Version 1.0.0
|
||||
* @filesource
|
||||
@@ -105,6 +105,13 @@ class CI_Zip {
|
||||
*/
|
||||
public $compression_level = 2;
|
||||
|
||||
/**
|
||||
* mbstring.func_overload flag
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected static $func_overload;
|
||||
|
||||
/**
|
||||
* Initialize zip compression class
|
||||
*
|
||||
@@ -112,6 +119,8 @@ class CI_Zip {
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
isset(self::$func_overload) OR self::$func_overload = (extension_loaded('mbstring') && ini_get('mbstring.func_overload'));
|
||||
|
||||
$this->now = time();
|
||||
log_message('info', 'Zip Compression Class Initialized');
|
||||
}
|
||||
@@ -182,7 +191,7 @@ class CI_Zip {
|
||||
.pack('V', 0) // crc32
|
||||
.pack('V', 0) // compressed filesize
|
||||
.pack('V', 0) // uncompressed filesize
|
||||
.pack('v', strlen($dir)) // length of pathname
|
||||
.pack('v', self::strlen($dir)) // length of pathname
|
||||
.pack('v', 0) // extra field length
|
||||
.$dir
|
||||
// below is "data descriptor" segment
|
||||
@@ -197,7 +206,7 @@ class CI_Zip {
|
||||
.pack('V',0) // crc32
|
||||
.pack('V',0) // compressed filesize
|
||||
.pack('V',0) // uncompressed filesize
|
||||
.pack('v', strlen($dir)) // length of pathname
|
||||
.pack('v', self::strlen($dir)) // length of pathname
|
||||
.pack('v', 0) // extra field length
|
||||
.pack('v', 0) // file comment length
|
||||
.pack('v', 0) // disk number start
|
||||
@@ -206,7 +215,7 @@ class CI_Zip {
|
||||
.pack('V', $this->offset) // relative offset of local header
|
||||
.$dir;
|
||||
|
||||
$this->offset = strlen($this->zipdata);
|
||||
$this->offset = self::strlen($this->zipdata);
|
||||
$this->entries++;
|
||||
}
|
||||
|
||||
@@ -255,10 +264,10 @@ class CI_Zip {
|
||||
{
|
||||
$filepath = str_replace('\\', '/', $filepath);
|
||||
|
||||
$uncompressed_size = strlen($data);
|
||||
$uncompressed_size = self::strlen($data);
|
||||
$crc32 = crc32($data);
|
||||
$gzdata = substr(gzcompress($data, $this->compression_level), 2, -4);
|
||||
$compressed_size = strlen($gzdata);
|
||||
$gzdata = self::substr(gzcompress($data, $this->compression_level), 2, -4);
|
||||
$compressed_size = self::strlen($gzdata);
|
||||
|
||||
$this->zipdata .=
|
||||
"\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00"
|
||||
@@ -267,7 +276,7 @@ class CI_Zip {
|
||||
.pack('V', $crc32)
|
||||
.pack('V', $compressed_size)
|
||||
.pack('V', $uncompressed_size)
|
||||
.pack('v', strlen($filepath)) // length of filename
|
||||
.pack('v', self::strlen($filepath)) // length of filename
|
||||
.pack('v', 0) // extra field length
|
||||
.$filepath
|
||||
.$gzdata; // "file data" segment
|
||||
@@ -279,7 +288,7 @@ class CI_Zip {
|
||||
.pack('V', $crc32)
|
||||
.pack('V', $compressed_size)
|
||||
.pack('V', $uncompressed_size)
|
||||
.pack('v', strlen($filepath)) // length of filename
|
||||
.pack('v', self::strlen($filepath)) // length of filename
|
||||
.pack('v', 0) // extra field length
|
||||
.pack('v', 0) // file comment length
|
||||
.pack('v', 0) // disk number start
|
||||
@@ -288,7 +297,7 @@ class CI_Zip {
|
||||
.pack('V', $this->offset) // relative offset of local header
|
||||
.$filepath;
|
||||
|
||||
$this->offset = strlen($this->zipdata);
|
||||
$this->offset = self::strlen($this->zipdata);
|
||||
$this->entries++;
|
||||
$this->file_num++;
|
||||
}
|
||||
@@ -401,8 +410,8 @@ class CI_Zip {
|
||||
.$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', strlen($this->directory)) // size of central dir
|
||||
.pack('V', strlen($this->zipdata)) // offset to start of central dir
|
||||
.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
|
||||
}
|
||||
|
||||
@@ -425,9 +434,9 @@ class CI_Zip {
|
||||
|
||||
flock($fp, LOCK_EX);
|
||||
|
||||
for ($result = $written = 0, $data = $this->get_zip(), $length = strlen($data); $written < $length; $written += $result)
|
||||
for ($result = $written = 0, $data = $this->get_zip(), $length = self::strlen($data); $written < $length; $written += $result)
|
||||
{
|
||||
if (($result = fwrite($fp, substr($data, $written))) === FALSE)
|
||||
if (($result = fwrite($fp, self::substr($data, $written))) === FALSE)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -481,4 +490,43 @@ class CI_Zip {
|
||||
return $this;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe strlen()
|
||||
*
|
||||
* @param string $str
|
||||
* @return int
|
||||
*/
|
||||
protected static function strlen($str)
|
||||
{
|
||||
return (self::$func_overload)
|
||||
? mb_strlen($str, '8bit')
|
||||
: strlen($str);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Byte-safe substr()
|
||||
*
|
||||
* @param string $str
|
||||
* @param int $start
|
||||
* @param int $length
|
||||
* @return string
|
||||
*/
|
||||
protected static function substr($str, $start, $length = NULL)
|
||||
{
|
||||
if (self::$func_overload)
|
||||
{
|
||||
// mb_substr($str, $start, null, '8bit') returns an empty
|
||||
// string on PHP 5.3
|
||||
isset($length) OR $length = ($start >= 0 ? self::strlen($str) - $start : -$start);
|
||||
return mb_substr($str, $start, $length, '8bit');
|
||||
}
|
||||
|
||||
return isset($length)
|
||||
? substr($str, $start, $length)
|
||||
: substr($str, $start);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user