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