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