fix open_basedir path's for newer php-versions as a trailing slash won't allow the usage of subfolders within the given folder, fixes #797

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-04-14 10:05:49 +02:00
parent 6da6915cac
commit 79b2adea16

View File

@@ -25,9 +25,23 @@
* *
* @return string * @return string
*/ */
function appendOpenBasedirPath($path = '', $first = false) function appendOpenBasedirPath($path = '', $first = false) {
{
$path = makeCorrectDir($path); $path = makeCorrectDir($path);
// check for php-version that requires the trailing
// slash to be removed as it does not allow the usage
// of the subfolders within the given folder, fixes #797
if ((PHP_MINOR_VERSION == 2 && PHP_VERSION_ID >= 50216)
|| PHP_VERSION_ID >= 50304
) {
// check trailing slash
if (substr($path, -1, 1) == '/') {
// remove it
$path = substr($path, 0, -1);
}
}
if($path != '' if($path != ''
&& $path != '/' && $path != '/'
&& !preg_match("#^/dev#i", $path) && !preg_match("#^/dev#i", $path)
@@ -36,8 +50,9 @@ function appendOpenBasedirPath($path = '', $first = false)
&& !preg_match("#^/sys#i", $path) && !preg_match("#^/sys#i", $path)
&& !preg_match("#:#", $path) && !preg_match("#:#", $path)
) { ) {
if($first) if ($first) {
return $path; return $path;
}
return ':' . $path; return ':' . $path;
} }