1 <form action="index.php?_step=3" method="post">
3 <h3>Check config files</h3>
6 require_once 'include/rcube_html.inc';
8 $read_main = is_readable('../config/main.inc.php');
9 $read_db = is_readable('../config/db.inc.php');
11 if ($read_main && !empty($RCI->config)) {
12 $RCI->pass('main.inc.php');
14 else if ($read_main) {
15 $RCI->fail('main.inc.php', 'Syntax error');
17 else if (!$read_main) {
18 $RCI->fail('main.inc.php', 'Unable to read file. Did you create the config files?');
22 if ($read_db && !empty($RCI->config['db_table_users'])) {
23 $RCI->pass('db.inc.php');
26 $RCI->fail('db.inc.php', 'Syntax error');
29 $RCI->fail('db.inc.php', 'Unable to read file. Did you create the config files?');
34 <h3>Check if directories are writable</h3>
35 <p>RoundCube may need to write/save files into these directories</p>
38 if ($RCI->configured) {
40 foreach (array($RCI->config['temp_dir'],$RCI->config['log_dir']) as $dir) {
41 $dirpath = $dir{0} == '/' ? $dir : $docroot . '/' . $dir;
42 if (is_writable(realpath($dirpath))) {
47 $RCI->fail($dir, 'not writeable for the webserver');
53 echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>';
56 $RCI->fail('Config', 'Could not read config files');
61 <h3>Check configured database settings</h3>
65 if ($RCI->configured) {
66 if (!empty($RCI->config['db_backend']) && !empty($RCI->config['db_dsnw'])) {
69 echo 'PEAR::' . strtoupper($RCI->config['db_backend']) . '<br />';
71 $_class = 'rcube_' . strtolower($RCI->config['db_backend']);
72 require_once 'include/' . $_class . '.inc';
74 $DB = new $_class($RCI->config['db_dsnw'], '', false);
76 if (!($db_error_msg = $DB->is_error())) {
77 $RCI->pass('DSN (write)');
82 $RCI->fail('DSN (write)', $db_error_msg);
83 echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />';
84 echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>';
85 if ($RCI->config['db_backend'] == 'mdb2')
86 echo '<p class="hint">There are known problems with MDB2 running on PHP 4. Try setting <tt>db_backend</tt> to \'db\' instead</p>';
90 $RCI->fail('DSN (write)', 'not set');
94 $RCI->fail('Config', 'Could not read config files');
97 // initialize db with schema found in /SQL/*
98 if ($db_working && $_POST['initdb']) {
99 if (!($success = $RCI->init_db($DB))) {
101 echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide.
102 Make sure that the configured database extists and that the user as write privileges</p>';
108 $db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}");
110 $RCI->fail('DB Schema', "Database not initialized");
112 echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
115 $RCI->pass('DB Schema');
120 // more database tests
123 $insert_id = md5(uniqid());
124 $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);
127 $RCI->pass('DB Write');
128 $DB->query("DELETE FROM {$RCI->config['db_table_session']} WHERE sess_id=?", $insert_id);
131 $RCI->fail('DB Write', $RCI->get_error());
135 // check timezone settings
136 $tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db';
137 $tz_db = $DB->query($tz_db);
138 $tz_db = $DB->fetch_assoc($tz_db);
139 $tz_db = (int) $tz_db['tz_db'];
140 $tz_local = (int) time();
141 $tz_diff = $tz_local - $tz_db;
143 // sometimes db and web servers are on separate hosts, so allow a 30 minutes delta
144 if (abs($tz_diff) > 1800) {
145 $RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time");
148 $RCI->pass('DB Time');
154 <h3>Test SMTP settings</h3>
157 Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br />
158 Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
162 if ($RCI->getprop('smtp_server')) {
163 $user = $RCI->getprop('smtp_user', '(none)');
164 $pass = $RCI->getprop('smtp_pass', '(none)');
167 $user_field = new textfield(array('name' => '_smtp_user'));
168 $user = $user_field->show($_POST['_smtp_user']);
171 $pass_field = new passwordfield(array('name' => '_smtp_pass'));
172 $pass = $pass_field->show();
175 echo "User: $user<br />";
176 echo "Password: $pass<br />";
179 $from_field = new textfield(array('name' => '_from', 'id' => 'sendmailfrom'));
180 $to_field = new textfield(array('name' => '_to', 'id' => 'sendmailto'));
187 if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) {
189 require_once 'lib/rc_mail_mime.inc';
190 require_once 'include/rcube_smtp.inc';
192 echo '<p>Trying to send email...<br />';
194 if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) &&
195 preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) {
198 'From' => trim($_POST['_from']),
199 'To' => trim($_POST['_to']),
200 'Subject' => 'Test message from RoundCube',
203 $body = 'This is a test to confirm that RoundCube can send email.';
204 $smtp_response = array();
206 // send mail using configured SMTP server
207 if ($RCI->getprop('smtp_server')) {
208 $CONFIG = $RCI->config;
210 if (!empty($_POST['_smtp_user'])) {
211 $CONFIG['smtp_user'] = $_POST['_smtp_user'];
213 if (!empty($_POST['_smtp_pass'])) {
214 $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
217 $mail_object = new rc_mail_mime();
218 $send_headers = $mail_object->headers($headers);
220 $status = smtp_mail($headers['From'], $headers['To'],
221 ($foo = $mail_object->txtHeaders($send_headers)),
222 $body, $smtp_response);
225 $header_str = 'From: ' . $headers['From'];
227 if (ini_get('safe_mode'))
228 $status = mail($headers['To'], $headers['Subject'], $body, $header_str);
230 $status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']);
233 $smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
237 $RCI->pass('SMTP send');
240 $RCI->fail('SMTP send', join('; ', $smtp_response));
244 $RCI->fail('SMTP send', 'Invalid sender or recipient');
255 <td><label for="sendmailfrom">Sender</label></td>
256 <td><?php echo $from_field->show($_POST['_from']); ?></td>
259 <td><label for="sendmailto">Recipient</label></td>
260 <td><?php echo $to_field->show($_POST['_to']); ?></td>
265 <p><input type="submit" name="sendmail" value="Send test mail" /></p>
268 <h3>Test IMAP configuration</h3>
272 $default_hosts = $RCI->get_hostlist();
273 if (!empty($default_hosts)) {
274 $host_field = new select(array('name' => '_host', 'id' => 'imaphost'));
275 $host_field->add($default_hosts);
278 $host_field = new textfield(array('name' => '_host', 'id' => 'imaphost'));
281 $user_field = new textfield(array('name' => '_user', 'id' => 'imapuser'));
282 $pass_field = new passwordfield(array('name' => '_pass', 'id' => 'imappass'));
289 <td><label for="imaphost">Server</label></td>
290 <td><?php echo $host_field->show($_POST['_host']); ?></td>
294 <td><?php echo $RCI->getprop('default_port'); ?></td>
297 <td><label for="imapuser">Username</label></td>
298 <td><?php echo $user_field->show($_POST['_user']); ?></td>
301 <td><label for="imappass">Password</label></td>
302 <td><?php echo $pass_field->show(); ?></td>
309 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
311 require_once 'include/rcube_imap.inc';
313 echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />';
315 $a_host = parse_url($_POST['_host']);
316 if ($a_host['host']) {
317 $imap_host = $a_host['host'];
318 $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
319 $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
322 $imap_host = trim($_POST['_host']);
323 $imap_port = $RCI->getprop('default_port');
326 $imap = new rcube_imap(null);
327 if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) {
328 $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
332 $RCI->fail('IMAP connect', $RCI->get_error());
338 <p><input type="submit" name="imaptest" value="Check login" /></p>
346 After completing the installation and the final tests please <b>remove</b> the whole
347 installer folder from the document root of the webserver.<br />
350 These files may expose sensitive configuration data like server passwords and encryption keys
351 to the public. Make sure you cannot access this installer from your browser.