Skip to content

Commit bf7d950

Browse files
committed
- FS#1824: Implemented maintenance mode.
1 parent 0d7f77f commit bf7d950

File tree

12 files changed

+89
-42
lines changed

12 files changed

+89
-42
lines changed

install/tpl/system.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ dashboard_atom_url_admin=http://www.ispconfig.org/atom
3434
dashboard_atom_url_reseller=http://www.ispconfig.org/atom
3535
dashboard_atom_url_client=http://www.ispconfig.org/atom
3636
monitor_key=
37+
maintenance_mode=n

interface/lib/classes/remoting.inc.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,21 @@ public function login($username, $password)
6767
{
6868
global $app, $conf, $server;
6969

70+
// Maintenance mode
71+
$app->uses('ini_parser,getconf');
72+
$server_config_array = $app->getconf->get_global_config('misc');
73+
if($server_config_array['maintenance_mode'] == 'y'){
74+
$this->server->fault('maintenance_mode', 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.');
75+
return false;
76+
}
77+
7078
if(empty($username)) {
71-
$this->server->fault('login_username_empty', 'The login username is empty');
79+
$this->server->fault('login_username_empty', 'The login username is empty.');
7280
return false;
7381
}
7482

7583
if(empty($password)) {
76-
$this->server->fault('login_password_empty', 'The login password is empty');
84+
$this->server->fault('login_password_empty', 'The login password is empty.');
7785
return false;
7886
}
7987

interface/web/admin/form/system_config.tform.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,12 @@
284284
'default' => '',
285285
'value' => ''
286286
),
287+
'maintenance_mode' => array (
288+
'datatype' => 'VARCHAR',
289+
'formtype' => 'CHECKBOX',
290+
'default' => 'n',
291+
'value' => array(0 => 'n',1 => 'y')
292+
),
287293
##################################
288294
# ENDE Datatable fields
289295
##################################

interface/web/admin/lib/lang/de_system_config.lng

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@ $wb['phpmyadmin_url_txt'] = 'PHPMyAdmin URL';
1515
$wb['dashboard_atom_url_admin_txt'] = 'Dashboard atom feed URL (admin)';
1616
$wb['dashboard_atom_url_reseller_txt'] = 'Dashboard atom feed URL (reseller)';
1717
$wb['dashboard_atom_url_client_txt'] = 'Dashboard atom feed URL (client)';
18-
$wb['webdavuser_prefix_txt'] = 'Webdav user prefix';
19-
$wb['webdavuser_prefix_error_regex'] = 'Char not allowed in webdav user prefix.';
20-
$wb['use_domain_module_txt'] = 'Use the domain-module to add new domains';
21-
$wb['use_domain_module_hint'] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They cannot free edit the domain-field.You have to re-login after changing this value, to make the changes visible.';
22-
$wb['new_domain_txt'] = 'HTML to create a new domain';
18+
$wb['webdavuser_prefix_txt'] = 'Webdav-User-Präfix';
19+
$wb['webdavuser_prefix_error_regex'] = 'Zeichen nicht zulässig im WebDAV-User-Präfix.';
20+
$wb['use_domain_module_txt'] = 'Das Domain-Modul benutzen, um neue Domains hinzuzufügen';
21+
$wb['use_domain_module_hint'] = 'Falls Sie dieses Modul benutzen, können Ihre Kunden nur eine der Domains auswählen, die der Admin für sie angelegt hat. Die Kunden können das Domain-Feld nicht frei editieren. Sie müssen sich neu einloggen, wenn Sie diesen Wert ändern.';
22+
$wb['new_domain_txt'] = 'HTML zum Anlegen einer neuen Domain';
2323
$wb['webftp_url_txt'] = 'WebFTP URL';
2424
$wb['enable_custom_login_txt'] = 'Abweichenden Login-Namen erlauben';
25-
$wb['mailmailinglist_link_txt'] = 'Link to mailing list in Mailing list list';
26-
$wb['mailmailinglist_url_txt'] = 'Mailing list URL';
27-
$wb['admin_mail_txt'] = 'Administrators e-mail';
28-
$wb['monitor_key_txt'] = 'Monitor keyword';
29-
$wb['admin_name_txt'] = 'Administrators name';
25+
$wb['mailmailinglist_link_txt'] = 'Link zur Mailingliste in der Mailinglisten-Übersicht';
26+
$wb['mailmailinglist_url_txt'] = 'Mailinglisten-URL';
27+
$wb['admin_mail_txt'] = 'Administrator Email';
28+
$wb['monitor_key_txt'] = 'Monitor-Passwort';
29+
$wb['admin_name_txt'] = 'Name des Administrators';
30+
$wb['maintenance_mode_txt'] = 'Wartungsmodus';
3031
?>

interface/web/admin/lib/lang/en_system_config.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ $wb["mailmailinglist_link_txt"] = 'Link to mailing list in Mailing list list';
2121
$wb["mailmailinglist_url_txt"] = 'Mailing list URL';
2222
$wb["phpmyadmin_url_txt"] = 'PHPMyAdmin URL';
2323
$wb["use_domain_module_txt"] = 'Use the domain-module to add new domains';
24-
$wb["use_domain_module_hint"] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They cannot free edit the domain-field.You have to re-login after changing this value, to make the changes visible.';
24+
$wb["use_domain_module_hint"] = 'If you use this module, your customers can only select one of the domains the admin creates for them. They cannot freely edit the domain-field. You have to re-login after changing this value, to make the changes visible.';
2525
$wb["new_domain_txt"] = 'HTML to create a new domain';
2626
$wb["webftp_url_txt"] = 'WebFTP URL';
2727
$wb['admin_mail_txt'] = 'Administrator\'s e-mail';
2828
$wb["monitor_key_txt"] = 'Monitor keyword';
2929
$wb['admin_name_txt'] = 'Administrator\'s name';
30+
$wb['maintenance_mode_txt'] = 'Maintenance Mode';
3031
?>

interface/web/admin/system_config_edit.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ function onUpdateSave($sql) {
108108
"FROM web_domain";
109109
$app->db->query($sql);
110110
}
111+
112+
// Maintenance mode
113+
if($server_config_array['misc']['maintenance_mode'] == 'y'){
114+
//print_r($_SESSION);
115+
//echo $_SESSION['s']['id'];
116+
$app->db->query("DELETE FROM sys_session WHERE session_id != '".$_SESSION['s']['id']."'");
117+
}
111118
}
112119

