From c0511d54fdfdb066957cd800a8a22f4839b342a1 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 25 Nov 2020 22:42:23 +0100 Subject: [PATCH 01/11] [ticket/16641] Fix CHMOD validation for config.php - PHP 8 PHPBB3-16641 --- phpBB/phpbb/filesystem/filesystem.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 7f44d5f1de..3749d12b48 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -613,11 +613,8 @@ class filesystem implements filesystem_interface } else { - $handle = @fopen($file, 'c'); - - if (is_resource($handle)) + if (is_writable($file)) { - fclose($handle); return true; } } From cd42c0e306caad1e4e3e6cb7a0dff68b4fb96f1e Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:44:15 +0100 Subject: [PATCH 02/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 6 +++++- phpBB/phpbb/filesystem/filesystem.php | 5 ++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index ffc830ec90..75c717728d 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -679,7 +679,11 @@ class acp_main } } - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)) + $config_ref = $phpbb_root_path . 'config.' . $phpEx; + + if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) + && (function_exists('is_writable') ? is_writable($config_ref) : $phpbb_filesystem->is_writable($config_ref)) + ) { // World-Writable? (000x) $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 3749d12b48..7f44d5f1de 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -613,8 +613,11 @@ class filesystem implements filesystem_interface } else { - if (is_writable($file)) + $handle = @fopen($file, 'c'); + + if (is_resource($handle)) { + fclose($handle); return true; } } From f711133580ec32215f8f129c6008befc281c6375 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:51:47 +0100 Subject: [PATCH 03/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 75c717728d..a1ce3a00c9 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -686,7 +686,7 @@ class acp_main ) { // World-Writable? (000x) - $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); + $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($config_ref) & 0x0002)); } $this->php_ini = $phpbb_container->get('php_ini'); From 146d72468f33f76dfe8b3503d0da7d96ca38f868 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 26 Nov 2020 23:58:34 +0100 Subject: [PATCH 04/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index a1ce3a00c9..368e7c5996 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -681,7 +681,7 @@ class acp_main $config_ref = $phpbb_root_path . 'config.' . $phpEx; - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) + if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref) && (function_exists('is_writable') ? is_writable($config_ref) : $phpbb_filesystem->is_writable($config_ref)) ) { From 4e8b1045434086720383d349bd3b8fe101c378d2 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Fri, 27 Nov 2020 20:50:06 +0100 Subject: [PATCH 05/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 5 ++--- phpBB/phpbb/filesystem/filesystem.php | 9 +++------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 368e7c5996..a222bfa1cc 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -679,11 +679,10 @@ class acp_main } } + // We define the variable so we avoid redundancies $config_ref = $phpbb_root_path . 'config.' . $phpEx; - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref) - && (function_exists('is_writable') ? is_writable($config_ref) : $phpbb_filesystem->is_writable($config_ref)) - ) + if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref) && $phpbb_filesystem->is_writable($config_ref)) { // World-Writable? (000x) $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($config_ref) & 0x0002)); diff --git a/phpBB/phpbb/filesystem/filesystem.php b/phpBB/phpbb/filesystem/filesystem.php index 7f44d5f1de..fc7cbdf27d 100644 --- a/phpBB/phpbb/filesystem/filesystem.php +++ b/phpBB/phpbb/filesystem/filesystem.php @@ -613,13 +613,10 @@ class filesystem implements filesystem_interface } else { - $handle = @fopen($file, 'c'); + $handle = new \SplFileInfo($file); - if (is_resource($handle)) - { - fclose($handle); - return true; - } + // Returns TRUE if writable, FALSE otherwise + return $handle->isWritable(); } } else From ea5028cf2aaf217df61056d1068faa4fa489b466 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sat, 28 Nov 2020 05:38:38 +0100 Subject: [PATCH 06/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index a222bfa1cc..6a450d2765 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -682,7 +682,7 @@ class acp_main // We define the variable so we avoid redundancies $config_ref = $phpbb_root_path . 'config.' . $phpEx; - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref) && $phpbb_filesystem->is_writable($config_ref)) + if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref)) { // World-Writable? (000x) $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($config_ref) & 0x0002)); From 557160f158b3f2923112f890b73f6126923f5e17 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sat, 28 Nov 2020 06:25:44 +0100 Subject: [PATCH 07/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 6a450d2765..a55cc57e9f 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -679,13 +679,10 @@ class acp_main } } - // We define the variable so we avoid redundancies $config_ref = $phpbb_root_path . 'config.' . $phpEx; - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref)) { - // World-Writable? (000x) - $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($config_ref) & 0x0002)); + $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($config_ref)); } $this->php_ini = $phpbb_container->get('php_ini'); From b9b50a108b892620f2f49c4cb0564e8b001b5456 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Sat, 28 Nov 2020 18:28:05 +0100 Subject: [PATCH 08/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index a55cc57e9f..eddd48bf2a 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -679,17 +679,17 @@ class acp_main } } - $config_ref = $phpbb_root_path . 'config.' . $phpEx; - if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($config_ref)) + if (!defined('PHPBB_DISABLE_CONFIG_CHECK')) { - $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($config_ref)); + $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)); } - $this->php_ini = $phpbb_container->get('php_ini'); - $func_overload = $this->php_ini->getNumeric('mbstring.func_overload'); - $encoding_translation = $this->php_ini->getString('mbstring.encoding_translation'); - $http_input = $this->php_ini->getString('mbstring.http_input'); - $http_output = $this->php_ini->getString('mbstring.http_output'); + $this->php_ini = $phpbb_container->get('php_ini'); + $func_overload = $this->php_ini->getNumeric('mbstring.func_overload'); + $encoding_translation = $this->php_ini->getString('mbstring.encoding_translation'); + $http_input = $this->php_ini->getString('mbstring.http_input'); + $http_output = $this->php_ini->getString('mbstring.http_output'); + if (extension_loaded('mbstring')) { $template->assign_vars(array( From 2c2ee90d587c548ea48fe0a426e8d4ef823ca216 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Tue, 29 Dec 2020 22:04:31 +0100 Subject: [PATCH 09/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index eddd48bf2a..bd50ea2046 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -681,7 +681,9 @@ class acp_main if (!defined('PHPBB_DISABLE_CONFIG_CHECK')) { - $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx)); + $template->assign_var('S_WRITABLE_CONFIG', + (bool) $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx) || (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002) + ); } $this->php_ini = $phpbb_container->get('php_ini'); From 7ceb43602186898f83c06031bfdf7b1fb15875cb Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Wed, 30 Dec 2020 03:02:10 +0100 Subject: [PATCH 10/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index bd50ea2046..77862e3b46 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -681,9 +681,9 @@ class acp_main if (!defined('PHPBB_DISABLE_CONFIG_CHECK')) { - $template->assign_var('S_WRITABLE_CONFIG', - (bool) $phpbb_filesystem->is_writable($phpbb_root_path . 'config.' . $phpEx) || (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002) - ); + $phpbb_config_file = $phpbb_root_path . 'config.' . $phpEx; + + $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($phpbb_config_file) || (@fileperms($phpbb_config_file) & 0x0002)); } $this->php_ini = $phpbb_container->get('php_ini'); From 2d548a026fa0b476cdf74dce28d2735e3a3b91e9 Mon Sep 17 00:00:00 2001 From: 3D-I <480857+3D-I@users.noreply.github.com> Date: Thu, 31 Dec 2020 22:30:10 +0100 Subject: [PATCH 11/11] [ticket/16641] Fix config.php validation in ACP - PHP 8 PHPBB3-16641 --- phpBB/includes/acp/acp_main.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index 77862e3b46..a46ac2c16f 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -681,9 +681,8 @@ class acp_main if (!defined('PHPBB_DISABLE_CONFIG_CHECK')) { - $phpbb_config_file = $phpbb_root_path . 'config.' . $phpEx; - - $template->assign_var('S_WRITABLE_CONFIG', (bool) $phpbb_filesystem->is_writable($phpbb_config_file) || (@fileperms($phpbb_config_file) & 0x0002)); + // World-Writable? (000x) + $template->assign_var('S_WRITABLE_CONFIG', (bool) (@fileperms($phpbb_root_path . 'config.' . $phpEx) & 0x0002)); } $this->php_ini = $phpbb_container->get('php_ini');