From 9606ffb32277ce4083144afc1a7f6194370cf69c Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 25 Jun 2006 05:18:00 -0400
Subject: [PATCH] Changed behavior to include host-specific configuration (Bug #1483849)

---
 program/include/main.inc |   22 ++++++++++++++++++++++
 config/main.inc.php.dist |    7 +++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/config/main.inc.php.dist b/config/main.inc.php.dist
index 9c72bbe..dda852c 100644
--- a/config/main.inc.php.dist
+++ b/config/main.inc.php.dist
@@ -173,6 +173,9 @@
  *                                                    'fuzzy_search'  => 0);
  */
 
+// try to load host-specific configuration
+$rcmail_config['include_host_config'] = FALSE;
+
 
 /***** these settings can be overwritten by user's preferences *****/
 
@@ -199,10 +202,6 @@
 
 // list of configuration option names that need to be available in Javascript.
 $rcmail_config['javascript_config'] = array('read_when_deleted', 'flag_for_deletion');
-
-/***** try to load host-specific configuration *****/
-
-@include($_SERVER['HTTP_HOST'].'.inc.php');
 
 
 // end of config file
diff --git a/program/include/main.inc b/program/include/main.inc
index b68a0c2..c5370b1 100644
--- a/program/include/main.inc
+++ b/program/include/main.inc
@@ -42,6 +42,10 @@
   // load config file
   include_once('config/main.inc.php');
   $CONFIG = is_array($rcmail_config) ? $rcmail_config : array();
+  
+  // load host-specific configuration
+  rcmail_load_host_config(&$CONFIG);
+  
   $CONFIG['skin_path'] = $CONFIG['skin_path'] ? preg_replace('/\/$/', '', $CONFIG['skin_path']) : 'skins/default';
 
   // load db conf
@@ -126,6 +130,24 @@
 
   register_shutdown_function('rcmail_shutdown');
   }
+
+
+// load a host-specific config file if configured
+function rcmail_load_host_config(&$config)
+  {
+  $fname = NULL;
+  
+  if (is_array($config['include_host_config']))
+    $fname = $config['include_host_config'][$_SERVER['HTTP_HOST']];
+  else if (!empty($config['include_host_config']))
+    $fname = preg_replace('/[^a-z0-9\.\-_]/i', '', $_SERVER['HTTP_HOST']) . '.inc.php';
+
+   if ($fname && is_file('config/'.$fname))
+     {
+     include('config/'.$fname);
+     $config = array_merge($config, $rcmail_config);
+     }
+  }
   
 
 // create authorization hash

--
Gitblit v1.9.1