From: Alexander Ebert Date: Thu, 3 Nov 2011 13:41:40 +0000 (+0100) Subject: Fixed application path on install X-Git-Tag: 2.0.0_Beta_1~1628^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3dcfb49789819f2ec05b76757860de005ab9ef16;p=GitHub%2FWoltLab%2FWCF.git Fixed application path on install --- diff --git a/wcfsetup/install/files/lib/system/WCFACP.class.php b/wcfsetup/install/files/lib/system/WCFACP.class.php index 0d75545cb6..7b2c5a971a 100644 --- a/wcfsetup/install/files/lib/system/WCFACP.class.php +++ b/wcfsetup/install/files/lib/system/WCFACP.class.php @@ -1,6 +1,7 @@ assign(array( - 'baseHref' => $phpSelf, + 'baseHref' => $host . $path, 'quickAccessPackages' => $this->getQuickAccessPackages(), //'timezone' => util\DateUtil::getTimezone() )); diff --git a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php index 014c7e1d3c..1f685fdc23 100644 --- a/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageInstallationDispatcher.class.php @@ -15,6 +15,7 @@ use wcf\system\form; use wcf\system\form\container; use wcf\system\form\element; use wcf\system\request\LinkHandler; +use wcf\system\request\RouteHandler; use wcf\system\WCF; use wcf\util\FileUtil; use wcf\util\HeaderUtil; @@ -218,18 +219,13 @@ class PackageInstallationDispatcher { $this->package = null; if ($package->standalone) { - $domainPath = ''; - if (isset($_SERVER['PHP_SELF'])) { - $domainPath = $_SERVER['PHP_SELF']; - if (strpos($domainPath, '.php') !== false) { - $domainPath = preg_replace('~index\.php$~', '', $domainPath); - } - } + $host = RouteHandler::getHost(); + $path = RouteHandler::getPath(array('acp')); // insert as application ApplicationEditor::create(array( - 'domainName' => (isset($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : '', - 'domainPath' => $domainPath, + 'domainName' => $host, + 'domainPath' => $path, 'packageID' => $package->packageID )); } diff --git a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php index f1ffa1e62b..c814fa8ed8 100644 --- a/wcfsetup/install/files/lib/system/request/RouteHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RouteHandler.class.php @@ -2,6 +2,7 @@ namespace wcf\system\request; use wcf\system\event\EventHandler; use wcf\system\SingletonFactory; +use wcf\util\FileUtil; /** * Handles routes for HTTP requests. @@ -17,6 +18,18 @@ use wcf\system\SingletonFactory; * @category Community Framework */ class RouteHandler extends SingletonFactory { + /** + * current host and protocol + * @var string + */ + protected static $host = ''; + + /** + * current absolute path + * @var string + */ + protected static $path = ''; + /** * router filter for ACP * @var boolean @@ -138,4 +151,52 @@ class RouteHandler extends SingletonFactory { throw new SystemException("Unable to build route, no available route is satisfied."); } + + /** + * Returns protocol and domain name. + * + * @return string + */ + public static function getHost() { + if (empty(self::$host)) { + // get protocol and domain name + $protocol = 'http://'; + if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443) { + $protocol = 'https://'; + } + + self::$host = $protocol . $_SERVER['HTTP_HOST']; + } + + return self::$host; + } + + /** + * Returns absolute domain path. + * + * @param array $removeComponents + * @return string + */ + public static function getPath(array $removeComponents = array()) { + if (empty(self::$path)) { + self::$path = FileUtil::addTrailingSlash(dirname($_SERVER['SCRIPT_NAME'])); + } + + if (!empty($removeComponents)) { + $path = explode('/', self::$path); + foreach ($path as $index => $component) { + if (empty($path[$index])) { + unset($path[$index]); + } + + if (in_array($component, $removeComponents)) { + unset($path[$index]); + } + } + + return implode('/', $path) . '/'; + } + + return self::$path; + } }