Reverted the init.php requirement. Marc raised some good points about init.php doing...
[squirrelmail.git] / src / configtest.php
1 <?php
2
3 /**
4 * SquirrelMail configtest script
5 *
6 * @copyright &copy; 2003-2006 The SquirrelMail Project Team
7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
9 * @package squirrelmail
10 * @subpackage config
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
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.
20 $warnings = 0;
21
22 function do_err($str, $fatal = TRUE) {
23 global $IND, $warnings;
24 $level = $fatal ? 'FATAL ERROR:' : 'WARNING:';
25 echo '<p>'.$IND.'<font color="red"><b>' . $level . '</b></font> ' .$str. "</p>\n";
26 if($fatal) {
27 echo '</body></html>';
28 exit;
29 } else {
30 $warnings++;
31 }
32 }
33
34 $IND = str_repeat('&nbsp;',4);
35
36 ob_implicit_flush();
37 /** @ignore */
38 define('SM_PATH', '../');
39
40 /* set default value in order to block remote access to script */
41 $allow_remote_configtest=false;
42
43 /*
44 * Load config before output begins. functions/strings.php depends on
45 * functions/globals.php. functions/global.php needs to be run before
46 * any html output starts. If config.php is missing, error will be displayed
47 * later.
48 */
49 if (file_exists(SM_PATH . 'config/config.php')) {
50 require(SM_PATH . 'config/config.php');
51 }
52 require(SM_PATH . 'functions/global.php');
53 require(SM_PATH . 'functions/strings.php');
54
55 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
56 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
57 <html>
58 <head>
59 <meta name="robots" content="noindex,nofollow">
60 <title>SquirrelMail configtest</title>
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>
67 in the <tt>config/</tt> directory first before you run this script.</p>
68
69 <?php
70
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 />'.
75 'You need to run <tt>conf.pl</tt> first.');
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 />'.
81 'Check permissions on that file.');
82 }
83
84 /* Block remote use of script */
85 if (! $allow_remote_configtest) {
86 sqGetGlobalVar('REMOTE_ADDR',$client_ip,SQ_SERVER);
87 sqGetGlobalVar('SERVER_ADDR',$server_ip,SQ_SERVER);
88
89 if ((! isset($client_ip) || $client_ip!='127.0.0.1') &&
90 (! isset($client_ip) || ! isset($server_ip) || $client_ip!=$server_ip)) {
91 do_err('Enable "Allow remote configtest" option in squirrelmail configuration in order to use this script.');
92 }
93 }
94 /* checking PHP specs */
95
96 echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" . $version . "</b></td></tr>\n" .
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";
101
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 }
106
107 echo "Checking PHP configuration...<br />\n";
108
109 if(!check_php_version(4,1,0)) {
110 do_err('Insufficient PHP version: '. PHP_VERSION . '! Minimum required: 4.1.0');
111 }
112
113 echo $IND . 'PHP version ' . PHP_VERSION . ' OK. (You have: ' . phpversion() . ". Minimum: 4.1.0)<br />\n";
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 }
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
123 echo $IND . "PHP extensions OK.<br />\n";
124
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
129 * scripts analyze 8bit strings byte after byte or use 8bit strings in regexp tests.
130 * Setting can be controlled in php.ini (php 4.2.0), webserver config (php 4.2.0)
131 * and .htaccess files (php 4.3.5).
132 */
133 if (function_exists('mb_internal_encoding') &&
134 check_php_version(4,2,0) &&
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 }
140
141 /* checking paths */
142
143 echo "Checking paths...<br />\n";
144
145 if(!file_exists($data_dir)) {
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 }
153 }
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 }
162 }
163 // datadir should be executable - but no clean way to test on that
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 }
171 }
172
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 }
179
180 if($data_dir == $attachment_dir) {
181 echo $IND . "Attachment dir is the same as data dir.<br />\n";
182 if (isset($data_dir_error)) {
183 do_err($data_dir_error);
184 }
185 } else {
186 if(!file_exists($attachment_dir)) {
187 do_err("Attachment dir ($attachment_dir) does not exist!");
188 }
189 if (!is_dir($attachment_dir)) {
190 do_err("Attachment dir ($attachment_dir) is not a directory!");
191 }
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 */
200 $bad_plugins = array(
201 'attachment_common', // Integrated into SquirrelMail 1.2 core
202 'auto_prune_sent', // Obsolete: See Proon Automatic Folder Pruning plugin
203 'compose_new_window', // Integrated into SquirrelMail 1.4 core
204 'delete_move_next', // Integrated into SquirrelMail 1.5 core
205 'disk_quota', // Obsolete: See Check Quota plugin
206 'email_priority', // Integrated into SquirrelMail 1.2 core
207 'emoticons', // Obsolete: See HTML Mail plugin
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
211 'hancock', // Not Working: See Random Signature Taglines plugin
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
217 'procfilter', // Obsolete: See Server Side Filter plugin
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
223 'sql_squirrel_logger', // Obsolete: See Squirrel Logger plugin
224 'tmda', // Obsolete: See TMDA Tools plugin
225 'vacation', // Obsolete: See Vacation Local plugin
226 'view_as_html', // Integrated into SquirrelMail 1.5.1 core
227 'xmailer' // Integrated into SquirrelMail 1.2 core
228 );
229
230 if (isset($plugins[0])) {
231 foreach($plugins as $plugin) {
232 if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
233 do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot find it.', FALSE);
234 } elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
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 }
239 }
240 echo $IND . "Plugins OK.<br />\n";
241 } else {
242 echo $IND . "Plugins are not enabled in config.<br />\n";
243 }
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
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 ) ) {
257 do_err('You have set <i>' . $squirrelmail_default_language .
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);
261 } elseif ( ! is_readable( $loc_path ) ) {
262 do_err('You have set <i>' . $squirrelmail_default_language .
263 '</i> as your default language, but I cannot read this translation (file '.
264 'in <tt>' . $loc_path . '</tt> unreadable).', FALSE);
265 } else {
266 echo $IND . "Default language OK.<br />\n";
267 }
268 } else {
269 echo $IND . "Default language OK.<br />\n";
270 }
271
272 echo $IND . "Base URL detected as: <tt>" . htmlspecialchars(get_location()) . "</tt><br />\n";
273
274 /* check minimal requirements for other security options */
275
276 /* imaps or ssmtp */
277 if($use_smtp_tls == 1 || $use_imap_tls == 1) {
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 }
285 /* starttls extensions */
286 if($use_smtp_tls === 2 || $use_imap_tls === 2) {
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 */
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)!");
306 }
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 {
313 $stream = fsockopen( ($use_smtp_tls==1?'tls://':'').$smtpServerAddress, $smtpPort,
314 $errorNumber, $errorString);
315 if(!$stream) {
316 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
317 "Server error: ($errorNumber) ".htmlspecialchars($errorString));
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) {
323 do_err("Error connecting to SMTP server. Server error: ".
324 htmlspecialchars($smtpline));
325 }
326
327 /* smtp starttls checks */
328 if ($use_smtp_tls===2) {
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)||
338 preg_match("/^250(-|\s)(\S*)\s+/",$line,$match)) {
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
377 fputs($stream, 'QUIT');
378 fclose($stream);
379 echo $IND . 'SMTP server OK (<tt><small>'.
380 trim(htmlspecialchars($smtpline))."</small></tt>)<br />\n";
381
382 /* POP before SMTP */
383 if($pop_before_smtp) {
384 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
385 if (!$stream) {
386 do_err("Error connecting to POP Server ($smtpServerAddress:110) "
387 . $err_no . ' : ' . htmlspecialchars($err_str));
388 }
389
390 $tmp = fgets($stream, 1024);
391 if (substr($tmp, 0, 3) != '+OK') {
392 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
393 . ' '.htmlspecialchars($tmp));
394 }
395 fputs($stream, 'QUIT');
396 fclose($stream);
397 echo $IND . "POP-before-SMTP OK.<br />\n";
398 }
399 }
400
401 /**
402 * Check the IMAP server
403 */
404 echo "Checking IMAP service....<br />\n";
405
406 /** Can we open a connection? */
407 $stream = fsockopen( ($use_imap_tls==1?'tls://':'').$imapServerAddress, $imapPort,
408 $errorNumber, $errorString);
409 if(!$stream) {
410 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
411 "Server error: ($errorNumber) ".
412 htmlspecialchars($errorString));
413 }
414
415 /** Is the first response 'OK'? */
416 $imapline = fgets($stream, 1024);
417 if(substr($imapline, 0,4) != '* OK') {
418 do_err('Error connecting to IMAP server. Server error: '.
419 htmlspecialchars($imapline));
420 }
421
422 echo $IND . 'IMAP server ready (<tt><small>'.
423 htmlspecialchars(trim($imapline))."</small></tt>)<br />\n";
424
425 /** Check capabilities */
426 fputs($stream, "A001 CAPABILITY\r\n");
427 $capline = '';
428 while ($line=fgets($stream, 1024)){
429 if (preg_match("/A001.*/",$line)) {
430 break;
431 } else {
432 $capline.=$line;
433 }
434 }
435
436 /* don't display capabilities before STARTTLS */
437 if ($use_imap_tls===2 && stristr($capline, 'STARTTLS') === false) {
438 do_err('Your server doesn\'t support STARTTLS.');
439 } elseif($use_imap_tls===2) {
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: '
445 .htmlspecialchars($starttls_line);
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 }
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. '.
469 'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '.
470 'in the SquirrelMail configuration.', FALSE);
471 }
472
473 /** OK, close connection */
474 fputs($stream, "A004 LOGOUT\r\n");
475 fclose($stream);
476
477 echo "Checking internationalization (i18n) settings...<br />\n";
478 echo "$IND gettext - ";
479 if (function_exists('gettext')) {
480 echo 'Gettext functions are available.'
481 .' On some systems you must have appropriate system locales compiled.'
482 ."<br />\n";
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 */
529 } else {
530 echo 'Gettext functions are unavailable.'
531 .' SquirrelMail will use slower internal gettext functions.'
532 ."<br />\n";
533 }
534 echo "$IND mbstring - ";
535 if (function_exists('mb_detect_encoding')) {
536 echo "Mbstring functions are available.<br />\n";
537 } else {
538 echo 'Mbstring functions are unavailable.'
539 ." Japanese translation won't work.<br />\n";
540 }
541 echo "$IND recode - ";
542 if (function_exists('recode')) {
543 echo "Recode functions are available.<br />\n";
544 } elseif (isset($use_php_recode) && $use_php_recode) {
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";
553 } elseif (isset($use_php_iconv) && $use_php_iconv) {
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')) ||
562 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
563 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
564 echo "Webmail users can change their time zone settings. \n";
565 } else {
566 echo "Webmail users can't change their time zone settings. \n";
567 }
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";
574
575 // Pear DB tests
576 echo "Checking database functions...<br />\n";
577 if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) {
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(
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 );
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) {
609 $aDsn = explode(':', $dsn);
610 $dbtype = array_shift($aDsn);
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)) .
619 ' in ' .$type .' DSN.');
620 }
621 $dbh->disconnect();
622 echo "$IND$type database connect successful.<br />\n";
623
624 } else {
625 do_err($dbtype.' database support not present!');
626 }
627 }
628 } else {
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);
633 }
634 } else {
635 echo $IND."not using database functionality.<br />\n";
636 }
637
638 // LDAP DB tests
639 echo "Checking LDAP functions...<br />\n";
640 if( empty($ldap_server) ) {
641 echo $IND."not using LDAP functionality.<br />\n";
642 } else {
643 if ( !function_exists('ldap_connect') ) {
644 do_err('Required LDAP support is not available.');
645 } else {
646 echo "$IND LDAP support present.<br />\n";
647 foreach ( $ldap_server as $param ) {
648
649 $linkid = @ldap_connect($param['host'], (empty($param['port']) ? 389 : $param['port']) );
650
651 if ( $linkid ) {
652 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
653
654 if ( !empty($param['protocol']) &&
655 !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION, $param['protocol']) ) {
656 do_err('Unable to set LDAP protocol');
657 }
658
659 if ( empty($param['binddn']) ) {
660 $bind = @ldap_bind($linkid);
661 } else {
662 $bind = @ldap_bind($param['binddn'], $param['bindpw']);
663 }
664
665 if ( $bind ) {
666 echo "$IND LDAP Bind Successful <br />";
667 } else {
668 do_err('Unable to Bind to LDAP Server');
669 }
670
671 @ldap_close($linkid);
672 } else {
673 do_err('Connection to LDAP failed');
674 }
675 }
676 }
677 }
678
679 echo '<hr width="75%" align="center">';
680 echo '<h2 align="center">Summary</h2>';
681 $footer = '<hr width="75%" align="center">';
682 if ($warnings) {
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;
685 } else {
686 print <<< EOF
687 <p>Congratulations, your SquirrelMail setup looks fine to me!</p>
688
689 <p><a href="login.php">Login now</a></p>
690
691 </body>
692 </html>
693 EOF;
694 echo $footer;
695 }
696 ?>