From fb251fee341b009ce860f28fb114c41c2c3bdb62 Mon Sep 17 00:00:00 2001 From: ThomasNgr-OpenDSI Date: Thu, 26 Mar 2026 17:28:28 +0100 Subject: [PATCH] FIX #GHSA-39vm-9q4p-6jjg - force disabling module possible on demo only (#37629) Co-authored-by: Laurent Destailleur --- htdocs/main.inc.php | 51 ++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 92a1b68b298..5b9d97f1e4e 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -79,6 +79,11 @@ require_once 'filefunc.inc.php'; * @var HookManager $hookmanager * @var Translate $langs * @var User $user + * @var ?string $php_session_save_handler + * @var ?string $dolibarr_main_force_https + * @var ?string $dolibarr_main_restrict_ip + * @var ?string $dolibarr_nocsrfcheck + * @var ?string $dolibarr_main_demo */ // If there is a POST parameter to tell to save automatically some POST parameters into cookies, we do it. @@ -422,31 +427,33 @@ if ((!defined('NOCSRFCHECK') && empty($dolibarr_nocsrfcheck) && getDolGlobalInt( // Note: There is another CSRF protection into the filefunc.inc.php } -// Disable modules (this must be after session_start and after conf has been loaded) -if (GETPOSTISSET('disablemodules')) { - $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha'); -} -if (!empty($_SESSION["disablemodules"])) { - $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal', 'websitetemplates'); +if (!empty($dolibarr_main_demo)) { + // Disable modules (this must be after session_start and after conf has been loaded) + if (GETPOSTISSET('disablemodules')) { + $_SESSION["disablemodules"] = GETPOST('disablemodules', 'alpha'); + } + if (!empty($_SESSION["disablemodules"])) { + $modulepartkeys = array('css', 'js', 'tabs', 'triggers', 'login', 'substitutions', 'menus', 'theme', 'sms', 'tpl', 'barcode', 'models', 'societe', 'hooks', 'dir', 'syslog', 'tpllinkable', 'contactelement', 'moduleforexternal', 'websitetemplates'); - $disabled_modules = explode(',', $_SESSION["disablemodules"]); - foreach ($disabled_modules as $module) { - if ($module) { - if (empty($conf->$module)) { - $conf->$module = new stdClass(); // To avoid warnings - } + $disabled_modules = explode(',', $_SESSION["disablemodules"]); + foreach ($disabled_modules as $module) { + if ($module) { + if (empty($conf->$module)) { + $conf->$module = new stdClass(); // To avoid warnings + } - $conf->$module->enabled = false; // Old usage - unset($conf->modules[$module]); + $conf->$module->enabled = false; // Old usage + unset($conf->modules[$module]); - foreach ($modulepartkeys as $modulepartkey) { - unset($conf->modules_parts[$modulepartkey][$module]); - } - if ($module == 'fournisseur') { // Special case - $conf->supplier_order->enabled = 0; // Old usage - $conf->supplier_invoice->enabled = 0; // Old usage - unset($conf->modules['supplier_order']); - unset($conf->modules['supplier_invoice']); + foreach ($modulepartkeys as $modulepartkey) { + unset($conf->modules_parts[$modulepartkey][$module]); + } + if ($module == 'fournisseur') { // Special case + $conf->supplier_order->enabled = 0; // Old usage + $conf->supplier_invoice->enabled = 0; // Old usage + unset($conf->modules['supplier_order']); + unset($conf->modules['supplier_invoice']); + } } } }