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 (limited to 'installer') 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 @@ +
+ +[do some tests as in check.php-dist here]

'; + +echo 'failures ? 'disabled' : '') . ' />'; + +?> +
diff --git a/installer/config.php b/installer/config.php new file mode 100644 index 000000000..effbf2b91 --- /dev/null +++ b/installer/config.php @@ -0,0 +1,188 @@ +
+ + +
+General configuration +
+ + +
product_name
+
+ '_product_name', 'size' => 30, 'id' => "cfgprodname")); +echo $input_prodname->show($RCI->getprop('product_name')); + +?> +
The name of your service (used to compose page titles)
+
+ +
skin_path
+
+ '_skin_path', 'size' => 30, 'id' => "cfgskinpath")); +echo $input_skinpath->show($RCI->getprop('skin_path')); + +?> +
Relative path to the skin folder
+
+ +
temp_dir
+
+ '_temp_dir', 'size' => 30, 'id' => "cfgtempdir")); +echo $input_tempdir->show($RCI->getprop('temp_dir')); + +?> +
Use this folder to store temp files (must be writebale for webserver)
+
+ +
log_dir
+
+ '_log_dir', 'size' => 30, 'id' => "cfglogdir")); +echo $input_logdir->show($RCI->getprop('log_dir')); + +?> +
Use this folder to store log files (must be writebale for webserver)
+
+ +
ip_check
+
+ '_ip_check', 'id' => "cfgipcheck")); +echo $check_ipcheck->show(intval($RCI->getprop('ip_check')), array('value' => 1)); + +?> +
+ +

This increases security but can cause sudden logouts when someone uses a proxy with changeing IPs.

+
+ +
des_key
+
+ '_des_key', 'size' => 30, 'id' => "cfgdeskey")); +echo $input_deskey->show($RCI->getprop('des_key')); + +?> +
This key is used to encrypt the users imap password before storing in the session record
+

It's a random generated string to ensure that every installation has it's own key. +If you enter it manually please provide a string of exactly 24 chars.

+
+ +
enable_caching
+
+ '_enable_caching', 'id' => "cfgcache")); +echo $check_caching->show(intval($RCI->getprop('enable_caching')), array('value' => 1)); + +?> +
+
+ +
+
+ +
+IMAP Settings +
+
auto_create_user
+
+ '_auto_create_user', 'id' => "cfgautocreate")); +echo $check_autocreate->show(intval($RCI->getprop('auto_create_user')), array('value' => 1)); + +?> +
+ +

A user is authenticated by the IMAP server but it requires a local record to store settings +and contacts. With this option enabled a new user record will automatically be created once the IMAP login succeeds.

+ +

If this option is disabled, the login only succeeds if there's a matching user-record in the local RoundCube database +what means that you have to create those records manually or disable this option after the first login.

+
+ +
+
+ +
+SMTP Settings +
+
TBD.
+
+
+ +
+Display settings +
+ +
locale_string
+
+ '_locale_string', 'size' => 6, 'id' => "cfglocale")); +echo $input_locale->show($RCI->getprop('locale_string')); + +?> +
The default locale setting. This also defines the language of the login screen.
+

Enter a RFC1766 formatted locale name. Examples: en_US, de, de_CH, fr, pt_BR

+
+ +
+
+ +failures ? 'disabled' : '') . ' />

'; + + +if (!empty($_POST['submit'])) { + echo "
\n"; + + echo '

Copy the following configurations and save them in two files (names above the text box)'; + echo ' within the config/ directory of your RoundCube installation.

'; + + $textbox = new textarea(array('rows' => 20, 'cols' => 60, 'class' => "configfile")); + + echo '
main.inc.php
'; + echo $textbox->show($RCI->create_config('main')); + + echo '
db.inc.php
'; + echo $textbox->show($RCI->create_config('db')); + + echo '

'; +} + +?> +
diff --git a/installer/images/banner_bg.gif b/installer/images/banner_bg.gif new file mode 100644 index 000000000..9cef8a7c5 Binary files /dev/null and b/installer/images/banner_bg.gif differ diff --git a/installer/images/banner_logo.gif b/installer/images/banner_logo.gif new file mode 100644 index 000000000..a7dd11426 Binary files /dev/null and b/installer/images/banner_logo.gif differ diff --git a/installer/images/banner_right.gif b/installer/images/banner_right.gif new file mode 100644 index 000000000..3248668ac Binary files /dev/null and b/installer/images/banner_right.gif differ diff --git a/installer/index.php b/installer/index.php new file mode 100644 index 000000000..be8657799 --- /dev/null +++ b/installer/index.php @@ -0,0 +1,63 @@ + + + +RoundCube Webmail Installer + + + + + + + + +
+ +

RoundCube Webmail Installer

