diff --git a/bootstrap.php b/bootstrap.php index 24cb524..502f3f0 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -42,8 +42,13 @@ if (is_callable('auth_outage_bootstrap_callback')) { call_user_func('auth_outage_bootstrap_callback'); } -// 2) Check for allowed IPs during outages. -if (file_exists($CFG->dataroot.'/climaintenance.php')) { +// 2) Check for allowed scripts or IPs during outages. +$allowed = !file_exists($CFG->dataroot.'/climaintenance.php') // Not in maintenance mode. + || (defined('ABORT_AFTER_CONFIG') && ABORT_AFTER_CONFIG) // Only config requested. + || (defined('CLI_SCRIPT') && CLI_SCRIPT) // Allow CLI scripts. +; +if (!$allowed) { + // Call the climaintenance.php which will check for allowed IPs. $CFG->dirroot = dirname(dirname(dirname(__FILE__))); // It is not defined yet but the script below needs it. require($CFG->dataroot.'/climaintenance.php'); // This call may terminate the script here or not. } diff --git a/classes/local/outagelib.php b/classes/local/outagelib.php index dbea92f..3bb3b45 100644 --- a/classes/local/outagelib.php +++ b/classes/local/outagelib.php @@ -263,6 +263,9 @@ if (time() >= {{STARTTIME}}) { header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Accept-Ranges: none'); + if ((defined('AJAX_SCRIPT') && AJAX_SCRIPT) || (defined('WS_SERVER') && WS_SERVER)) { + exit(0); + } echo ''; if (file_exists($CFG->dataroot.'/climaintenance.template.html')) { require($CFG->dataroot.'/climaintenance.template.html'); diff --git a/tests/phpunit/local/outagelib_test.php b/tests/phpunit/local/outagelib_test.php index 949219f..bc48793 100644 --- a/tests/phpunit/local/outagelib_test.php +++ b/tests/phpunit/local/outagelib_test.php @@ -304,6 +304,9 @@ e.e.e.e/20')) { header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Accept-Ranges: none'); + if ((defined('AJAX_SCRIPT') && AJAX_SCRIPT) || (defined('WS_SERVER') && WS_SERVER)) { + exit(0); + } echo ''; if (file_exists($CFG->dataroot.'/climaintenance.template.html')) { require($CFG->dataroot.'/climaintenance.template.html'); @@ -339,6 +342,9 @@ if (time() >= 123) { header('Expires: Mon, 20 Aug 1969 09:23:00 GMT'); header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); header('Accept-Ranges: none'); + if ((defined('AJAX_SCRIPT') && AJAX_SCRIPT) || (defined('WS_SERVER') && WS_SERVER)) { + exit(0); + } echo ''; if (file_exists($CFG->dataroot.'/climaintenance.template.html')) { require($CFG->dataroot.'/climaintenance.template.html');