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] [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