Page MenuHomePhorge

No OneTemporary

diff --git a/installer/images/error.png b/installer/images/error.png
new file mode 100755
index 000000000..628cf2dae
Binary files /dev/null and b/installer/images/error.png differ
diff --git a/installer/index.php b/installer/index.php
index d14e6ff37..6ece82385 100644
--- a/installer/index.php
+++ b/installer/index.php
@@ -1,118 +1,135 @@
<?php
ini_set('error_reporting', E_ALL&~E_NOTICE);
ini_set('display_errors', 1);
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/../').'/');
define('RCMAIL_CONFIG_DIR', INSTALL_PATH . 'config');
$include_path = INSTALL_PATH . 'program/lib' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program' . PATH_SEPARATOR;
$include_path .= INSTALL_PATH . 'program/include' . PATH_SEPARATOR;
$include_path .= ini_get('include_path');
set_include_path($include_path);
session_start();
/**
* Use PHP5 autoload for dynamic class loading
* (copy from program/incllude/iniset.php)
*/
function __autoload($classname)
{
$filename = preg_replace(
array('/MDB2_(.+)/', '/Mail_(.+)/', '/^html_.+/', '/^utf8$/'),
array('MDB2/\\1', 'Mail/\\1', 'html', 'utf8.class'),
$classname
);
include_once $filename. '.php';
}
$RCI = rcube_install::get_instance();
$RCI->load_config();
if (isset($_GET['_getfile']) && in_array($_GET['_getfile'], array('main', 'db'))) {
$filename = $_GET['_getfile'] . '.inc.php';
if (!empty($_SESSION[$filename])) {
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$filename.'"');
echo $_SESSION[$filename];
exit;
}
else {
header('HTTP/1.0 404 Not found');
die("The requested configuration was not found. Please run the installer from the beginning.");
}
}
+if (isset($_GET['_mergeconfig']) && in_array($_GET['_mergeconfig'], array('main', 'db'))) {
+ $filename = $_GET['_mergeconfig'] . '.inc.php';
+
+ header('Content-type: text/plain');
+ header('Content-Disposition: attachment; filename="'.$filename.'"');
+
+ $RCI->merge_config();
+ echo $RCI->create_config($_GET['_mergeconfig'], true);
+ exit;
+}
+
+// go to 'test' step if we have a local configuration
+if ($RCI->configured && empty($_REQUEST['_step'])) {
+ header("Location: ./?_step=3");
+ exit;
+}
+
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>RoundCube Webmail Installer</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="styles.css" />
<script type="text/javascript" src="client.js"></script>
</head>
<body>
<div id="banner">
<div id="header">
<div class="banner-logo"><a href="http://www.roundcube.net"><img src="images/banner_logo.gif" width="200" height="56" border="0" alt="RoundCube Webmal Project" /></a></div>
<div class="banner-right"><img src="images/banner_right.gif" width="10" height="56" alt="" /></div>
</div>
<div id="topnav">
<a href="http://trac.roundcube.net/wiki/Howto_Install">How-to Wiki</a>
</div>
</div>
<div id="content">
<?php
// exit if installation is complete
if ($RCI->configured && !$RCI->getprop('enable_installer') && !$_SESSION['allowinstaller']) {
// header("HTTP/1.0 404 Not Found");
echo '<h2 class="error">The installer is disabled!</h2>';
echo '<p>To enable it again, set <tt>$rcmail_config[\'enable_installer\'] = true;</tt> in '.RCMAIL_CONFIG_DIR.'/main.inc.php</p>';
echo '</div></body></html>';
exit;
}
?>
<h1>RoundCube Webmail Installer</h1>
<ol id="progress">
<?php
foreach (array('Check environment', 'Create config', 'Test config') as $i => $item) {
$j = $i + 1;
$link = ($RCI->step >= $j || $RCI->configured) ? '<a href="./index.php?_step='.$j.'">' . Q($item) . '</a>' : Q($item);
printf('<li class="step%d%s">%s</li>', $j+1, $RCI->step > $j ? ' passed' : ($RCI->step == $j ? ' current' : ''), $link);
}
?>
</ol>
<?php
$include_steps = array('welcome.html', 'check.php', 'config.php', 'test.php');
if ($include_steps[$RCI->step]) {
include $include_steps[$RCI->step];
}
else {
header("HTTP/1.0 404 Not Found");
echo '<h2 class="error">Invalid step</h2>';
}
?>
</div>
<div id="footer">
Installer by the RoundCube Dev Team. Copyright &copy; 2008 - Published under the GNU Public License;&nbsp;
Icons by <a href="http://famfamfam.com">famfamfam</a>
</div>
</body>
</html>
diff --git a/installer/rcube_install.php b/installer/rcube_install.php
index 37645adbc..21e353c9c 100644
--- a/installer/rcube_install.php
+++ b/installer/rcube_install.php
@@ -1,384 +1,465 @@
<?php
/*
+-----------------------------------------------------------------------+
| rcube_install.php |
| |
| This file is part of the RoundCube Webmail package |
| Copyright (C) 2008, RoundCube Dev. - Switzerland |
| Licensed under the GNU Public License |
+-----------------------------------------------------------------------+
$Id: $
*/
/**
* Class to control the installation process of the RoundCube Webmail package
*
* @category Install
* @package RoundCube
* @author Thomas Bruederli
*/
class rcube_install
{
var $step;
var $is_post = false;
var $failures = 0;
var $config = array();
var $configured = false;
var $last_error = null;
var $email_pattern = '([a-z0-9][a-z0-9\-\.\+\_]*@[a-z0-9]([a-z0-9\-][.]?)*[a-z0-9])';
var $config_props = array();
+
+ var $obsolete_config = array('db_backend');
+ var $replaced_config = array('skin_path' => 'skin', 'locale_string' => 'language');
+
+ // these config options are optional or can be set to null
+ var $optional_config = array(
+ 'log_driver', 'syslog_id', 'syslog_facility', 'imap_auth_type',
+ 'smtp_helo_host', 'sendmail_delay', 'double_auth', 'language',
+ 'mail_header_delimiter', 'create_default_folders',
+ 'quota_zero_as_unlimited', 'spellcheck_uri', 'spellcheck_languages',
+ 'http_received_header', 'session_domain', 'mime_magic', 'log_logins',
+ 'enable_installer', 'skin_include_php');
/**
* Constructor
*/
function rcube_install()
{
$this->step = intval($_REQUEST['_step']);
$this->is_post = $_SERVER['REQUEST_METHOD'] == 'POST';
}
/**
* Singleton getter
*/
function get_instance()
{
static $inst;
if (!$inst)
$inst = new rcube_install();
return $inst;
}
/**
* Read the default config files and store properties
*/
function load_defaults()
{
$this->_load_config('.php.dist');
}
/**
* Read the local config files and store properties
*/
function load_config()
{
$this->config = array();
$this->_load_config('.php');
$this->configured = !empty($this->config);
}
/**
* Read the default config file and store properties
* @access private
*/
function _load_config($suffix)
{
@include RCMAIL_CONFIG_DIR . '/main.inc' . $suffix;
if (is_array($rcmail_config)) {
$this->config += $rcmail_config;
}
@include RCMAIL_CONFIG_DIR . '/db.inc'. $suffix;
if (is_array($rcmail_config)) {
$this->config += $rcmail_config;
}
}
/**
* Getter for a certain config property
*
* @param string Property name
* @param string Default value
* @return string The property value
*/
function getprop($name, $default = '')
{
$value = $this->config[$name];
if ($name == 'des_key' && !$this->configured && !isset($_REQUEST["_$name"]))
$value = rcube_install::random_key(24);
return $value !== null && $value !== '' ? $value : $default;
}
/**
* 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)
+ function create_config($which, $force = false)
{
$out = file_get_contents("../config/{$which}.inc.php.dist");
if (!$out)
return '[Warning: could not read the template file]';
foreach ($this->config as $prop => $default) {
$value = (isset($_POST["_$prop"]) || $this->config_props[$prop]) ? $_POST["_$prop"] : $default;
// convert some form data
if ($prop == 'debug_level') {
$val = 0;
if (is_array($value))
foreach ($value as $dbgval)
$val += intval($dbgval);
$value = $val;
}
else if ($which == 'db' && $prop == 'db_dsnw' && !empty($_POST['_dbtype'])) {
if ($_POST['_dbtype'] == 'sqlite')
$value = sprintf('%s://%s?mode=0646', $_POST['_dbtype'], $_POST['_dbname']{0} == '/' ? '/' . $_POST['_dbname'] : $_POST['_dbname']);
else
$value = sprintf('%s://%s:%s@%s/%s', $_POST['_dbtype'],
rawurlencode($_POST['_dbuser']), rawurlencode($_POST['_dbpass']), $_POST['_dbhost'], $_POST['_dbname']);
}
else if ($prop == 'smtp_auth_type' && $value == '0') {
$value = '';
}
else if ($prop == 'default_host' && is_array($value)) {
$value = rcube_install::_clean_array($value);
if (count($value) <= 1)
$value = $value[0];
}
else if ($prop == 'pagesize') {
$value = max(2, intval($value));
}
else if ($prop == 'smtp_user' && !empty($_POST['_smtp_user_u'])) {
$value = '%u';
}
else if ($prop == 'smtp_pass' && !empty($_POST['_smtp_user_u'])) {
$value = '%p';
}
else if (is_bool($default)) {
$value = (bool)$value;
}
else if (is_numeric($value)) {
$value = intval($value);
}
// skip this property
- if ($value == $default)
+ if (!$force && ($value == $default))
continue;
// save change
$this->config[$prop] = $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 trim($out);
}
+
+
+ /**
+ * Check the current configuration for missing properties
+ * and deprecated or obsolete settings
+ *
+ * @return array List with problems detected
+ */
+ function check_config()
+ {
+ $this->config = array();
+ $this->load_defaults();
+ $defaults = $this->config;
+
+ $this->load_config();
+ if (!$this->configured)
+ return null;
+
+ $out = $seen = array();
+ $optional = array_flip($this->optional_config);
+
+ // ireate over the current configuration
+ foreach ($this->config as $prop => $value) {
+ if ($replacement = $this->replaced_config[$prop]) {
+ $out['replaced'][] = array('prop' => $prop, 'replacement' => $replacement);
+ $seen[$replacement] = true;
+ }
+ else if (!$seen[$prop] && in_array($prop, $this->obsolete_config)) {
+ $out['obsolete'][] = array('prop' => $prop);
+ $seen[$prop] = true;
+ }
+ }
+
+ // iterate over default config
+ foreach ($defaults as $prop => $value) {
+ if (!$seen[$prop] && !isset($this->config[$prop]) && !isset($optional[$prop]))
+ $out['missing'][] = array('prop' => $prop);
+ }
+
+ return $out;
+ }
+
+
+ /**
+ * Merge the current configuration with the defaults
+ * and copy replaced values to the new options.
+ */
+ function merge_config()
+ {
+ $current = $this->config;
+ $this->config = array();
+ $this->load_defaults();
+
+ foreach ($this->replaced_config as $prop => $replacement)
+ if (isset($current[$prop])) {
+ if ($prop == 'skin_path')
+ $this->config[$replacement] = preg_replace('#skins/(\w+)/?$#', '\\1', $current[$prop]);
+ else
+ $this->config[$replacement] = $current[$prop];
+
+ unset($current[$prop]);
+ }
+
+ foreach ($this->obsolete_config as $prop) {
+ unset($current[$prop]);
+ }
+
+ $this->config = array_merge($current, $this->config);
+ }
/**
* Getter for the last error message
*
* @return string Error message or null if none exists
*/
function get_error()
{
return $this->last_error['message'];
}
/**
* Return a list with all imap hosts configured
*
* @return array Clean list with imap hosts
*/
function get_hostlist()
{
$default_hosts = (array)$this->getprop('default_host');
$out = array();
foreach ($default_hosts as $key => $name) {
if (!empty($name))
$out[] = is_numeric($key) ? $name : $key;
}
return $out;
}
/**
* Display OK status
*
* @param string Test name
* @param string Confirm message
*/
function pass($name, $message = '')
{
echo Q($name) . ':&nbsp; <span class="success">OK</span>';
$this->_showhint($message);
}
/**
* 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) . ':&nbsp; <span class="fail">NOT OK</span>';
$this->_showhint($message, $url);
}
/**
* Display warning status
*
* @param string Test name
* @param string Warning message
* @param string URL for details
*/
function na($name, $message = '', $url = '')
{
echo Q($name) . ':&nbsp; <span class="na">NOT AVAILABLE</span>';
$this->_showhint($message, $url);
}
function _showhint($message, $url = '')
{
$hint = Q($message);
if ($url)
$hint .= ($hint ? '; ' : '') . 'See <a href="' . Q($url) . '" target="_blank">' . Q($url) . '</a>';
if ($hint)
echo '<span class="indent">(' . $hint . ')</span>';
}
function _clean_array($arr)
{
$out = array();
foreach (array_unique($arr) as $i => $val)
if (!empty($val))
$out[] = $val;
return $out;
}
/**
* Initialize the database with the according schema
*
* @param object rcube_db Database connection
* @return boolen True on success, False on error
*/
function init_db($DB)
{
$db_map = array('pgsql' => 'postgres', 'mysqli' => 'mysql');
$engine = isset($db_map[$DB->db_provider]) ? $db_map[$DB->db_provider] : $DB->db_provider;
// find out db version
if ($engine == 'mysql') {
$DB->query('SELECT VERSION() AS version');
$sql_arr = $DB->fetch_assoc();
$version = floatval($sql_arr['version']);
if ($version >= 4.1)
$engine = 'mysql5';
}
// read schema file from /SQL/*
$fname = "../SQL/$engine.initial.sql";
if ($lines = @file($fname, FILE_SKIP_EMPTY_LINES)) {
$buff = '';
foreach ($lines as $i => $line) {
if (eregi('^--', $line))
continue;
$buff .= $line . "\n";
if (eregi(';$', trim($line))) {
$DB->query($buff);
$buff = '';
if ($this->get_error())
break;
}
}
}
else {
$this->fail('DB Schema', "Cannot read the schema file: $fname");
return false;
}
if ($err = $this->get_error()) {
$this->fail('DB Schema', "Error creating database schema: $err");
return false;
}
return true;
}
/**
* Handler for RoundCube errors
*/
function raise_error($p)
{
$this->last_error = $p;
}
/**
* 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);
}
/**
* Fake rinternal error handler to catch errors
*/
function raise_error($p)
{
$rci = rcube_install::get_instance();
$rci->raise_error($p);
}
diff --git a/installer/styles.css b/installer/styles.css
index ed64ff001..1acdc9cd0 100644
--- a/installer/styles.css
+++ b/installer/styles.css
@@ -1,231 +1,244 @@
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 a {
color: #999;
text-decoration: none;
}
#progress li a:hover {
text-decoration: underline;
}
#progress li.current {
color: #000;
font-weight: bold;
}
#progress li.passed,
#progress li.passed a,
#progress li.current a {
color: #333;
}
fieldset {
margin-bottom: 1.5em;
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: 30em;
}
-dt.propname {
+.propname {
font-family: monospace;
font-size: 9pt;
margin-top: 1em;
margin-bottom: 0.6em;
}
dd div {
margin-top: 0.3em;
}
dd label {
padding-left: 0.5em;
}
th {
text-align: left;
}
ul li {
margin: 0.3em 0 0.4em -1em;
}
ul li ul li {
margin-bottom: 0.2em;
}
h3 {
font-size: 1.1em;
margin-top: 1.5em;
margin-bottom: 0.6em;
}
h4 {
margin-bottom: 0.2em;
}
a.blocktoggle {
color: #666;
text-decoration: none;
}
a.addlink {
color: #999;
font-size: 0.9em;
padding: 1px 0 1px 20px;
background: url('images/add.png') top left no-repeat;
text-decoration: none;
}
a.removelink {
color: #999;
font-size: 0.9em;
padding: 1px 0 1px 24px;
background: url('images/delete.png') 4px 0 no-repeat;
text-decoration: none;
}
.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 {
+.suggestion {
+ padding: 0.6em;
+ background-color: #ebebeb;
+ border: 1px solid #999;
+}
+
+p.warning,
+div.warning {
padding: 1em;
background-color: #ef9398;
border: 2px solid #dc5757;
}
+h3.warning {
+ color: #c00;
+ background: url('images/error.png') top left no-repeat;
+ padding-left: 24px;
+}
+
.userconf {
color: #00c;
font-family: "Lucida Grande", Verdana, Arial, Helvetica, sans-serif;
}
diff --git a/installer/test.php b/installer/test.php
index ca7c7add4..8af6a6aef 100644
--- a/installer/test.php
+++ b/installer/test.php
@@ -1,345 +1,389 @@
<form action="index.php?_step=3" method="post">
<h3>Check config files</h3>
<?php
$read_main = is_readable(RCMAIL_CONFIG_DIR.'/main.inc.php');
$read_db = is_readable(RCMAIL_CONFIG_DIR.'/db.inc.php');
if ($read_main && !empty($RCI->config)) {
$RCI->pass('main.inc.php');
}
else if ($read_main) {
$RCI->fail('main.inc.php', 'Syntax error');
}
else if (!$read_main) {
$RCI->fail('main.inc.php', 'Unable to read file. Did you create the config files?');
}
echo '<br />';
if ($read_db && !empty($RCI->config['db_table_users'])) {
$RCI->pass('db.inc.php');
}
else if ($read_db) {
$RCI->fail('db.inc.php', 'Syntax error');
}
else if (!$read_db) {
$RCI->fail('db.inc.php', 'Unable to read file. Did you create the config files?');
}
+if ($RCI->configured && ($messages = $RCI->check_config())) {
+
+ if (is_array($messages['missing'])) {
+ echo '<h3 class="warning">Missing config options</h3>';
+ echo '<p class="hint">The following config options are not present in the current configuration.<br/>';
+ echo 'Please check the default config files and add the missing properties to your local config files.</p>';
+
+ echo '<ul class="configwarings">';
+ foreach ($messages['missing'] as $msg) {
+ echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ':&nbsp;' . $msg['name'] : ''));
+ }
+ echo '</ul>';
+ }
+
+ if (is_array($messages['replaced'])) {
+ echo '<h3 class="warning">Replaced config options</h3>';
+ echo '<p class="hint">The following config options have been replaced or renamed. ';
+ echo 'Please update them accordingly in your config files.</p>';
+
+ echo '<ul class="configwarings">';
+ foreach ($messages['replaced'] as $msg) {
+ echo html::tag('li', null, html::span('propname', $msg['prop']) .
+ ' was replaced by ' . html::span('propname', $msg['replacement']));
+ }
+ echo '</ul>';
+ }
+
+ if (is_array($messages['obsolete'])) {
+ echo '<h3>Obsolete config options</h3>';
+ echo '<p class="hint">You still have some obsolete or inexistent properties set. This isn\'t a problem but should be noticed.</p>';
+
+ echo '<ul class="configwarings">';
+ foreach ($messages['obsolete'] as $msg) {
+ echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ':&nbsp;' . $msg['name'] : ''));
+ }
+ echo '</ul>';
+ }
+
+ echo '<p class="suggestion">OK, lazy people can download the updated config files here: ';
+ echo html::a(array('href' => './?_mergeconfig=main'), 'main.inc.php') . ' &nbsp;';
+ echo html::a(array('href' => './?_mergeconfig=db'), 'db.inc.php');
+ echo "</p>";
+}
+
?>
<h3>Check if directories are writable</h3>
<p>RoundCube may need to write/save files into these directories</p>
<?php
if ($RCI->configured) {
$pass = false;
$dirs[] = $RCI->config['temp_dir'];
if($RCI->config['log_driver'] != 'syslog')
$dirs[] = $RCI->config['log_dir'];
foreach ($dirs as $dir) {
$dirpath = $dir{0} == '/' ? $dir : INSTALL_PATH . $dir;
if (is_writable(realpath($dirpath))) {
$RCI->pass($dir);
$pass = true;
}
else {
$RCI->fail($dir, 'not writeable for the webserver');
}
echo '<br />';
}
if (!$pass)
echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>';
}
else {
$RCI->fail('Config', 'Could not read config files');
}
?>
<h3>Check configured database settings</h3>
<?php
$db_working = false;
if ($RCI->configured) {
if (!empty($RCI->config['db_dsnw'])) {
$DB = new rcube_mdb2($RCI->config['db_dsnw'], '', false);
$DB->db_connect('w');
if (!($db_error_msg = $DB->is_error())) {
$RCI->pass('DSN (write)');
echo '<br />';
$db_working = true;
}
else {
$RCI->fail('DSN (write)', $db_error_msg);
echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />';
echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>';
}
}
else {
$RCI->fail('DSN (write)', 'not set');
}
}
else {
$RCI->fail('Config', 'Could not read config files');
}
// initialize db with schema found in /SQL/*
if ($db_working && $_POST['initdb']) {
if (!($success = $RCI->init_db($DB))) {
$db_working = false;
echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide.
Make sure that the configured database extists and that the user as write privileges</p>';
}
}
// test database
if ($db_working) {
$db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}");
if (!$db_read) {
$RCI->fail('DB Schema', "Database not initialized");
$db_working = false;
echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
}
else {
$RCI->pass('DB Schema');
}
echo '<br />';
}
// more database tests
if ($db_working) {
// write test
$insert_id = md5(uniqid());
$db_write = $DB->query("INSERT INTO {$RCI->config['db_table_session']} (sess_id, created, ip, vars) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
if ($db_write) {
$RCI->pass('DB Write');
$DB->query("DELETE FROM {$RCI->config['db_table_session']} WHERE sess_id=?", $insert_id);
}
else {
$RCI->fail('DB Write', $RCI->get_error());
}
echo '<br />';
// check timezone settings
$tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db';
$tz_db = $DB->query($tz_db);
$tz_db = $DB->fetch_assoc($tz_db);
$tz_db = (int) $tz_db['tz_db'];
$tz_local = (int) time();
$tz_diff = $tz_local - $tz_db;
// sometimes db and web servers are on separate hosts, so allow a 30 minutes delta
if (abs($tz_diff) > 1800) {
$RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time");
}
else {
$RCI->pass('DB Time');
}
}
?>
<h3>Test SMTP settings</h3>
<p>
Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br />
Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
<?php
if ($RCI->getprop('smtp_server')) {
$user = $RCI->getprop('smtp_user', '(none)');
$pass = $RCI->getprop('smtp_pass', '(none)');
if ($user == '%u') {
$user_field = new html_inputfield(array('name' => '_smtp_user'));
$user = $user_field->show($_POST['_smtp_user']);
}
if ($pass == '%p') {
$pass_field = new html_passwordfield(array('name' => '_smtp_pass'));
$pass = $pass_field->show();
}
echo "User: $user<br />";
echo "Password: $pass<br />";
}
$from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom'));
$to_field = new html_inputfield(array('name' => '_to', 'id' => 'sendmailto'));
?>
</p>
<?php
if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) {
require_once 'rcube_smtp.inc';
echo '<p>Trying to send email...<br />';
if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) &&
preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) {
$headers = array(
'From' => trim($_POST['_from']),
'To' => trim($_POST['_to']),
'Subject' => 'Test message from RoundCube',
);
$body = 'This is a test to confirm that RoundCube can send email.';
$smtp_response = array();
// send mail using configured SMTP server
if ($RCI->getprop('smtp_server')) {
$CONFIG = $RCI->config;
if (!empty($_POST['_smtp_user'])) {
$CONFIG['smtp_user'] = $_POST['_smtp_user'];
}
if (!empty($_POST['_smtp_pass'])) {
$CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
}
$mail_object = new rcube_mail_mime();
$send_headers = $mail_object->headers($headers);
$status = smtp_mail($headers['From'], $headers['To'],
($foo = $mail_object->txtHeaders($send_headers)),
$body, $smtp_response);
}
else { // use mail()
$header_str = 'From: ' . $headers['From'];
if (ini_get('safe_mode'))
$status = mail($headers['To'], $headers['Subject'], $body, $header_str);
else
$status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']);
if (!$status)
$smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
}
if ($status) {
$RCI->pass('SMTP send');
}
else {
$RCI->fail('SMTP send', join('; ', $smtp_response));
}
}
else {
$RCI->fail('SMTP send', 'Invalid sender or recipient');
}
}
echo '</p>';
?>
<table>
<tbody>
<tr>
<td><label for="sendmailfrom">Sender</label></td>
<td><?php echo $from_field->show($_POST['_from']); ?></td>
</tr>
<tr>
<td><label for="sendmailto">Recipient</label></td>
<td><?php echo $to_field->show($_POST['_to']); ?></td>
</tr>
</tbody>
</table>
<p><input type="submit" name="sendmail" value="Send test mail" /></p>
<h3>Test IMAP configuration</h3>
<?php
$default_hosts = $RCI->get_hostlist();
if (!empty($default_hosts)) {
$host_field = new html_select(array('name' => '_host', 'id' => 'imaphost'));
$host_field->add($default_hosts);
}
else {
$host_field = new html_inputfield(array('name' => '_host', 'id' => 'imaphost'));
}
$user_field = new html_inputfield(array('name' => '_user', 'id' => 'imapuser'));
$pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass'));
?>
<table>
<tbody>
<tr>
<td><label for="imaphost">Server</label></td>
<td><?php echo $host_field->show($_POST['_host']); ?></td>
</tr>
<tr>
<td>Port</td>
<td><?php echo $RCI->getprop('default_port'); ?></td>
</tr>
<tr>
<td><label for="imapuser">Username</label></td>
<td><?php echo $user_field->show($_POST['_user']); ?></td>
</tr>
<tr>
<td><label for="imappass">Password</label></td>
<td><?php echo $pass_field->show(); ?></td>
</tr>
</tbody>
</table>
<?php
if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />';
$a_host = parse_url($_POST['_host']);
if ($a_host['host']) {
$imap_host = $a_host['host'];
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
}
else {
$imap_host = trim($_POST['_host']);
$imap_port = $RCI->getprop('default_port');
}
$imap = new rcube_imap(null);
if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) {
$RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
$imap->close();
}
else {
$RCI->fail('IMAP connect', $RCI->get_error());
}
}
?>
<p><input type="submit" name="imaptest" value="Check login" /></p>
</form>
<hr />
<p class="warning">
After completing the installation and the final tests please <b>remove</b> the whole
installer folder from the document root of the webserver.<br />
<br />
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.
</p>

File Metadata

Mime Type
text/x-diff
Expires
Sat, Mar 1, 10:27 AM (11 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
166714
Default Alt Text
(32 KB)

Event Timeline