diff options
Diffstat (limited to 'system')
-rw-r--r-- | system/core/Common.php | 2 | ||||
-rw-r--r-- | system/database/DB_driver.php | 12 | ||||
-rw-r--r-- | system/helpers/captcha_helper.php | 12 | ||||
-rw-r--r-- | system/libraries/Cache/drivers/Cache_redis.php | 27 | ||||
-rw-r--r-- | system/libraries/Session/drivers/Session_files_driver.php | 4 | ||||
-rw-r--r-- | system/libraries/Upload.php | 4 | ||||
-rw-r--r-- | system/libraries/Zip.php | 3 |
7 files changed, 55 insertions, 9 deletions
diff --git a/system/core/Common.php b/system/core/Common.php index fadc0a0b1..f8ab7e800 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -569,7 +569,7 @@ if ( ! function_exists('set_status_header')) return; } - $server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2'), TRUE)) + $server_protocol = (isset($_SERVER['SERVER_PROTOCOL']) && in_array($_SERVER['SERVER_PROTOCOL'], array('HTTP/1.0', 'HTTP/1.1', 'HTTP/2', 'HTTP/2.0'), TRUE)) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1'; header($server_protocol.' '.$code.' '.$text, TRUE, $code); } diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index b4f16b905..f3433f849 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -825,6 +825,18 @@ abstract class CI_DB_driver { { return $this->_trans_status; } + + // -------------------------------------------------------------------- + + /** + * Returns TRUE if a transaction is currently active + * + * @return bool + */ + public function trans_active() + { + return (bool) $this->_trans_depth; + } // -------------------------------------------------------------------- diff --git a/system/helpers/captcha_helper.php b/system/helpers/captcha_helper.php index 642ff3a50..dcd6882c8 100644 --- a/system/helpers/captcha_helper.php +++ b/system/helpers/captcha_helper.php @@ -103,6 +103,18 @@ if ( ! function_exists('create_captcha')) return FALSE; } + if ($img_path === '' OR $img_url === '') + { + log_message('error', 'create_captcha(): $img_path and $img_url are required.'); + return FALSE; + } + + if ( ! is_dir($img_path) OR ! is_really_writable($img_path)) + { + log_message('error', "create_captcha(): '{$img_path}' is not a dir, nor is it writable."); + return FALSE; + } + if ($img_url !== '' OR $img_path !== '') { if ($img_path === '' OR $img_url === '') diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 9dbe52844..9b082d11b 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -77,6 +77,13 @@ class CI_Cache_redis extends CI_Driver */ protected static $_delete_name; + /** + * sRem()/sRemove() method name depending on phpRedis version + * + * @var string + */ + protected static $_sRemove_name; + // ------------------------------------------------------------------------ /** @@ -98,9 +105,19 @@ class CI_Cache_redis extends CI_Driver return; } - isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('redis'), '5', '>=') - ? 'del' - : 'delete'; + if ( ! isset(static::$_delete_name, static::$_sRemove_name)) + { + if (version_compare(phpversion('redis'), '5', '>=')) + { + static::$_delete_name = 'del'; + static::$_sRemove_name = 'sRem'; + } + else + { + static::$_delete_name = 'delete'; + static::$_sRemove_name = 'sRemove'; + } + } $CI =& get_instance(); @@ -210,7 +227,7 @@ class CI_Cache_redis extends CI_Driver } else { - $this->_redis->sRemove('_ci_redis_serialized', $id); + $this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $id); } return TRUE; @@ -231,7 +248,7 @@ class CI_Cache_redis extends CI_Driver return FALSE; } - $this->_redis->sRemove('_ci_redis_serialized', $key); + $this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $key); return TRUE; } diff --git a/system/libraries/Session/drivers/Session_files_driver.php b/system/libraries/Session/drivers/Session_files_driver.php index 2899b7dec..d9966273b 100644 --- a/system/libraries/Session/drivers/Session_files_driver.php +++ b/system/libraries/Session/drivers/Session_files_driver.php @@ -196,6 +196,10 @@ class CI_Session_files_driver extends CI_Session_driver implements SessionHandle $this->_fingerprint = md5(''); return ''; } + + // Prevent possible data corruption + // See https://github.com/bcit-ci/CodeIgniter/issues/5857 + clearstatcache(TRUE, $this->_file_path.$session_id); } // We shouldn't need this, but apparently we do ... // See https://github.com/bcit-ci/CodeIgniter/issues/4039 diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 8c891cff6..95f765b78 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -867,7 +867,7 @@ class CI_Upload { $this->file_type = 'image/jpeg'; } - $img_mimes = array('image/gif', 'image/jpeg', 'image/png'); + $img_mimes = array('image/gif', 'image/jpeg', 'image/png', 'image/webp'); return in_array($this->file_type, $img_mimes, TRUE); } @@ -901,7 +901,7 @@ class CI_Upload { } // Images get some additional checks - if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png'), TRUE) && @getimagesize($this->file_temp) === FALSE) + if (in_array($ext, array('gif', 'jpg', 'jpeg', 'jpe', 'png', 'webp'), TRUE) && @getimagesize($this->file_temp) === FALSE) { return FALSE; } diff --git a/system/libraries/Zip.php b/system/libraries/Zip.php index 5fba1cf3a..4579e8c2b 100644 --- a/system/libraries/Zip.php +++ b/system/libraries/Zip.php @@ -406,13 +406,14 @@ class CI_Zip { return FALSE; } + // @see https://github.com/bcit-ci/CodeIgniter/issues/5864 $footer = $this->directory."\x50\x4b\x05\x06\x00\x00\x00\x00" .pack('v', $this->entries) // total # of entries "on this disk" .pack('v', $this->entries) // total # of entries overall .pack('V', self::strlen($this->directory)) // size of central dir .pack('V', self::strlen($this->zipdata)) // offset to start of central dir ."\x00\x00"; // .zip file comment length - return $this->zipdata . $footer; + return $this->zipdata.$footer; } // -------------------------------------------------------------------- |