3 // Substitute {section/var} variables in Apache templates
5 // Don't try to connect to the DB, just reading config files
6 putenv('FUSIONFORGE_NO_DB=true');
8 require (dirname(__FILE__).'/../common/include/env.inc.php');
9 require_once $gfcommon.'include/pre.php';
11 if (count($argv) != 3) {
12 echo "Usage: $argv[0] template.inc destination.inc\n";
13 echo "(Note: you can use php://stdin and php://stdout)\n";
17 // forge_get_config('source_path').'/etc/httpd.conf.d/'.
18 $lines = file($argv[1]);
19 if ($lines === FALSE) {
20 echo "$argv[0]: cannot open $argv[1]\n";
24 $out = fopen($argv[2], 'w');
26 echo "$argv[0]: cannot write to $argv[2]\n";
31 // Replace the variable with the configuration value
32 foreach($lines as $line) {
33 $line = preg_replace_callback(
34 ',{([a-z_]*)/([a-z_]*)},',
36 return forge_get_config($matches[2], $matches[1]);