From: Alexander Ebert Date: Sat, 18 May 2013 12:59:11 +0000 (+0200) Subject: Added rescue mode X-Git-Tag: 2.0.0_Beta_1~158^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c329938304c48adc73d6ea3637b288d2ced93ec7;p=GitHub%2FWoltLab%2FWCF.git Added rescue mode Fixes #1126 --- diff --git a/wcfsetup/install/files/lib/system/WCFACP.class.php b/wcfsetup/install/files/lib/system/WCFACP.class.php index e52542ee60..15d0207e7e 100644 --- a/wcfsetup/install/files/lib/system/WCFACP.class.php +++ b/wcfsetup/install/files/lib/system/WCFACP.class.php @@ -65,7 +65,16 @@ class WCFACP extends WCF { if (WCF::getUser()->userID == 0) { // build redirect path $application = ApplicationHandler::getInstance()->getActiveApplication(); - $path = $application->getPageURL() . 'acp/index.php/Login/' . SID_ARG_1ST . '&url=' . rawurlencode(WCF::getSession()->requestURI); + + // fallback for unknown host (rescue mode) + if ($application->domainName != $_SERVER['HTTP_HOST']) { + $pageURL = RouteHandler::getProtocol() . $_SERVER['HTTP_HOST'] . RouteHandler::getPath(array('acp')); + } + else { + $pageURL = $application->getPageURL(); + } + + $path = $pageURL . 'acp/index.php/Login/' . SID_ARG_1ST . '&url=' . rawurlencode(WCF::getSession()->requestURI); HeaderUtil::redirect($path); exit; diff --git a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php index c85cbac3a9..e1a1c5dcae 100644 --- a/wcfsetup/install/files/lib/system/request/LinkHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/LinkHandler.class.php @@ -144,18 +144,25 @@ class LinkHandler extends SingletonFactory { $url = RouteHandler::getHost() . RouteHandler::getPath(array('acp')) . ($isACP ? 'acp/' : '') . $url; } else { - // try to resolve abbreviation - $application = null; - if ($abbreviation != 'wcf') { - $application = ApplicationHandler::getInstance()->getApplication($abbreviation); + if (RequestHandler::getInstance()->inRescueMode()) { + $pageURL = RouteHandler::getHost() . RouteHandler::getPath(array('acp')); } - - // fallback to primary application if abbreviation is 'wcf' or unknown - if ($application === null) { - $application = ApplicationHandler::getInstance()->getPrimaryApplication(); + else { + // try to resolve abbreviation + $application = null; + if ($abbreviation != 'wcf') { + $application = ApplicationHandler::getInstance()->getApplication($abbreviation); + } + + // fallback to primary application if abbreviation is 'wcf' or unknown + if ($application === null) { + $application = ApplicationHandler::getInstance()->getPrimaryApplication(); + } + + $pageURL = $application->getPageURL(); } - $url = $application->getPageURL() . ($isACP ? 'acp/' : '') . $url; + $url = $pageURL . ($isACP ? 'acp/' : '') . $url; } // append previously removed anchor diff --git a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php index 68a11ceec7..ef43988a38 100644 --- a/wcfsetup/install/files/lib/system/request/RequestHandler.class.php +++ b/wcfsetup/install/files/lib/system/request/RequestHandler.class.php @@ -1,5 +1,6 @@ getApplications() as $application) { + if ($application->domainName == $_SERVER['HTTP_HOST']) { + $this->inRescueMode = false; + break; + } + } + } + /** * Handles a http request. * @@ -171,4 +190,13 @@ class RequestHandler extends SingletonFactory { public function isACPRequest() { return $this->isACPRequest; } + + /** + * Returns true, if current host mismatches any known domain. + * + * @return boolean + */ + public function inRescueMode() { + return $this->inRescueMode; + } }