From 1dc4bc4654b655360fee11789450fdcbb73cb5a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=85kre=20Solberg?= <andreas.solberg@uninett.no> Date: Tue, 24 Feb 2009 11:48:43 +0000 Subject: [PATCH] Add support for hostbased override of configuration files git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1314 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Configuration.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Configuration.php b/lib/SimpleSAML/Configuration.php index e33b77b36..9026210c7 100644 --- a/lib/SimpleSAML/Configuration.php +++ b/lib/SimpleSAML/Configuration.php @@ -58,7 +58,25 @@ class SimpleSAML_Configuration { echo '<p>This file was missing: [' . $filename . ']</p>'; exit; } - require_once($filename); + require($filename); + + // Check that $config array is defined... + if (!isset($config) || !is_array($config)) + throw new Exception('Configuration file [' . $this->configfilename . '] does not contain a valid $config array.'); + + if(array_key_exists('override.host', $config)) { + foreach($config['override.host'] AS $host => $ofs) { + if (SimpleSAML_Utilities::getSelfHost() === $host) { + foreach(SimpleSAML_Utilities::arrayize($ofs) AS $of) { + $overrideFile = $this->configpath . '/' . $of; + if (!file_exists($overrideFile)) + throw new Exception('Config file [' . $this->configfilename . '] requests override for host ' . $host . ' but file does not exists [' . $of . ']'); + require($overrideFile); + } + } + } + } + $this->configuration = $config; } -- GitLab