Happy New Year
[squirrelmail.git] / src / configtest.php
CommitLineData
d1ae9d4c 1<?php
134e4174 2
30967a1e 3/**
d1ae9d4c 4 * SquirrelMail configtest script
5 *
f197ec88 6 * @copyright 2003-2016 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
ebd2391c 18/** This is the configtest page */
19define('PAGE_NAME', 'configtest');
20
df758744 21// This script could really use some restructuring as it has grown quite rapidly
22// but is not very 'clean'. Feel free to get some structure into this thing.
23
8a6b8e1f 24// force verbose error reporting and turn on display of errors, but not before
25// getting their original values
26$php_display_errors_original_value = ini_get('display_errors');
27$php_error_reporting_original_value = ini_get('error_reporting');
dda39a1a 28error_reporting(E_ALL);
29ini_set('display_errors',1);
30
31/** Blockcopy from init.php. Cleans globals. */
32if ((bool) ini_get('register_globals') &&
33 strtolower(ini_get('register_globals'))!='off') {
34 /**
35 * Remove all globals that are not reserved by PHP
36 * 'value' and 'key' are used by foreach. Don't unset them inside foreach.
37 */
38 foreach ($GLOBALS as $key => $value) {
39 switch($key) {
40 case 'HTTP_POST_VARS':
41 case '_POST':
42 case 'HTTP_GET_VARS':
43 case '_GET':
44 case 'HTTP_COOKIE_VARS':
45 case '_COOKIE':
46 case 'HTTP_SERVER_VARS':
47 case '_SERVER':
48 case 'HTTP_ENV_VARS':
49 case '_ENV':
50 case 'HTTP_POST_FILES':
51 case '_FILES':
52 case '_REQUEST':
53 case 'HTTP_SESSION_VARS':
54 case '_SESSION':
55 case 'GLOBALS':
56 case 'key':
57 case 'value':
58 break;
59 default:
60 unset($GLOBALS[$key]);
61 }
62 }
63 // Unset variables used in foreach
64 unset($GLOBALS['key']);
65 unset($GLOBALS['value']);
66}
67
68
69/**
70 * Displays error messages and warnings
71 * @param string $str message
72 * @param boolean $fatal fatal error or only warning
73 */
3a196538 74function do_err($str, $fatal = TRUE) {
f084f987 75 global $IND, $warnings;
76 $level = $fatal ? 'FATAL ERROR:' : 'WARNING:';
3a196538 77 echo '<p>'.$IND.'<font color="red"><b>' . $level . '</b></font> ' .$str. "</p>\n";
78 if($fatal) {
f084f987 79 echo '</body></html>';
80 exit;
3a196538 81 } else {
f084f987 82 $warnings++;
83 }
5b53b7e0 84}
85
5b53b7e0 86ob_implicit_flush();
30967a1e 87/** @ignore */
5b53b7e0 88define('SM_PATH', '../');
dda39a1a 89/** load minimal function set */
b37e457f 90require(SM_PATH . 'include/constants.php');
dda39a1a 91require(SM_PATH . 'functions/global.php');
92require(SM_PATH . 'functions/strings.php');
b578bd7c 93require(SM_PATH . 'functions/files.php');
a895042a 94$SQM_INTERNAL_VERSION = explode('.', SM_VERSION, 3);
b37e457f 95$SQM_INTERNAL_VERSION[2] = intval($SQM_INTERNAL_VERSION[2]);
5b53b7e0 96
dda39a1a 97/** set default value in order to block remote access */
d0184454 98$allow_remote_configtest=false;
99
dda39a1a 100/** Load all configuration files before output begins */
101
102/* load default configuration */
103require(SM_PATH . 'config/config_default.php');
104/* reset arrays in default configuration */
105$ldap_server = array();
106$plugins = array();
107$fontsets = array();
108$theme = array();
109$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
110$theme[0]['NAME'] = 'Default';
111$aTemplateSet = array();
112$aTemplateSet[0]['ID'] = 'default';
113$aTemplateSet[0]['NAME'] = 'Default';
114/* load site configuration */
5b53b7e0 115if (file_exists(SM_PATH . 'config/config.php')) {
dda39a1a 116 require(SM_PATH . 'config/config.php');
5b53b7e0 117}
dda39a1a 118/* load local configuration overrides */
119if (file_exists(SM_PATH . 'config/config_local.php')) {
120 require(SM_PATH . 'config/config_local.php');
121}
122
caa592dc 123sqGetGlobalVar('REMOTE_ADDR',$client_ip,SQ_SERVER);
124sqGetGlobalVar('SERVER_ADDR',$server_ip,SQ_SERVER);
125
1dc63862 126/**
127 * Include Compatibility plugin if available.
128 */
129if (!$disable_plugins && file_exists(SM_PATH . 'plugins/compatibility/functions.php'))
130 include_once(SM_PATH . 'plugins/compatibility/functions.php');
131
8459a9bb 132/** Load plugins */
133global $disable_plugins;
134$squirrelmail_plugin_hooks = array();
135if (!$disable_plugins && file_exists(SM_PATH . 'config/plugin_hooks.php')) {
136 require(SM_PATH . 'config/plugin_hooks.php');
137}
138
dda39a1a 139/** Warning counter */
140$warnings = 0;
141
142/** indent */
143$IND = str_repeat('&nbsp;',4);
c772f125 144
69792446 145/**
146 * get_location starts session and must be run before output is started.
147 */
148$test_location = get_location();
149
151562a7 150?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
151 "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
d1ae9d4c 152<html>
153<head>
f084f987 154 <meta name="robots" content="noindex,nofollow">
155 <title>SquirrelMail configtest</title>
d1ae9d4c 156</head>
157<body>
158<h1>SquirrelMail configtest</h1>
159
160<p>This script will try to check some aspects of your SquirrelMail configuration
161and point you to errors whereever it can find them. You need to go run <tt>conf.pl</tt>
d18703d3 162in the <tt>config/</tt> directory first before you run this script.</p>
d1ae9d4c 163
164<?php
165
d1ae9d4c 166$included = array_map('basename', get_included_files() );
167if(!in_array('config.php', $included)) {
168 if(!file_exists(SM_PATH . 'config/config.php')) {
169 do_err('Config file '.SM_PATH . 'config/config.php does not exist!<br />'.
f084f987 170 'You need to run <tt>conf.pl</tt> first.');
d1ae9d4c 171 }
172 do_err('Could not read '.SM_PATH.'config/config.php! Check file permissions.');
173}
174if(!in_array('strings.php', $included)) {
175 do_err('Could not include '.SM_PATH.'functions/strings.php!<br />'.
f084f987 176 'Check permissions on that file.');
d1ae9d4c 177}
178
d0184454 179/* Block remote use of script */
180if (! $allow_remote_configtest) {
a15f9d93 181
182 if ((! isset($client_ip) || $client_ip!='127.0.0.1') &&
f084f987 183 (! isset($client_ip) || ! isset($server_ip) || $client_ip!=$server_ip)) {
f8a1ed5a 184 do_err('Enable "Allow remote configtest" option in squirrelmail configuration in order to use this script.');
d0184454 185 }
186}
d1ae9d4c 187
b37e457f 188echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" . SM_VERSION . "</b></td></tr>\n" .
f084f987 189 '<tr><td>Config file version:</td><td><b>' . $config_version . "</b></td></tr>\n" .
190 '<tr><td>Config file last modified:</td><td><b>' .
191 date ('d F Y H:i:s', filemtime(SM_PATH . 'config/config.php')) .
192 "</b></td></tr>\n</table>\n</p>\n\n";
d1ae9d4c 193
c3da9f50 194/* check $config_version */
65efa982 195if ($config_version!='1.5.0') {
c3da9f50 196 do_err('Configuration file version does not match required version. Please update your configuration file.');
197}
a15f9d93 198
a1912bbc 199
200/* checking PHP specs */
201
d1ae9d4c 202echo "Checking PHP configuration...<br />\n";
203
abd74f7d 204if(!check_php_version(4,1,0)) {
205 do_err('Insufficient PHP version: '. PHP_VERSION . '! Minimum required: 4.1.0');
d1ae9d4c 206}
207
3a196538 208echo $IND . 'PHP version ' . PHP_VERSION . ' OK. (You have: ' . phpversion() . ". Minimum: 4.1.0)<br />\n";
a1912bbc 209
385ead4a 210// try to determine information about the user and group the web server is running as
211//
212$webOwnerID = 'N/A';
213$webOwnerInfo = array('name' => 'N/A');
214if (function_exists('posix_getuid'))
215 $webOwnerID = posix_getuid();
216if ($webOwnerID === FALSE)
217 $webOwnerID = 'N/A';
218if ($webOwnerID !== 'N/A' && function_exists('posix_getpwuid'))
219 $webOwnerInfo = posix_getpwuid($webOwnerID);
220if (!$webOwnerInfo)
221 $webOwnerInfo = array('name' => 'N/A');
222$webGroupID = 'N/A';
223$webGroupInfo = array('name' => 'N/A');
224if (function_exists('posix_getgid'))
225 $webGroupID = posix_getgid();
226if ($webGroupID === FALSE)
227 $webGroupID = 'N/A';
228if ($webGroupID !== 'N/A' && function_exists('posix_getgrgid'))
229 $webGroupInfo = posix_getgrgid($webGroupID);
230if (!$webGroupInfo)
231 $webGroupInfo = array('name' => 'N/A');
232
233echo $IND . 'Running as ' . $webOwnerInfo['name'] . '(' . $webOwnerID
234 . ') / ' . $webGroupInfo['name'] . '(' . $webGroupID . ")<br />\n";
235
8a6b8e1f 236echo $IND . 'display_errors: ' . $php_display_errors_original_value . " (overridden with 1 for this page only)<br />\n";
0cc820f9 237
0fcb1271 238echo $IND . 'error_reporting: ' . $php_error_reporting_original_value . " (overridden with " . E_ALL . " for this page only)<br />\n";
0cc820f9 239
ccbde363 240$safe_mode = ini_get('safe_mode');
241if ($safe_mode) {
7777a968 242 //FIXME: should show that safe_mode is off when it is (this only shows the safe_mode setting when it's on) (also might be generally helpful to show things like open_basedir, too or even add phpinfo() output or a link to another script that has phpinfo()
ccbde363 243 echo $IND . 'safe_mode: ' . $safe_mode;
244 if (empty($prefs_dsn) || empty($addrbook_dsn))
245 echo ' (<font color="red">double check data and attachment directory ownership, etc!</font>)';
dc528046 246 if (!empty($addrbook_dsn) || !empty($prefs_dsn) || !empty($addrbook_global_dsn))
ccbde363 247 echo ' (<font color="red">does PHP have access to database interface?</font>)';
248 echo "<br />\n";
249 $safe_mode_exec_dir = ini_get('safe_mode_exec_dir');
250 echo $IND . 'safe_mode_exec_dir: ' . $safe_mode_exec_dir . "<br />\n";
251}
252
a1912bbc 253/* register_globals check: test for boolean false and any string that is not equal to 'off' */
254
dc528046 255if ((bool) ini_get('register_globals') &&
a3b99374 256 strtolower(ini_get('register_globals'))!='off') {
b00dce9b 257 do_err('You have register_globals turned on. This is not an error, but it CAN be a security hazard. Consider turning register_globals off.', false);
c772f125 258}
a1912bbc 259
260
261/* variables_order check */
262
b00dce9b 263// FIXME(?): Hmm, how do we distinguish between when an ini setting is not available (ini_set() returns empty string) and when the administrator set the value to an empty string? The latter is sure to be highly rare, so for now, just assume that empty value means the setting isn't even available (could also check PHP version when this setting was implemented) although, we'll also warn the user if it is empty, with a non-fatal error
47fa8e9b 264$variables_order = strtoupper(ini_get('variables_order'));
265if (empty($variables_order))
b00dce9b 266 do_err('Your variables_order setting seems to be empty. Make sure it is undefined in any PHP ini files, .htaccess files, etc. and not specifically set to an empty value or SquirrelMail may not function correctly', false);
47fa8e9b 267else if (strpos($variables_order, 'G') === FALSE
a1912bbc 268 || strpos($variables_order, 'P') === FALSE
269 || strpos($variables_order, 'C') === FALSE
47fa8e9b 270 || strpos($variables_order, 'S') === FALSE) {
3047e291 271 do_err('Your variables_order setting is insufficient for SquirrelMail to function. It needs at least "GPCS", but you have it set to "' . sm_encode_html_special_chars($variables_order) . '"', true);
a1912bbc 272} else {
273 echo $IND . "variables_order OK: $variables_order.<br />\n";
274}
275
276
47fa8e9b 277/* gpc_order check (removed from PHP as of v5.0) */
278
279if (!check_php_version(5)) {
b00dce9b 280 // FIXME(?): Hmm, how do we distinguish between when an ini setting is not available (ini_set() returns empty string) and when the administrator set the value to an empty string? The latter is sure to be highly rare, so for now, just assume that empty value means the setting isn't even available (could also check PHP version when this setting was implemented) although, we'll also warn the user if it is empty, with a non-fatal error
47fa8e9b 281 $gpc_order = strtoupper(ini_get('gpc_order'));
282 if (empty($gpc_order))
b00dce9b 283 do_err('Your gpc_order setting seems to be empty. Make sure it is undefined in any PHP ini files, .htaccess files, etc. and not specifically set to an empty value or SquirrelMail may not function correctly', false);
47fa8e9b 284 else if (strpos($gpc_order, 'G') === FALSE
285 || strpos($gpc_order, 'P') === FALSE
286 || strpos($gpc_order, 'C') === FALSE) {
3047e291 287 do_err('Your gpc_order setting is insufficient for SquirrelMail to function. It needs to be set to "GPC", but you have it set to "' . sm_encode_html_special_chars($gpc_order) . '"', true);
47fa8e9b 288 } else {
289 echo $IND . "gpc_order OK: $gpc_order.<br />\n";
290 }
a1912bbc 291}
292
293
294/* check PHP extensions */
295
d1ae9d4c 296$php_exts = array('session','pcre');
297$diff = array_diff($php_exts, get_loaded_extensions());
298if(count($diff)) {
299 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
300}
301
d053c206 302echo $IND . "PHP extensions OK. Dynamic loading is ";
303
304if (!(bool)ini_get('enable_dl') || (bool)ini_get('safe_mode')) {
305 echo "disabled.<br />\n";
306} else {
307 echo "enabled.<br />\n";
308}
309
d1ae9d4c 310
8f186a2a 311/* dangerous php settings */
312/**
313 * mbstring.func_overload allows to replace original string and regexp functions
314 * with their equivalents from php mbstring extension. It causes problems when
d0184454 315 * scripts analyze 8bit strings byte after byte or use 8bit strings in regexp tests.
9211bcef 316 * Setting can be controlled in php.ini (php 4.2.0), webserver config (php 4.2.0)
8f186a2a 317 * and .htaccess files (php 4.3.5).
318 */
319if (function_exists('mb_internal_encoding') &&
9211bcef 320 check_php_version(4,2,0) &&
8f186a2a 321 (int)ini_get('mbstring.func_overload')!=0) {
322 $mb_error='You have enabled mbstring overloading.'
323 .' It can cause problems with SquirrelMail scripts that rely on single byte string functions.';
324 do_err($mb_error);
325}
d1ae9d4c 326
99c1c0d6 327/**
328 * Do not use SquirrelMail with magic_quotes_* on.
329 */
430a19f3 330if ( (function_exists('get_magic_quotes_runtime') && @get_magic_quotes_runtime()) ||
331 (function_exists('get_magic_quotes_gpc') && @get_magic_quotes_gpc()) ||
99c1c0d6 332 ( (bool) ini_get('magic_quotes_sybase') && ini_get('magic_quotes_sybase') != 'off' )
333 ) {
334 $magic_quotes_warning='You have enabled any one of <tt>magic_quotes_runtime</tt>, '
335 .'<tt>magic_quotes_gpc</tt> or <tt>magic_quotes_sybase</tt> in your PHP '
336 .'configuration. We recommend all those settings to be off. SquirrelMail '
337 .'may work with them on, but when experiencing stray backslashes in your mail '
338 .'or other strange behaviour, it may be advisable to turn them off.';
339 do_err($magic_quotes_warning,false);
340}
341
dc528046 342if (ini_get('short_open_tag') == 0) {
343 $short_open_tag_warning = 'You have configured PHP not to allow short tags '
344 . '(<tt>short_open_tag=off</tt>). This shouldn\'t be a problem with '
345 . 'SquirrelMail or any plugin coded coded according to the '
346 . 'SquirrelMail Coding Guidelines, but if you experience problems with '
347 . 'PHP code being displayed in some of the pages and changing setting '
348 . 'to "on" solves the problem, please file a bug report against the '
349 . 'failing plugin. The correct contact information is most likely '
350 . 'to be found in the plugin documentation.';
351 do_err($short_open_tag_warning, false);
352}
99c1c0d6 353
e45a534b 354
355/* check who the web server is running as if possible */
356
357if ($process_info = get_process_owner_info()) {
358 echo $IND . 'Web server is running as user: ' . $process_info['name'] . ' (' . $process_info['uid'] . ")<br />\n";
359 //echo $IND . 'Web server is running as effective user: ' . $process_info['ename'] . ' (' . $process_info['euid'] . ")<br />\n";
360 echo $IND . 'Web server is running as group: ' . $process_info['group'] . ' (' . $process_info['gid'] . ")<br />\n";
361 //echo $IND . 'Web server is running as effective group: ' . $process_info['egroup'] . ' (' . $process_info['egid'] . ")<br />\n";
362}
363
364
d1ae9d4c 365/* checking paths */
366
367echo "Checking paths...<br />\n";
368
369if(!file_exists($data_dir)) {
d0184454 370 // data_dir is not that important in db_setups.
ccbde363 371 if (!empty($prefs_dsn)) {
d0184454 372 $data_dir_error = "Data dir ($data_dir) does not exist!\n";
373 echo $IND .'<font color="red"><b>ERROR:</b></font> ' . $data_dir_error;
374 } else {
375 do_err("Data dir ($data_dir) does not exist!");
376 }
91e0dccc 377}
d0184454 378// don't check if errors
379if(!isset($data_dir_error) && !is_dir($data_dir)) {
ccbde363 380 if (!empty($prefs_dsn)) {
d0184454 381 $data_dir_error = "Data dir ($data_dir) is not a directory!\n";
382 echo $IND . '<font color="red"><b>ERROR:</b></font> ' . $data_dir_error;
383 } else {
384 do_err("Data dir ($data_dir) is not a directory!");
385 }
91e0dccc 386}
d4eaadbe 387// datadir should be executable - but no clean way to test on that
0a496c76 388if(!isset($data_dir_error) && !sq_is_writable($data_dir)) {
ccbde363 389 if (!empty($prefs_dsn)) {
d0184454 390 $data_dir_error = "Data dir ($data_dir) is not writable!\n";
391 echo $IND . '<font color="red"><b>ERROR:</b></font> ' . $data_dir_error;
392 } else {
393 do_err("Data dir ($data_dir) is not writable!");
394 }
d1ae9d4c 395}
396
d0184454 397if (isset($data_dir_error)) {
398 echo " Some plugins might need access to data directory.<br />\n";
399} else {
400 // todo_ornot: actually write something and read it back.
401 echo $IND . "Data dir OK.<br />\n";
402}
d1ae9d4c 403
404if($data_dir == $attachment_dir) {
405 echo $IND . "Attachment dir is the same as data dir.<br />\n";
d0184454 406 if (isset($data_dir_error)) {
407 do_err($data_dir_error);
408 }
d1ae9d4c 409} else {
410 if(!file_exists($attachment_dir)) {
411 do_err("Attachment dir ($attachment_dir) does not exist!");
91e0dccc 412 }
d1ae9d4c 413 if (!is_dir($attachment_dir)) {
414 do_err("Attachment dir ($attachment_dir) is not a directory!");
91e0dccc 415 }
0a496c76 416 if (!sq_is_writable($attachment_dir)) {
d1ae9d4c 417 do_err("I cannot write to attachment dir ($attachment_dir)!");
418 }
419 echo $IND . "Attachment dir OK.<br />\n";
420}
421
422
646b17e0 423echo "Checking plugins...<br />\n";
424
d1ae9d4c 425/* check plugins and themes */
d17b7894 426//FIXME: check requirements given in plugin _info() function, such as required PHP extensions, Pear packages, other plugins, SM version, etc see development docs for list of returned info from that function
427//FIXME: update this list with most recent contents of the Obsolete category - I think it has changed recently
f084f987 428$bad_plugins = array(
0880efc9 429 'attachment_common', // Integrated into SquirrelMail 1.2 core
eb7bd9b7 430 'auto_prune_sent', // Obsolete: See Proon Automatic Folder Pruning plugin
0880efc9 431 'compose_new_window', // Integrated into SquirrelMail 1.4 core
432 'delete_move_next', // Integrated into SquirrelMail 1.5 core
eb7bd9b7 433 'disk_quota', // Obsolete: See Check Quota plugin
0880efc9 434 'email_priority', // Integrated into SquirrelMail 1.2 core
eb7bd9b7 435 'emoticons', // Obsolete: See HTML Mail plugin
0880efc9 436 'focus_change', // Integrated into SquirrelMail 1.2 core
437 'folder_settings', // Integrated into SquirrelMail 1.5.1 core
438 'global_sql_addressbook', // Integrated into SquirrelMail 1.4 core
eb7bd9b7 439 'hancock', // Not Working: See Random Signature Taglines plugin
0880efc9 440 'msg_flags', // Integrated into SquirrelMail 1.5.1 core
441 'message_source', // Added to SquirrelMail 1.4 Core Plugins (message_details)
442 'motd', // Integrated into SquirrelMail 1.2 core
443 'paginator', // Integrated into SquirrelMail 1.2 core
444 'printer_friendly', // Integrated into SquirrelMail 1.2 core
eb7bd9b7 445 'procfilter', // Obsolete: See Server Side Filter plugin
0880efc9 446 'redhat_php_cgi_fix', // Integrated into SquirrelMail 1.1.1 core
447 'send_to_semicolon', // Integrated into SquirrelMail 1.4.1 core
448 'spamassassin', // Not working beyond SquirrelMail 1.2.7: See Spamassassin SpamFilter (Frontend) v2 plugin
449 'sqcalendar', // Added to SquirrelMail 1.2 Core Plugins (calendar)
450 'sqclock', // Integrated into SquirrelMail 1.2 core
eb7bd9b7 451 'sql_squirrel_logger', // Obsolete: See Squirrel Logger plugin
452 'tmda', // Obsolete: See TMDA Tools plugin
453 'vacation', // Obsolete: See Vacation Local plugin
0880efc9 454 'view_as_html', // Integrated into SquirrelMail 1.5.1 core
455 'xmailer' // Integrated into SquirrelMail 1.2 core
f084f987 456 );
3a196538 457
5b53b7e0 458if (isset($plugins[0])) {
459 foreach($plugins as $plugin) {
460 if(!file_exists(SM_PATH .'plugins/'.$plugin)) {
f084f987 461 do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot find it.', FALSE);
5b53b7e0 462 } elseif (!is_readable(SM_PATH .'plugins/'.$plugin.'/setup.php')) {
1dc63862 463 do_err('You have enabled the <i>'.$plugin.'</i> plugin, but I cannot locate or read its setup.php file.', FALSE);
f084f987 464 } elseif (in_array($plugin, $bad_plugins)) {
465 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);
466 }
d1ae9d4c 467 }
1dc63862 468
469
69792446 470 // load plugin functions
471 include_once(SM_PATH . 'functions/plugin.php');
1dc63862 472
69792446 473 // turn on output buffering in order to prevent output of new lines
474 ob_start();
475 foreach ($plugins as $name) {
476 use_plugin($name);
1dc63862 477
478 // get output and remove whitespace
479 $output = trim(ob_get_contents());
480
481 // if plugin outputs more than newlines and spacing, stop script execution.
482 if (!empty($output)) {
3047e291 483 $plugin_load_error = 'Some output was produced when plugin <i>' . $name . '</i> was loaded. Usually this means there is an error in the plugin\'s setup or configuration file. The output was: '.sm_encode_html_special_chars($output);
1dc63862 484 do_err($plugin_load_error);
485 }
69792446 486 }
69792446 487 ob_end_clean();
1dc63862 488
489
490 /**
491 * Check the contents of the static plugin hooks array file against
492 * the plugin setup file, which may have changed in an upgrade, etc.
493 * This helps remind admins to re-run the configuration utility when
494 * a plugin has been changed or upgraded.
495 */
496 $static_squirrelmail_plugin_hooks = $squirrelmail_plugin_hooks;
497 $squirrelmail_plugin_hooks = array();
498 foreach ($plugins as $name) {
499 $function = "squirrelmail_plugin_init_$name";
500 if (function_exists($function)) {
501 $function();
502
503 // now iterate through each hook and make sure the
504 // plugin is registered on the correct ones in the
505 // static plugin configuration file
506 //
507 foreach ($squirrelmail_plugin_hooks as $hook_name => $hooked_plugins)
508 foreach ($hooked_plugins as $hooked_plugin => $hooked_function)
509 if ($hooked_plugin == $name
510 && (empty($static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin])
511 || $static_squirrelmail_plugin_hooks[$hook_name][$hooked_plugin] != $hooked_function))
512 do_err('The plugin <i>' . $name . '</i> is supposed to be registered on the <i>' . $hook_name . '</i> hook, but it is not. You need to re-run the configuration utility and re-save your configuration file.', FALSE);
513 }
69792446 514 }
1dc63862 515 $squirrelmail_plugin_hooks = $static_squirrelmail_plugin_hooks;
516
517
dc528046 518 /**
56f9bb83 519 * Print plugin versions
520 */
56f9bb83 521 echo $IND . "Plugin versions...<br />\n";
522 foreach ($plugins as $name) {
d95b10b3 523 $plugin_version = get_plugin_version($name);
daa0c5b8 524 $english_name = get_plugin_requirement($name, 'english_name');
525 echo $IND . $IND . (empty($english_name) ? $name . ' ' : $english_name . ' (' . $name . ') ') . (empty($plugin_version) ? '??' : $plugin_version) . "<br />\n";
2cbaf68d 526
dc528046 527 // check if this plugin has any other plugin
2cbaf68d 528 // dependencies and if they are satisfied
529 //
530 $failed_dependencies = check_plugin_dependencies($name);
f258865c 531 if ($failed_dependencies === SQ_INCOMPATIBLE) {
03a69f57 532 do_err($name . ' is NOT COMPATIBLE with this version of SquirrelMail', FALSE);
533 }
534 else if (is_array($failed_dependencies)) {
2cbaf68d 535 $missing_plugins = '';
e1a125cd 536 $incompatible_plugins = '';
fc6228e4 537 foreach ($failed_dependencies as $depend_name => $depend_requirements) {
e1a125cd 538 if ($depend_requirements['version'] == SQ_INCOMPATIBLE)
539 $incompatible_plugins .= ', ' . $depend_name;
540 else
541 $missing_plugins .= ', ' . $depend_name . ' (version ' . $depend_requirements['version'] . ', ' . ($depend_requirements['activate'] ? 'must be activated' : 'need not be activated') . ')';
2cbaf68d 542 }
e1a125cd 543 $error_string = (!empty($incompatible_plugins) ? $name . ' cannot be activated at the same time as the following plugins: ' . trim($incompatible_plugins, ', ') : '')
544 . (!empty($missing_plugins) ? (!empty($incompatible_plugins) ? '. ' . $name . ' is also ' : $name . ' is ') . 'missing some dependencies: ' . trim($missing_plugins, ', ') : '');
545 do_err($error_string, FALSE);
2cbaf68d 546 }
547
56f9bb83 548 }
1dc63862 549
550
69792446 551 /**
dc528046 552 * This hook was added in 1.5.2 and 1.4.10. Each plugins should print an error
6e515418 553 * message and return TRUE if there are any errors in its setup/configuration.
69792446 554 */
62fb877b 555 $plugin_err = boolean_hook_function('configtest', $null, 1);
69792446 556 if($plugin_err) {
557 do_err('Some plugin tests failed.');
558 } else {
559 echo $IND . "Plugins OK.<br />\n";
560 }
5b53b7e0 561} else {
562 echo $IND . "Plugins are not enabled in config.<br />\n";
d1ae9d4c 563}
d1ae9d4c 564foreach($theme as $thm) {
565 if(!file_exists($thm['PATH'])) {
566 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
567 } elseif(!is_readable($thm['PATH'])) {
568 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
569 }
570}
571
572echo $IND . "Themes OK.<br />\n";
573
07337c9b 574if ( $squirrelmail_default_language != 'en_US' ) {
575 $loc_path = SM_PATH .'locale/'.$squirrelmail_default_language.'/LC_MESSAGES/squirrelmail.mo';
576 if( ! file_exists( $loc_path ) ) {
f8a1ed5a 577 do_err('You have set <i>' . $squirrelmail_default_language .
f084f987 578 '</i> as your default language, but I cannot find this translation (should be '.
579 'in <tt>' . $loc_path . '</tt>). Please note that you have to download translations '.
580 'separately from the main SquirrelMail package.', FALSE);
07337c9b 581 } elseif ( ! is_readable( $loc_path ) ) {
f8a1ed5a 582 do_err('You have set <i>' . $squirrelmail_default_language .
f084f987 583 '</i> as your default language, but I cannot read this translation (file '.
584 'in <tt>' . $loc_path . '</tt> unreadable).', FALSE);
07337c9b 585 } else {
586 echo $IND . "Default language OK.<br />\n";
587 }
588} else {
589 echo $IND . "Default language OK.<br />\n";
590}
591
3047e291 592echo $IND . "Base URL detected as: <tt>" . sm_encode_html_special_chars($test_location) .
74530cf4 593 "</tt> (location base " . (empty($config_location_base) ? 'autodetected' : 'set to <tt>' .
3047e291 594 sm_encode_html_special_chars($config_location_base)."</tt>") . ")<br />\n";
23649466 595
a15f9d93 596/* check minimal requirements for other security options */
d1ae9d4c 597
a15f9d93 598/* imaps or ssmtp */
599if($use_smtp_tls == 1 || $use_imap_tls == 1) {
d1ae9d4c 600 if(!check_php_version(4,3,0)) {
601 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
602 }
603 if(!extension_loaded('openssl')) {
604 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
605 }
606}
a15f9d93 607/* starttls extensions */
1c4f110f 608if($use_smtp_tls === 2 || $use_imap_tls === 2) {
a15f9d93 609 if (! function_exists('stream_socket_enable_crypto')) {
610 do_err('If you want to use STARTTLS extension, you need stream_socket_enable_crypto() function from PHP 5.1.0 and newer.');
611 }
612}
613/* digest-md5 */
614if ($smtp_auth_mech=='digest-md5' || $imap_auth_mech =='digest-md5') {
615 if (!extension_loaded('xml')) {
616 do_err('You need the PHP XML extension to use Digest-MD5 authentication!');
617 }
618}
619
620/* check outgoing mail */
d1ae9d4c 621
622echo "Checking outgoing mail service....<br />\n";
623
624if($useSendmail) {
625 // is_executable also checks for existance, but we want to be as precise as possible with the errors
626 if(!file_exists($sendmail_path)) {
627 do_err("Location of sendmail program incorrect ($sendmail_path)!");
91e0dccc 628 }
d1ae9d4c 629 if(!is_executable($sendmail_path)) {
630 do_err("I cannot execute the sendmail program ($sendmail_path)!");
631 }
632
633 echo $IND . "sendmail OK<br />\n";
634} else {
3ee5d63b 635 // NB: Using "ssl://" ensures the highest possible TLS version
636 // will be negotiated with the server (whereas "tls://" only
637 // uses TLS version 1.0)
638 $stream = fsockopen( ($use_smtp_tls==1?'ssl://':'').$smtpServerAddress, $smtpPort,
f084f987 639 $errorNumber, $errorString);
d1ae9d4c 640 if(!$stream) {
641 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
3047e291 642 "Server error: ($errorNumber) ".sm_encode_html_special_chars($errorString));
d1ae9d4c 643 }
644
645 // check for SMTP code; should be 2xx to allow us access
646 $smtpline = fgets($stream, 1024);
647 if(((int) $smtpline{0}) > 3) {
9c941728 648 do_err("Error connecting to SMTP server. Server error: ".
3047e291 649 sm_encode_html_special_chars($smtpline));
d1ae9d4c 650 }
651
a15f9d93 652 /* smtp starttls checks */
1c4f110f 653 if ($use_smtp_tls===2) {
a15f9d93 654 // if something breaks, script should close smtp connection on exit.
655
a820ac9d 656
657 // format EHLO argument correctly if needed
658 //
870ffc40 659 if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $client_ip))
a820ac9d 660 $helohost = '[' . $client_ip . ']';
661 else // some day might add IPv6 here
662 $helohost = $client_ip;
663
664
a15f9d93 665 // say helo
a820ac9d 666 fwrite($stream,"EHLO $helohost\r\n");
a15f9d93 667
668 $ehlo=array();
669 $ehlo_error = false;
670 while ($line=fgets($stream, 1024)){
671 if (preg_match("/^250(-|\s)(\S*)\s+(\S.*)/",$line,$match)||
f084f987 672 preg_match("/^250(-|\s)(\S*)\s+/",$line,$match)) {
a15f9d93 673 if (!isset($match[3])) {
674 // simple one word extension
675 $ehlo[strtoupper($match[2])]='';
676 } else {
677 // ehlo-keyword + ehlo-param
678 $ehlo[strtoupper($match[2])]=trim($match[3]);
679 }
680 if ($match[1]==' ') {
681 $ret = $line;
682 break;
683 }
684 } else {
dc528046 685 //
a15f9d93 686 $ehlo_error = true;
687 $ehlo[]=$line;
688 break;
689 }
690 }
691 if ($ehlo_error) {
692 do_err('SMTP EHLO failed. You need ESMTP support for SMTP STARTTLS');
693 } elseif (!array_key_exists('STARTTLS',$ehlo)) {
694 do_err('STARTTLS support is not declared by SMTP server.');
695 }
696
697 fwrite($stream,"STARTTLS\r\n");
698 $starttls_response=fgets($stream, 1024);
699 if ($starttls_response[0]!=2) {
700 $starttls_cmd_err = 'SMTP STARTTLS failed. Server replied: '
3047e291 701 .sm_encode_html_special_chars($starttls_response);
a15f9d93 702 do_err($starttls_cmd_err);
703 } elseif(! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
704 do_err('Failed to enable encryption on SMTP STARTTLS connection.');
705 } else {
706 echo $IND . "SMTP STARTTLS extension looks OK.<br />\n";
707 }
708 // According to RFC we should second ehlo call here.
709 }
710
d1ae9d4c 711 fputs($stream, 'QUIT');
712 fclose($stream);
9c941728 713 echo $IND . 'SMTP server OK (<tt><small>'.
3047e291 714 trim(sm_encode_html_special_chars($smtpline))."</small></tt>)<br />\n";
d1ae9d4c 715
716 /* POP before SMTP */
717 if($pop_before_smtp) {
783e926e 718 if (empty($pop_before_smtp_host)) $pop_before_smtp_host = $smtpServerAddress;
719 $stream = fsockopen($pop_before_smtp_host, 110, $err_no, $err_str);
d1ae9d4c 720 if (!$stream) {
783e926e 721 do_err("Error connecting to POP Server ($pop_before_smtp_host:110) "
3047e291 722 . $err_no . ' : ' . sm_encode_html_special_chars($err_str));
d1ae9d4c 723 }
724
725 $tmp = fgets($stream, 1024);
726 if (substr($tmp, 0, 3) != '+OK') {
783e926e 727 do_err("Error connecting to POP Server ($pop_before_smtp_host:110)"
3047e291 728 . ' '.sm_encode_html_special_chars($tmp));
d1ae9d4c 729 }
730 fputs($stream, 'QUIT');
731 fclose($stream);
732 echo $IND . "POP-before-SMTP OK.<br />\n";
733 }
734}
735
df758744 736/**
737 * Check the IMAP server
738 */
d1ae9d4c 739echo "Checking IMAP service....<br />\n";
740
df758744 741/** Can we open a connection? */
3ee5d63b 742// NB: Using "ssl://" ensures the highest possible TLS version
743// will be negotiated with the server (whereas "tls://" only
744// uses TLS version 1.0)
745$stream = fsockopen( ($use_imap_tls==1?'ssl://':'').$imapServerAddress, $imapPort,
f084f987 746 $errorNumber, $errorString);
d1ae9d4c 747if(!$stream) {
70b71161 748 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
f084f987 749 "Server error: ($errorNumber) ".
3047e291 750 sm_encode_html_special_chars($errorString));
d1ae9d4c 751}
752
df758744 753/** Is the first response 'OK'? */
d1ae9d4c 754$imapline = fgets($stream, 1024);
755if(substr($imapline, 0,4) != '* OK') {
f084f987 756 do_err('Error connecting to IMAP server. Server error: '.
3047e291 757 sm_encode_html_special_chars($imapline));
d1ae9d4c 758}
759
df758744 760echo $IND . 'IMAP server ready (<tt><small>'.
3047e291 761 sm_encode_html_special_chars(trim($imapline))."</small></tt>)<br />\n";
d1ae9d4c 762
df758744 763/** Check capabilities */
764fputs($stream, "A001 CAPABILITY\r\n");
a15f9d93 765$capline = '';
766while ($line=fgets($stream, 1024)){
f084f987 767 if (preg_match("/A001.*/",$line)) {
768 break;
769 } else {
770 $capline.=$line;
771 }
a15f9d93 772}
773
774/* don't display capabilities before STARTTLS */
1c4f110f 775if ($use_imap_tls===2 && stristr($capline, 'STARTTLS') === false) {
a15f9d93 776 do_err('Your server doesn\'t support STARTTLS.');
1c4f110f 777} elseif($use_imap_tls===2) {
a15f9d93 778 /* try starting starttls */
779 fwrite($stream,"A002 STARTTLS\r\n");
780 $starttls_line=fgets($stream, 1024);
781 if (! preg_match("/^A002 OK.*/i",$starttls_line)) {
782 $imap_starttls_err = 'IMAP STARTTLS failed. Server replied: '
3047e291 783 .sm_encode_html_special_chars($starttls_line);
a15f9d93 784 do_err($imap_starttls_err);
785 } elseif (! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
786 do_err('Failed to enable encryption on IMAP connection.');
787 } else {
788 echo $IND . "IMAP STARTTLS extension looks OK.<br />\n";
789 }
790
791 // get new capability line
792 fwrite($stream,"A003 CAPABILITY\r\n");
793 $capline='';
794 while ($line=fgets($stream, 1024)){
795 if (preg_match("/A003.*/",$line)) {
796 break;
797 } else {
798 $capline.=$line;
799 }
800 }
801}
df758744 802
3047e291 803echo $IND . 'Capabilities: <tt>'.sm_encode_html_special_chars($capline)."</tt><br />\n";
df758744 804
805if($imap_auth_mech == 'login' && stristr($capline, 'LOGINDISABLED') !== FALSE) {
806 do_err('Your server doesn\'t allow plaintext logins. '.
f084f987 807 'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '.
808 'in the SquirrelMail configuration.', FALSE);
df758744 809}
df758744 810
ceb7ad3c 811if (stristr($capline, 'XMAGICTRASH') !== false) {
812 $magic_trash = 'It looks like IMAP_MOVE_EXPUNGE_TO_TRASH option is turned on '
813 .'in your Courier IMAP configuration. Courier does not provide tools that '
814 .'allow to detect folder used for Trash or commands are not documented. '
815 .'SquirrelMail can\'t detect special trash folder. SquirrelMail manages '
816 .'all message deletion or move operations internally and '
817 .'IMAP_MOVE_EXPUNGE_TO_TRASH option can cause errors in message and '
818 .'folder management operations. Please turn off IMAP_MOVE_EXPUNGE_TO_TRASH '
819 .'option in Courier imapd configuration.';
820 do_err($magic_trash,false);
821}
822
0fa9bde7 823/* add warning about IMAP delivery */
824if (stristr($capline, 'XCOURIEROUTBOX') !== false) {
825 $courier_outbox = 'OUTBOX setting is enabled in your Courier imapd '
826 .'configuration. SquirrelMail uses standard SMTP protocol or sendmail '
827 .'binary to send emails. Courier IMAP delivery method is not supported'
828 .' and can create duplicate email messages.';
829 do_err($courier_outbox,false);
830}
831
df758744 832/** OK, close connection */
a15f9d93 833fputs($stream, "A004 LOGOUT\r\n");
df758744 834fclose($stream);
835
17fca61d 836echo "Checking internationalization (i18n) settings...<br />\n";
0ed3bdc3 837echo "$IND gettext - ";
838if (function_exists('gettext')) {
8f186a2a 839 echo 'Gettext functions are available.'
840 .' On some systems you must have appropriate system locales compiled.'
841 ."<br />\n";
fd72907b 842
843 /* optional setlocale() tests. Should work only on glibc systems. */
844 if (sqgetGlobalVar('testlocales',$testlocales,SQ_GET)) {
867fed37 845 include_once(SM_PATH . 'include/languages.php');
fd72907b 846 echo $IND . $IND . 'Testing translations:<br>';
847 foreach ($languages as $lang_code => $lang_data) {
848 /* don't test aliases */
849 if (isset($lang_data['NAME'])) {
850 /* locale can be $lang_code or $lang_data['LOCALE'] */
851 if (isset($lang_data['LOCALE'])) {
852 $setlocale = $lang_data['LOCALE'];
853 } else {
854 $setlocale = $lang_code;
855 }
856 /* prepare information about tested locales */
857 if (is_array($setlocale)) {
858 $display_locale = implode(', ',$setlocale);
859 $locale_count = count($setlocale);
860 } else {
861 $display_locale = $setlocale;
862 $locale_count = 1;
863 }
3047e291 864 $tested_locales_msg = 'Tested '.sm_encode_html_special_chars($display_locale).' '
fd72907b 865 .($locale_count>1 ? 'locales':'locale'). '.';
866
867 echo $IND . $IND .$IND . $lang_data['NAME'].' (' .$lang_code. ') - ';
868 $retlocale = sq_setlocale(LC_ALL,$setlocale);
869 if (is_bool($retlocale)) {
870 echo '<font color="red">unsupported</font>. ';
871 echo $tested_locales_msg;
872 } else {
873 echo 'supported. '
874 .$tested_locales_msg
3047e291 875 .' setlocale() returned "'.sm_encode_html_special_chars($retlocale).'"';
fd72907b 876 }
877 echo "<br />\n";
878 }
879 }
880 echo $IND . $IND . '<a href="configtest.php">Don\'t test translations</a>';
881 } else {
882 echo $IND . $IND . '<a href="configtest.php?testlocales=1">Test translations</a>. '
883 .'This test is not accurate and might work only on some systems.'
884 ."\n";
885 }
886 echo "<br />\n";
887 /* end of translation tests */
0ed3bdc3 888} else {
8f186a2a 889 echo 'Gettext functions are unavailable.'
890 .' SquirrelMail will use slower internal gettext functions.'
891 ."<br />\n";
0ed3bdc3 892}
893echo "$IND mbstring - ";
894if (function_exists('mb_detect_encoding')) {
895 echo "Mbstring functions are available.<br />\n";
896} else {
8f186a2a 897 echo 'Mbstring functions are unavailable.'
898 ." Japanese translation won't work.<br />\n";
0ed3bdc3 899}
900echo "$IND recode - ";
901if (function_exists('recode')) {
902 echo "Recode functions are available.<br />\n";
ba17b6c7 903} elseif (isset($use_php_recode) && $use_php_recode) {
0ed3bdc3 904 echo "Recode functions are unavailable.<br />\n";
905 do_err('Your configuration requires recode support, but recode support is missing.');
906} else {
907 echo "Recode functions are unavailable.<br />\n";
908}
909echo "$IND iconv - ";
910if (function_exists('iconv')) {
911 echo "Iconv functions are available.<br />\n";
ba17b6c7 912} elseif (isset($use_php_iconv) && $use_php_iconv) {
0ed3bdc3 913 echo "Iconv functions are unavailable.<br />\n";
914 do_err('Your configuration requires iconv support, but iconv support is missing.');
915} else {
916 echo "Iconv functions are unavailable.<br />\n";
917}
867fed37 918// same test as in include/init.php + date_default_timezone_set check
0ed3bdc3 919echo "$IND timezone - ";
867fed37 920if ( (!ini_get('safe_mode')) || function_exists('date_default_timezone_set') ||
f084f987 921 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
922 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
fd72907b 923 echo "Webmail users can change their time zone settings. \n";
0ed3bdc3 924} else {
fd72907b 925 echo "Webmail users can't change their time zone settings. \n";
4764a7ff 926}
fd72907b 927if (isset($_ENV['TZ'])) {
3047e291 928 echo 'Default time zone is '.sm_encode_html_special_chars($_ENV['TZ']);
fd72907b 929} else {
930 echo 'Current time zone is '.date('T');
931}
932echo ".<br />\n";
d18703d3 933
4764a7ff 934// Pear DB tests
d18703d3 935echo "Checking database functions...<br />\n";
936if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) {
134e4174 937 @include_once('DB.php');
938 if (class_exists('DB')) {
939 echo "$IND PHP Pear DB support is present.<br />\n";
940 $db_functions=array(
f084f987 941 'dbase' => 'dbase_open',
942 'fbsql' => 'fbsql_connect',
943 'interbase' => 'ibase_connect',
944 'informix' => 'ifx_connect',
945 'msql' => 'msql_connect',
946 'mssql' => 'mssql_connect',
947 'mysql' => 'mysql_connect',
948 'mysqli' => 'mysqli_connect',
949 'oci8' => 'ocilogon',
950 'odbc' => 'odbc_connect',
951 'pgsql' => 'pg_connect',
952 'sqlite' => 'sqlite_open',
953 'sybase' => 'sybase_connect'
954 );
134e4174 955
956 $dsns = array();
957 if($prefs_dsn) {
958 $dsns['preferences'] = $prefs_dsn;
959 }
960 if($addrbook_dsn) {
961 $dsns['addressbook'] = $addrbook_dsn;
962 }
963 if($addrbook_global_dsn) {
964 $dsns['global addressbook'] = $addrbook_global_dsn;
965 }
966
967 foreach($dsns as $type => $dsn) {
ba17b6c7 968 $aDsn = explode(':', $dsn);
969 $dbtype = array_shift($aDsn);
d053c206 970
134e4174 971 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
972 echo "$IND$dbtype database support present.<br />\n";
d053c206 973 } elseif(!(bool)ini_get('enable_dl') || (bool)ini_get('safe_mode')) {
974 do_err($dbtype.' database support not present!');
975 } else {
976 // Non-fatal error
977 do_err($dbtype.' database support not present or not configured!
978 Trying to dynamically load '.$dbtype.' extension.
979 Please note that it is advisable to not rely on dynamic loading of extensions.', FALSE);
980 }
134e4174 981
134e4174 982
d053c206 983 // now, test this interface:
134e4174 984
d053c206 985 $dbh = DB::connect($dsn, true);
986 if (DB::isError($dbh)) {
3047e291 987 do_err('Database error: '. sm_encode_html_special_chars(DB::errorMessage($dbh)) .
d053c206 988 ' in ' .$type .' DSN.');
d18703d3 989 }
d053c206 990 $dbh->disconnect();
991 echo "$IND$type database connect successful.<br />\n";
134e4174 992 }
993 } else {
8f186a2a 994 $db_error='Required PHP PEAR DB support is not available.'
995 .' Is PEAR installed and is the include path set correctly to find <tt>DB.php</tt>?'
dc528046 996 .' The include path is now: "<tt>' . ini_get('include_path') . '</tt>".';
8f186a2a 997 do_err($db_error);
134e4174 998 }
4764a7ff 999} else {
d18703d3 1000 echo $IND."not using database functionality.<br />\n";
0ed3bdc3 1001}
7562c55b 1002
1003// LDAP DB tests
1004echo "Checking LDAP functions...<br />\n";
1005if( empty($ldap_server) ) {
134e4174 1006 echo $IND."not using LDAP functionality.<br />\n";
7562c55b 1007} else {
d0184454 1008 if ( !function_exists('ldap_connect') ) {
7562c55b 1009 do_err('Required LDAP support is not available.');
1010 } else {
134e4174 1011 echo "$IND LDAP support present.<br />\n";
7562c55b 1012 foreach ( $ldap_server as $param ) {
1013
d0184454 1014 $linkid = @ldap_connect($param['host'], (empty($param['port']) ? 389 : $param['port']) );
7562c55b 1015
1016 if ( $linkid ) {
f084f987 1017 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
91e0dccc 1018
7562c55b 1019 if ( !empty($param['protocol']) &&
f084f987 1020 !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION, $param['protocol']) ) {
7562c55b 1021 do_err('Unable to set LDAP protocol');
91e0dccc 1022 }
7562c55b 1023
1024 if ( empty($param['binddn']) ) {
d0184454 1025 $bind = @ldap_bind($linkid);
7562c55b 1026 } else {
eb2ae346 1027 $bind = @ldap_bind($linkid, $param['binddn'], $param['bindpw']);
7562c55b 1028 }
1029
1030 if ( $bind ) {
1031 echo "$IND LDAP Bind Successful <br />";
1032 } else {
1033 do_err('Unable to Bind to LDAP Server');
1034 }
91e0dccc 1035
d0184454 1036 @ldap_close($linkid);
7562c55b 1037 } else {
1038 do_err('Connection to LDAP failed');
1039 }
1040 }
1041 }
1042}
a2b193bc 1043
3a196538 1044echo '<hr width="75%" align="center">';
1045echo '<h2 align="center">Summary</h2>';
1046$footer = '<hr width="75%" align="center">';
1047if ($warnings) {
b00dce9b 1048 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>';
f084f987 1049 echo $footer;
3a196538 1050} else {
f084f987 1051 print <<< EOF
d1ae9d4c 1052<p>Congratulations, your SquirrelMail setup looks fine to me!</p>
1053
13721b47 1054<p><a href="login.php">Login now</a></p>
d1ae9d4c 1055
1056</body>
3a196538 1057</html>
1058EOF;
f084f987 1059 echo $footer;
3a196538 1060}