From 3ea69c31133f662621efc06ce25aa28421344416 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Jan 2023 12:59:26 +0100 Subject: [PATCH] NEW #0002205 Mode maintenance --- block.html-example | 5 +++++ html/admin-noalyss.php | 3 +++ html/ajax.php | 4 +++- html/compute.php | 3 +++ html/direct.php | 2 ++ html/do.php | 6 ++++-- html/export.php | 3 +++ html/extension.raw.php | 2 ++ html/fid.php | 3 ++- html/fid_card.php | 3 +++ html/index.php | 2 ++ html/login.php | 3 ++- html/mobile.php | 5 ++++- html/recherche.php | 2 ++ html/user_login.php | 2 ++ include/lib/ac_common.php | 12 ++++++++++++ unit-test/global.php | 2 +- 17 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 block.html-example diff --git a/block.html-example b/block.html-example new file mode 100644 index 000000000..886160f1d --- /dev/null +++ b/block.html-example @@ -0,0 +1,5 @@ +

Nous sommes en maintenance

+

+ Le site est actuellement en maintenance. +

+ diff --git a/html/admin-noalyss.php b/html/admin-noalyss.php index c6d273783..bafab207b 100644 --- a/html/admin-noalyss.php +++ b/html/admin-noalyss.php @@ -31,6 +31,7 @@ if (file_exists("../include/config.inc.php") ) { define ('ALLOWED',1); define ('ALLOWED_ADMIN',1); require_once '../include/constant.php'; + require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; \Noalyss\Dbg::echo_file(__FILE__); if ( DEBUGNOALYSS > 1 ) { @@ -41,6 +42,8 @@ if (file_exists("../include/config.inc.php") ) { \Noalyss\Dbg::display_request(); \Noalyss\Dbg::display_global(); } //<--- if DEBUG + + MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/admin_repo.inc.php'; } else { // Redirect to install file , if this file exists then diff --git a/html/ajax.php b/html/ajax.php index ecac8dc10..2d32d7521 100644 --- a/html/ajax.php +++ b/html/ajax.php @@ -14,12 +14,13 @@ */ if ( ! defined ('ALLOWED') ) define ('ALLOWED',1); require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; require_once NOALYSS_INCLUDE.'/class/extension.class.php'; if ( !isset ($_REQUEST['gDossier'])) exit(); - +MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/class/noalyss_parameter_folder.class.php'; mb_internal_encoding("UTF-8"); /** @@ -29,6 +30,7 @@ if ( ! isset($_SESSION[SESSION_KEY."g_user"])) { echo "NOCONX"; die(); } + global $g_user,$cn,$g_parameter; $cn=Dossier::connect(); $g_parameter=new Noalyss_Parameter_Folder($cn); diff --git a/html/compute.php b/html/compute.php index 8f4ad674e..7d70e99dd 100644 --- a/html/compute.php +++ b/html/compute.php @@ -37,6 +37,9 @@ require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_tva.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + // Check if the needed field does exist extract ($_GET, EXTR_SKIP ); foreach (array('t','c','p','q','n','gDossier') as $a) diff --git a/html/direct.php b/html/direct.php index 3148e2226..1f10466a4 100644 --- a/html/direct.php +++ b/html/direct.php @@ -24,6 +24,8 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); $cn=Dossier::connect(); global $g_user; diff --git a/html/do.php b/html/do.php index d24e5bf0d..68e9b21c2 100644 --- a/html/do.php +++ b/html/do.php @@ -23,13 +23,15 @@ define('ALLOWED',1); * \brief Main file */ require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/constant.security.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; + +MaintenanceMode("block.html"); require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; require_once NOALYSS_INCLUDE.'/lib/user_common.php'; -require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; require_once NOALYSS_INCLUDE.'/lib/function_javascript.php'; -require_once NOALYSS_INCLUDE.'/constant.security.php'; require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; diff --git a/html/export.php b/html/export.php index e56a3423e..dda4479b4 100644 --- a/html/export.php +++ b/html/export.php @@ -26,6 +26,9 @@ */ define ('ALLOWED',1); require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + global $g_user,$cn,$g_parameter; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; diff --git a/html/extension.raw.php b/html/extension.raw.php index b484ff547..2b639dc90 100644 --- a/html/extension.raw.php +++ b/html/extension.raw.php @@ -33,6 +33,8 @@ require_once NOALYSS_INCLUDE.'/lib/html_input.class.php'; require_once NOALYSS_INCLUDE.'/lib/iselect.class.php'; require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; +MaintenanceMode("block.html"); + global $g_user,$cn,$g_parameter; $http=new HttpInput(); $cn=Dossier::connect(); diff --git a/html/fid.php b/html/fid.php index 1f18cfa29..854b6a512 100644 --- a/html/fid.php +++ b/html/fid.php @@ -33,7 +33,8 @@ *\note if the j is -1 then all the card are shown */ require_once '../include/constant.php'; - +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); /** * if not connected, session is expired then exit with a message NOCONX */ diff --git a/html/fid_card.php b/html/fid_card.php index 27bfc71a3..fa8a98694 100644 --- a/html/fid_card.php +++ b/html/fid_card.php @@ -40,6 +40,9 @@ require_once '../include/constant.php'; require_once NOALYSS_INCLUDE.'/class/database.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; require_once NOALYSS_INCLUDE.'/class/dossier.class.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + /** * if not connected, session is expired then exit with a message NOCONX */ diff --git a/html/index.php b/html/index.php index 501e843c6..81d11a029 100644 --- a/html/index.php +++ b/html/index.php @@ -158,6 +158,8 @@ $my_domain=""; require_once '../include/constant.php'; require_once '../include/config.inc.php'; require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + if ( file_exists("install.php")&& DEBUGNOALYSS == 0 ) { // At the end of the installation procedure , the install file must be removed diff --git a/html/login.php b/html/login.php index 7fb03441a..d3588d023 100644 --- a/html/login.php +++ b/html/login.php @@ -19,7 +19,8 @@ // Copyright Author Dany De Bontridder danydb@aevalys.eu require_once '../include/constant.php'; -include_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); /*! \file * \brief Login page diff --git a/html/mobile.php b/html/mobile.php index 5c19d8ef3..a62d688a6 100644 --- a/html/mobile.php +++ b/html/mobile.php @@ -23,8 +23,11 @@ * @file * @brief only for mobile device */ - + require_once '../include/constant.php'; +require_once NOALYSS_INCLUDE.'/lib/ac_common.php'; +MaintenanceMode("block.html"); + global $g_user; $cn=new Database(); diff --git a/html/recherche.php b/html/recherche.php index c914bdf0d..5d04bf7ec 100644 --- a/html/recherche.php +++ b/html/recherche.php @@ -28,6 +28,8 @@ require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php'; require_once NOALYSS_INCLUDE.'/class/acc_ledger_search.class.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; require_once NOALYSS_INCLUDE.'/lib/http_input.class.php'; +MaintenanceMode("block.html"); + if ( ! isset ($_SESSION[SESSION_KEY.'g_theme'])) { echo "

"._('Vous êtes déconnecté')."

"; diff --git a/html/user_login.php b/html/user_login.php index 3582a17c9..e4477ff43 100644 --- a/html/user_login.php +++ b/html/user_login.php @@ -30,6 +30,8 @@ require_once NOALYSS_INCLUDE.'/lib/function_javascript.php'; require_once NOALYSS_INCLUDE.'/lib/icon_action.class.php'; @html_page_start($_SESSION[SESSION_KEY.'g_theme']); +MaintenanceMode("block.html"); + $rep=new Database(); require_once NOALYSS_INCLUDE . '/class/noalyss_user.class.php'; $User=new Noalyss_user($rep); diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index a2659f714..98ec334db 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -1686,3 +1686,15 @@ function linkTo($p_url) return $p_url; } } +/** + * @brief When you want to prevent users to connect, create a file in noalyss/ (NOALYSS_BASE) with the + * message in Html + * @param string $p_file file in NOALYSS_BASE + */ +function MaintenanceMode($p_file) +{ + if ( file_exists(NOALYSS_BASE."/".$p_file )) { + include NOALYSS_BASE."/".$p_file; + exit; + } +} diff --git a/unit-test/global.php b/unit-test/global.php index 2eeeb83aa..13d094206 100644 --- a/unit-test/global.php +++ b/unit-test/global.php @@ -24,7 +24,7 @@ * Global variables */ global $g_connection,$g_parameter,$g_user; -if (!defined("DOSSIER"))define ("DOSSIER",25); +if (!defined("DOSSIER"))define ("DOSSIER",101); $_REQUEST['gDossier'] = DOSSIER; $g_connection=new Database(DOSSIER);