113120
}

interface/web/admin/templates/system_config_misc_edit.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
2020
<label for="monitor_key">{tmpl_var name='monitor_key_txt'}</label>
2121
<input name="monitor_key" id="monitor_key" value="{tmpl_var name='monitor_key'}" size="" maxlength="" type="text" class="textInput" />
2222
</div>
23+
<div class="ctrlHolder">
24+
<p class="label">{tmpl_var name='maintenance_mode_txt'}</p>
25+
<div class="multiField">
26+
{tmpl_var name='maintenance_mode'}
27+
</div>
28+
</div>
2329
</fieldset>
2430
<input type="hidden" name="id" value="{tmpl_var name='id'}">
2531
<div class="buttonHolder buttons">

interface/web/capp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636

3737
//* Check if user is logged in
3838
if($_SESSION["s"]["user"]['active'] != 1) {
39-
header("Location: index.php?phpsessid=".$_SESSION["s"]["id"]);
40-
die();
39+
die("URL_REDIRECT: /index.php");
40+
//die();
4141
}
4242

4343
//* Check if user may use the module.

interface/web/js/scrigo.js.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ function capp(module) {
4343
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) {
4444
var parts = jqXHR.responseText.split(':');
4545
loadContent(parts[1]);
46+
} else if (jqXHR.responseText.indexOf('URL_REDIRECT:') > -1) {
47+
var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length);
48+
document.location.href = newUrl;
4649
} else {
47-
alert(jqXHR.responseText);
50+
//alert(jqXHR.responseText);
4851
}
4952
}
5053
loadMenus();

