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 |
|
bba657
|
6 |
$read_main = is_readable(RCMAIL_CONFIG_DIR.'/main.inc.php'); |
T |
7 |
$read_db = is_readable(RCMAIL_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>"; |
|
72 |
} |
|
73 |
|
354978
|
74 |
?> |
c5042d
|
75 |
|
308f41
|
76 |
<h3>Check if directories are writable</h3> |
T |
77 |
<p>RoundCube may need to write/save files into these directories</p> |
|
78 |
<?php |
|
79 |
|
|
80 |
if ($RCI->configured) { |
|
81 |
$pass = false; |
b77d0d
|
82 |
|
A |
83 |
$dirs[] = $RCI->config['temp_dir']; |
|
84 |
if($RCI->config['log_driver'] != 'syslog') |
|
85 |
$dirs[] = $RCI->config['log_dir']; |
|
86 |
|
|
87 |
foreach ($dirs as $dir) { |
47124c
|
88 |
$dirpath = $dir{0} == '/' ? $dir : INSTALL_PATH . $dir; |
308f41
|
89 |
if (is_writable(realpath($dirpath))) { |
T |
90 |
$RCI->pass($dir); |
|
91 |
$pass = true; |
|
92 |
} |
|
93 |
else { |
|
94 |
$RCI->fail($dir, 'not writeable for the webserver'); |
|
95 |
} |
|
96 |
echo '<br />'; |
|
97 |
} |
|
98 |
|
|
99 |
if (!$pass) |
|
100 |
echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>'; |
|
101 |
} |
|
102 |
else { |
|
103 |
$RCI->fail('Config', 'Could not read config files'); |
|
104 |
} |
|
105 |
|
|
106 |
?> |
|
107 |
|
c5042d
|
108 |
<h3>Check configured database settings</h3> |
T |
109 |
<?php |
|
110 |
|
|
111 |
$db_working = false; |
308f41
|
112 |
if ($RCI->configured) { |
9e8e5f
|
113 |
if (!empty($RCI->config['db_dsnw'])) { |
c5042d
|
114 |
|
9e8e5f
|
115 |
$DB = new rcube_mdb2($RCI->config['db_dsnw'], '', false); |
c5042d
|
116 |
$DB->db_connect('w'); |
T |
117 |
if (!($db_error_msg = $DB->is_error())) { |
|
118 |
$RCI->pass('DSN (write)'); |
190e97
|
119 |
echo '<br />'; |
c5042d
|
120 |
$db_working = true; |
T |
121 |
} |
|
122 |
else { |
190e97
|
123 |
$RCI->fail('DSN (write)', $db_error_msg); |
34eab0
|
124 |
echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />'; |
190e97
|
125 |
echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>'; |
c5042d
|
126 |
} |
T |
127 |
} |
|
128 |
else { |
|
129 |
$RCI->fail('DSN (write)', 'not set'); |
|
130 |
} |
|
131 |
} |
|
132 |
else { |
|
133 |
$RCI->fail('Config', 'Could not read config files'); |
|
134 |
} |
|
135 |
|
|
136 |
// initialize db with schema found in /SQL/* |
|
137 |
if ($db_working && $_POST['initdb']) { |
190e97
|
138 |
if (!($success = $RCI->init_db($DB))) { |
c5042d
|
139 |
$db_working = false; |
190e97
|
140 |
echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide. |
T |
141 |
Make sure that the configured database extists and that the user as write privileges</p>'; |
c5042d
|
142 |
} |
T |
143 |
} |
|
144 |
|
190e97
|
145 |
// test database |
c5042d
|
146 |
if ($db_working) { |
190e97
|
147 |
$db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}"); |
T |
148 |
if (!$db_read) { |
c5042d
|
149 |
$RCI->fail('DB Schema', "Database not initialized"); |
190e97
|
150 |
$db_working = false; |
c5042d
|
151 |
echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>'; |
T |
152 |
} |
|
153 |
else { |
|
154 |
$RCI->pass('DB Schema'); |
|
155 |
} |
|
156 |
echo '<br />'; |
190e97
|
157 |
} |
T |
158 |
|
|
159 |
// more database tests |
|
160 |
if ($db_working) { |
|
161 |
// write test |
50e5ee
|
162 |
$insert_id = md5(uniqid()); |
T |
163 |
$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); |
|
164 |
|
|
165 |
if ($db_write) { |
190e97
|
166 |
$RCI->pass('DB Write'); |
50e5ee
|
167 |
$DB->query("DELETE FROM {$RCI->config['db_table_session']} WHERE sess_id=?", $insert_id); |
190e97
|
168 |
} |
T |
169 |
else { |
|
170 |
$RCI->fail('DB Write', $RCI->get_error()); |
|
171 |
} |
|
172 |
echo '<br />'; |
|
173 |
|
|
174 |
// check timezone settings |
c5042d
|
175 |
$tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db'; |
T |
176 |
$tz_db = $DB->query($tz_db); |
|
177 |
$tz_db = $DB->fetch_assoc($tz_db); |
|
178 |
$tz_db = (int) $tz_db['tz_db']; |
|
179 |
$tz_local = (int) time(); |
|
180 |
$tz_diff = $tz_local - $tz_db; |
|
181 |
|
|
182 |
// sometimes db and web servers are on separate hosts, so allow a 30 minutes delta |
|
183 |
if (abs($tz_diff) > 1800) { |
|
184 |
$RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time"); |
190e97
|
185 |
} |
T |
186 |
else { |
c5042d
|
187 |
$RCI->pass('DB Time'); |
T |
188 |
} |
|
189 |
} |
|
190 |
|
|
191 |
?> |
|
192 |
|
ad43e6
|
193 |
<h3>Test SMTP settings</h3> |
T |
194 |
|
|
195 |
<p> |
|
196 |
Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br /> |
|
197 |
Port: <?php echo $RCI->getprop('smtp_port'); ?><br /> |
fa7539
|
198 |
|
T |
199 |
<?php |
|
200 |
|
|
201 |
if ($RCI->getprop('smtp_server')) { |
|
202 |
$user = $RCI->getprop('smtp_user', '(none)'); |
|
203 |
$pass = $RCI->getprop('smtp_pass', '(none)'); |
|
204 |
|
|
205 |
if ($user == '%u') { |
47124c
|
206 |
$user_field = new html_inputfield(array('name' => '_smtp_user')); |
7635d2
|
207 |
$user = $user_field->show($_POST['_smtp_user']); |
fa7539
|
208 |
} |
T |
209 |
if ($pass == '%p') { |
47124c
|
210 |
$pass_field = new html_passwordfield(array('name' => '_smtp_pass')); |
fa7539
|
211 |
$pass = $pass_field->show(); |
T |
212 |
} |
|
213 |
|
|
214 |
echo "User: $user<br />"; |
|
215 |
echo "Password: $pass<br />"; |
|
216 |
} |
27564f
|
217 |
|
47124c
|
218 |
$from_field = new html_inputfield(array('name' => '_from', 'id' => 'sendmailfrom')); |
T |
219 |
$to_field = new html_inputfield(array('name' => '_to', 'id' => 'sendmailto')); |
fa7539
|
220 |
|
T |
221 |
?> |
ad43e6
|
222 |
</p> |
T |
223 |
|
|
224 |
<?php |
|
225 |
|
|
226 |
if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) { |
|
227 |
|
47124c
|
228 |
require_once 'rcube_smtp.inc'; |
ad43e6
|
229 |
|
T |
230 |
echo '<p>Trying to send email...<br />'; |
|
231 |
|
|
232 |
if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) && |
|
233 |
preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) { |
|
234 |
|
|
235 |
$headers = array( |
7635d2
|
236 |
'From' => trim($_POST['_from']), |
T |
237 |
'To' => trim($_POST['_to']), |
ad43e6
|
238 |
'Subject' => 'Test message from RoundCube', |
T |
239 |
); |
|
240 |
|
|
241 |
$body = 'This is a test to confirm that RoundCube can send email.'; |
|
242 |
$smtp_response = array(); |
fa7539
|
243 |
|
T |
244 |
// send mail using configured SMTP server |
|
245 |
if ($RCI->getprop('smtp_server')) { |
|
246 |
$CONFIG = $RCI->config; |
|
247 |
|
7635d2
|
248 |
if (!empty($_POST['_smtp_user'])) { |
T |
249 |
$CONFIG['smtp_user'] = $_POST['_smtp_user']; |
|
250 |
} |
|
251 |
if (!empty($_POST['_smtp_pass'])) { |
|
252 |
$CONFIG['smtp_pass'] = $_POST['_smtp_pass']; |
|
253 |
} |
|
254 |
|
47124c
|
255 |
$mail_object = new rcube_mail_mime(); |
fa7539
|
256 |
$send_headers = $mail_object->headers($headers); |
T |
257 |
|
|
258 |
$status = smtp_mail($headers['From'], $headers['To'], |
|
259 |
($foo = $mail_object->txtHeaders($send_headers)), |
|
260 |
$body, $smtp_response); |
|
261 |
} |
|
262 |
else { // use mail() |
|
263 |
$header_str = 'From: ' . $headers['From']; |
|
264 |
|
|
265 |
if (ini_get('safe_mode')) |
|
266 |
$status = mail($headers['To'], $headers['Subject'], $body, $header_str); |
|
267 |
else |
|
268 |
$status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']); |
|
269 |
|
|
270 |
if (!$status) |
|
271 |
$smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details'; |
|
272 |
} |
ad43e6
|
273 |
|
T |
274 |
if ($status) { |
|
275 |
$RCI->pass('SMTP send'); |
|
276 |
} |
|
277 |
else { |
|
278 |
$RCI->fail('SMTP send', join('; ', $smtp_response)); |
|
279 |
} |
|
280 |
} |
|
281 |
else { |
|
282 |
$RCI->fail('SMTP send', 'Invalid sender or recipient'); |
|
283 |
} |
|
284 |
} |
|
285 |
|
|
286 |
echo '</p>'; |
|
287 |
|
|
288 |
?> |
|
289 |
|
|
290 |
<table> |
|
291 |
<tbody> |
27564f
|
292 |
<tr> |
T |
293 |
<td><label for="sendmailfrom">Sender</label></td> |
|
294 |
<td><?php echo $from_field->show($_POST['_from']); ?></td> |
|
295 |
</tr> |
|
296 |
<tr> |
|
297 |
<td><label for="sendmailto">Recipient</label></td> |
|
298 |
<td><?php echo $to_field->show($_POST['_to']); ?></td> |
|
299 |
</tr> |
ad43e6
|
300 |
</tbody> |
T |
301 |
</table> |
|
302 |
|
|
303 |
<p><input type="submit" name="sendmail" value="Send test mail" /></p> |
|
304 |
|
|
305 |
|
27564f
|
306 |
<h3>Test IMAP configuration</h3> |
T |
307 |
|
|
308 |
<?php |
|
309 |
|
112c54
|
310 |
$default_hosts = $RCI->get_hostlist(); |
T |
311 |
if (!empty($default_hosts)) { |
47124c
|
312 |
$host_field = new html_select(array('name' => '_host', 'id' => 'imaphost')); |
112c54
|
313 |
$host_field->add($default_hosts); |
T |
314 |
} |
|
315 |
else { |
47124c
|
316 |
$host_field = new html_inputfield(array('name' => '_host', 'id' => 'imaphost')); |
112c54
|
317 |
} |
27564f
|
318 |
|
47124c
|
319 |
$user_field = new html_inputfield(array('name' => '_user', 'id' => 'imapuser')); |
T |
320 |
$pass_field = new html_passwordfield(array('name' => '_pass', 'id' => 'imappass')); |
27564f
|
321 |
|
T |
322 |
?> |
|
323 |
|
|
324 |
<table> |
|
325 |
<tbody> |
|
326 |
<tr> |
|
327 |
<td><label for="imaphost">Server</label></td> |
112c54
|
328 |
<td><?php echo $host_field->show($_POST['_host']); ?></td> |
27564f
|
329 |
</tr> |
T |
330 |
<tr> |
|
331 |
<td>Port</td> |
|
332 |
<td><?php echo $RCI->getprop('default_port'); ?></td> |
|
333 |
</tr> |
|
334 |
<tr> |
|
335 |
<td><label for="imapuser">Username</label></td> |
|
336 |
<td><?php echo $user_field->show($_POST['_user']); ?></td> |
|
337 |
</tr> |
|
338 |
<tr> |
|
339 |
<td><label for="imappass">Password</label></td> |
|
340 |
<td><?php echo $pass_field->show(); ?></td> |
|
341 |
</tr> |
|
342 |
</tbody> |
|
343 |
</table> |
|
344 |
|
|
345 |
<?php |
|
346 |
|
|
347 |
if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) { |
|
348 |
|
|
349 |
echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />'; |
|
350 |
|
|
351 |
$a_host = parse_url($_POST['_host']); |
|
352 |
if ($a_host['host']) { |
|
353 |
$imap_host = $a_host['host']; |
|
354 |
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; |
|
355 |
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']); |
|
356 |
} |
|
357 |
else { |
|
358 |
$imap_host = trim($_POST['_host']); |
|
359 |
$imap_port = $RCI->getprop('default_port'); |
|
360 |
} |
|
361 |
|
|
362 |
$imap = new rcube_imap(null); |
|
363 |
if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) { |
|
364 |
$RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no')); |
|
365 |
$imap->close(); |
|
366 |
} |
|
367 |
else { |
|
368 |
$RCI->fail('IMAP connect', $RCI->get_error()); |
|
369 |
} |
|
370 |
} |
|
371 |
|
|
372 |
?> |
|
373 |
|
|
374 |
<p><input type="submit" name="imaptest" value="Check login" /></p> |
c5042d
|
375 |
|
354978
|
376 |
</form> |
T |
377 |
|
27564f
|
378 |
<hr /> |
T |
379 |
|
354978
|
380 |
<p class="warning"> |
T |
381 |
|
|
382 |
After completing the installation and the final tests please <b>remove</b> the whole |
|
383 |
installer folder from the document root of the webserver.<br /> |
|
384 |
<br /> |
|
385 |
|
|
386 |
These files may expose sensitive configuration data like server passwords and encryption keys |
|
387 |
to the public. Make sure you cannot access this installer from your browser. |
|
388 |
|
|
389 |
</p> |