From 79b2adea16f48867c4c32ebeb5bd0feaaa5f48d1 Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Sun, 14 Apr 2013 10:05:49 +0200 Subject: [PATCH] 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) --- .../function.appendOpenbasedirPath.php | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/functions/validate/function.appendOpenbasedirPath.php b/lib/functions/validate/function.appendOpenbasedirPath.php index e26a7177..16016542 100644 --- a/lib/functions/validate/function.appendOpenbasedirPath.php +++ b/lib/functions/validate/function.appendOpenbasedirPath.php @@ -25,9 +25,23 @@ * * @return string */ -function appendOpenBasedirPath($path = '', $first = false) -{ +function appendOpenBasedirPath($path = '', $first = false) { + $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 != '' && $path != '/' && !preg_match("#^/dev#i", $path) @@ -36,8 +50,9 @@ function appendOpenBasedirPath($path = '', $first = false) && !preg_match("#^/sys#i", $path) && !preg_match("#:#", $path) ) { - if($first) + if ($first) { return $path; + } return ':' . $path; }