diff --git a/approot.inc.php b/approot.inc.php index dc2ad4b16..d07b3e6cd 100644 --- a/approot.inc.php +++ b/approot.inc.php @@ -26,7 +26,7 @@ if (!isset($bBypassMaintenance)) if (file_exists(MAINTENANCE_MODE_FILE) && !$bBypassMaintenance) { - $sMessage = 'Application is currently in maintenance'; + $sMessage = 'This application is currently under maintenance.'; $sTitle = 'Maintenance'; http_response_code(503); diff --git a/index.php b/index.php index 6ee5341ba..8d7384d92 100644 --- a/index.php +++ b/index.php @@ -3,6 +3,37 @@ $sConfigFile = 'conf/production/config-itop.php'; $sStartPage = './pages/UI.php'; $sSetupPage = './setup/index.php'; +// +// Maintenance mode +// +define('APPROOT', dirname(__FILE__).'/'); +define('MAINTENANCE_MODE_FILE', APPROOT.'data/.maintenance'); + +// Use 'maintenance' parameter to bypass maintenance mode +if (!isset($bBypassMaintenance)) +{ + $bBypassMaintenance = isset($_REQUEST['maintenance']) ? boolval($_REQUEST['maintenance']) : false; +} + +if (file_exists(MAINTENANCE_MODE_FILE) && !$bBypassMaintenance) +{ + http_response_code(503); + echo 'This application is currently under maintenance'; + exit(); +} + +/** + * helper to test if a string ends with another + * @param $haystack + * @param $needle + * + * @return bool + */ +function EndsWith($haystack, $needle) { + return substr_compare($haystack, $needle, -strlen($needle)) === 0; +} + + /** * Check that the configuration file exists and has the appropriate access rights * If the file does not exist, launch the configuration wizard to create it @@ -29,4 +60,3 @@ else // Config file does not exist, need to run the setup wizard to create it header("Location: $sSetupPage"); } -?>