+++ /dev/null
-<?php
-/**
- * @file mod/maintenance.php
- */
-use Friendica\App;
-use Friendica\Core\Config;
-use Friendica\Core\L10n;
-use Friendica\Core\Renderer;
-use Friendica\Util\Strings;
-
-function maintenance_content(App $a)
-{
- $reason = Config::get('system', 'maintenance_reason');
-
- if (substr(Strings::normaliseLink($reason), 0, 7) == 'http://') {
- header("HTTP/1.1 307 Temporary Redirect");
- header("Location:".$reason);
- return;
- }
-
- header('HTTP/1.1 503 Service Temporarily Unavailable');
- header('Status: 503 Service Temporarily Unavailable');
- header('Retry-After: 600');
-
- return Renderer::replaceMacros(Renderer::getMarkupTemplate('maintenance.tpl'), [
- '$sysdown' => L10n::t('System down for maintenance'),
- '$reason' => $reason
- ]);
-}
// in install mode, any url loads install module
// but we need "view" module for stylesheet
- if ($this->getMode()->isInstall() && $this->module != 'view') {
- $this->module = 'install';
- } elseif (!$this->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $this->module != 'view') {
- $this->module = 'maintenance';
+ if ($this->getMode()->isInstall() && $this->module !== 'install') {
+ $this->internalRedirect('install');
+ } elseif (!$this->getMode()->has(App\Mode::MAINTENANCEDISABLED) && $this->module !== 'maintenance') {
+ $this->internalRedirect('maintenance');
} else {
$this->checkURL();
Core\Update::check($this->getBasePath(), false, $this->getMode());
$this->routeCollector->addRoute(['GET', 'POST'], '/login', Module\Login::class);
$this->routeCollector->addRoute(['GET', 'POST'], '/logout', Module\Logout::class);
$this->routeCollector->addRoute(['GET'], '/magic', Module\Magic::class);
+ $this->routeCollector->addRoute(['GET'], '/maintenance', Module\Maintenance::class);
$this->routeCollector->addRoute(['GET'], '/manifest', Module\Manifest::class);
$this->routeCollector->addRoute(['GET'], '/nodeinfo/1.0', Module\NodeInfo::class);
$this->routeCollector->addRoute(['GET'], '/nogroup', Module\Group::class);
case 301:
header('HTTP/1.1 301 Moved Permanently');
break;
+ case 307:
+ header('HTTP/1.1 307 Temporary Redirect');
+ break;
}
header("Location: $url");
--- /dev/null
+<?php
+
+namespace Friendica\Module;
+
+use Friendica\BaseModule;
+use Friendica\Core\L10n;
+use Friendica\Core\Renderer;
+use Friendica\Core\System;
+use Friendica\Util\Strings;
+
+/**
+ * Shows the maintenance reason
+ * or redirects to the alternate location
+ */
+class Maintenance extends BaseModule
+{
+ public static function content()
+ {
+ $config = self::getApp()->getConfig();
+
+ $reason = $config->get('system', 'maintenance_reason');
+
+ if ((substr(Strings::normaliseLink($reason), 0, 7) === 'http://') ||
+ (substr(Strings::normaliseLink($reason), 0, 8) === 'https://')) {
+ System::externalRedirect($reason, 307);
+ }
+
+ header('HTTP/1.1 503 Service Temporarily Unavailable');
+ header('Status: 503 Service Temporarily Unavailable');
+ header('Retry-After: 600');
+
+ return Renderer::replaceMacros(Renderer::getMarkupTemplate('maintenance.tpl'), [
+ '$sysdown' => L10n::t('System down for maintenance'),
+ '$reason' => $reason
+ ]);
+ }
+}