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;
$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
<?php
namespace wcf\system\request;
+use wcf\system\application\ApplicationHandler;
use wcf\system\exception\AJAXException;
use wcf\system\exception\IllegalLinkException;
use wcf\system\exception\SystemException;
*/
protected $activeRequest = null;
+ /**
+ * true, if current domain mismatch any known domain
+ * @var boolean
+ */
+ protected $inRescueMode = true;
+
/**
* indicates if the request is an acp request
* @var boolean
*/
protected $isACPRequest = false;
+ /**
+ * @see wcf\system\SingletonFactory::init()
+ */
+ protected function init() {
+ foreach (ApplicationHandler::getInstance()->getApplications() as $application) {
+ if ($application->domainName == $_SERVER['HTTP_HOST']) {
+ $this->inRescueMode = false;
+ break;
+ }
+ }
+ }
+
/**
* Handles a http request.
*
public function isACPRequest() {
return $this->isACPRequest;
}
+
+ /**
+ * Returns true, if current host mismatches any known domain.
+ *
+ * @return boolean
+ */
+ public function inRescueMode() {
+ return $this->inRescueMode;
+ }
}