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