init maintenance mode (#467)
This commit is contained in:
parent
567587718b
commit
23d3a73b01
@ -8,6 +8,18 @@ include S9Y_INCLUDE_PATH . 'include/admin/import.inc.php';
|
||||
$data['importMenu'] = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
if ($_POST['adminAction'] == "maintenanceMode") {
|
||||
if (serendipity_db_bool(serendipity_get_config_var("maintenanceMode", false)) === true) {
|
||||
serendipity_set_config_var("maintenanceMode", false);
|
||||
} else {
|
||||
serendipity_set_config_var("maintenanceMode", true);
|
||||
# after the specified time, given in hours from now, we want the maintenance mode to not be active anymore.
|
||||
# This prevents users from logging themselves out.
|
||||
$activeTill = time() + ($_POST['hours'] * 3600);
|
||||
serendipity_set_config_var("maintenanceModeEnd", $activeTill);
|
||||
}
|
||||
}
|
||||
|
||||
switch($serendipity['GET']['adminAction']) {
|
||||
case 'integrity':
|
||||
$data['action'] = "integrity";
|
||||
@ -32,6 +44,9 @@ switch($serendipity['GET']['adminAction']) {
|
||||
break;
|
||||
}
|
||||
|
||||
$data['maintenance_mode'] = serendipity_db_bool(serendipity_get_config_var("maintenanceMode", false));
|
||||
$data['maintenance_mode_end'] = strftime('%d.%m.%y %T', serendipity_get_config_var("maintenanceModeEnd"));
|
||||
$data['maintenance_mode_active'] = $data['maintenance_mode'] && time() < serendipity_get_config_var("maintenanceModeEnd", 0);
|
||||
echo serendipity_smarty_show('admin/maintenance.inc.tpl', $data);
|
||||
|
||||
/* vim: set sts=4 ts=4 expandtab : */
|
||||
|
@ -421,6 +421,22 @@ $serendipity['permissionLevels'] = array(USERLEVEL_EDITOR => USERLEVEL_EDITOR_DE
|
||||
USERLEVEL_CHIEF => USERLEVEL_CHIEF_DESC,
|
||||
USERLEVEL_ADMIN => USERLEVEL_ADMIN_DESC);
|
||||
|
||||
// Some stuff...
|
||||
if (!isset($_SESSION['serendipityAuthedUser'])) {
|
||||
$_SESSION['serendipityAuthedUser'] = false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['serendipityUser'])) {
|
||||
$serendipity['user'] = $_SESSION['serendipityUser'];
|
||||
}
|
||||
|
||||
# && maintenanceMode is on
|
||||
//if ( {
|
||||
if (($_SESSION['serendipityAuthedUser'] === false) && (serendipity_db_bool(serendipity_get_config_var("maintenanceMode", false)) === true) && time() < serendipity_get_config_var("maintenanceModeEnd", 0)) {
|
||||
header('HTTP/1.1 503 Service Unavailable');
|
||||
serendipity_die("Maintenance mode is on, please check back later");
|
||||
}
|
||||
|
||||
// Redirect to the upgrader
|
||||
if (IS_up2date === false && !defined('IN_upgrader')) {
|
||||
if (preg_match(PAT_CSS, $_SERVER['REQUEST_URI'], $matches)) {
|
||||
@ -447,15 +463,6 @@ if (isset($serendipity['GET']['searchTerm'])) {
|
||||
$serendipity['GET']['searchTerm'] = (is_string($serendipity['GET']['searchTerm']) ? serendipity_specialchars(strip_tags($serendipity['GET']['searchTerm'])) : '');
|
||||
}
|
||||
|
||||
// Some stuff...
|
||||
if (!isset($_SESSION['serendipityAuthedUser'])) {
|
||||
$_SESSION['serendipityAuthedUser'] = false;
|
||||
}
|
||||
|
||||
if (isset($_SESSION['serendipityUser'])) {
|
||||
$serendipity['user'] = $_SESSION['serendipityUser'];
|
||||
}
|
||||
|
||||
if (isset($_SESSION['serendipityEmail'])) {
|
||||
$serendipity['email'] = $_SESSION['serendipityEmail'];
|
||||
}
|
||||
|
@ -92,6 +92,26 @@
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{if 'siteConfiguration'|checkPermission || 'blogConfiguration'|checkPermission}
|
||||
<section id="maintenance_mode" class="equal_heights quick_list">
|
||||
<h3>{$CONST.MAINTENANCE_MODE}</h3>
|
||||
|
||||
<form method="POST" target="?">
|
||||
<input type="hidden" name="adminAction" value="maintenanceMode"/>
|
||||
<p>Activate maintenance mode to prevent access from users that are not logged in.</p>
|
||||
{if $maintenance_mode_active}
|
||||
Will be active till: {$maintenance_mode_end}
|
||||
<button type="submit">Deactivate</button>
|
||||
{else}
|
||||
<label>How many hours shall it be active?</label>
|
||||
<input type="number" name="hours" value="1"/>
|
||||
<button type="submit">Activate</button>
|
||||
{/if}
|
||||
</form>
|
||||
|
||||
</section>
|
||||
{/if}
|
||||
|
||||
{serendipity_hookPlugin hook="backend_maintenance" hookAll="true"}
|
||||
|
||||
</div>
|
Loading…
x
Reference in New Issue
Block a user