From d7628787523e9a6967f07c809859a396103b801a Mon Sep 17 00:00:00 2001
From: Thomas B. <thomas@roundcube.net>
Date: Wed, 17 Jul 2013 15:31:26 -0400
Subject: [PATCH] Merge pull request #90 from Dennis1993/master

---
 installer/rcube_install.php |   15 +++++++++++++++
 installer/config.php        |   40 ++++++++++++++++++++++++++++------------
 2 files changed, 43 insertions(+), 12 deletions(-)

diff --git a/installer/config.php b/installer/config.php
index f990fc2..ee8eb72 100644
--- a/installer/config.php
+++ b/installer/config.php
@@ -24,21 +24,37 @@
 $_SESSION['allowinstaller'] = true;
 
 if (!empty($_POST['submit'])) {
-  echo '<p class="notice">Copy or download the following configuration and save it';
-  echo ' as <tt><b>config.inc.php</b></tt> within the <tt>'.RCUBE_CONFIG_DIR.'</tt> directory of your Roundcube installation.<br/>';
-  echo ' Make sure that there are no characters outside the <tt>&lt;?php ?&gt;</tt> brackets when saving the file.';
-  echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
-  if ($RCI->legacy_config) {
-      echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt>';
-      echo ' from the config directory.';
-  }
-  echo '</p>';
+  $_SESSION['config'] = $RCI->create_config();
 
-  $textbox = new html_textarea(array('rows' => 16, 'cols' => 60, 'class' => "configfile"));
-  echo $textbox->show(($_SESSION['config'] = $RCI->create_config()));
+  if($RCI->save_configfile())
+  {
+     echo '<p class="notice">The config file was saved successfully into <tt>'.RCMAIL_CONFIG_DIR.'</tt> directory of your Roundcube installation.';
+
+     if($RCI->legacy_config) {
+        echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt> from the config directory.';
+     }
+
+     echo '</p>';
+  }
+  else
+  {
+      echo '<p class="notice">Copy or download the following configuration and save it';
+      echo ' as <tt><b>config.inc.php</b></tt> within the <tt>'.RCUBE_CONFIG_DIR.'</tt> directory of your Roundcube installation.<br/>';
+      echo ' Make sure that there are no characters outside the <tt>&lt;?php ?&gt;</tt> brackets when saving the file.';
+      echo '&nbsp;<input type="button" onclick="location.href=\'index.php?_getconfig=1\'" value="Download" />';
+
+      if($RCI->legacy_config) {
+         echo '<br/><br/>Afterwards, please <b>remove</b> the old configuration files <tt>main.inc.php</tt> and <tt>db.inc.php</tt> from the config directory.';
+      }
+
+      echo '</p>';
+
+      $textbox = new html_textarea(array('rows' => 16, 'cols' => 60, 'class' => "configfile"));
+      echo $textbox->show(($_SESSION['config']));
+  }
 
   echo '<p class="hint">Of course there are more options to configure.
-    Have a look at the defaults.inc.php file or visit <a href="http://trac.roundcube.net/wiki/Howto_Config">Howto_Config</a> to find out.</p>';
+    Have a look at the defaults.inc.php file or visit <a href="http://trac.roundcube.net/wiki/Howto_Config" target="_blank">Howto_Config</a> to find out.</p>';
 
   echo '<p><input type="button" onclick="location.href=\'./index.php?_step=3\'" value="CONTINUE" /></p>';
 
diff --git a/installer/rcube_install.php b/installer/rcube_install.php
index 0e137e1..76d6a7f 100644
--- a/installer/rcube_install.php
+++ b/installer/rcube_install.php
@@ -273,6 +273,21 @@
 
 
   /**
+   * save generated config file in RCUBE_CONFIG_DIR
+   *
+   * @return boolean True if the file was saved successfully, false if not
+   */
+  function save_configfile()
+  {
+    if(is_writable(RCUBE_CONFIG_DIR))
+	   {
+	     	return file_put_contents(RCUBE_CONFIG_DIR . 'config.inc.php', $_SESSION['config']);
+   	}
+
+	   return false;
+  }
+
+  /**
    * Check the current configuration for missing properties
    * and deprecated or obsolete settings
    *

--
Gitblit v1.9.1