+ + + +
    + $item) { + $j = $i + 1; + $link = $RCI->step > $j ? '' . Q($item) . '' : Q($item); + printf('
  1. %s
  2. ', $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) . ':  OK'; + if ($message) + echo '' . Q($name) . ''; + } + + + /** + * Display an error status and increase failure count + * + * @param string Test name + * @param string Error message + * @param string URL for details + */ + function fail($name, $message = '', $url = '') + { + $this->failures++; + + echo Q($name) . ':  NOT OK'; + if ($message) + echo '' . Q($name) . ''; + if ($url) + echo '(See ' . Q($url) . ')'; + } + + + /** + * Display warning status + * + * @param string Test name + * @param string Warning message + * @param string URL for details + */ + function warning($name, $message = '', $url = '') + { + echo Q($name) . ':  NOT AVAILABLE'; + if ($message) + echo '' . Q($name) . ''; + if ($url) + echo '(See ' . Q($url) . ')'; + } + + + /** + * Generarte a ramdom string to be used as encryption key + * + * @param int Key length + * @return string The generated random string + * @static + */ + function random_key($length) + { + $alpha = 'ABCDEFGHIJKLMNOPQERSTUVXYZabcdefghijklmnopqrtsuvwxyz0123456789+*%&?!$-_='; + $out = ''; + + for ($i=0; $i < $length; $i++) + $out .= $alpha{rand(0, strlen($alpha)-1)}; + + return $out; + } + +} + + +/** + * Shortcut function for htmlentities() + * + * @param string String to quote + * @return string The html-encoded string + */ +function Q($string) +{ + return htmlentities($string); +} + diff --git a/installer/styles.css b/installer/styles.css new file mode 100644 index 000000000..2af840a3d --- /dev/null +++ b/installer/styles.css @@ -0,0 +1,186 @@ + +body { + margin: 1em 2em 2em 2em; + background-color: #fff; +} + +body, td, th, div, p { + font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif; + font-size: small; + color: #000; +} + +#banner { + position: relative; +} + +#header { + position: relative; + height: 56px; + background: url('images/banner_bg.gif') top left repeat-x #fff; +} + +#header div.banner-logo { + position: absolute; + top: 0px; + left: 0px; + width: 200px; + height: 56px; +} + +#header div.banner-right { + position: absolute; + right: 0px; + top: 0px; + width: 10px; + height: 56px; +} + +#topnav { + position: absolute; + right: 20px; + bottom: 8px; + text-align: right; + color: #ebebeb; + font-size: smaller; +} + +#topnav a { + color: #ebebeb; + font-size: 11px; + text-decoration: none; +} + +#topnav a:hover { + text-decoration: underline; +} + +#content { + margin: 8px 20px; +} + +#footer { + margin: 2em 20px 1em 20px; + padding-top: 0.6em; + font-size: smaller; + text-align: center; + border-top: 1px dotted #999; +} + +#progress { + margin-bottom: 2em; + border: 1px solid #aaa; + background-color: #f9f9f9; +} + +#progress:after { + content: "."; + display: block; + height: 0; + font-size: 0; + clear: both; + visibility: hidden; +} + +#progress li { + float: left; + color: #999; + padding: 1em 5em 1em 0.2em; +} + +#progress li.current { + color: #000; + font-weight: bold; +} + +#progress li.passed, +#progress li.passed a { + color: #333; + text-decoration: none; +} + +#progress li.passed a:hover { + text-decoration: underline; +} + +fieldset { + margin-bottom: 2em; + border: 1px solid #aaa; + background-color: #f9f9f9; +} + +fieldset p.hint { + margin-top: 0.5em; +} + +legend { + font-size: 1.1em; + font-weight: bold; +} + +textarea.configfile { + background-color: #f9f9f9; + font-family: monospace; + font-size: 9pt; + width: 100%; + height: 40em; +} + +dt.propname { + font-family: monospace; + font-size: 9pt; + margin-top: 1em; + margin-bottom: 0.6em; +} + +dd div { + margin-top: 0.3em; +} + +label { + padding-left: 0.5em; +} + +th { + text-align: left; +} + +h4 { + margin-bottom: 0.2em; +} + +.hint { + color: #666; + font-size: 0.95em; +} + +.success { + color: #006400; + font-weight: bold !important; +} + +.fail { + color: #ff0000 !important; + font-weight: bold !important; +} + +.na { + color: #f60; + font-weight: bold; +} + +.indent { + padding-left: 0.8em; +} + +.notice { + padding: 1em; + background-color: #f7fdcb; + border: 2px solid #c2d071; +} + +.warning { + padding: 1em; + background-color: #ef9398; + border: 2px solid #dc5757; +} diff --git a/installer/test.php b/installer/test.php new file mode 100644 index 000000000..254144e04 --- /dev/null +++ b/installer/test.php @@ -0,0 +1,21 @@ +
+ +[do some tests as in check.php-dist here]

'; + +echo ''; + +?> +
+ +

+ +After completing the installation and the final tests please remove the whole +installer folder from the document root of the webserver.
+
+ +These files may expose sensitive configuration data like server passwords and encryption keys +to the public. Make sure you cannot access this installer from your browser. + +

diff --git a/installer/welcome.html b/installer/welcome.html new file mode 100644 index 000000000..2fec0db67 --- /dev/null +++ b/installer/welcome.html @@ -0,0 +1,14 @@ +
+ + +

Welcome to the interactive install script for the RoundCube Webmail package

+

First let's check your local environment and find out if everything RoundCube needs is available.

+ +

The basic requirements are:

+ + + + +
-- cgit v1.2.3