d1ae9d4c |
1 | <?php |
134e4174 |
2 | |
30967a1e |
3 | /** |
d1ae9d4c |
4 | * SquirrelMail configtest script |
5 | * |
47ccfad4 |
6 | * @copyright © 2003-2006 The SquirrelMail Project Team |
4b4abf93 |
7 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
30967a1e |
8 | * @version $Id$ |
9 | * @package squirrelmail |
10 | * @subpackage config |
d1ae9d4c |
11 | */ |
12 | |
13 | /************************************************************ |
14 | * NOTE: you do not need to change this script! * |
15 | * If it throws errors you need to adjust your config. * |
16 | ************************************************************/ |
17 | |
df758744 |
18 | // This script could really use some restructuring as it has grown quite rapidly |
19 | // but is not very 'clean'. Feel free to get some structure into this thing. |
3a196538 |
20 | $warnings = 0; |
df758744 |
21 | |
3a196538 |
22 | function do_err($str, $fatal = TRUE) { |
f084f987 |
23 | global $IND, $warnings; |
24 | $level = $fatal ? 'FATAL ERROR:' : 'WARNING:'; |
3a196538 |
25 | echo '<p>'.$IND.'<font color="red"><b>' . $level . '</b></font> ' .$str. "</p>\n"; |
26 | if($fatal) { |
f084f987 |
27 | echo '</body></html>'; |
28 | exit; |
3a196538 |
29 | } else { |
f084f987 |
30 | $warnings++; |
31 | } |
5b53b7e0 |
32 | } |
33 | |
34 | $IND = str_repeat(' ',4); |
35 | |
36 | ob_implicit_flush(); |
30967a1e |
37 | /** @ignore */ |
5b53b7e0 |
38 | define('SM_PATH', '../'); |
39 | |
d0184454 |
40 | /* set default value in order to block remote access to script */ |
41 | $allow_remote_configtest=false; |
42 | |
5b53b7e0 |
43 | /* |
91e0dccc |
44 | * Load config before output begins. functions/strings.php depends on |
5b53b7e0 |
45 | * functions/globals.php. functions/global.php needs to be run before |
91e0dccc |
46 | * any html output starts. If config.php is missing, error will be displayed |
5b53b7e0 |
47 | * later. |
48 | */ |
49 | if (file_exists(SM_PATH . 'config/config.php')) { |
c772f125 |
50 | require(SM_PATH . 'config/config.php'); |
5b53b7e0 |
51 | } |
c772f125 |
52 | require(SM_PATH . 'functions/global.php'); |
53 | require(SM_PATH . 'functions/strings.php'); |
54 | |
151562a7 |
55 | ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
56 | "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> |
d1ae9d4c |
57 | <html> |
58 | <head> |
f084f987 |
59 | <meta name="robots" content="noindex,nofollow"> |
60 | <title>SquirrelMail configtest</title> |
d1ae9d4c |
61 | </head> |
62 | <body> |
63 | <h1>SquirrelMail configtest</h1> |
64 | |
65 | <p>This script will try to check some aspects of your SquirrelMail configuration |
66 | and point you to errors whereever it can find them. You need to go run <tt>conf.pl</tt> |
d18703d3 |
67 | in the <tt>config/</tt> directory first before you run this script.</p> |
d1ae9d4c |
68 | |
69 | <?php |
70 | |
d1ae9d4c |
71 | $included = array_map('basename', get_included_files() ); |
72 | if(!in_array('config.php', $included)) { |
73 | if(!file_exists(SM_PATH . 'config/config.php')) { |
74 | do_err('Config file '.SM_PATH . 'config/config.php does not exist!<br />'. |
f084f987 |
75 | 'You need to run <tt>conf.pl</tt> first.'); |
d1ae9d4c |
76 | } |
77 | do_err('Could not read '.SM_PATH.'config/config.php! Check file permissions.'); |
78 | } |
79 | if(!in_array('strings.php', $included)) { |
80 | do_err('Could not include '.SM_PATH.'functions/strings.php!<br />'. |
f084f987 |
81 | 'Check permissions on that file.'); |
d1ae9d4c |
82 | } |
83 | |
d0184454 |
84 | /* Block remote use of script */ |
85 | if (! $allow_remote_configtest) { |
86 | sqGetGlobalVar('REMOTE_ADDR',$client_ip,SQ_SERVER); |
a15f9d93 |
87 | sqGetGlobalVar('SERVER_ADDR',$server_ip,SQ_SERVER); |
88 | |
89 | if ((! isset($client_ip) || $client_ip!='127.0.0.1') && |
f084f987 |
90 | (! isset($client_ip) || ! isset($server_ip) || $client_ip!=$server_ip)) { |
f8a1ed5a |
91 | do_err('Enable "Allow remote configtest" option in squirrelmail configuration in order to use this script.'); |
d0184454 |
92 | } |
93 | } |
d1ae9d4c |
94 | /* checking PHP specs */ |
95 | |
17fca61d |
96 | echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" . $version . "</b></td></tr>\n" . |
f084f987 |
97 | '<tr><td>Config file version:</td><td><b>' . $config_version . "</b></td></tr>\n" . |
98 | '<tr><td>Config file last modified:</td><td><b>' . |
99 | date ('d F Y H:i:s', filemtime(SM_PATH . 'config/config.php')) . |
100 | "</b></td></tr>\n</table>\n</p>\n\n"; |
d1ae9d4c |
101 | |
c3da9f50 |
102 | /* check $config_version */ |
103 | if ($config_version!='1.4.0') { |
104 | do_err('Configuration file version does not match required version. Please update your configuration file.'); |
105 | } |
a15f9d93 |
106 | |
d1ae9d4c |
107 | echo "Checking PHP configuration...<br />\n"; |
108 | |
abd74f7d |
109 | if(!check_php_version(4,1,0)) { |
110 | do_err('Insufficient PHP version: '. PHP_VERSION . '! Minimum required: 4.1.0'); |
d1ae9d4c |
111 | } |
112 | |
3a196538 |
113 | echo $IND . 'PHP version ' . PHP_VERSION . ' OK. (You have: ' . phpversion() . ". Minimum: 4.1.0)<br />\n"; |
c772f125 |
114 | if ((bool) ini_get('register_globals')) { |
115 | do_err('You have register_globals turned on. This is not an error, but it CAN be a security hazard. Consider turning register_globals off.', false); |
116 | } |
d1ae9d4c |
117 | $php_exts = array('session','pcre'); |
118 | $diff = array_diff($php_exts, get_loaded_extensions()); |
119 | if(count($diff)) { |
120 | do_err('Required PHP extensions missing: '.implode(', ',$diff) ); |
121 | } |
122 | |
17fca61d |
123 | echo $IND . "PHP extensions OK.<br />\n"; |
d1ae9d4c |
124 | |
8f186a2a |
125 | /* dangerous php settings */ |
126 | /** |
127 | * mbstring.func_overload allows to replace original string and regexp functions |
128 | * with their equivalents from php mbstring extension. It causes problems when |
d0184454 |
129 | * scripts analyze 8bit strings byte after byte or use 8bit strings in regexp tests. |
9211bcef |
130 | * Setting can be controlled in php.ini (php 4.2.0), webserver config (php 4.2.0) |
8f186a2a |
131 | * and .htaccess files (php 4.3.5). |
132 | */ |
133 | if (function_exists('mb_internal_encoding') && |
9211bcef |
134 | check_php_version(4,2,0) && |
8f186a2a |
135 | (int)ini_get('mbstring.func_overload')!=0) { |
136 | $mb_error='You have enabled mbstring overloading.' |
137 | .' It can cause problems with SquirrelMail scripts that rely on single byte string functions.'; |
138 | do_err($mb_error); |
139 | } |
d1ae9d4c |
140 | |
141 | /* checking paths */ |
142 | |
143 | echo "Checking paths...<br />\n"; |
144 | |
145 | if(!file_exists($data_dir)) { |
d0184454 |
146 | // data_dir is not that important in db_setups. |
147 | if (isset($prefs_dsn) && ! empty($prefs_dsn)) { |
148 | $data_dir_error = "Data dir ($data_dir) does not exist!\n"; |
149 | echo $IND .'<font color="red"><b>ERROR:</b></font> ' . $data_dir_error; |
150 | } else { |
151 | do_err("Data dir ($data_dir) does not exist!"); |
152 | } |
91e0dccc |
153 | } |
d0184454 |
154 | // don't check if errors |
155 | if(!isset($data_dir_error) && !is_dir($data_dir)) { |
156 | if (isset($prefs_dsn) && ! empty($prefs_dsn)) { |
157 | $data_dir_error = "Data dir ($data_dir) is not a directory!\n"; |
158 | echo $IND . '<font color="red"><b>ERROR:</b></font> ' . $data_dir_error; |
159 | } else { |
160 | do_err("Data dir ($data_dir) is not a directory!"); |
161 | } |
91e0dccc |
162 | } |
d4eaadbe |
163 | // datadir should be executable - but no clean way to test on that |
d0184454 |
164 | if(!isset($data_dir_error) && !is_writable($data_dir)) { |
165 | if (isset($prefs_dsn) && ! empty($prefs_dsn)) { |
166 | $data_dir_error = "Data dir ($data_dir) is not writable!\n"; |
167 | echo $IND . '<font color="red"><b>ERROR:</b></font> ' . $data_dir_error; |
168 | } else { |
169 | do_err("Data dir ($data_dir) is not writable!"); |
170 | } |
d1ae9d4c |
171 | } |
172 | |
d0184454 |
173 | if (isset($data_dir_error)) { |
174 | echo " Some plugins might need access to data directory.<br />\n"; |
175 | } else { |
176 | // todo_ornot: actually write something and read it back. |
177 | echo $IND . "Data dir OK.<br />\n"; |
178 | } |
d1ae9d4c |
179 | |
180 | if($data_dir == $attachment_dir) { |
181 | echo $IND . "Attachment dir is the same as data dir.<br />\n"; |
d0184454 |
182 | if (isset($data_dir_error)) { |
183 | do_err($data_dir_error); |
184 | } |
d1ae9d4c |
185 | } else { |
186 | if(!file_exists($attachment_dir)) { |
187 | do_err("Attachment dir ($attachment_dir) does not exist!"); |
91e0dccc |
188 | } |
d1ae9d4c |
189 | if (!is_dir($attachment_dir)) { |
190 | do_err("Attachment dir ($attachment_dir) is not a directory!"); |
91e0dccc |
191 | } |
d1ae9d4c |
192 | if (!is_writable($attachment_dir)) { |
193 | do_err("I cannot write to attachment dir ($attachment_dir)!"); |
194 | } |
195 | echo $IND . "Attachment dir OK.<br />\n"; |
196 | } |
197 | |
198 | |
199 | /* check plugins and themes */ |
f084f987 |
200 | $bad_plugins = array( |
0880efc9 |
201 | 'attachment_common', // Integrated into SquirrelMail 1.2 core |
eb7bd9b7 |
202 | 'auto_prune_sent', // Obsolete: See Proon Automatic Folder Pruning plugin |
0880efc9 |
203 | 'compose_new_window', // Integrated into SquirrelMail 1.4 core |
204 | 'delete_move_next', // Integrated into SquirrelMail 1.5 core |
eb7bd9b7 |
205 | 'disk_quota', // Obsolete: See Check Quota plugin |
0880efc9 |
206 | 'email_priority', // Integrated into SquirrelMail 1.2 core |
eb7bd9b7 |
207 | 'emoticons', // Obsolete: See HTML Mail plugin |
0880efc9 |
208 | 'focus_change', // Integrated into SquirrelMail 1.2 core |
209 | 'folder_settings', // Integrated into SquirrelMail 1.5.1 core |
210 | 'global_sql_addressbook', // Integrated into SquirrelMail 1.4 core |
eb7bd9b7 |
211 | 'hancock', // Not Working: See Random Signature Taglines plugin |
0880efc9 |
212 | 'msg_flags', // Integrated into SquirrelMail 1.5.1 core |
213 | 'message_source', // Added to SquirrelMail 1.4 Core Plugins (message_details) |
214 | 'motd', // Integrated into SquirrelMail 1.2 core |
215 | 'paginator', // Integrated into SquirrelMail 1.2 core |
216 | 'printer_friendly', // Integrated into SquirrelMail 1.2 core |
eb7bd9b7 |
217 | 'procfilter', // Obsolete: See Server Side Filter plugin |
0880efc9 |
218 | 'redhat_php_cgi_fix', // Integrated into SquirrelMail 1.1.1 core |
219 | 'send_to_semicolon', // Integrated into SquirrelMail 1.4.1 core |
220 | 'spamassassin', // Not working beyond SquirrelMail 1.2.7: See Spamassassin SpamFilter (Frontend) v2 plugin |
221 | 'sqcalendar', // Added to SquirrelMail 1.2 Core Plugins (calendar) |
222 | 'sqclock', // Integrated into SquirrelMail 1.2 core |
eb7bd9b7 |
223 | 'sql_squirrel_logger', // Obsolete: See Squirrel Logger plugin |
224 | 'tmda', // Obsolete: See TMDA Tools plugin |
225 | 'vacation', // Obsolete: See Vacation Local plugin |
0880efc9 |
226 | 'view_as_html', // Integrated into SquirrelMail 1.5.1 core |
227 | 'xmailer' // Integrated into SquirrelMail 1.2 core |
f084f987 |
228 | ); |
3a196538 |
229 | |
5b53b7e0 |
230 | if (isset($plugins[0])) { |
231 | foreach($plugins as $plugin) { |
232 | if(!file_exists(SM_PATH .'plugins/'.$plugin)) { |
f084f987 |
233 | do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot find it.', FALSE); |
5b53b7e0 |
234 | } elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) { |
f084f987 |
235 | do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot read its setup.php file.', FALSE); |
236 | } elseif (in_array($plugin, $bad_plugins)) { |
237 | do_err('You have enabled the <i>'.$plugin.'</i> plugin, which causes problems with this version of SquirrelMail. Please check the ReleaseNotes or other documentation for more information.', false); |
238 | } |
d1ae9d4c |
239 | } |
5b53b7e0 |
240 | echo $IND . "Plugins OK.<br />\n"; |
241 | } else { |
242 | echo $IND . "Plugins are not enabled in config.<br />\n"; |
d1ae9d4c |
243 | } |
d1ae9d4c |
244 | foreach($theme as $thm) { |
245 | if(!file_exists($thm['PATH'])) { |
246 | do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE); |
247 | } elseif(!is_readable($thm['PATH'])) { |
248 | do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE); |
249 | } |
250 | } |
251 | |
252 | echo $IND . "Themes OK.<br />\n"; |
253 | |
07337c9b |
254 | if ( $squirrelmail_default_language != 'en_US' ) { |
255 | $loc_path = SM_PATH .'locale/'.$squirrelmail_default_language.'/LC_MESSAGES/squirrelmail.mo'; |
256 | if( ! file_exists( $loc_path ) ) { |
f8a1ed5a |
257 | do_err('You have set <i>' . $squirrelmail_default_language . |
f084f987 |
258 | '</i> as your default language, but I cannot find this translation (should be '. |
259 | 'in <tt>' . $loc_path . '</tt>). Please note that you have to download translations '. |
260 | 'separately from the main SquirrelMail package.', FALSE); |
07337c9b |
261 | } elseif ( ! is_readable( $loc_path ) ) { |
f8a1ed5a |
262 | do_err('You have set <i>' . $squirrelmail_default_language . |
f084f987 |
263 | '</i> as your default language, but I cannot read this translation (file '. |
264 | 'in <tt>' . $loc_path . '</tt> unreadable).', FALSE); |
07337c9b |
265 | } else { |
266 | echo $IND . "Default language OK.<br />\n"; |
267 | } |
268 | } else { |
269 | echo $IND . "Default language OK.<br />\n"; |
270 | } |
271 | |
23649466 |
272 | echo $IND . "Base URL detected as: <tt>" . htmlspecialchars(get_location()) . "</tt><br />\n"; |
273 | |
a15f9d93 |
274 | /* check minimal requirements for other security options */ |
d1ae9d4c |
275 | |
a15f9d93 |
276 | /* imaps or ssmtp */ |
277 | if($use_smtp_tls == 1 || $use_imap_tls == 1) { |
d1ae9d4c |
278 | if(!check_php_version(4,3,0)) { |
279 | do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!'); |
280 | } |
281 | if(!extension_loaded('openssl')) { |
282 | do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!'); |
283 | } |
284 | } |
a15f9d93 |
285 | /* starttls extensions */ |
1c4f110f |
286 | if($use_smtp_tls === 2 || $use_imap_tls === 2) { |
a15f9d93 |
287 | if (! function_exists('stream_socket_enable_crypto')) { |
288 | do_err('If you want to use STARTTLS extension, you need stream_socket_enable_crypto() function from PHP 5.1.0 and newer.'); |
289 | } |
290 | } |
291 | /* digest-md5 */ |
292 | if ($smtp_auth_mech=='digest-md5' || $imap_auth_mech =='digest-md5') { |
293 | if (!extension_loaded('xml')) { |
294 | do_err('You need the PHP XML extension to use Digest-MD5 authentication!'); |
295 | } |
296 | } |
297 | |
298 | /* check outgoing mail */ |
d1ae9d4c |
299 | |
300 | echo "Checking outgoing mail service....<br />\n"; |
301 | |
302 | if($useSendmail) { |
303 | // is_executable also checks for existance, but we want to be as precise as possible with the errors |
304 | if(!file_exists($sendmail_path)) { |
305 | do_err("Location of sendmail program incorrect ($sendmail_path)!"); |
91e0dccc |
306 | } |
d1ae9d4c |
307 | if(!is_executable($sendmail_path)) { |
308 | do_err("I cannot execute the sendmail program ($sendmail_path)!"); |
309 | } |
310 | |
311 | echo $IND . "sendmail OK<br />\n"; |
312 | } else { |
a15f9d93 |
313 | $stream = fsockopen( ($use_smtp_tls==1?'tls://':'').$smtpServerAddress, $smtpPort, |
f084f987 |
314 | $errorNumber, $errorString); |
d1ae9d4c |
315 | if(!$stream) { |
316 | do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".". |
f084f987 |
317 | "Server error: ($errorNumber) ".htmlspecialchars($errorString)); |
d1ae9d4c |
318 | } |
319 | |
320 | // check for SMTP code; should be 2xx to allow us access |
321 | $smtpline = fgets($stream, 1024); |
322 | if(((int) $smtpline{0}) > 3) { |
9c941728 |
323 | do_err("Error connecting to SMTP server. Server error: ". |
f084f987 |
324 | htmlspecialchars($smtpline)); |
d1ae9d4c |
325 | } |
326 | |
a15f9d93 |
327 | /* smtp starttls checks */ |
1c4f110f |
328 | if ($use_smtp_tls===2) { |
a15f9d93 |
329 | // if something breaks, script should close smtp connection on exit. |
330 | |
331 | // say helo |
332 | fwrite($stream,"EHLO $client_ip\r\n"); |
333 | |
334 | $ehlo=array(); |
335 | $ehlo_error = false; |
336 | while ($line=fgets($stream, 1024)){ |
337 | if (preg_match("/^250(-|\s)(\S*)\s+(\S.*)/",$line,$match)|| |
f084f987 |
338 | preg_match("/^250(-|\s)(\S*)\s+/",$line,$match)) { |
a15f9d93 |
339 | if (!isset($match[3])) { |
340 | // simple one word extension |
341 | $ehlo[strtoupper($match[2])]=''; |
342 | } else { |
343 | // ehlo-keyword + ehlo-param |
344 | $ehlo[strtoupper($match[2])]=trim($match[3]); |
345 | } |
346 | if ($match[1]==' ') { |
347 | $ret = $line; |
348 | break; |
349 | } |
350 | } else { |
351 | // |
352 | $ehlo_error = true; |
353 | $ehlo[]=$line; |
354 | break; |
355 | } |
356 | } |
357 | if ($ehlo_error) { |
358 | do_err('SMTP EHLO failed. You need ESMTP support for SMTP STARTTLS'); |
359 | } elseif (!array_key_exists('STARTTLS',$ehlo)) { |
360 | do_err('STARTTLS support is not declared by SMTP server.'); |
361 | } |
362 | |
363 | fwrite($stream,"STARTTLS\r\n"); |
364 | $starttls_response=fgets($stream, 1024); |
365 | if ($starttls_response[0]!=2) { |
366 | $starttls_cmd_err = 'SMTP STARTTLS failed. Server replied: ' |
367 | .htmlspecialchars($starttls_response); |
368 | do_err($starttls_cmd_err); |
369 | } elseif(! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
370 | do_err('Failed to enable encryption on SMTP STARTTLS connection.'); |
371 | } else { |
372 | echo $IND . "SMTP STARTTLS extension looks OK.<br />\n"; |
373 | } |
374 | // According to RFC we should second ehlo call here. |
375 | } |
376 | |
d1ae9d4c |
377 | fputs($stream, 'QUIT'); |
378 | fclose($stream); |
9c941728 |
379 | echo $IND . 'SMTP server OK (<tt><small>'. |
f084f987 |
380 | trim(htmlspecialchars($smtpline))."</small></tt>)<br />\n"; |
d1ae9d4c |
381 | |
382 | /* POP before SMTP */ |
383 | if($pop_before_smtp) { |
384 | $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str); |
385 | if (!$stream) { |
9c941728 |
386 | do_err("Error connecting to POP Server ($smtpServerAddress:110) " |
f084f987 |
387 | . $err_no . ' : ' . htmlspecialchars($err_str)); |
d1ae9d4c |
388 | } |
389 | |
390 | $tmp = fgets($stream, 1024); |
391 | if (substr($tmp, 0, 3) != '+OK') { |
392 | do_err("Error connecting to POP Server ($smtpServerAddress:110)" |
f084f987 |
393 | . ' '.htmlspecialchars($tmp)); |
d1ae9d4c |
394 | } |
395 | fputs($stream, 'QUIT'); |
396 | fclose($stream); |
397 | echo $IND . "POP-before-SMTP OK.<br />\n"; |
398 | } |
399 | } |
400 | |
df758744 |
401 | /** |
402 | * Check the IMAP server |
403 | */ |
d1ae9d4c |
404 | echo "Checking IMAP service....<br />\n"; |
405 | |
df758744 |
406 | /** Can we open a connection? */ |
a15f9d93 |
407 | $stream = fsockopen( ($use_imap_tls==1?'tls://':'').$imapServerAddress, $imapPort, |
f084f987 |
408 | $errorNumber, $errorString); |
d1ae9d4c |
409 | if(!$stream) { |
70b71161 |
410 | do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".". |
f084f987 |
411 | "Server error: ($errorNumber) ". |
412 | htmlspecialchars($errorString)); |
d1ae9d4c |
413 | } |
414 | |
df758744 |
415 | /** Is the first response 'OK'? */ |
d1ae9d4c |
416 | $imapline = fgets($stream, 1024); |
417 | if(substr($imapline, 0,4) != '* OK') { |
f084f987 |
418 | do_err('Error connecting to IMAP server. Server error: '. |
419 | htmlspecialchars($imapline)); |
d1ae9d4c |
420 | } |
421 | |
df758744 |
422 | echo $IND . 'IMAP server ready (<tt><small>'. |
9c941728 |
423 | htmlspecialchars(trim($imapline))."</small></tt>)<br />\n"; |
d1ae9d4c |
424 | |
df758744 |
425 | /** Check capabilities */ |
426 | fputs($stream, "A001 CAPABILITY\r\n"); |
a15f9d93 |
427 | $capline = ''; |
428 | while ($line=fgets($stream, 1024)){ |
f084f987 |
429 | if (preg_match("/A001.*/",$line)) { |
430 | break; |
431 | } else { |
432 | $capline.=$line; |
433 | } |
a15f9d93 |
434 | } |
435 | |
436 | /* don't display capabilities before STARTTLS */ |
1c4f110f |
437 | if ($use_imap_tls===2 && stristr($capline, 'STARTTLS') === false) { |
a15f9d93 |
438 | do_err('Your server doesn\'t support STARTTLS.'); |
1c4f110f |
439 | } elseif($use_imap_tls===2) { |
a15f9d93 |
440 | /* try starting starttls */ |
441 | fwrite($stream,"A002 STARTTLS\r\n"); |
442 | $starttls_line=fgets($stream, 1024); |
443 | if (! preg_match("/^A002 OK.*/i",$starttls_line)) { |
444 | $imap_starttls_err = 'IMAP STARTTLS failed. Server replied: ' |
f084f987 |
445 | .htmlspecialchars($starttls_line); |
a15f9d93 |
446 | do_err($imap_starttls_err); |
447 | } elseif (! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) { |
448 | do_err('Failed to enable encryption on IMAP connection.'); |
449 | } else { |
450 | echo $IND . "IMAP STARTTLS extension looks OK.<br />\n"; |
451 | } |
452 | |
453 | // get new capability line |
454 | fwrite($stream,"A003 CAPABILITY\r\n"); |
455 | $capline=''; |
456 | while ($line=fgets($stream, 1024)){ |
457 | if (preg_match("/A003.*/",$line)) { |
458 | break; |
459 | } else { |
460 | $capline.=$line; |
461 | } |
462 | } |
463 | } |
df758744 |
464 | |
465 | echo $IND . 'Capabilities: <tt>'.htmlspecialchars($capline)."</tt><br />\n"; |
466 | |
467 | if($imap_auth_mech == 'login' && stristr($capline, 'LOGINDISABLED') !== FALSE) { |
468 | do_err('Your server doesn\'t allow plaintext logins. '. |
f084f987 |
469 | 'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '. |
470 | 'in the SquirrelMail configuration.', FALSE); |
df758744 |
471 | } |
df758744 |
472 | |
473 | /** OK, close connection */ |
a15f9d93 |
474 | fputs($stream, "A004 LOGOUT\r\n"); |
df758744 |
475 | fclose($stream); |
476 | |
17fca61d |
477 | echo "Checking internationalization (i18n) settings...<br />\n"; |
0ed3bdc3 |
478 | echo "$IND gettext - "; |
479 | if (function_exists('gettext')) { |
8f186a2a |
480 | echo 'Gettext functions are available.' |
481 | .' On some systems you must have appropriate system locales compiled.' |
482 | ."<br />\n"; |
fd72907b |
483 | |
484 | /* optional setlocale() tests. Should work only on glibc systems. */ |
485 | if (sqgetGlobalVar('testlocales',$testlocales,SQ_GET)) { |
486 | include_once(SM_PATH . 'functions/i18n.php'); |
487 | echo $IND . $IND . 'Testing translations:<br>'; |
488 | foreach ($languages as $lang_code => $lang_data) { |
489 | /* don't test aliases */ |
490 | if (isset($lang_data['NAME'])) { |
491 | /* locale can be $lang_code or $lang_data['LOCALE'] */ |
492 | if (isset($lang_data['LOCALE'])) { |
493 | $setlocale = $lang_data['LOCALE']; |
494 | } else { |
495 | $setlocale = $lang_code; |
496 | } |
497 | /* prepare information about tested locales */ |
498 | if (is_array($setlocale)) { |
499 | $display_locale = implode(', ',$setlocale); |
500 | $locale_count = count($setlocale); |
501 | } else { |
502 | $display_locale = $setlocale; |
503 | $locale_count = 1; |
504 | } |
505 | $tested_locales_msg = 'Tested '.htmlspecialchars($display_locale).' ' |
506 | .($locale_count>1 ? 'locales':'locale'). '.'; |
507 | |
508 | echo $IND . $IND .$IND . $lang_data['NAME'].' (' .$lang_code. ') - '; |
509 | $retlocale = sq_setlocale(LC_ALL,$setlocale); |
510 | if (is_bool($retlocale)) { |
511 | echo '<font color="red">unsupported</font>. '; |
512 | echo $tested_locales_msg; |
513 | } else { |
514 | echo 'supported. ' |
515 | .$tested_locales_msg |
516 | .' setlocale() returned "'.htmlspecialchars($retlocale).'"'; |
517 | } |
518 | echo "<br />\n"; |
519 | } |
520 | } |
521 | echo $IND . $IND . '<a href="configtest.php">Don\'t test translations</a>'; |
522 | } else { |
523 | echo $IND . $IND . '<a href="configtest.php?testlocales=1">Test translations</a>. ' |
524 | .'This test is not accurate and might work only on some systems.' |
525 | ."\n"; |
526 | } |
527 | echo "<br />\n"; |
528 | /* end of translation tests */ |
0ed3bdc3 |
529 | } else { |
8f186a2a |
530 | echo 'Gettext functions are unavailable.' |
531 | .' SquirrelMail will use slower internal gettext functions.' |
532 | ."<br />\n"; |
0ed3bdc3 |
533 | } |
534 | echo "$IND mbstring - "; |
535 | if (function_exists('mb_detect_encoding')) { |
536 | echo "Mbstring functions are available.<br />\n"; |
537 | } else { |
8f186a2a |
538 | echo 'Mbstring functions are unavailable.' |
539 | ." Japanese translation won't work.<br />\n"; |
0ed3bdc3 |
540 | } |
541 | echo "$IND recode - "; |
542 | if (function_exists('recode')) { |
543 | echo "Recode functions are available.<br />\n"; |
ba17b6c7 |
544 | } elseif (isset($use_php_recode) && $use_php_recode) { |
0ed3bdc3 |
545 | echo "Recode functions are unavailable.<br />\n"; |
546 | do_err('Your configuration requires recode support, but recode support is missing.'); |
547 | } else { |
548 | echo "Recode functions are unavailable.<br />\n"; |
549 | } |
550 | echo "$IND iconv - "; |
551 | if (function_exists('iconv')) { |
552 | echo "Iconv functions are available.<br />\n"; |
ba17b6c7 |
553 | } elseif (isset($use_php_iconv) && $use_php_iconv) { |
0ed3bdc3 |
554 | echo "Iconv functions are unavailable.<br />\n"; |
555 | do_err('Your configuration requires iconv support, but iconv support is missing.'); |
556 | } else { |
557 | echo "Iconv functions are unavailable.<br />\n"; |
558 | } |
559 | // same test as in include/validate.php |
560 | echo "$IND timezone - "; |
561 | if ( (!ini_get('safe_mode')) || |
f084f987 |
562 | !strcmp(ini_get('safe_mode_allowed_env_vars'),'') || |
563 | preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) { |
fd72907b |
564 | echo "Webmail users can change their time zone settings. \n"; |
0ed3bdc3 |
565 | } else { |
fd72907b |
566 | echo "Webmail users can't change their time zone settings. \n"; |
4764a7ff |
567 | } |
fd72907b |
568 | if (isset($_ENV['TZ'])) { |
569 | echo 'Default time zone is '.htmlspecialchars($_ENV['TZ']); |
570 | } else { |
571 | echo 'Current time zone is '.date('T'); |
572 | } |
573 | echo ".<br />\n"; |
d18703d3 |
574 | |
4764a7ff |
575 | // Pear DB tests |
d18703d3 |
576 | echo "Checking database functions...<br />\n"; |
577 | if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) { |
134e4174 |
578 | @include_once('DB.php'); |
579 | if (class_exists('DB')) { |
580 | echo "$IND PHP Pear DB support is present.<br />\n"; |
581 | $db_functions=array( |
f084f987 |
582 | 'dbase' => 'dbase_open', |
583 | 'fbsql' => 'fbsql_connect', |
584 | 'interbase' => 'ibase_connect', |
585 | 'informix' => 'ifx_connect', |
586 | 'msql' => 'msql_connect', |
587 | 'mssql' => 'mssql_connect', |
588 | 'mysql' => 'mysql_connect', |
589 | 'mysqli' => 'mysqli_connect', |
590 | 'oci8' => 'ocilogon', |
591 | 'odbc' => 'odbc_connect', |
592 | 'pgsql' => 'pg_connect', |
593 | 'sqlite' => 'sqlite_open', |
594 | 'sybase' => 'sybase_connect' |
595 | ); |
134e4174 |
596 | |
597 | $dsns = array(); |
598 | if($prefs_dsn) { |
599 | $dsns['preferences'] = $prefs_dsn; |
600 | } |
601 | if($addrbook_dsn) { |
602 | $dsns['addressbook'] = $addrbook_dsn; |
603 | } |
604 | if($addrbook_global_dsn) { |
605 | $dsns['global addressbook'] = $addrbook_global_dsn; |
606 | } |
607 | |
608 | foreach($dsns as $type => $dsn) { |
ba17b6c7 |
609 | $aDsn = explode(':', $dsn); |
610 | $dbtype = array_shift($aDsn); |
134e4174 |
611 | if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) { |
612 | echo "$IND$dbtype database support present.<br />\n"; |
613 | |
614 | // now, test this interface: |
615 | |
616 | $dbh = DB::connect($dsn, true); |
617 | if (DB::isError($dbh)) { |
618 | do_err('Database error: '. htmlspecialchars(DB::errorMessage($dbh)) . |
f084f987 |
619 | ' in ' .$type .' DSN.'); |
134e4174 |
620 | } |
621 | $dbh->disconnect(); |
622 | echo "$IND$type database connect successful.<br />\n"; |
623 | |
624 | } else { |
ba17b6c7 |
625 | do_err($dbtype.' database support not present!'); |
d18703d3 |
626 | } |
134e4174 |
627 | } |
628 | } else { |
8f186a2a |
629 | $db_error='Required PHP PEAR DB support is not available.' |
630 | .' Is PEAR installed and is the include path set correctly to find <tt>DB.php</tt>?' |
631 | .' The include path is now:<tt>' . ini_get('include_path') . '</tt>.'; |
632 | do_err($db_error); |
134e4174 |
633 | } |
4764a7ff |
634 | } else { |
d18703d3 |
635 | echo $IND."not using database functionality.<br />\n"; |
0ed3bdc3 |
636 | } |
7562c55b |
637 | |
638 | // LDAP DB tests |
639 | echo "Checking LDAP functions...<br />\n"; |
640 | if( empty($ldap_server) ) { |
134e4174 |
641 | echo $IND."not using LDAP functionality.<br />\n"; |
7562c55b |
642 | } else { |
d0184454 |
643 | if ( !function_exists('ldap_connect') ) { |
7562c55b |
644 | do_err('Required LDAP support is not available.'); |
645 | } else { |
134e4174 |
646 | echo "$IND LDAP support present.<br />\n"; |
7562c55b |
647 | foreach ( $ldap_server as $param ) { |
648 | |
d0184454 |
649 | $linkid = @ldap_connect($param['host'], (empty($param['port']) ? 389 : $param['port']) ); |
7562c55b |
650 | |
651 | if ( $linkid ) { |
f084f987 |
652 | echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n"; |
91e0dccc |
653 | |
7562c55b |
654 | if ( !empty($param['protocol']) && |
f084f987 |
655 | !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION, $param['protocol']) ) { |
7562c55b |
656 | do_err('Unable to set LDAP protocol'); |
91e0dccc |
657 | } |
7562c55b |
658 | |
659 | if ( empty($param['binddn']) ) { |
d0184454 |
660 | $bind = @ldap_bind($linkid); |
7562c55b |
661 | } else { |
d0184454 |
662 | $bind = @ldap_bind($param['binddn'], $param['bindpw']); |
7562c55b |
663 | } |
664 | |
665 | if ( $bind ) { |
666 | echo "$IND LDAP Bind Successful <br />"; |
667 | } else { |
668 | do_err('Unable to Bind to LDAP Server'); |
669 | } |
91e0dccc |
670 | |
d0184454 |
671 | @ldap_close($linkid); |
7562c55b |
672 | } else { |
673 | do_err('Connection to LDAP failed'); |
674 | } |
675 | } |
676 | } |
677 | } |
a2b193bc |
678 | |
3a196538 |
679 | echo '<hr width="75%" align="center">'; |
680 | echo '<h2 align="center">Summary</h2>'; |
681 | $footer = '<hr width="75%" align="center">'; |
682 | if ($warnings) { |
f084f987 |
683 | echo '<p>No fatal errors were found, but there was at least 1 warning. Please check the flagged issue(s) carefully, as correcting them may prevent erratic, undefined, or incorrect behavior (or flat out breakage).</p>'; |
684 | echo $footer; |
3a196538 |
685 | } else { |
f084f987 |
686 | print <<< EOF |
d1ae9d4c |
687 | <p>Congratulations, your SquirrelMail setup looks fine to me!</p> |
688 | |
13721b47 |
689 | <p><a href="login.php">Login now</a></p> |
d1ae9d4c |
690 | |
691 | </body> |
3a196538 |
692 | </html> |
693 | EOF; |
f084f987 |
694 | echo $footer; |
3a196538 |
695 | } |
09efeab8 |
696 | ?> |