}
$php = '';
+$path = $registry->get('fileroot', $app) . '/config';
+$configFile = $path . '/conf.php';
+if (is_link($configFile)) {
+ $configFile = readlink($configFile);
+}
if (Horde_Util::getFormData('submitbutton') == _("Revert Configuration")) {
- $path = $registry->get('fileroot', $app) . '/config';
- if (@copy($path . '/conf.bak.php', $path . '/conf.php')) {
+ if (@copy($path . '/conf.bak.php', $configFile)) {
$notification->push(_("Successfully reverted configuration. Reload to see changes."), 'horde.success');
@unlink($path . '/conf.bak.php');
} else {
} elseif ($form->validate($vars)) {
$config = new Horde_Config($app);
$php = $config->generatePHPConfig($vars);
- $path = $registry->get('fileroot', $app) . '/config';
- if (file_exists($path . '/conf.php')) {
- if (@copy($path . '/conf.php', $path . '/conf.bak.php')) {
+ if (file_exists($configFile)) {
+ if (@copy($configFile, $path . '/conf.bak.php')) {
$notification->push(sprintf(_("Successfully saved the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.success');
} else {
$notification->push(sprintf(_("Could not save the backup configuration file %s."), Horde_Util::realPath($path . '/conf.bak.php')), 'horde.warning');
}
}
- if ($fp = @fopen($path . '/conf.php', 'w')) {
+ if ($fp = @fopen($configFile, 'w')) {
/* Can write, so output to file. */
fwrite($fp, $php);
fclose($fp);
- $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($path . '/conf.php')), 'horde.success');
+ $notification->push(sprintf(_("Successfully wrote %s"), Horde_Util::realPath($configFile)), 'horde.success');
$registry->clearCache();
Horde::url('admin/config/index.php', true)->redirect();
} else {
/* Cannot write. */
- $notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($path . '/conf.php'), Horde::link(Horde::url('admin/config/index.php') . '#update', _("Configuration")) . _("Configuration") . '</a>', Horde_Util::realPath($path . '/conf.php')), 'horde.warning', array('content.raw'));
+ $notification->push(sprintf(_("Could not save the configuration file %s. You can either use one of the options to save the code back on %s or copy manually the code below to %s."), Horde_Util::realPath($configFile), Horde::link(Horde::url('admin/config/index.php') . '#update', _("Configuration")) . _("Configuration") . '</a>', Horde_Util::realPath($configFile)), 'horde.warning', array('content.raw'));
/* Save to session. */
$session->set('horde', 'config/' . $app, $php);
$data = '';
if ($setup == 'conf' && $type == 'php') {
- /* A bit ugly here, save PHP code into a string for creating the script
- * to be run at the command prompt. */
+ /* Save PHP code into a string for creating the script to be run at the
+ * command prompt. */
$data = '#!/usr/bin/env php' . "\n";
$data .= '<?php' . "\n";
foreach ($session->get('horde', 'config/') as $app => $php) {
$path = $registry->get('fileroot', $app) . '/config';
+ $data .= '$conf = \'' . $path . '/conf.php\';' . "\n";
/* Add code to save backup. */
- $data .= 'if (file_exists(\'' . $path . '/conf.php\')) {' . "\n";
- $data .= ' if (@copy(\'' . $path . '/conf.php\', \'' . $path . '/conf.bak.php\')) {' . "\n";
+ $data .= 'if (file_exists(\'$conf\')) {' . "\n";
+ $data .= ' if (is_link(\'$conf\')) {' . "\n";
+ $data .= ' $conf = readlink($conf);' . "\n";
+ $data .= ' }' . "\n";
+ $data .= ' if (@copy(\'$conf\', \'' . $path . '/conf.bak.php\')) {' . "\n";
$data .= ' echo \'Successfully saved backup configuration.\' . "\n";' . "\n";
$data .= ' } else {' . "\n";
$data .= ' echo \'Could NOT save a backup configuation.\' . "\n";' . "\n";
$data .= ' }' . "\n";
$data .= '}' . "\n";
- $data .= 'if ($fp = @fopen(\'' . $path . '/conf.php\', \'w\')) {' . "\n";
+ $data .= 'if ($fp = @fopen(\'$conf\', \'w\')) {' . "\n";
$data .= ' fwrite($fp, \'';
$data .= str_replace(array('\\', '\''), array('\\\\', '\\\''), $php);
$data .= '\');' . "\n";
$tmp_dir = Horde::getTempDir();
/* Add self-destruct code. */
$data .= 'echo \'Self-destructing...\' . "\n";' . "\n";
-$data .= 'if (unlink(__FILE__)) {' . "\n";
+$data .= 'if (@unlink(__FILE__)) {' . "\n";
$data .= ' echo \'Upgrade script deleted.\' . "\n";' . "\n";
$data .= '} else {' . "\n";
$data .= ' echo \'WARNING!!! REMOVE SCRIPT MANUALLY FROM ' . $tmp_dir . '\' . "\n";' . "\n";