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