interface/web/login/index.php

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,15 @@ public function render() {
5454
$error = '';
5555

5656
$app->load_language_file('web/login/lib/lang/'.$conf["language"].'.lng');
57-
57+
58+
// Maintenance mode
59+
$maintenance_mode = false;
60+
$app->uses('ini_parser,getconf');
61+
$server_config_array = $app->getconf->get_global_config('misc');
62+
if($server_config_array['maintenance_mode'] == 'y'){
63+
$maintenance_mode = true;
64+
$maintenance_mode_error = $app->lng('error_maintenance_mode');
65+
}
5866

5967
//* Login Form was send
6068
if(count($_POST) > 0) {
@@ -167,33 +175,36 @@ public function render() {
167175

168176
if($user) {
169177
if($user['active'] == 1) {
170-
// User login right, so attempts can be deleted
171-
$sql = "DELETE FROM `attempts_login` WHERE `ip`='{$ip}'";
172-
$app->db->query($sql);
173-
$user = $app->db->toLower($user);
178+
// Maintenance mode - allow logins only when maintenance mode is off or if the user is admin
179+
if(!$maintenance_mode || $user['typ'] == 'admin'){
180+
// User login right, so attempts can be deleted
181+
$sql = "DELETE FROM `attempts_login` WHERE `ip`='{$ip}'";
182+
$app->db->query($sql);
183+
$user = $app->db->toLower($user);
174184

175-
if ($loginAs) $oldSession = $_SESSION['s'];
176-
$_SESSION = array();
177-
if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
178-
$_SESSION['s']['user'] = $user;
179-
$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
180-
$_SESSION['s']['language'] = $user['language'];
181-
$_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
185+
if ($loginAs) $oldSession = $_SESSION['s'];
186+
$_SESSION = array();
187+
if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
188+
$_SESSION['s']['user'] = $user;
189+
$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
190+
$_SESSION['s']['language'] = $user['language'];
191+
$_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
182192

183-
if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
184-
include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
185-
$_SESSION['s']['module'] = $module;
186-
}
193+
if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
194+
include_once($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php');
195+
$_SESSION['s']['module'] = $module;
196+
}
187197

188-
$app->plugin->raiseEvent('login',$this);
198+
$app->plugin->raiseEvent('login',$this);
189199

190-
/*
191-
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
192-
* new theme, if the logged-in user has another
193-
*/
194-
echo 'LOGIN_REDIRECT:'.$_SESSION['s']['module']['startpage'];
200+
/*
201+
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
202+
* new theme, if the logged-in user has another
203+
*/
204+
echo 'LOGIN_REDIRECT:'.$_SESSION['s']['module']['startpage'];
195205

196-
exit;
206+
exit;
207+
}
197208
} else {
198209
$error = $app->lng('error_user_blocked');
199210
}
@@ -222,12 +233,13 @@ public function render() {
222233
$app->plugin->raiseEvent('login_empty',$this);
223234
}
224235
}
236+
237+
// Maintenance mode - show message when people try to log in and also when people are forcedly logged off
238+
if($maintenance_mode_error != '') $error = '<strong>'.$maintenance_mode_error.'</strong><br><br>'.$error;
225239
if($error != ''){
226240
$error = '<div class="box box_error"><h1>Error</h1>'.$error.'</div>';
227241
}
228242

229-
230-
231243
$app->tpl->setVar('error', $error);
232244
$app->tpl->setVar('username_txt', $app->lng('username_txt'));
233245
$app->tpl->setVar('password_txt', $app->lng('password_txt'));

0 commit comments

Comments
 (0)