diff --git a/include/class.misc.php b/include/class.misc.php index b92909caac5f4f80bae768d9acf812fce5fb4c41..8d5dbb382d9c1f7755df71a407790c95b27873c6 100644 --- a/include/class.misc.php +++ b/include/class.misc.php @@ -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); }