From 3cdb99872374251ce318de781483302c40fb5431 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 6 Oct 2016 13:21:40 +0200 Subject: [PATCH] Fixed core installation in a path other than current --- .../application/ApplicationHandler.class.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php index 70630e0a2a..c172cf67c2 100644 --- a/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php +++ b/wcfsetup/install/files/lib/system/application/ApplicationHandler.class.php @@ -4,9 +4,12 @@ use wcf\data\application\Application; use wcf\data\application\ApplicationAction; use wcf\data\application\ApplicationList; use wcf\system\cache\builder\ApplicationCacheBuilder; +use wcf\system\exception\SystemException; +use wcf\system\io\File; use wcf\system\request\RouteHandler; use wcf\system\Regex; use wcf\system\SingletonFactory; +use wcf\util\FileUtil; /** * Handles multi-application environments. @@ -92,12 +95,21 @@ class ApplicationHandler extends SingletonFactory { // work-around during WCFSetup if (!PACKAGE_ID) { $host = str_replace(RouteHandler::getProtocol(), '', RouteHandler::getHost()); + $documentRoot = FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator(realpath($_SERVER['DOCUMENT_ROOT']))); + + // always use the core directory + if (empty($_POST['directories']) || empty($_POST['directories']['wcf'])) { + // within ACP + $_POST['directories'] = ['wcf' => $documentRoot . FileUtil::removeLeadingSlash(RouteHandler::getPath(['acp']))]; + } + + $path = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash(FileUtil::unifyDirSeparator(FileUtil::getRelativePath($documentRoot, $_POST['directories']['wcf'])))); return new Application(null, [ 'domainName' => $host, - 'domainPath' => RouteHandler::getPath(['acp']), + 'domainPath' => $path, 'cookieDomain' => $host, - 'cookiePath' => RouteHandler::getPath(['acp']) + 'cookiePath' => $path ]); } else if (isset($this->cache['application'][PACKAGE_ID])) { -- 2.20.1