Add PHP 5 compatible recursive dirname()
This commit is contained in:
parent
b08e5ab41b
commit
607f7daf51
19
boot.php
19
boot.php
|
@ -854,3 +854,22 @@ function validate_include(&$file)
|
||||||
// Simply return flag
|
// Simply return flag
|
||||||
return $valid;
|
return $valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP 5 compatible dirname() with count parameter
|
||||||
|
*
|
||||||
|
* @see http://php.net/manual/en/function.dirname.php#113193
|
||||||
|
*
|
||||||
|
* @deprecated with PHP 7
|
||||||
|
* @param string $path
|
||||||
|
* @param int $levels
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function rdirname($path, $levels = 1)
|
||||||
|
{
|
||||||
|
if ($levels > 1) {
|
||||||
|
return dirname(rdirname($path, --$levels));
|
||||||
|
} else {
|
||||||
|
return dirname($path);
|
||||||
|
}
|
||||||
|
}
|
|
@ -523,7 +523,7 @@ class App
|
||||||
if (!empty($relative_script_path)) {
|
if (!empty($relative_script_path)) {
|
||||||
// Module
|
// Module
|
||||||
if (!empty($_SERVER['QUERY_STRING'])) {
|
if (!empty($_SERVER['QUERY_STRING'])) {
|
||||||
$path = trim(dirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
|
$path = trim(rdirname($relative_script_path, substr_count(trim($_SERVER['QUERY_STRING'], '/'), '/') + 1), '/');
|
||||||
} else {
|
} else {
|
||||||
// Root page
|
// Root page
|
||||||
$path = trim($relative_script_path, '/');
|
$path = trim($relative_script_path, '/');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user