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 configured database settings</h3>
38 if (!empty($RCI->config)) {
39 if (!empty($RCI->config['db_backend']) && !empty($RCI->config['db_dsnw'])) {
42 echo 'PEAR::' . strtoupper($RCI->config['db_backend']) . '<br />';
44 $_class = 'rcube_' . strtolower($RCI->config['db_backend']);
45 require_once 'include/' . $_class . '.inc';
47 $DB = new $_class($RCI->config['db_dsnw'], '', false);
49 if (!($db_error_msg = $DB->is_error())) {
50 $RCI->pass('DSN (write)');
55 $RCI->fail('DSN (write)', $db_error_msg);
56 echo '<p class="hint">Make sure that the configured database extists and that the user as write privileges<br />';
57 echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>';
58 if ($RCI->config['db_backend'] == 'mdb2')
59 echo '<p class="hint">There are known problems with MDB2 running on PHP 4. Try setting <tt>db_backend</tt> to \'db\' instead</p>';
63 $RCI->fail('DSN (write)', 'not set');
67 $RCI->fail('Config', 'Could not read config files');
70 // initialize db with schema found in /SQL/*
71 if ($db_working && $_POST['initdb']) {
72 if (!($success = $RCI->init_db($DB))) {
74 echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide.
75 Make sure that the configured database extists and that the user as write privileges</p>';
81 $db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}");
83 $RCI->fail('DB Schema', "Database not initialized");
85 echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
88 $RCI->pass('DB Schema');
93 // more database tests
96 $db_write = $DB->query("INSERT INTO {$RCI->config['db_table_cache']} (session_id, cache_key, data, user_id) VALUES (?, ?, ?, 0)", '1234567890abcdef', 'test', 'test');
97 $insert_id = $DB->insert_id($RCI->config['db_sequence_cache']);
99 if ($db_write && $insert_id) {
100 $RCI->pass('DB Write');
101 $DB->query("DELETE FROM {$RCI->config['db_table_cache']} WHERE cache_id=?", $insert_id);
104 $RCI->fail('DB Write', $RCI->get_error());
108 // check timezone settings
109 $tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db';
110 $tz_db = $DB->query($tz_db);
111 $tz_db = $DB->fetch_assoc($tz_db);
112 $tz_db = (int) $tz_db['tz_db'];
113 $tz_local = (int) time();
114 $tz_diff = $tz_local - $tz_db;
116 // sometimes db and web servers are on separate hosts, so allow a 30 minutes delta
117 if (abs($tz_diff) > 1800) {
118 $RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time");
121 $RCI->pass('DB Time');
127 <h3>Test SMTP settings</h3>
130 Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br />
131 Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
135 if ($RCI->getprop('smtp_server')) {
136 $user = $RCI->getprop('smtp_user', '(none)');
137 $pass = $RCI->getprop('smtp_pass', '(none)');
140 $user_field = new textfield(array('name' => '_user'));
141 $user = $user_field->show($_POST['_user']);
144 $pass_field = new passwordfield(array('name' => '_pass'));
145 $pass = $pass_field->show();
148 echo "User: $user<br />";
149 echo "Password: $pass<br />";
152 $from_field = new textfield(array('name' => '_from', 'id' => 'sendmailfrom'));
153 $to_field = new textfield(array('name' => '_to', 'id' => 'sendmailto'));
160 if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) {
162 require_once 'lib/rc_mail_mime.inc';
163 require_once 'include/rcube_smtp.inc';
165 echo '<p>Trying to send email...<br />';
167 if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) &&
168 preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) {
171 'From' => trim($_POST['_from']),
172 'To' => trim($_POST['_to']),
173 'Subject' => 'Test message from RoundCube',
176 $body = 'This is a test to confirm that RoundCube can send email.';
177 $smtp_response = array();
179 // send mail using configured SMTP server
180 if ($RCI->getprop('smtp_server')) {
181 $CONFIG = $RCI->config;
183 if (!empty($_POST['_user']))
184 $CONFIG['smtp_user'] = $_POST['_user'];
185 if (!empty($_POST['_pass']))
186 $CONFIG['smtp_pass'] = $_POST['_pass'];
188 $mail_object = new rc_mail_mime();
189 $send_headers = $mail_object->headers($headers);
191 $status = smtp_mail($headers['From'], $headers['To'],
192 ($foo = $mail_object->txtHeaders($send_headers)),
193 $body, $smtp_response);
196 $header_str = 'From: ' . $headers['From'];
198 if (ini_get('safe_mode'))
199 $status = mail($headers['To'], $headers['Subject'], $body, $header_str);
201 $status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']);
204 $smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details';
208 $RCI->pass('SMTP send');
211 $RCI->fail('SMTP send', join('; ', $smtp_response));
215 $RCI->fail('SMTP send', 'Invalid sender or recipient');
226 <td><label for="sendmailfrom">Sender</label></td>
227 <td><?php echo $from_field->show($_POST['_from']); ?></td>
230 <td><label for="sendmailto">Recipient</label></td>
231 <td><?php echo $to_field->show($_POST['_to']); ?></td>
236 <p><input type="submit" name="sendmail" value="Send test mail" /></p>
239 <h3>Test IMAP configuration</h3>
243 $default_hosts = $RCI->get_hostlist();
244 if (!empty($default_hosts)) {
245 $host_field = new select(array('name' => '_host', 'id' => 'imaphost'));
246 $host_field->add($default_hosts);
249 $host_field = new textfield(array('name' => '_host', 'id' => 'imaphost'));
252 $user_field = new textfield(array('name' => '_user', 'id' => 'imapuser'));
253 $pass_field = new passwordfield(array('name' => '_pass', 'id' => 'imappass'));
260 <td><label for="imaphost">Server</label></td>
261 <td><?php echo $host_field->show($_POST['_host']); ?></td>
265 <td><?php echo $RCI->getprop('default_port'); ?></td>
268 <td><label for="imapuser">Username</label></td>
269 <td><?php echo $user_field->show($_POST['_user']); ?></td>
272 <td><label for="imappass">Password</label></td>
273 <td><?php echo $pass_field->show(); ?></td>
280 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
282 require_once 'include/rcube_imap.inc';
284 echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />';
286 $a_host = parse_url($_POST['_host']);
287 if ($a_host['host']) {
288 $imap_host = $a_host['host'];
289 $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
290 $imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']);
293 $imap_host = trim($_POST['_host']);
294 $imap_port = $RCI->getprop('default_port');
297 $imap = new rcube_imap(null);
298 if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) {
299 $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
303 $RCI->fail('IMAP connect', $RCI->get_error());
309 <p><input type="submit" name="imaptest" value="Check login" /></p>
317 After completing the installation and the final tests please <b>remove</b> the whole
318 installer folder from the document root of the webserver.<br />
321 These files may expose sensitive configuration data like server passwords and encryption keys
322 to the public. Make sure you cannot access this installer from your browser.