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 |
|
fa7539
|
6 |
require_once 'include/rcube_html.inc'; |
T |
7 |
|
c5042d
|
8 |
$read_main = is_readable('../config/main.inc.php'); |
T |
9 |
$read_db = is_readable('../config/db.inc.php'); |
|
10 |
|
|
11 |
if ($read_main && !empty($RCI->config)) { |
|
12 |
$RCI->pass('main.inc.php'); |
|
13 |
} |
|
14 |
else if ($read_main) { |
|
15 |
$RCI->fail('main.inc.php', 'Syntax error'); |
|
16 |
} |
|
17 |
else if (!$read_main) { |
|
18 |
$RCI->fail('main.inc.php', 'Unable to read file. Did you create the config files?'); |
|
19 |
} |
|
20 |
echo '<br />'; |
|
21 |
|
|
22 |
if ($read_db && !empty($RCI->config['db_table_users'])) { |
|
23 |
$RCI->pass('db.inc.php'); |
|
24 |
} |
|
25 |
else if ($read_db) { |
|
26 |
$RCI->fail('db.inc.php', 'Syntax error'); |
|
27 |
} |
|
28 |
else if (!$read_db) { |
|
29 |
$RCI->fail('db.inc.php', 'Unable to read file. Did you create the config files?'); |
|
30 |
} |
354978
|
31 |
|
T |
32 |
?> |
c5042d
|
33 |
|
308f41
|
34 |
<h3>Check if directories are writable</h3> |
T |
35 |
<p>RoundCube may need to write/save files into these directories</p> |
|
36 |
<?php |
|
37 |
|
|
38 |
if ($RCI->configured) { |
|
39 |
$pass = false; |
|
40 |
foreach (array($RCI->config['temp_dir'],$RCI->config['log_dir']) as $dir) { |
|
41 |
$dirpath = $dir{0} == '/' ? $dir : $docroot . '/' . $dir; |
|
42 |
if (is_writable(realpath($dirpath))) { |
|
43 |
$RCI->pass($dir); |
|
44 |
$pass = true; |
|
45 |
} |
|
46 |
else { |
|
47 |
$RCI->fail($dir, 'not writeable for the webserver'); |
|
48 |
} |
|
49 |
echo '<br />'; |
|
50 |
} |
|
51 |
|
|
52 |
if (!$pass) |
|
53 |
echo '<p class="hint">Use <tt>chmod</tt> or <tt>chown</tt> to grant write privileges to the webserver</p>'; |
|
54 |
} |
|
55 |
else { |
|
56 |
$RCI->fail('Config', 'Could not read config files'); |
|
57 |
} |
|
58 |
|
|
59 |
?> |
|
60 |
|
c5042d
|
61 |
<h3>Check configured database settings</h3> |
T |
62 |
<?php |
|
63 |
|
|
64 |
$db_working = false; |
308f41
|
65 |
if ($RCI->configured) { |
c5042d
|
66 |
if (!empty($RCI->config['db_backend']) && !empty($RCI->config['db_dsnw'])) { |
T |
67 |
|
|
68 |
echo 'Backend: '; |
|
69 |
echo 'PEAR::' . strtoupper($RCI->config['db_backend']) . '<br />'; |
|
70 |
|
|
71 |
$_class = 'rcube_' . strtolower($RCI->config['db_backend']); |
|
72 |
require_once 'include/' . $_class . '.inc'; |
|
73 |
|
|
74 |
$DB = new $_class($RCI->config['db_dsnw'], '', false); |
|
75 |
$DB->db_connect('w'); |
|
76 |
if (!($db_error_msg = $DB->is_error())) { |
|
77 |
$RCI->pass('DSN (write)'); |
190e97
|
78 |
echo '<br />'; |
c5042d
|
79 |
$db_working = true; |
T |
80 |
} |
|
81 |
else { |
190e97
|
82 |
$RCI->fail('DSN (write)', $db_error_msg); |
34eab0
|
83 |
echo '<p class="hint">Make sure that the configured database exists and that the user has write privileges<br />'; |
190e97
|
84 |
echo 'DSN: ' . $RCI->config['db_dsnw'] . '</p>'; |
807d17
|
85 |
if ($RCI->config['db_backend'] == 'mdb2') |
T |
86 |
echo '<p class="hint">There are known problems with MDB2 running on PHP 4. Try setting <tt>db_backend</tt> to \'db\' instead</p>'; |
c5042d
|
87 |
} |
T |
88 |
} |
|
89 |
else { |
|
90 |
$RCI->fail('DSN (write)', 'not set'); |
|
91 |
} |
|
92 |
} |
|
93 |
else { |
|
94 |
$RCI->fail('Config', 'Could not read config files'); |
|
95 |
} |
|
96 |
|
|
97 |
// initialize db with schema found in /SQL/* |
|
98 |
if ($db_working && $_POST['initdb']) { |
190e97
|
99 |
if (!($success = $RCI->init_db($DB))) { |
c5042d
|
100 |
$db_working = false; |
190e97
|
101 |
echo '<p class="warning">Please try to inizialize the database manually as described in the INSTALL guide. |
T |
102 |
Make sure that the configured database extists and that the user as write privileges</p>'; |
c5042d
|
103 |
} |
T |
104 |
} |
|
105 |
|
190e97
|
106 |
// test database |
c5042d
|
107 |
if ($db_working) { |
190e97
|
108 |
$db_read = $DB->query("SELECT count(*) FROM {$RCI->config['db_table_users']}"); |
T |
109 |
if (!$db_read) { |
c5042d
|
110 |
$RCI->fail('DB Schema', "Database not initialized"); |
190e97
|
111 |
$db_working = false; |
c5042d
|
112 |
echo '<p><input type="submit" name="initdb" value="Initialize database" /></p>'; |
T |
113 |
} |
|
114 |
else { |
|
115 |
$RCI->pass('DB Schema'); |
|
116 |
} |
|
117 |
echo '<br />'; |
190e97
|
118 |
} |
T |
119 |
|
|
120 |
// more database tests |
|
121 |
if ($db_working) { |
|
122 |
// write test |
|
123 |
$db_write = $DB->query("INSERT INTO {$RCI->config['db_table_cache']} (session_id, cache_key, data, user_id) VALUES (?, ?, ?, 0)", '1234567890abcdef', 'test', 'test'); |
|
124 |
$insert_id = $DB->insert_id($RCI->config['db_sequence_cache']); |
c5042d
|
125 |
|
190e97
|
126 |
if ($db_write && $insert_id) { |
T |
127 |
$RCI->pass('DB Write'); |
|
128 |
$DB->query("DELETE FROM {$RCI->config['db_table_cache']} WHERE cache_id=?", $insert_id); |
|
129 |
} |
|
130 |
else { |
|
131 |
$RCI->fail('DB Write', $RCI->get_error()); |
|
132 |
} |
|
133 |
echo '<br />'; |
|
134 |
|
|
135 |
// check timezone settings |
c5042d
|
136 |
$tz_db = 'SELECT ' . $DB->unixtimestamp($DB->now()) . ' AS tz_db'; |
T |
137 |
$tz_db = $DB->query($tz_db); |
|
138 |
$tz_db = $DB->fetch_assoc($tz_db); |
|
139 |
$tz_db = (int) $tz_db['tz_db']; |
|
140 |
$tz_local = (int) time(); |
|
141 |
$tz_diff = $tz_local - $tz_db; |
|
142 |
|
|
143 |
// sometimes db and web servers are on separate hosts, so allow a 30 minutes delta |
|
144 |
if (abs($tz_diff) > 1800) { |
|
145 |
$RCI->fail('DB Time', "Database time differs {$td_ziff}s from PHP time"); |
190e97
|
146 |
} |
T |
147 |
else { |
c5042d
|
148 |
$RCI->pass('DB Time'); |
T |
149 |
} |
|
150 |
} |
|
151 |
|
|
152 |
?> |
|
153 |
|
ad43e6
|
154 |
<h3>Test SMTP settings</h3> |
T |
155 |
|
|
156 |
<p> |
|
157 |
Server: <?php echo $RCI->getprop('smtp_server', 'PHP mail()'); ?><br /> |
|
158 |
Port: <?php echo $RCI->getprop('smtp_port'); ?><br /> |
fa7539
|
159 |
|
T |
160 |
<?php |
|
161 |
|
|
162 |
if ($RCI->getprop('smtp_server')) { |
|
163 |
$user = $RCI->getprop('smtp_user', '(none)'); |
|
164 |
$pass = $RCI->getprop('smtp_pass', '(none)'); |
|
165 |
|
|
166 |
if ($user == '%u') { |
7635d2
|
167 |
$user_field = new textfield(array('name' => '_smtp_user')); |
T |
168 |
$user = $user_field->show($_POST['_smtp_user']); |
fa7539
|
169 |
} |
T |
170 |
if ($pass == '%p') { |
7635d2
|
171 |
$pass_field = new passwordfield(array('name' => '_smtp_pass')); |
fa7539
|
172 |
$pass = $pass_field->show(); |
T |
173 |
} |
|
174 |
|
|
175 |
echo "User: $user<br />"; |
|
176 |
echo "Password: $pass<br />"; |
|
177 |
} |
27564f
|
178 |
|
T |
179 |
$from_field = new textfield(array('name' => '_from', 'id' => 'sendmailfrom')); |
|
180 |
$to_field = new textfield(array('name' => '_to', 'id' => 'sendmailto')); |
fa7539
|
181 |
|
T |
182 |
?> |
ad43e6
|
183 |
</p> |
T |
184 |
|
|
185 |
<?php |
|
186 |
|
|
187 |
if (isset($_POST['sendmail']) && !empty($_POST['_from']) && !empty($_POST['_to'])) { |
|
188 |
|
|
189 |
require_once 'lib/rc_mail_mime.inc'; |
|
190 |
require_once 'include/rcube_smtp.inc'; |
|
191 |
|
|
192 |
echo '<p>Trying to send email...<br />'; |
|
193 |
|
|
194 |
if (preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_from'])) && |
|
195 |
preg_match('/^' . $RCI->email_pattern . '$/i', trim($_POST['_to']))) { |
|
196 |
|
|
197 |
$headers = array( |
7635d2
|
198 |
'From' => trim($_POST['_from']), |
T |
199 |
'To' => trim($_POST['_to']), |
ad43e6
|
200 |
'Subject' => 'Test message from RoundCube', |
T |
201 |
); |
|
202 |
|
|
203 |
$body = 'This is a test to confirm that RoundCube can send email.'; |
|
204 |
$smtp_response = array(); |
fa7539
|
205 |
|
T |
206 |
// send mail using configured SMTP server |
|
207 |
if ($RCI->getprop('smtp_server')) { |
|
208 |
$CONFIG = $RCI->config; |
|
209 |
|
7635d2
|
210 |
if (!empty($_POST['_smtp_user'])) { |
T |
211 |
$CONFIG['smtp_user'] = $_POST['_smtp_user']; |
|
212 |
} |
|
213 |
if (!empty($_POST['_smtp_pass'])) { |
|
214 |
$CONFIG['smtp_pass'] = $_POST['_smtp_pass']; |
|
215 |
} |
|
216 |
|
fa7539
|
217 |
$mail_object = new rc_mail_mime(); |
T |
218 |
$send_headers = $mail_object->headers($headers); |
|
219 |
|
|
220 |
$status = smtp_mail($headers['From'], $headers['To'], |
|
221 |
($foo = $mail_object->txtHeaders($send_headers)), |
|
222 |
$body, $smtp_response); |
|
223 |
} |
|
224 |
else { // use mail() |
|
225 |
$header_str = 'From: ' . $headers['From']; |
|
226 |
|
|
227 |
if (ini_get('safe_mode')) |
|
228 |
$status = mail($headers['To'], $headers['Subject'], $body, $header_str); |
|
229 |
else |
|
230 |
$status = mail($headers['To'], $headers['Subject'], $body, $header_str, '-f'.$headers['From']); |
|
231 |
|
|
232 |
if (!$status) |
|
233 |
$smtp_response[] = 'Mail delivery with mail() failed. Check your error logs for details'; |
|
234 |
} |
ad43e6
|
235 |
|
T |
236 |
if ($status) { |
|
237 |
$RCI->pass('SMTP send'); |
|
238 |
} |
|
239 |
else { |
|
240 |
$RCI->fail('SMTP send', join('; ', $smtp_response)); |
|
241 |
} |
|
242 |
} |
|
243 |
else { |
|
244 |
$RCI->fail('SMTP send', 'Invalid sender or recipient'); |
|
245 |
} |
|
246 |
} |
|
247 |
|
|
248 |
echo '</p>'; |
|
249 |
|
|
250 |
?> |
|
251 |
|
|
252 |
<table> |
|
253 |
<tbody> |
27564f
|
254 |
<tr> |
T |
255 |
<td><label for="sendmailfrom">Sender</label></td> |
|
256 |
<td><?php echo $from_field->show($_POST['_from']); ?></td> |
|
257 |
</tr> |
|
258 |
<tr> |
|
259 |
<td><label for="sendmailto">Recipient</label></td> |
|
260 |
<td><?php echo $to_field->show($_POST['_to']); ?></td> |
|
261 |
</tr> |
ad43e6
|
262 |
</tbody> |
T |
263 |
</table> |
|
264 |
|
|
265 |
<p><input type="submit" name="sendmail" value="Send test mail" /></p> |
|
266 |
|
|
267 |
|
27564f
|
268 |
<h3>Test IMAP configuration</h3> |
T |
269 |
|
|
270 |
<?php |
|
271 |
|
112c54
|
272 |
$default_hosts = $RCI->get_hostlist(); |
T |
273 |
if (!empty($default_hosts)) { |
|
274 |
$host_field = new select(array('name' => '_host', 'id' => 'imaphost')); |
|
275 |
$host_field->add($default_hosts); |
|
276 |
} |
|
277 |
else { |
|
278 |
$host_field = new textfield(array('name' => '_host', 'id' => 'imaphost')); |
|
279 |
} |
27564f
|
280 |
|
T |
281 |
$user_field = new textfield(array('name' => '_user', 'id' => 'imapuser')); |
|
282 |
$pass_field = new passwordfield(array('name' => '_pass', 'id' => 'imappass')); |
|
283 |
|
|
284 |
?> |
|
285 |
|
|
286 |
<table> |
|
287 |
<tbody> |
|
288 |
<tr> |
|
289 |
<td><label for="imaphost">Server</label></td> |
112c54
|
290 |
<td><?php echo $host_field->show($_POST['_host']); ?></td> |
27564f
|
291 |
</tr> |
T |
292 |
<tr> |
|
293 |
<td>Port</td> |
|
294 |
<td><?php echo $RCI->getprop('default_port'); ?></td> |
|
295 |
</tr> |
|
296 |
<tr> |
|
297 |
<td><label for="imapuser">Username</label></td> |
|
298 |
<td><?php echo $user_field->show($_POST['_user']); ?></td> |
|
299 |
</tr> |
|
300 |
<tr> |
|
301 |
<td><label for="imappass">Password</label></td> |
|
302 |
<td><?php echo $pass_field->show(); ?></td> |
|
303 |
</tr> |
|
304 |
</tbody> |
|
305 |
</table> |
|
306 |
|
|
307 |
<?php |
|
308 |
|
|
309 |
if (isset($_POST['imaptest']) && !empty($_POST['_host']) && !empty($_POST['_user'])) { |
|
310 |
|
|
311 |
require_once 'include/rcube_imap.inc'; |
|
312 |
|
|
313 |
echo '<p>Connecting to ' . Q($_POST['_host']) . '...<br />'; |
|
314 |
|
|
315 |
$a_host = parse_url($_POST['_host']); |
|
316 |
if ($a_host['host']) { |
|
317 |
$imap_host = $a_host['host']; |
|
318 |
$imap_ssl = (isset($a_host['scheme']) && in_array($a_host['scheme'], array('ssl','imaps','tls'))) ? $a_host['scheme'] : null; |
|
319 |
$imap_port = isset($a_host['port']) ? $a_host['port'] : ($imap_ssl ? 993 : $CONFIG['default_port']); |
|
320 |
} |
|
321 |
else { |
|
322 |
$imap_host = trim($_POST['_host']); |
|
323 |
$imap_port = $RCI->getprop('default_port'); |
|
324 |
} |
|
325 |
|
|
326 |
$imap = new rcube_imap(null); |
|
327 |
if ($imap->connect($imap_host, $_POST['_user'], $_POST['_pass'], $imap_port, $imap_ssl)) { |
|
328 |
$RCI->pass('IMAP connect', 'SORT capability: ' . ($imap->get_capability('SORT') ? 'yes' : 'no')); |
|
329 |
$imap->close(); |
|
330 |
} |
|
331 |
else { |
|
332 |
$RCI->fail('IMAP connect', $RCI->get_error()); |
|
333 |
} |
|
334 |
} |
|
335 |
|
|
336 |
?> |
|
337 |
|
|
338 |
<p><input type="submit" name="imaptest" value="Check login" /></p> |
c5042d
|
339 |
|
354978
|
340 |
</form> |
T |
341 |
|
27564f
|
342 |
<hr /> |
T |
343 |
|
354978
|
344 |
<p class="warning"> |
T |
345 |
|
|
346 |
After completing the installation and the final tests please <b>remove</b> the whole |
|
347 |
installer folder from the document root of the webserver.<br /> |
|
348 |
<br /> |
|
349 |
|
|
350 |
These files may expose sensitive configuration data like server passwords and encryption keys |
|
351 |
to the public. Make sure you cannot access this installer from your browser. |
|
352 |
|
|
353 |
</p> |