New Maintenance mode with IP whitelist

This commit is contained in:
Michael Kleger 2022-02-07 11:51:08 +01:00
parent 770184675e
commit 7e346f2011
6 changed files with 1110 additions and 1011 deletions

View file

@ -95,8 +95,11 @@ if($_REQUEST['action'] == 'common')
if($_POST['language'] != $bm_prefs['language']) if($_POST['language'] != $bm_prefs['language'])
setcookie('bm_language', $_POST['language'], time()+TIME_ONE_YEAR); setcookie('bm_language', $_POST['language'], time()+TIME_ONE_YEAR);
// maintenance whitelist
$dbwhitelist = explode(',', $_POST['wartung_whitelist']);
$db->Query('UPDATE {pre}prefs SET titel=?, b1gmta_host=?, selffolder=?, selfurl=?, mobile_url=?, search_engine=?, datafolder=?, language=?, std_land=?, datumsformat=?, ordner_proseite=?, gut_regged=?, autocancel=?, wartung=?, structstorage=?, cron_interval=?, logouturl=?, contact_history=?, ip_lock=?, cookie_lock=?, domain_combobox=?, ssl_url=?, ssl_login_option=?, ssl_login_enable=?, ssl_signup_enable=?, auto_tz=?, compress_pages=?, redirect_mobile=?, calendar_defaultviewmode=?, ' $db->Query('UPDATE {pre}prefs SET titel=?, b1gmta_host=?, selffolder=?, selfurl=?, mobile_url=?, search_engine=?, datafolder=?, language=?, std_land=?, datumsformat=?, ordner_proseite=?, gut_regged=?, autocancel=?, wartung=?, wartung_whitelist_ips=?, structstorage=?, cron_interval=?, logouturl=?, contact_history=?, ip_lock=?, cookie_lock=?, domain_combobox=?, ssl_url=?, ssl_login_option=?, ssl_login_enable=?, ssl_signup_enable=?, auto_tz=?, compress_pages=?, redirect_mobile=?, calendar_defaultviewmode=?, '
. 'logs_autodelete=?, logs_autodelete_days=?, logs_autodelete_archive=?, hotkeys_default=?, contactform=?, contactform_to=?, contactform_name=?, notify_interval=?, notify_lifetime=?, mail_groupmode=?', . 'logs_autodelete=?, logs_autodelete_days=?, logs_autodelete_archive=?, hotkeys_default=?, contactform=?, contactform_to=?, contactform_name=?, notify_interval=?, notify_lifetime=?, mail_groupmode=?',
$_POST['titel'], $_POST['titel'],
$_POST['b1gmta_host'], $_POST['b1gmta_host'],
@ -112,6 +115,7 @@ if($_REQUEST['action'] == 'common')
isset($_POST['gut_regged']) ? 'yes' : 'no', isset($_POST['gut_regged']) ? 'yes' : 'no',
isset($_POST['autocancel']) ? 'yes' : 'no', isset($_POST['autocancel']) ? 'yes' : 'no',
isset($_POST['wartung']) ? 'yes' : 'no', isset($_POST['wartung']) ? 'yes' : 'no',
serialize($dbwhitelist),
isset($_POST['structstorage']) ? 'yes' : 'no', isset($_POST['structstorage']) ? 'yes' : 'no',
$_POST['cron_interval'], $_POST['cron_interval'],
$_POST['logouturl'], $_POST['logouturl'],
@ -145,8 +149,16 @@ if($_REQUEST['action'] == 'common')
// get available languages // get available languages
$languages = GetAvailableLanguages(); $languages = GetAvailableLanguages();
$countries = CountryList(); $countries = CountryList();
// maintenance whitelist
$whitelist = NULL;
foreach (unserialize($bm_prefs['wartung_whitelist_ips']) as $whiteip) {
$whitelist .= $whiteip .', ';
}
$whitelist = rtrim($whitelist, ', ');
// assign // assign
$tpl->assign('wartungwhitelist', $whitelist);
$tpl->assign('safemode', ini_get('safe_mode')); $tpl->assign('safemode', ini_get('safe_mode'));
$tpl->assign('languages', $languages); $tpl->assign('languages', $languages);
$tpl->assign('countries', CountryList()); $tpl->assign('countries', CountryList());

View file

@ -4,7 +4,7 @@
<table> <table>
<tr> <tr>
<td width="40" valign="top" rowspan="14"><img src="{$tpldir}images/ico_prefs_common.png" border="0" alt="" width="32" height="32" /></td> <td width="40" valign="top" rowspan="13"><img src="{$tpldir}images/ico_prefs_common.png" border="0" alt="" width="32" height="32" /></td>
<td class="td1" width="220">{lng p="projecttitle"}:</td> <td class="td1" width="220">{lng p="projecttitle"}:</td>
<td class="td2"><input type="text" name="titel" value="{text allowEmpty=true value=$bm_prefs.titel}" size="36" /></td> <td class="td2"><input type="text" name="titel" value="{text allowEmpty=true value=$bm_prefs.titel}" size="36" /></td>
</tr> </tr>
@ -48,10 +48,22 @@
<td class="td1" width="220">{lng p="compresspages"}?</td> <td class="td1" width="220">{lng p="compresspages"}?</td>
<td class="td2"><input name="compress_pages"{if $bm_prefs.compress_pages=='yes'} checked="checked"{/if} type="checkbox" /></td> <td class="td2"><input name="compress_pages"{if $bm_prefs.compress_pages=='yes'} checked="checked"{/if} type="checkbox" /></td>
</tr> </tr>
</table>
</fieldset>
<fieldset>
<legend>{lng p="maintmode"}</legend>
<table>
<tr> <tr>
<td width="40" valign="top" rowspan="2"><img src="{$tpldir}images/ico_prefs_cmd.png" border="0" alt="" width="32" height="32" /></td>
<td class="td1" width="220">{lng p="maintmode"}?</td> <td class="td1" width="220">{lng p="maintmode"}?</td>
<td class="td2"><input name="wartung"{if $bm_prefs.wartung=='yes'} checked="checked"{/if} type="checkbox" /></td> <td class="td2"><input name="wartung"{if $bm_prefs.wartung=='yes'} checked="checked"{/if} type="checkbox" /></td>
</tr> </tr>
<tr>
<td class="td1" width="220">{lng p="whitelist"}:</td>
<td class="td2"><input type="text" name="wartung_whitelist" value="{text allowEmpty=true value=$wartungwhitelist}" size="36" /></td>
</tr>
</table> </table>
</fieldset> </fieldset>

View file

@ -1795,6 +1795,7 @@ $lang_admin['allow_newsletter_optout'] = 'Newsletter-Abmeldung erlauben';
$lang_admin['gutregged'] = 'Gutscheine für reg. Benutzer'; $lang_admin['gutregged'] = 'Gutscheine für reg. Benutzer';
$lang_admin['autocancel'] = 'Mitgliedschaft selbst beendbar'; $lang_admin['autocancel'] = 'Mitgliedschaft selbst beendbar';
$lang_admin['maintmode'] = 'Wartungsmodus'; $lang_admin['maintmode'] = 'Wartungsmodus';
$lang_admin['whitelist'] = 'Zugangsliste';
$lang_admin['maintmodenote'] = 'Der Wartungsmodus ist aktiv. Die b1gMail-Installation ist für Benutzer nicht erreichbar.'; $lang_admin['maintmodenote'] = 'Der Wartungsmodus ist aktiv. Die b1gMail-Installation ist für Benutzer nicht erreichbar.';
$lang_admin['dldate'] = 'Paket-Datum'; $lang_admin['dldate'] = 'Paket-Datum';
$lang_admin['invalidserial'] = 'Die angegebene Seriennummer ist ungültig. Bitte versuchen Sie es erneut.'; $lang_admin['invalidserial'] = 'Die angegebene Seriennummer ist ungültig. Bitte versuchen Sie es erneut.';

View file

@ -1850,6 +1850,7 @@ $lang_admin['allow_newsletter_optout'] = 'Allow newsletter opt-out';
$lang_admin['gutregged'] = 'Vouchers for registered users'; $lang_admin['gutregged'] = 'Vouchers for registered users';
$lang_admin['autocancel'] = 'Account deletable by user'; $lang_admin['autocancel'] = 'Account deletable by user';
$lang_admin['maintmode'] = 'Maintenance mode'; $lang_admin['maintmode'] = 'Maintenance mode';
$lang_admin['whitelist'] = 'Access list';
$lang_admin['maintmodenote'] = 'Maintenance mode is enabled. The b1gMail installation is not accessible for users.'; $lang_admin['maintmodenote'] = 'Maintenance mode is enabled. The b1gMail installation is not accessible for users.';
$lang_admin['dldate'] = 'Package date'; $lang_admin['dldate'] = 'Package date';
$lang_admin['invalidserial'] = 'The serial number you have entered is invalid. Please try again.'; $lang_admin['invalidserial'] = 'The serial number you have entered is invalid. Please try again.';

File diff suppressed because it is too large Load diff

View file

@ -434,17 +434,21 @@ if (!file_exists($templateFolder)) {
} }
$tpl = _new('Template'); $tpl = _new('Template');
/* /**
* maintenance mode => error * maintenance mode => error
*/ */
if (MAINTENANCE_MODE && INTERFACE_MODE) { if(MAINTENANCE_MODE && INTERFACE_MODE)
echo 'System down for maintenance. Please try again later.'; {
exit(1); echo('System down for maintenance. Please try again later.');
} elseif (MAINTENANCE_MODE) { exit(1);
$tpl->assign('text', $lang_custom['maintenance']);
$tpl->display('nli/maintenance.tpl');
exit();
} }
else if(MAINTENANCE_MODE && !in_array($_SERVER['REMOTE_ADDR'], unserialize($bm_prefs['wartung_whitelist_ips'])))
{
$tpl->assign('text', $lang_custom['maintenance']);
$tpl->display('nli/maintenance.tpl');
exit();
}
/* /*
* mobile redirect override * mobile redirect override