Move mod/maintenance to src/Module/Maintenance
This commit is contained in:
parent
0046e62077
commit
62fd5375dc
|
@ -1,29 +0,0 @@
|
|||
<?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
|
||||
]);
|
||||
}
|
|
@ -1077,10 +1077,10 @@ class App
|
|||
|
||||
// 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());
|
||||
|
|
|
@ -138,6 +138,7 @@ class Router
|
|||
$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);
|
||||
|
|
|
@ -242,6 +242,9 @@ class System extends BaseObject
|
|||
case 301:
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
break;
|
||||
case 307:
|
||||
header('HTTP/1.1 307 Temporary Redirect');
|
||||
break;
|
||||
}
|
||||
|
||||
header("Location: $url");
|
||||
|
|
37
src/Module/Maintenance.php
Normal file
37
src/Module/Maintenance.php
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?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
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue