[Fusionforge-commits] r9645 - in trunk/gforge: common/include www/include

Roland Mas lolando at libremir.placard.fr.eu.org
Thu Apr 29 16:20:14 CEST 2010


Author: lolando
Date: 2010-04-29 16:20:14 +0200 (Thu, 29 Apr 2010)
New Revision: 9645

Modified:
   trunk/gforge/common/include/config.php
   trunk/gforge/www/include/pre.php
Log:
Allow reading several config files (and even a config dir)

Modified: trunk/gforge/common/include/config.php
===================================================================
--- trunk/gforge/common/include/config.php	2010-04-29 09:53:01 UTC (rev 9644)
+++ trunk/gforge/common/include/config.php	2010-04-29 14:20:14 UTC (rev 9645)
@@ -133,6 +133,30 @@
 	return $c->read_config_file ($file) ;
 }
 
+function forge_read_config_dir ($path) {
+	$c = FusionForgeConfig::get_instance () ;
+	
+	$files = array () ;
+	
+	if ($handle = opendir($path)) {
+		while (false !== ($file = readdir($handle))) {
+			if ($file != "." 
+			    && $file != ".."
+			    // Avoid .bak, .old, .dpkg-old and so on
+			    && preg_match (/^[0-9a-zA-Z_-]+$/, $file) {
+				$files[] = "$path/$file" ;
+			}
+		}
+		
+		closedir($handle);
+	}
+
+	natsort ($files) ;
+	foreach ($files as $file) {
+		$c->read_config_file ($file) ;
+	}
+}
+
 // Local Variables:
 // mode: php
 // c-file-style: "bsd"

Modified: trunk/gforge/www/include/pre.php
===================================================================
--- trunk/gforge/www/include/pre.php	2010-04-29 09:53:01 UTC (rev 9644)
+++ trunk/gforge/www/include/pre.php	2010-04-29 14:20:14 UTC (rev 9645)
@@ -48,6 +48,21 @@
 require $gfcommon.'include/config-vars.php';
 
 forge_read_config_file ($gfconfig.'/config.ini') ;
+forge_read_config_dir ($gfconfig.'/config.ini.d/') ;
+if (($ecf = forge_get_config ('extra_config_files')) != NULL) {
+	$ecfa = explode (',', $ecf) ;
+	foreach ($ecfa as $cf) {
+		$cf = trim ($cf) ;
+		forge_read_config_file ($cf) ;
+	}
+}
+if (($ecd = forge_get_config ('extra_config_dirs')) != NULL) {
+	$ecda = explode (',', $ecd) ;
+	foreach ($ecda as $cd) {
+		$cd = trim ($cd) ;
+		forge_read_config_file ($cd) ;
+	}
+}
 
 // Get constants used for flags or status
 require $gfcommon.'include/constants.php';




More information about the Fusionforge-commits mailing list