From df1657c09475d61efb98f7a9562fe92e0cba6889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20OUDOT?= Date: Mon, 22 May 2023 18:41:35 +0200 Subject: [PATCH] Load multi-tenant config files --- conf/config.inc.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/conf/config.inc.php b/conf/config.inc.php index 04b7177..e6710f0 100644 --- a/conf/config.inc.php +++ b/conf/config.inc.php @@ -197,6 +197,9 @@ # Smarty debug mode - will popup debug information on web interface $smarty_debug = false; +# The name of an HTTP Header that may hold a reference to an extra config file to include. +#$header_name_extra_config="WP-Extra-Config"; + # Allow to override current settings with local configuration if (file_exists (dirname (__FILE__) . '/config.inc.local.php')) { include dirname (__FILE__) . '/config.inc.local.php'; @@ -207,4 +210,15 @@ define("SMARTY", "/usr/share/php/smarty3/Smarty.class.php"); } +# Allow to override current settings with an extra configuration file, whose reference is passed in HTTP_HEADER $header_name_extra_config +if (isset($header_name_extra_config)) { + $extraConfigKey = "HTTP_".strtoupper(str_replace('-','_',$header_name_extra_config)); + if (array_key_exists($extraConfigKey, $_SERVER)) { + $extraConfig = preg_replace("/[^a-zA-Z0-9-_]+/", "", filter_var($_SERVER[$extraConfigKey], FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH)); + if (strlen($extraConfig) > 0 && file_exists (__DIR__ . "/config.inc.".$extraConfig.".php")) { + require __DIR__ . "/config.inc.".$extraConfig.".php"; + } + } +} + ?>