From b12fb53ee2e1597f0246a961dc5ff29f8af04d47 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 19 May 2016 12:07:58 +0200 Subject: work work work work work --- modules-available/baseconfig/api.inc.php | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'modules-available/baseconfig/api.inc.php') diff --git a/modules-available/baseconfig/api.inc.php b/modules-available/baseconfig/api.inc.php index c692a0b2..db890299 100644 --- a/modules-available/baseconfig/api.inc.php +++ b/modules-available/baseconfig/api.inc.php @@ -59,9 +59,33 @@ foreach ($defaults as $setting => $value) { $configVars[$setting] = $value; } -// Finally, output what we gathered -foreach ($configVars as $setting => $value) { - echo $setting, "='", escape($value), "'\n"; +// All done, now output + +if (Request::any('save') === 'true') { + // output AND save to disk: Generate contents + $lines = ''; + foreach ($configVars as $setting => $value) { + $lines .= $setting . "='" . escape($value) . "'\n"; + } + // Save to all the locations + $data = Property::getVersionCheckInformation(); + if (is_array($data) && isset($data['systems'])) { + foreach ($data['systems'] as $system) { + $path = CONFIG_HTTP_DIR . '/' . $system['id'] . '/config'; + if (file_put_contents($path, $lines) > 0) { + echo "# Saved config to $path\n"; + } else { + echo "# Error saving config to $path\n"; + } + } + } + // Output to browser + echo $lines; +} else { + // Only output to client + foreach ($configVars as $setting => $value) { + echo $setting, "='", escape($value), "'\n"; + } } // For quick testing or custom extensions: Include external file that should do nothing -- cgit v1.2.3-55-g7522