Skip to content

Commit

Permalink
Load multi-tenant config files
Browse files Browse the repository at this point in the history
  • Loading branch information
coudot committed May 22, 2023
1 parent 59fec15 commit df1657c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions conf/config.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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";
}
}
}

?>

0 comments on commit df1657c

Please sign in to comment.