FIX #GHSA-39vm-9q4p-6jjg - force disabling module possible on demo only (#37629)

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
ThomasNgr-OpenDSI 2026-03-26 17:28:28 +01:00 committed by GitHub
parent 1f1b6bf49b
commit fb251fee34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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']);
}
}
}
}