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