mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 22:28:51 +00:00
Correctly determine writable status of files on Windows operating system. #39035
git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@9528 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
62aa26c9a6
commit
be8457d3c4
3 changed files with 63 additions and 1 deletions
|
@ -88,6 +88,7 @@
|
||||||
<a name="v305"></a><h3>1.i. Changes since 3.0.5</h3>
|
<a name="v305"></a><h3>1.i. Changes since 3.0.5</h3>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
|
<li>[Fix] Correctly determine writable status of files on Windows operating system. (Bug #39035)</li>
|
||||||
<li>[Feature] Backported 3.2 cpatcha plugins.</li>
|
<li>[Feature] Backported 3.2 cpatcha plugins.</li>
|
||||||
<li>[Feature] Introduced new ACM plugins: null</li>
|
<li>[Feature] Introduced new ACM plugins: null</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -504,7 +504,7 @@ class acp_main
|
||||||
$template->assign_var('S_REMOVE_INSTALL', true);
|
$template->assign_var('S_REMOVE_INSTALL', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx))
|
if (!defined('PHPBB_DISABLE_CONFIG_CHECK') && file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx))
|
||||||
{
|
{
|
||||||
// World-Writable? (000x)
|
// 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($phpbb_root_path . 'config.' . $phpEx) & 0x0002));
|
||||||
|
|
|
@ -669,6 +669,67 @@ function phpbb_chmod($filename, $perms = CHMOD_READ)
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test if a file/directory is writable
|
||||||
|
*
|
||||||
|
* This function calls the native is_writable() when not running under
|
||||||
|
* Windows and it is not disabled.
|
||||||
|
*
|
||||||
|
* @param string $file Path to perform write test on
|
||||||
|
* @return bool True when the path is writable, otherwise false.
|
||||||
|
*/
|
||||||
|
function phpbb_is_writable($file)
|
||||||
|
{
|
||||||
|
if (substr(PHP_OS, 0, 3) === 'WIN' || !function_exists('is_writable'))
|
||||||
|
{
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
// Canonicalise path to absolute path
|
||||||
|
$file = phpbb_realpath($file);
|
||||||
|
|
||||||
|
if (is_dir($file))
|
||||||
|
{
|
||||||
|
// Test directory by creating a file inside the directory
|
||||||
|
$result = @tempnam($file, 'i_w');
|
||||||
|
|
||||||
|
if (is_string($result) && file_exists($result))
|
||||||
|
{
|
||||||
|
unlink($result);
|
||||||
|
|
||||||
|
// Ensure the file is actually in the directory (returned realpathed)
|
||||||
|
return (strpos($result, $file) === 0) ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$handle = @fopen($file, 'r+');
|
||||||
|
|
||||||
|
if (is_resource($handle))
|
||||||
|
{
|
||||||
|
fclose($handle);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// file does not exist test if we can write to the directory
|
||||||
|
|
||||||
|
$dir = dirname($file);
|
||||||
|
|
||||||
|
if (file_exists($dir) && is_dir($dir) && phpbb_is_writable($dir))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return is_writable($file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Compatibility functions
|
// Compatibility functions
|
||||||
|
|
||||||
if (!function_exists('array_combine'))
|
if (!function_exists('array_combine'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue