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