From 3549785897093452a5c523e517ac42842bea694d Mon Sep 17 00:00:00 2001
From: thomascube
Date: Tue, 19 Feb 2008 22:28:28 +0000
Subject: First steps to implement an installer
---
installer/check.php | 10 ++
installer/config.php | 188 +++++++++++++++++++++++++++++++++++
installer/images/banner_bg.gif | Bin 0 -> 587 bytes
installer/images/banner_logo.gif | Bin 0 -> 4345 bytes
installer/images/banner_right.gif | Bin 0 -> 433 bytes
installer/index.php | 63 ++++++++++++
installer/rcube_install.php | 199 ++++++++++++++++++++++++++++++++++++++
installer/styles.css | 186 +++++++++++++++++++++++++++++++++++
installer/test.php | 21 ++++
installer/welcome.html | 14 +++
10 files changed, 681 insertions(+)
create mode 100644 installer/check.php
create mode 100644 installer/config.php
create mode 100644 installer/images/banner_bg.gif
create mode 100644 installer/images/banner_logo.gif
create mode 100644 installer/images/banner_right.gif
create mode 100644 installer/index.php
create mode 100644 installer/rcube_install.php
create mode 100644 installer/styles.css
create mode 100644 installer/test.php
create mode 100644 installer/welcome.html
diff --git a/installer/check.php b/installer/check.php
new file mode 100644
index 000000000..49f186471
--- /dev/null
+++ b/installer/check.php
@@ -0,0 +1,10 @@
+
';
+
+echo '
+
+
RoundCube Webmail Installer
+
+
+
+
+ $item) {
+ $j = $i + 1;
+ $link = $RCI->step > $j ? '' . Q($item) . '' : Q($item);
+ printf('- %s
', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
+ }
+?>
+
+
+step]) {
+ include $include_steps[$RCI->step];
+}
+else {
+ header("HTTP/1.0 404 Not Found");
+ echo '
Invalid step
';
+}
+
+?>
+
+
+
+
+
diff --git a/installer/rcube_install.php b/installer/rcube_install.php
new file mode 100644
index 000000000..eee0fb732
--- /dev/null
+++ b/installer/rcube_install.php
@@ -0,0 +1,199 @@
+step = intval($_REQUEST['_step']);
+ $this->get_defaults();
+ }
+
+
+ /**
+ * Read the default config file and store properties
+ */
+ function get_defaults()
+ {
+ $suffix = is_readable('../config/main.inc.php.dist') ? '.dist' : '';
+
+ include '../config/main.inc.php' . $suffix;
+ if (is_array($rcmail_config)) {
+ $this->defaults = $rcmail_config;
+ }
+
+ include '../config/db.inc.php'. $suffix;
+ if (is_array($rcmail_config)) {
+ $this->defaults += $rcmail_config;
+ }
+ }
+
+
+ /**
+ * Getter for a certain config property
+ *
+ * @param string Property name
+ * @return string The property value
+ */
+ function getprop($name)
+ {
+ $value = isset($_REQUEST["_$name"]) ? $_REQUEST["_$name"] : $this->defaults[$name];
+
+ if ($name == 'des_key' && !isset($_REQUEST["_$name"]))
+ $value = self::random_key(24);
+
+ return $value;
+ }
+
+
+ /**
+ * Take the default config file and replace the parameters
+ * with the submitted form data
+ *
+ * @param string Which config file (either 'main' or 'db')
+ * @return string The complete config file content
+ */
+ function create_config($which)
+ {
+ $out = file_get_contents("../config/{$which}.inc.php.dist");
+
+ if (!$out)
+ return '[Warning: could not read the template file]';
+
+ foreach ($this->defaults as $prop => $default) {
+ $value = $_POST["_$prop"] ? $_POST["_$prop"] : $default;
+
+ // skip this property
+ if (!isset($_POST["_$prop"]) || $value == $default)
+ continue;
+
+ // convert some form data
+ if ($prop == 'debug_level' && is_array($value)) {
+ $val = 0;
+ foreach ($value as $i => $dbgval)
+ $val += intval($dbgval);
+ $value = $val;
+ }
+ else if (is_bool($default))
+ $value = is_numeric($value) ? (bool)$value : $value;
+
+ // replace the matching line in config file
+ $out = preg_replace(
+ '/(\$rcmail_config\[\''.preg_quote($prop).'\'\])\s+=\s+(.+);/Uie',
+ "'\\1 = ' . var_export(\$value, true) . ';'",
+ $out);
+ }
+
+ return $out;
+ }
+
+
+ /**
+ * Display OK status
+ *
+ * @param string Test name
+ * @param string Confirm message
+ */
+ function pass($name, $message = '')
+ {
+ echo Q($name) . ':