* SPDX-License-Identifier: AGPL-3.0-only ************************************/ /* crmv@91979 */ /** * This class displays the maintenance page or the maintenance message for other API. * This file is completely independent from the rest of VTE, so any change in other * files or database won't affect the maintenance message. */ class MaintenanceMode { static $strings = array( 'it_it' => array( 'PAGE_TITLE' => 'Manutenzione', 'MAIN_TEXT' => 'Il sistema è in manutenzione', ), 'en_us' => array( 'PAGE_TITLE' => 'Maintenance', 'MAIN_TEXT' => 'The system is in maintenance mode', ), 'de_de' => array( 'PAGE_TITLE' => 'Wartungsmodus', 'MAIN_TEXT' => 'Das System ist im Wartungsmodus', ), 'pt_br' => array( 'PAGE_TITLE' => 'Manutenção', 'MAIN_TEXT' => 'O sistema está em modo de manutenção', ), ); /** * Check if the system should enter the maintenance state */ public static function check() { if (is_readable('maintenance.php')) { include('maintenance.php'); return ($vte_maintenance === true || $vte_maintenance === 1); } return false; } protected static function getLangStrings($language = null) { // set the language if (empty($language) && is_readable('config.inc.php')) { @include('config.inc.php'); if (array_key_exists($default_language, self::$strings)) { $language = $default_language; } } if (empty($language)) $language = 'en_us'; $strings = self::$strings[$language]; return $strings; } /** * Display the maintenance mode page. */ public static function display($language = null) { $strings = self::getLangStrings($language); // check for ajax page $ajaxPage = preg_match("/Ajax$/", $_REQUEST['action']); if ($ajaxPage) { echo ''; return; } $str = << {$strings['PAGE_TITLE']}
{$strings['MAIN_TEXT']}
EOM; echo $str; } /** * Display the maintenance message for standard webservices */ public static function displayWS($language = null) { $strings = self::getLangStrings($language); $response = array('success' => false, 'error' => $strings['MAIN_TEXT']); echo json_encode($response); } /** * Display the maintenance message for Touch (app) webservices */ public static function displayTouchWS($language = null) { $strings = self::getLangStrings($language); $response = array('success' => false, 'error' => $strings['MAIN_TEXT']); echo json_encode($response); } /** * Display the maintenance message for the cron process */ public static function displayCron($language = null) { $strings = self::getLangStrings($language); // do nothing by default, if you want, you can print a message //error_log($strings['MAIN_TEXT']); } }