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