Trying to fix package dir/domain path on broken setups
authorAlexander Ebert <ebert@woltlab.com>
Sat, 1 Jun 2013 16:59:23 +0000 (18:59 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Sat, 1 Jun 2013 16:59:23 +0000 (18:59 +0200)
wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php

index 81a43823065d8651e5522b99b478aa47d7b45534..4f43a6470cd06e23e9252fcc484306d450d28a0c 100644 (file)
@@ -633,11 +633,11 @@ class PackageInstallationDispatcher {
                else {
                        $document = PackageInstallationFormManager::getForm($this->queue, 'packageDir');
                        $document->handleRequest();
-                       $packageDir = $document->getValue('packageDir');
+                       $packageDir = FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator($document->getValue('packageDir')));
                        
                        if ($packageDir !== null) {
                                // validate package dir
-                               if (file_exists(FileUtil::addTrailingSlash($packageDir) . 'global.php')) {
+                               if (file_exists($packageDir . 'global.php')) {
                                        $document->setError('packageDir', WCF::getLanguage()->get('wcf.acp.package.packageDir.notAvailable'));
                                        return $document;
                                }
@@ -648,15 +648,11 @@ class PackageInstallationDispatcher {
                                        'packageDir' => FileUtil::getRelativePath(WCF_DIR, $packageDir)
                                ));
                                
-                               // parse domain path
-                               $domainPath = FileUtil::getRelativePath(FileUtil::unifyDirSeperator($_SERVER['DOCUMENT_ROOT']), FileUtil::unifyDirSeperator($packageDir));
-                               
-                               // work-around for applications installed in document root
-                               if ($domainPath == './') {
-                                       $domainPath = '';
-                               }
-                               
-                               $domainPath = FileUtil::addLeadingSlash(FileUtil::addTrailingSlash($domainPath));
+                               // determine domain path, in some environments (e.g. ISPConfig) the $_SERVER paths are
+                               // faked and differ from the real filesystem path
+                               $currentPath = RouteHandler::getPath();
+                               $pathToDocumentRoot = str_replace(RouteHandler::getPath(), '', FileUtil::unifyDirSeperator(WCF_DIR));
+                               $domainPath = str_replace($pathToDocumentRoot, '', $packageDir);
                                
                                // update application path
                                $application = new Application($this->getPackage()->packageID);