Skip to content
Snippets Groups Projects
Commit f574da55 authored by Jared Hancock's avatar Jared Hancock
Browse files

Provide default ROOT_PATH for command-line scripts

parent 346202fd
No related branches found
No related tags found
No related merge requests found
......@@ -141,11 +141,17 @@ class Misc {
/* static */
function siteRootPath($main_inc_path) {
if (!$_SERVER['DOCUMENT_ROOT'])
return './';
$root = str_replace('\\', '/', $main_inc_path);
$root2 = str_replace('\\','/', $_SERVER['DOCUMENT_ROOT']);
$path = '';
while (strpos($_SERVER['DOCUMENT_ROOT'], $root) === false) {
$lastslash = strrpos($root, '/');
if ($lastslash === false)
// Unable to find any commonality between $root and
// DOCUMENT_ROOT
return './';
$path = substr($root, $lastslash) . $path;
$root = substr($root, 0, $lastslash);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment