$config_dir = (($app == 'horde') && defined('HORDE_BASE'))
? HORDE_BASE . '/config/'
: $registry->get('fileroot', $app) . '/config/';
- $file = $config_dir . $config_file;
+ $base_path = $file = $config_dir . $config_file;
if (file_exists($file)) {
$filelist[$file] = 1;
}
// Load global configuration stanzas in .d directory
- $directory = preg_replace('/\.php$/', '.d', $config_dir . $config_file);
+ $directory = preg_replace('/\.php$/', '.d', $base_path);
if (file_exists($directory) &&
is_dir($directory) &&
($sub_files = glob("$directory/*.php"))) {
}
}
- // Load vhost configuration file.
- if (!empty($conf['vhosts']) || !empty($GLOBALS['conf']['vhosts'])) {
- $server_name = isset($GLOBALS['conf'])
- ? $GLOBALS['conf']['server']['name']
- : $conf['server']['name'];
- $file = $config_dir . substr($config_file, 0, -4) . '-' . $server_name . '.php';
-
- if (file_exists($file)) {
- $filelist[$file] = 0;
- }
- }
-
foreach ($filelist as $file => $log_check) {
/* If we are not exporting variables located in the configuration
* file, or we are not capturing the output, then there is no
: include $file;
$output = self::endBuffer();
+ if (!$success) {
+ throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $file));
+ }
+
if (!empty($output) && !$show_output) {
/* Horde 3 -> 4 conversion checking. This is the only place
* to catch PEAR_LOG errors. */
}
}
+ $was_included = true;
+ }
+
+ // Load vhost configuration file.
+ if (!empty($GLOBALS['conf']['vhosts']) ||
+ (($app == 'horde') &&
+ ($config_file == 'conf.php') &&
+ !empty($conf['vhosts']))) {
+ $server_name = isset($GLOBALS['conf'])
+ ? $GLOBALS['conf']['server']['name']
+ : $conf['server']['name'];
+ $file = $config_dir . substr($config_file, 0, -4) . '-' . $server_name . '.php';
+
+ self::startBuffer();
+ $success = (is_null($var_names) && !$show_output)
+ ? include_once $file
+ : include $file;
+ $output = self::endBuffer();
+
if (!$success) {
throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $file));
+ } elseif (!empty($output) && !$show_output) {
+ throw new Horde_Exception(sprintf('Failed to import configuration file "%s": ', $file) . strip_tags($output));
}
$was_included = true;
// Return an error if neither main or vhosted versions of the config
// file exist.
if (!$was_included) {
- throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $config_dir . $config_file));
+ throw new Horde_Exception(sprintf('Failed to import configuration file "%s".', $base_path));
}
if (isset($output) && $show_output) {
return compact($var_names);
} elseif (isset($$var_names)) {
return $$var_names;
- } else {
- return array();
}
+
+ return array();
}
/**