1 <form action="index.php?_step=3" method="post">
3 <h3>Check config files</h3>
6 $read_main = is_readable(INSTALL_PATH.'config/main.inc.php');
7 $read_db = is_readable(INSTALL_PATH.'config/db.inc.php');
9 if ($read_main && !empty($RCI->config)) {
10 $RCI->pass('main.inc.php');
12 else if ($read_main) {
13 $RCI->fail('main.inc.php', 'Syntax error');
15 else if (!$read_main) {
16 $RCI->fail('main.inc.php', 'Unable to read file. Did you create the config files?');
20 if ($read_db && !empty($RCI->config['db_table_users'])) {
21 $RCI->pass('db.inc.php');
24 $RCI->fail('db.inc.php', 'Syntax error');
27 $RCI->fail('db.inc.php', 'Unable to read file. Did you create the config files?');
32 <h3>Check if directories are writable</h3>
33 <p>RoundCube may need to write/save files into these directories</p>
36 if ($RCI->configured) {
38 foreach (array($RCI->config['temp_dir'],$RCI->config['log_dir']) as $dir) {
39 $dirpath = $dir{0} == '/' ? $dir : INSTALL_PATH . $dir;
40 if (is_writable(realpath($dirpath))) {
45 $RCI->fail($dir, 'not writeable for the webserver');
51 echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>';
54 $RCI->fail('Config', 'Could not read config files');
59 <h3>Check configured database settings</h3>
63 if ($RCI->configured) {
64 if (!empty($RCI->config['db_backend']) && !empty($RCI->config['db_dsnw'])) {
67 echo 'PEAR::' . strtoupper($RCI->config['db_backend']) . '<br />';
69 $dbclass = 'rcube_' . strtolower($RCI->config['db_backend']);
71 $DB = new $dbclass($RCI->config['db_dsnw'], '', false);
73 if (!($db_error_msg = $DB->is_error())) {
74 $RCI->pass('DSN (write)');
79 $RCI->fail('DSN (write)', $db_error_msg);
80 echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />';
81 echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>';
82 if ($RCI->config['db_backend'] == 'mdb2')
83 echo '<p class="hint">There are known problems with MDB2 running on PHP 4. Try setting <tt>db_backend</tt> to \'db\' instead</p>';
87 $RCI->fail('DSN (write)', 'not set');
91 $RCI->fail('Config', 'Could not read config files');
94 // initialize db with schema found in /SQL/*
95 if ($db_working && $_POST['initdb']) {
96 if (!($success = $RCI->init_db($DB))) {
98 echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide.
99 Make sure that the configured database extists and that the user as write privileges</p>';
105 $db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}");
107 $RCI->fail('DB Schema', "Database not initialized");
109 echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
112 $RCI->pass('DB Schema');
117 // more database tests
120 $insert_id = md5(uniqid());
121 $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);
124 $RCI->pass('DB Write');
125 $DB->query("DELETE FROM {$RCI->config['db_table_session']} WHERE sess_id=?", $insert_id);
128 $RCI->fail('DB Write', $RCI->get_error());
132 // check timezone settings
133 $tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db';
134 $tz_db = $DB->query($tz_db);
135 $tz_db = $DB->fetch_assoc($tz_db);
136 $tz_db = (int) $tz_db['tz_db'];
137 $tz_local = (int) time();
138 $tz_diff = $tz_local - $tz_db;
140 // sometimes db and web servers are on separate hosts, so allow a 30 minutes delta
141 if (abs($tz_diff) > 1800) {
142 $RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time");
145 $RCI->pass('DB Time');
151 <h3>Test SMTP settings</h3>
154 Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br />
155 Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
159 if ($RCI->getprop('smtp_server')) {
160 $user = $RCI->getprop('smtp_user', '(none)');
161 $pass = $RCI->getprop('smtp_pass', '(none)');
164 $user_field = new html_inputfield(array('name' => '_smtp_user'));
165 $user = $user_field->show($_POST['_smtp_user']);
168 $pass_field = new html_passwordfield(array('name' => '_smtp_pass'));
169 $pass = $pass_field->show();
172 echo "User: $user<br />";
173 echo "Password: $pass<br />";
176 $from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom'));
177 $to_field = new html_inputfield(array('name' => '_to', 'id' => 'sendmailto'));
184 if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) {
186 require_once 'rcube_smtp.inc';
188 echo '<p>Trying to send email...<br />';
190 if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) &&
191 preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) {
194 'From' => trim($_POST['_from']),
195 'To' => trim($_POST['_to']),
196 'Subject' => 'Test message from RoundCube',
199 $body = 'This is a test to confirm that RoundCube can send email.';
200 $smtp_response = array();
202 // send mail using configured SMTP server
203 if ($RCI->getprop('smtp_server')) {
204 $CONFIG = $RCI->config;
206 if (!empty($_POST['_smtp_user'])) {
207 $CONFIG['smtp_user'] = $_POST['_smtp_user'];
209 if (!empty($_POST['_smtp_pass'])) {
210 $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
213 $mail_object = new rcube_mail_mime();
214 $send_headers = $mail_object->headers($headers);
216 $status = smtp_mail($headers['From'], $headers['To'],
217 ($foo = $mail_object->txtHeaders($send_headers)),
218 $body, $smtp_response);
221 $header_str = 'From: ' . $headers['From'];
223 if (ini_get('safe_mode'))
224 $status = mail($headers['To'], $headers['Subject'], $body, $header_str);
226 $status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']);
229 $smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
233 $RCI->pass('SMTP send');
236 $RCI->fail('SMTP send', join('; ', $smtp_response));
240 $RCI->fail('SMTP send', 'Invalid sender or recipient');
251 <td><label for="sendmailfrom">Sender</label></td>
252 <td><?php echo $from_field->show($_POST['_from']); ?></td>
255 <td><label for="sendmailto">Recipient</label></td>
256 <td><?php echo $to_field->show($_POST['_to']); ?></td>
261 <p><input type="submit" name="sendmail" value="Send test mail" /></p>
264 <h3>Test IMAP configuration</h3>
268 $default_hosts = $RCI->get_hostlist();
269 if (!empty($default_hosts)) {
270 $host_field = new html_select(array('name' => '_host', 'id' => 'imaphost'));
271 $host_field->add($default_hosts);
274 $host_field = new html_inputfield(array('name' => '_host', 'id' => 'imaphost'));
277 $user_field = new html_inputfield(array('name' => '_user', 'id' => 'imapuser'));
278 $pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass'));
285 <td><label for="imaphost">Server</label></td>
286 <td><?php echo $host_field->show($_POST['_host']); ?></td>
290 <td><?php echo $RCI->getprop('default_port'); ?></td>
293 <td><label for="imapuser">Username</label></td>
294 <td><?php echo $user_field->show($_POST['_user']); ?></td>
297 <td><label for="imappass">Password</label></td>
298 <td><?php echo $pass_field->show(); ?></td>
305 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
307 echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />';
309 $a_host = parse_url($_POST['_host']);
310 if ($a_host['host']) {
311 $imap_host = $a_host['host'];
312 $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
313 $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
316 $imap_host = trim($_POST['_host']);
317 $imap_port = $RCI->getprop('default_port');
320 $imap = new rcube_imap(null);
321 if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) {
322 $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
326 $RCI->fail('IMAP connect', $RCI->get_error());
332 <p><input type="submit" name="imaptest" value="Check login" /></p>
340 After completing the installation and the final tests please <b>remove</b> the whole
341 installer folder from the document root of the webserver.<br />
344 These files may expose sensitive configuration data like server passwords and encryption keys
345 to the public. Make sure you cannot access this installer from your browser.