From 99ae1c8a79a84c17e5e9b6f1c44e1fbf4699f974 Mon Sep 17 00:00:00 2001 From: k4be Date: Sat, 28 Oct 2023 15:41:21 +0200 Subject: Fix compatibility problems with PHP 8. Tested with PHP 8.1.20. Includes fixes from misterludvigsen and ColdSphinX. --- htdocs/application/helpers/captcha_helper.php | 6 +++--- htdocs/application/libraries/Carabiner.php | 2 +- htdocs/system/core/Input.php | 2 +- htdocs/system/libraries/Pagination.php | 2 +- .../libraries/Session/drivers/Session_database_driver.php | 12 ++++++------ 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/htdocs/application/helpers/captcha_helper.php b/htdocs/application/helpers/captcha_helper.php index 9bcb132..6e86060 100644 --- a/htdocs/application/helpers/captcha_helper.php +++ b/htdocs/application/helpers/captcha_helper.php @@ -350,7 +350,7 @@ if (!function_exists('display_captcha')) { $rad1 = $radius * (($i + 1) / $points); $x1 = ($rad1 * cos($theta)) + $x_axis; $y1 = ($rad1 * sin($theta)) + $y_axis; - imageline($im, $x, $y, $x1, $y1, $grid_color); + imageline($im, (int)$x, (int)$y, (int)$x1, (int)$y1, $grid_color); $theta = $theta - $thetac; } @@ -368,11 +368,11 @@ if (!function_exists('display_captcha')) { if ($use_font == false) { $font_size = 5; - $x = mt_rand(0, $img_width / ($length / 3)); + $x = mt_rand(0, (int)($img_width / ($length / 3))); $y = 0; } else { $font_size = 16; - $x = mt_rand(0, $img_width / ($length / 1.5)); + $x = mt_rand(0, (int)($img_width / ($length / 1.5))); $y = $font_size + 2; } for ($i = 0; $i < strlen($word); $i++) { diff --git a/htdocs/application/libraries/Carabiner.php b/htdocs/application/libraries/Carabiner.php index f8037cf..6fbafe2 100644 --- a/htdocs/application/libraries/Carabiner.php +++ b/htdocs/application/libraries/Carabiner.php @@ -461,7 +461,7 @@ class Carabiner { * @param String of the group name with which the asset is to be associated. NOT REQUIRED * @return Void */ - private function _asset($type, $dev_file, $prod_file = '', $combine, $minify, $media = 'screen', $group = 'main') + private function _asset($type, $dev_file, $prod_file = '', $combine = TRUE, $minify = TRUE, $media = 'screen', $group = 'main') { if ($type == 'css') : diff --git a/htdocs/system/core/Input.php b/htdocs/system/core/Input.php index 143babf..61b7a3e 100644 --- a/htdocs/system/core/Input.php +++ b/htdocs/system/core/Input.php @@ -565,7 +565,7 @@ class CI_Input { $which = FILTER_FLAG_IPV6; break; default: - $which = NULL; + $which = FILTER_DEFAULT; break; } diff --git a/htdocs/system/libraries/Pagination.php b/htdocs/system/libraries/Pagination.php index 3fe3d3a..3933448 100644 --- a/htdocs/system/libraries/Pagination.php +++ b/htdocs/system/libraries/Pagination.php @@ -522,7 +522,7 @@ class CI_Pagination { } // If something isn't quite right, back to the default base page. - if ( ! ctype_digit($this->cur_page) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) + if ( ! ctype_digit(strval($this->cur_page)) OR ($this->use_page_numbers && (int) $this->cur_page === 0)) { $this->cur_page = $base_page; } diff --git a/htdocs/system/libraries/Session/drivers/Session_database_driver.php b/htdocs/system/libraries/Session/drivers/Session_database_driver.php index 074accf..70774aa 100644 --- a/htdocs/system/libraries/Session/drivers/Session_database_driver.php +++ b/htdocs/system/libraries/Session/drivers/Session_database_driver.php @@ -126,7 +126,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $name Session cookie name, unused * @return bool */ - public function open($save_path, $name) + public function open(string $path, string $name): bool { if (empty($this->_db->conn_id) && ! $this->_db->db_connect()) { @@ -148,7 +148,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_id Session ID * @return string Serialized session data */ - public function read($session_id) + public function read($session_id): string|false { if ($this->_get_lock($session_id) !== FALSE) { @@ -205,7 +205,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_data Serialized session data * @return bool */ - public function write($session_id, $session_data) + public function write($session_id, $session_data): bool { // Prevent previous QB calls from messing with our queries $this->_db->reset_query(); @@ -277,7 +277,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * * @return bool */ - public function close() + public function close() : bool { return ($this->_lock && ! $this->_release_lock()) ? $this->_fail() @@ -294,7 +294,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param string $session_id Session ID * @return bool */ - public function destroy($session_id) + public function destroy($session_id) : bool { if ($this->_lock) { @@ -332,7 +332,7 @@ class CI_Session_database_driver extends CI_Session_driver implements SessionHan * @param int $maxlifetime Maximum lifetime of sessions * @return bool */ - public function gc($maxlifetime) + public function gc(int $max_lifetime): int|false { // Prevent previous QB calls from messing with our queries $this->_db->reset_query(); -- cgit v1.2.3 From 3d885eaa50a1ed7d179124fa08925c295b9940ae Mon Sep 17 00:00:00 2001 From: k4be Date: Sun, 29 Oct 2023 12:14:09 +0100 Subject: Fix /cron for php8 --- htdocs/system/core/Output.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/system/core/Output.php b/htdocs/system/core/Output.php index 3cda062..9bb9066 100644 --- a/htdocs/system/core/Output.php +++ b/htdocs/system/core/Output.php @@ -454,7 +454,7 @@ class CI_Output { if ($this->parse_exec_vars === TRUE) { $memory = round(memory_get_usage() / 1024 / 1024, 2).'MB'; - $output = str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output); + $output = $output ? str_replace(array('{elapsed_time}', '{memory_usage}'), array($elapsed, $memory), $output) : ''; } // -------------------------------------------------------------------- -- cgit v1.2.3 From 9b84e0c07fae337757dd4d75d1947e36860b1916 Mon Sep 17 00:00:00 2001 From: k4be Date: Sun, 29 Oct 2023 14:38:46 +0100 Subject: Fix various theme issues with php8 Reported by PeGaSuS-Coder --- htdocs/application/libraries/Carabiner.php | 6 ++++-- htdocs/application/libraries/Jsmin.php | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/htdocs/application/libraries/Carabiner.php b/htdocs/application/libraries/Carabiner.php index 6fbafe2..7480368 100644 --- a/htdocs/application/libraries/Carabiner.php +++ b/htdocs/application/libraries/Carabiner.php @@ -938,14 +938,16 @@ class Carabiner { private function _get_contents($ref) { + $contents = false; if( $this->isURL($ref) && ( ini_get('allow_url_fopen') == 0 || $this->force_curl ) ): $this->_load('curl'); $contents = $this->CI->curl->simple_get($ref); else: - - $contents = file_get_contents( $ref ); + if($ref){ + $contents = file_get_contents( $ref ); + } endif; diff --git a/htdocs/application/libraries/Jsmin.php b/htdocs/application/libraries/Jsmin.php index 620514f..8299b85 100644 --- a/htdocs/application/libraries/Jsmin.php +++ b/htdocs/application/libraries/Jsmin.php @@ -174,7 +174,7 @@ class JSMin { } protected function isAlphaNum($c) { - return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1; + return $c ? ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1 : false; } protected function min() { @@ -306,4 +306,4 @@ class JSMin { // -- Exceptions --------------------------------------------------------------- class JSMinException extends Exception {} -?> \ No newline at end of file +?> -- cgit v1.2.3 From 03e9c1a99eea56ceed39f0fcea38955a6716570e Mon Sep 17 00:00:00 2001 From: k4be Date: Mon, 30 Oct 2023 16:15:39 +0100 Subject: Fix another php8 error with 'default' theme --- htdocs/themes/default/views/view/search.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/themes/default/views/view/search.php b/htdocs/themes/default/views/view/search.php index d568aab..67dcc57 100644 --- a/htdocs/themes/default/views/view/search.php +++ b/htdocs/themes/default/views/view/search.php @@ -3,7 +3,10 @@
- input->get('search')); ?>" id="search" maxlength="100" tabindex="1" /> + " id="search" maxlength="100" tabindex="1" />
-- cgit v1.2.3