diff --git a/web/classes/contentcache.class.php b/web/classes/contentcache.class.php index 7272a4cc71..d7e83b1bbb 100644 --- a/web/classes/contentcache.class.php +++ b/web/classes/contentcache.class.php @@ -45,7 +45,7 @@ public function store($file, $content) !isset($content) || $content == '') return false; - $file = FrontController::absolutePath($this->_docRoot.'/'.$file); + $file = absolutePath($this->_docRoot.'/'.$file); /*try {*/ @@ -88,7 +88,7 @@ public function store($file, $content) */ public function has($relPath) { - return (bool) file_exists(FrontController::nativePath($this->_docRoot."/$relPath")); + return (bool) file_exists(nativePath($this->_docRoot."/$relPath")); } /** @@ -101,7 +101,7 @@ public function has($relPath) */ public function retrieve($relPath) { - $path = FrontController::nativePath($this->_docRoot."/$relPath"); + $path = nativePath($this->_docRoot."/$relPath"); if(!$path || !file_exists($path)) throw new Exception(sprintf('file %s not present in content cache.', $relPath)); @@ -126,7 +126,7 @@ public function info($relPath, &$info) { if(!$info instanceof ContentInfo) return FALSE; - $path = FrontController::nativePath($this->_docRoot."/$relPath"); + $path = nativePath($this->_docRoot."/$relPath"); if(!$path || !file_exists($path)) return FALSE; $info->modifiedTime = filemtime($path); @@ -141,7 +141,7 @@ public function info($relPath, &$info) */ public function touch($relPath) { - $path = FrontController::nativePath($this->_docRoot."/$relPath"); + $path = nativePath($this->_docRoot."/$relPath"); if(!$path || !file_exists($path)) return FALSE; touch($path); @@ -157,7 +157,7 @@ public function touch($relPath) */ public function import($relPath) { - $path = FrontController::nativePath($this->_docRoot."/$relPath"); + $path = nativePath($this->_docRoot."/$relPath"); if(!$path || !file_exists($path)) throw new Exception(sprintf('file %s not present in content cache.', $relPath)); diff --git a/web/classes/frontcontroller.class.php b/web/classes/frontcontroller.class.php index 7a451eb856..784b99eb0e 100644 --- a/web/classes/frontcontroller.class.php +++ b/web/classes/frontcontroller.class.php @@ -651,44 +651,6 @@ public static function &contentCache() return self::fc()->getContentCache(); } - public static function absolutePath($path) - { - return $_SERVER['DOCUMENT_ROOT'] . self::nativePath('/'.$path); - } - - public static function nativePath($path) - { - $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); - - $result = array(); - $pathA = explode(DIRECTORY_SEPARATOR, $path); - if(!$pathA[0]) - $result[] = ''; - foreach($pathA AS $key => $dir) - { - if($dir == '..') - { - if(end($result) == '..') - { - $result[] = '..'; - } - else if(!array_pop($result)) - { - $result[] = '..'; - } - } - else if($dir && $dir != '.') - { - $result[] = $dir; - } - } - - if(!end($pathA)) - $result[] = ''; - - return implode(DIRECTORY_SEPARATOR, $result); - } - public static function ErrorHandler($errno, $errmsg, $filename, $linenum, $vars) { $errortype = array ( diff --git a/web/includes/utilities.inc.php b/web/includes/utilities.inc.php index 15194be301..53cfa28866 100644 --- a/web/includes/utilities.inc.php +++ b/web/includes/utilities.inc.php @@ -27,6 +27,44 @@ includeGuard('Utils'); +function nativePath($path) +{ + $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); + + $result = array(); + $pathA = explode(DIRECTORY_SEPARATOR, $path); + if(!$pathA[0]) + $result[] = ''; + foreach($pathA AS $key => $dir) + { + if($dir == '..') + { + if(end($result) == '..') + { + $result[] = '..'; + } + else if(!array_pop($result)) + { + $result[] = '..'; + } + } + else if($dir && $dir != '.') + { + $result[] = $dir; + } + } + + if(!end($pathA)) + $result[] = ''; + + return implode(DIRECTORY_SEPARATOR, $result); +} + +function absolutePath($path) +{ + return $_SERVER['DOCUMENT_ROOT'] . nativePath('/'.$path); +} + function checkImagePath($path, $formats) { if(!isset($path) || !isset($formats) || !is_array($formats)) diff --git a/web/plugins/addonrepository/addonrepository.php b/web/plugins/addonrepository/addonrepository.php index 2a10173ef8..a669e27a1b 100644 --- a/web/plugins/addonrepository/addonrepository.php +++ b/web/plugins/addonrepository/addonrepository.php @@ -201,7 +201,7 @@ public function execute($args=NULL) $fc = &FrontController::fc(); // Build the add-ons collection. - $addonListXml = file_get_contents(FrontController::nativePath("plugins/addonrepository/addons.xml")); + $addonListXml = file_get_contents(nativePath("plugins/addonrepository/addons.xml")); $this->addons = array(); AddonsParser::parse($addonListXml, $this->addons); diff --git a/web/plugins/disabled.screens/screens.php b/web/plugins/disabled.screens/screens.php index fc7d12cdf7..f0f8e751b1 100644 --- a/web/plugins/disabled.screens/screens.php +++ b/web/plugins/disabled.screens/screens.php @@ -48,8 +48,6 @@ public function title() */ public function InterpretRequest($request) { - global $FrontController; - $url = urldecode($request->url()->path()); // @kludge skip over the first '/' in the home URL. @@ -64,7 +62,7 @@ public function InterpretRequest($request) if(count($tokens) && !strcasecmp(self::$baseRequestName, $tokens[0])) { - $FrontController->enqueueAction($this, NULL); + FrontController::fc()->enqueueAction($this, NULL); return true; // Eat the request. } @@ -170,6 +168,6 @@ public function execute($args=NULL) ?>endPage(); + $fc->endPage(); } }