0
|
1 <?php
|
|
2
|
|
3 if (!class_exists('rcmail_install', false) || !is_object($RCI)) {
|
|
4 die("Not allowed! Please open installer/index.php instead.");
|
|
5 }
|
|
6
|
|
7 ?>
|
|
8 <form action="index.php?_step=3" method="post">
|
|
9
|
|
10 <h3>Check config file</h3>
|
|
11 <?php
|
|
12
|
|
13 if ($read_config = is_readable(RCUBE_CONFIG_DIR . 'defaults.inc.php')) {
|
|
14 $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'defaults.inc.php');
|
|
15 if (!empty($config)) {
|
|
16 $RCI->pass('defaults.inc.php');
|
|
17 }
|
|
18 else {
|
|
19 $RCI->fail('defaults.inc.php', 'Syntax error');
|
|
20 }
|
|
21 }
|
|
22 else {
|
|
23 $RCI->fail('defaults.inc.php', 'Unable to read default config file?');
|
|
24 }
|
|
25 echo '<br />';
|
|
26
|
|
27 if ($read_config = is_readable(RCUBE_CONFIG_DIR . 'config.inc.php')) {
|
|
28 $config = $RCI->load_config_file(RCUBE_CONFIG_DIR . 'config.inc.php');
|
|
29 if (!empty($config)) {
|
|
30 $RCI->pass('config.inc.php');
|
|
31 }
|
|
32 else {
|
|
33 $RCI->fail('config.inc.php', 'Syntax error');
|
|
34 }
|
|
35 }
|
|
36 else {
|
|
37 $RCI->fail('config.inc.php', 'Unable to read file. Did you create the config file?');
|
|
38 }
|
|
39 echo '<br />';
|
|
40
|
|
41
|
|
42 if ($RCI->configured && ($messages = $RCI->check_config())) {
|
|
43 if (is_array($messages['replaced'])) {
|
|
44 echo '<h3 class="warning">Replaced config options</h3>';
|
|
45 echo '<p class="hint">The following config options have been replaced or renamed. ';
|
|
46 echo 'Please update them accordingly in your config files.</p>';
|
|
47
|
|
48 echo '<ul class="configwarings">';
|
|
49 foreach ($messages['replaced'] as $msg) {
|
|
50 echo html::tag('li', null, html::span('propname', $msg['prop']) .
|
|
51 ' was replaced by ' . html::span('propname', $msg['replacement']));
|
|
52 }
|
|
53 echo '</ul>';
|
|
54 }
|
|
55
|
|
56 if (is_array($messages['obsolete'])) {
|
|
57 echo '<h3>Obsolete config options</h3>';
|
|
58 echo '<p class="hint">You still have some obsolete or inexistent properties set. This isn\'t a problem but should be noticed.</p>';
|
|
59
|
|
60 echo '<ul class="configwarings">';
|
|
61 foreach ($messages['obsolete'] as $msg) {
|
|
62 echo html::tag('li', null, html::span('propname', $msg['prop']) . ($msg['name'] ? ': ' . $msg['name'] : ''));
|
|
63 }
|
|
64 echo '</ul>';
|
|
65 }
|
|
66
|
|
67 echo '<p class="suggestion">OK, lazy people can download the updated config file here: ';
|
|
68 echo html::a(array('href' => './?_mergeconfig=1'), 'config.inc.php') . ' ';
|
|
69 echo "</p>";
|
|
70
|
|
71 if (is_array($messages['dependencies'])) {
|
|
72 echo '<h3 class="warning">Dependency check failed</h3>';
|
|
73 echo '<p class="hint">Some of your configuration settings require other options to be configured or additional PHP modules to be installed</p>';
|
|
74
|
|
75 echo '<ul class="configwarings">';
|
|
76 foreach ($messages['dependencies'] as $msg) {
|
|
77 echo html::tag('li', null, html::span('propname', $msg['prop']) . ': ' . $msg['explain']);
|
|
78 }
|
|
79 echo '</ul>';
|
|
80 }
|
|
81 }
|
|
82
|
|
83 ?>
|
|
84
|
|
85 <h3>Check if directories are writable</h3>
|
|
86 <p>Roundcube may need to write/save files into these directories</p>
|
|
87 <?php
|
|
88
|
|
89 $dirs[] = $RCI->config['temp_dir'] ? $RCI->config['temp_dir'] : 'temp';
|
|
90 if ($RCI->config['log_driver'] != 'syslog')
|
|
91 $dirs[] = $RCI->config['log_dir'] ? $RCI->config['log_dir'] : 'logs';
|
|
92
|
|
93 foreach ($dirs as $dir) {
|
|
94 $dirpath = rcube_utils::is_absolute_path($dir) ? $dir : INSTALL_PATH . $dir;
|
|
95 if (is_writable(realpath($dirpath))) {
|
|
96 $RCI->pass($dir);
|
|
97 $pass = true;
|
|
98 }
|
|
99 else {
|
|
100 $RCI->fail($dir, 'not writeable for the webserver');
|
|
101 }
|
|
102 echo '<br />';
|
|
103 }
|
|
104
|
|
105 if (!$pass) {
|
|
106 echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>';
|
|
107 }
|
|
108
|
|
109 ?>
|
|
110
|
|
111 <h3>Check DB config</h3>
|
|
112 <?php
|
|
113
|
|
114 $db_working = false;
|
|
115 if ($RCI->configured) {
|
|
116 if (!empty($RCI->config['db_dsnw'])) {
|
|
117 $DB = rcube_db::factory($RCI->config['db_dsnw'], '', false);
|
|
118 $DB->set_debug((bool)$RCI->config['sql_debug']);
|
|
119 $DB->db_connect('w');
|
|
120
|
|
121 if (!($db_error_msg = $DB->is_error())) {
|
|
122 $RCI->pass('DSN (write)');
|
|
123 echo '<br />';
|
|
124 $db_working = true;
|
|
125 }
|
|
126 else {
|
|
127 $RCI->fail('DSN (write)', $db_error_msg);
|
|
128 echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />';
|
|
129 echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>';
|
|
130 }
|
|
131 }
|
|
132 else {
|
|
133 $RCI->fail('DSN (write)', 'not set');
|
|
134 }
|
|
135 }
|
|
136 else {
|
|
137 $RCI->fail('DSN (write)', 'Could not read config file');
|
|
138 }
|
|
139
|
|
140 // initialize db with schema found in /SQL/*
|
|
141 if ($db_working && $_POST['initdb']) {
|
|
142 if (!($success = $RCI->init_db($DB))) {
|
|
143 $db_working = false;
|
|
144 echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide.
|
|
145 Make sure that the configured database extists and that the user as write privileges</p>';
|
|
146 }
|
|
147 }
|
|
148
|
|
149 else if ($db_working && $_POST['updatedb']) {
|
|
150 if (!($success = $RCI->update_db($_POST['version']))) {
|
|
151 echo '<p class="warning">Database schema update failed.</p>';
|
|
152 }
|
|
153 }
|
|
154
|
|
155 // test database
|
|
156 if ($db_working) {
|
|
157 $db_read = $DB->query("SELECT count(*) FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'users'));
|
|
158 if ($DB->is_error()) {
|
|
159 $RCI->fail('DB Schema', "Database not initialized");
|
|
160 echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>';
|
|
161 $db_working = false;
|
|
162 }
|
|
163 else if ($err = $RCI->db_schema_check($DB, $update = !empty($_POST['updatedb']))) {
|
|
164 $RCI->fail('DB Schema', "Database schema differs");
|
|
165 echo '<ul style="margin:0"><li>' . join("</li>\n<li>", $err) . "</li></ul>";
|
|
166 $select = $RCI->versions_select(array('name' => 'version'));
|
|
167 $select->add('0.9 or newer', '');
|
|
168 echo '<p class="suggestion">You should run the update queries to get the schema fixed.<br/><br/>Version to update from: ' . $select->show() . ' <input type="submit" name="updatedb" value="Update" /></p>';
|
|
169 $db_working = false;
|
|
170 }
|
|
171 else {
|
|
172 $RCI->pass('DB Schema');
|
|
173 echo '<br />';
|
|
174 }
|
|
175 }
|
|
176
|
|
177 // more database tests
|
|
178 if ($db_working) {
|
|
179 // write test
|
|
180 $insert_id = md5(uniqid());
|
|
181 $db_write = $DB->query("INSERT INTO " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session')
|
8
|
182 . " (`sess_id`, `changed`, `ip`, `vars`) VALUES (?, ".$DB->now().", '127.0.0.1', 'foo')", $insert_id);
|
0
|
183
|
|
184 if ($db_write) {
|
|
185 $RCI->pass('DB Write');
|
|
186 $DB->query("DELETE FROM " . $DB->quote_identifier($RCI->config['db_prefix'] . 'session')
|
|
187 . " WHERE `sess_id` = ?", $insert_id);
|
|
188 }
|
|
189 else {
|
|
190 $RCI->fail('DB Write', $RCI->get_error());
|
|
191 }
|
|
192 echo '<br />';
|
|
193
|
|
194 // check timezone settings
|
|
195 $tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db';
|
|
196 $tz_db = $DB->query($tz_db);
|
|
197 $tz_db = $DB->fetch_assoc($tz_db);
|
|
198 $tz_db = (int) $tz_db['tz_db'];
|
|
199 $tz_local = (int) time();
|
|
200 $tz_diff = $tz_local - $tz_db;
|
|
201
|
|
202 // sometimes db and web servers are on separate hosts, so allow a 30 minutes delta
|
|
203 if (abs($tz_diff) > 1800) {
|
|
204 $RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time");
|
|
205 }
|
|
206 else {
|
|
207 $RCI->pass('DB Time');
|
|
208 }
|
|
209 }
|
|
210
|
|
211 ?>
|
|
212
|
|
213 <h3>Test filetype detection</h3>
|
|
214
|
|
215 <?php
|
|
216
|
|
217 if ($errors = $RCI->check_mime_detection()) {
|
|
218 $RCI->fail('Fileinfo/mime_content_type configuration');
|
|
219 if (!empty($RCI->config['mime_magic'])) {
|
|
220 echo '<p class="hint">Try setting the <tt>mime_magic</tt> config option to <tt>null</tt>.</p>';
|
|
221 }
|
|
222 else {
|
|
223 echo '<p class="hint">Check the <a href="http://www.php.net/manual/en/function.finfo-open.php">Fileinfo functions</a> of your PHP installation.<br/>';
|
|
224 echo 'The path to the magic.mime file can be set using the <tt>mime_magic</tt> config option in Roundcube.</p>';
|
|
225 }
|
|
226 }
|
|
227 else {
|
|
228 $RCI->pass('Fileinfo/mime_content_type configuration');
|
|
229 echo "<br/>";
|
|
230 }
|
|
231
|
|
232
|
|
233 if ($errors = $RCI->check_mime_extensions()) {
|
|
234 $RCI->fail('Mimetype to file extension mapping');
|
|
235 echo '<p class="hint">Please set a valid path to your webserver\'s mime.types file to the <tt>mime_types</tt> config option.<br/>';
|
|
236 echo 'If you can\'t find such a file, download it from <a href="http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types">svn.apache.org</a>.</p>';
|
|
237 }
|
|
238 else {
|
|
239 $RCI->pass('Mimetype to file extension mapping');
|
|
240 echo "<br/>";
|
|
241 }
|
|
242
|
|
243 ?>
|
|
244
|
|
245
|
|
246 <h3>Test SMTP config</h3>
|
|
247
|
|
248 <p>
|
8
|
249 Server: <?php echo rcube_utils::parse_host($RCI->getprop('smtp_server', 'localhost')); ?><br />
|
0
|
250 Port: <?php echo $RCI->getprop('smtp_port'); ?><br />
|
|
251
|
|
252 <?php
|
|
253
|
|
254 if ($RCI->getprop('smtp_server')) {
|
|
255 $user = $RCI->getprop('smtp_user', '(none)');
|
|
256 $pass = $RCI->getprop('smtp_pass', '(none)');
|
8
|
257
|
0
|
258 if ($user == '%u') {
|
|
259 $user_field = new html_inputfield(array('name' => '_smtp_user'));
|
|
260 $user = $user_field->show($_POST['_smtp_user']);
|
|
261 }
|
|
262 if ($pass == '%p') {
|
|
263 $pass_field = new html_passwordfield(array('name' => '_smtp_pass'));
|
|
264 $pass = $pass_field->show();
|
|
265 }
|
8
|
266
|
0
|
267 echo "User: $user<br />";
|
|
268 echo "Password: $pass<br />";
|
|
269 }
|
|
270
|
|
271 $from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom'));
|
|
272 $to_field = new html_inputfield(array('name' => '_to', 'id' => 'sendmailto'));
|
|
273
|
|
274 ?>
|
|
275 </p>
|
|
276
|
|
277 <?php
|
|
278
|
|
279 if (isset($_POST['sendmail'])) {
|
|
280
|
|
281 echo '<p>Trying to send email...<br />';
|
|
282
|
|
283 $from = idn_to_ascii(trim($_POST['_from']));
|
|
284 $to = idn_to_ascii(trim($_POST['_to']));
|
|
285
|
|
286 if (preg_match('/^' . $RCI->email_pattern . '$/i', $from) &&
|
|
287 preg_match('/^' . $RCI->email_pattern . '$/i', $to)
|
|
288 ) {
|
|
289 $headers = array(
|
|
290 'From' => $from,
|
|
291 'To' => $to,
|
|
292 'Subject' => 'Test message from Roundcube',
|
|
293 );
|
|
294
|
|
295 $body = 'This is a test to confirm that Roundcube can send email.';
|
|
296
|
|
297 // send mail using configured SMTP server
|
8
|
298 $CONFIG = $RCI->config;
|
0
|
299
|
8
|
300 if (!empty($_POST['_smtp_user'])) {
|
|
301 $CONFIG['smtp_user'] = $_POST['_smtp_user'];
|
|
302 }
|
|
303 if (!empty($_POST['_smtp_pass'])) {
|
|
304 $CONFIG['smtp_pass'] = $_POST['_smtp_pass'];
|
|
305 }
|
0
|
306
|
8
|
307 $mail_object = new Mail_mime();
|
|
308 $send_headers = $mail_object->headers($headers);
|
|
309 $head = $mail_object->txtHeaders($send_headers);
|
0
|
310
|
8
|
311 $SMTP = new rcube_smtp();
|
|
312 $SMTP->connect(rcube_utils::parse_host($RCI->getprop('smtp_server')),
|
|
313 $RCI->getprop('smtp_port'), $CONFIG['smtp_user'], $CONFIG['smtp_pass']);
|
|
314
|
|
315 $status = $SMTP->send_mail($headers['From'], $headers['To'], $head, $body);
|
|
316 $smtp_response = $SMTP->get_response();
|
0
|
317
|
|
318 if ($status) {
|
|
319 $RCI->pass('SMTP send');
|
|
320 }
|
|
321 else {
|
|
322 $RCI->fail('SMTP send', join('; ', $smtp_response));
|
|
323 }
|
|
324 }
|
|
325 else {
|
|
326 $RCI->fail('SMTP send', 'Invalid sender or recipient');
|
|
327 }
|
8
|
328
|
0
|
329 echo '</p>';
|
|
330 }
|
|
331
|
|
332 ?>
|
|
333
|
|
334 <table>
|
|
335 <tbody>
|
|
336 <tr>
|
|
337 <td><label for="sendmailfrom">Sender</label></td>
|
|
338 <td><?php echo $from_field->show($_POST['_from']); ?></td>
|
|
339 </tr>
|
|
340 <tr>
|
|
341 <td><label for="sendmailto">Recipient</label></td>
|
|
342 <td><?php echo $to_field->show($_POST['_to']); ?></td>
|
|
343 </tr>
|
|
344 </tbody>
|
|
345 </table>
|
|
346
|
|
347 <p><input type="submit" name="sendmail" value="Send test mail" /></p>
|
|
348
|
|
349
|
|
350 <h3>Test IMAP config</h3>
|
|
351
|
|
352 <?php
|
|
353
|
|
354 $default_hosts = $RCI->get_hostlist();
|
|
355 if (!empty($default_hosts)) {
|
|
356 $host_field = new html_select(array('name' => '_host', 'id' => 'imaphost'));
|
|
357 $host_field->add($default_hosts);
|
|
358 }
|
|
359 else {
|
|
360 $host_field = new html_inputfield(array('name' => '_host', 'id' => 'imaphost'));
|
|
361 }
|
|
362
|
|
363 $user_field = new html_inputfield(array('name' => '_user', 'id' => 'imapuser'));
|
|
364 $pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass'));
|
|
365
|
|
366 ?>
|
|
367
|
|
368 <table>
|
|
369 <tbody>
|
|
370 <tr>
|
|
371 <td><label for="imaphost">Server</label></td>
|
|
372 <td><?php echo $host_field->show($_POST['_host']); ?></td>
|
|
373 </tr>
|
|
374 <tr>
|
|
375 <td>Port</td>
|
|
376 <td><?php echo $RCI->getprop('default_port'); ?></td>
|
|
377 </tr>
|
|
378 <tr>
|
|
379 <td><label for="imapuser">Username</label></td>
|
|
380 <td><?php echo $user_field->show($_POST['_user']); ?></td>
|
|
381 </tr>
|
|
382 <tr>
|
|
383 <td><label for="imappass">Password</label></td>
|
|
384 <td><?php echo $pass_field->show(); ?></td>
|
|
385 </tr>
|
|
386 </tbody>
|
|
387 </table>
|
|
388
|
|
389 <?php
|
|
390
|
|
391 if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) {
|
|
392
|
8
|
393 echo '<p>Connecting to ' . rcube::Q($_POST['_host']) . '...<br />';
|
0
|
394
|
|
395 $imap_host = trim($_POST['_host']);
|
|
396 $imap_port = $RCI->getprop('default_port');
|
|
397 $a_host = parse_url($imap_host);
|
|
398
|
|
399 if ($a_host['host']) {
|
|
400 $imap_host = $a_host['host'];
|
|
401 $imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null;
|
|
402 if (isset($a_host['port']))
|
|
403 $imap_port = $a_host['port'];
|
|
404 else if ($imap_ssl && $imap_ssl != 'tls' && (!$imap_port || $imap_port == 143))
|
|
405 $imap_port = 993;
|
|
406 }
|
|
407
|
|
408 $imap_host = idn_to_ascii($imap_host);
|
|
409 $imap_user = idn_to_ascii($_POST['_user']);
|
|
410
|
|
411 $imap = new rcube_imap(null);
|
|
412 $imap->set_options(array(
|
|
413 'auth_type' => $RCI->getprop('imap_auth_type'),
|
|
414 'debug' => $RCI->getprop('imap_debug'),
|
|
415 'socket_options' => $RCI->getprop('imap_conn_options'),
|
|
416 ));
|
|
417
|
|
418 if ($imap->connect($imap_host, $imap_user, $_POST['_pass'], $imap_port, $imap_ssl)) {
|
|
419 $RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no'));
|
|
420 $imap->close();
|
|
421 }
|
|
422 else {
|
|
423 $RCI->fail('IMAP connect', $RCI->get_error());
|
|
424 }
|
|
425 }
|
|
426
|
|
427 ?>
|
|
428
|
|
429 <p><input type="submit" name="imaptest" value="Check login" /></p>
|
|
430
|
|
431 </form>
|
|
432
|
|
433 <hr />
|
|
434
|
|
435 <p class="warning">
|
|
436
|
|
437 After completing the installation and the final tests please <b>remove</b> the whole
|
|
438 installer folder from the document root of the webserver or make sure that
|
|
439 <tt>enable_installer</tt> option in <tt>config.inc.php</tt> is disabled.<br />
|
|
440 <br />
|
|
441
|
|
442 These files may expose sensitive configuration data like server passwords and encryption keys
|
|
443 to the public. Make sure you cannot access this installer from your browser.
|
|
444
|
|
445 </p>
|