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