diff --git a/include/class.misc.php b/include/class.misc.php index e913a8de0fdd052b0e9a87ec9693b720cc36e03b..b92909caac5f4f80bae768d9acf812fce5fb4c41 100644 --- a/include/class.misc.php +++ b/include/class.misc.php @@ -139,21 +139,17 @@ class Misc { return $output; } - function siteBaseUrl() { - # Detects Alias-ing - $paths = explode('/', $_SERVER['REQUEST_URI']); - # Drop the last item -- it will be the php page we're on - array_pop($paths); - $leading = array(); - while (count($paths)) { - if (in_array($paths[0], array('scp','client'))) - break; - $leading[] = array_shift($paths); + /* static */ + function siteRootPath($main_inc_path) { + $root = str_replace('\\', '/', $main_inc_path); + $root2 = str_replace('\\','/', $_SERVER['DOCUMENT_ROOT']); + $path = ''; + while (strpos($_SERVER['DOCUMENT_ROOT'], $root) === false) { + $lastslash = strrpos($root, '/'); + $path = substr($root, $lastslash) . $path; + $root = substr($root, 0, $lastslash); } - if (count($leading) > 1) - return implode('/', $leading); - else - return ''; + return $path; } } diff --git a/main.inc.php b/main.inc.php index 4b69b3e1638a2fc8f90f9d9533c092f31a9dffbd..428a33e4a63ff98ef9e5b53b24b20f8babe0b74c 100644 --- a/main.inc.php +++ b/main.inc.php @@ -60,13 +60,6 @@ } #Set Dir constants - $here = substr(realpath(dirname(__file__)), - strlen($_SERVER['DOCUMENT_ROOT'])); - // Determine the path in the URI used as the base of the osTicket - // installation - if (!defined('ROOT_PATH')) - define('ROOT_PATH', str_replace('\\', '/', $here.'/')); //root path. Damn directories - define('ROOT_DIR',str_replace('\\\\', '/', realpath(dirname(__FILE__))).'/'); #Get real path for root dir ---linux and windows define('INCLUDE_DIR',ROOT_DIR.'include/'); //Change this if include is moved outside the web path. define('PEAR_DIR',INCLUDE_DIR.'pear/'); @@ -75,6 +68,13 @@ define('UPGRADE_DIR', INCLUDE_DIR.'upgrader/'); define('I18N_DIR', INCLUDE_DIR.'i18n/'); + require(INCLUDE_DIR.'class.misc.php'); + + // Determine the path in the URI used as the base of the osTicket + // installation + if (!defined('ROOT_PATH')) + define('ROOT_PATH', Misc::siteRootPath(realpath(dirname(__file__))).'/'); //root path. Damn directories + /*############## Do NOT monkey with anything else beyond this point UNLESS you really know what you are doing ##############*/ #Current version && schema signature (Changes from version to version) @@ -117,7 +117,6 @@ require(INCLUDE_DIR.'class.pagenate.php'); //Pagenate helper! require(INCLUDE_DIR.'class.log.php'); require(INCLUDE_DIR.'class.crypto.php'); - require(INCLUDE_DIR.'class.misc.php'); require(INCLUDE_DIR.'class.timezone.php'); require(INCLUDE_DIR.'class.http.php'); require(INCLUDE_DIR.'class.signal.php');