Fix uninitialized client IP address. Thanks to Wuerr Marcus
[squirrelmail.git] / src / configtest.php
CommitLineData
d1ae9d4c 1<?php
134e4174 2
30967a1e 3/**
d1ae9d4c 4 * SquirrelMail configtest script
5 *
5e5daa47 6 * @copyright 2003-2015 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 {
a15f9d93 635 $stream = fsockopen( ($use_smtp_tls==1?'tls://':'').$smtpServerAddress, $smtpPort,
f084f987 636 $errorNumber, $errorString);
d1ae9d4c 637 if(!$stream) {
638 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
3047e291 639 "Server error: ($errorNumber) ".sm_encode_html_special_chars($errorString));
d1ae9d4c 640 }
641
642 // check for SMTP code; should be 2xx to allow us access
643 $smtpline = fgets($stream, 1024);
644 if(((int) $smtpline{0}) > 3) {
9c941728 645 do_err("Error connecting to SMTP server. Server error: ".
3047e291 646 sm_encode_html_special_chars($smtpline));
d1ae9d4c 647 }
648
a15f9d93 649 /* smtp starttls checks */
1c4f110f 650 if ($use_smtp_tls===2) {
a15f9d93 651 // if something breaks, script should close smtp connection on exit.
652
a820ac9d 653
654 // format EHLO argument correctly if needed
655 //
870ffc40 656 if (preg_match('/^\d+\.\d+\.\d+\.\d+$/', $client_ip))
a820ac9d 657 $helohost = '[' . $client_ip . ']';
658 else // some day might add IPv6 here
659 $helohost = $client_ip;
660
661
a15f9d93 662 // say helo
a820ac9d 663 fwrite($stream,"EHLO $helohost\r\n");
a15f9d93 664
665 $ehlo=array();
666 $ehlo_error = false;
667 while ($line=fgets($stream, 1024)){
668 if (preg_match("/^250(-|\s)(\S*)\s+(\S.*)/",$line,$match)||
f084f987 669 preg_match("/^250(-|\s)(\S*)\s+/",$line,$match)) {
a15f9d93 670 if (!isset($match[3])) {
671 // simple one word extension
672 $ehlo[strtoupper($match[2])]='';
673 } else {
674 // ehlo-keyword + ehlo-param
675 $ehlo[strtoupper($match[2])]=trim($match[3]);
676 }
677 if ($match[1]==' ') {
678 $ret = $line;
679 break;
680 }
681 } else {
dc528046 682 //
a15f9d93 683 $ehlo_error = true;
684 $ehlo[]=$line;
685 break;
686 }
687 }
688 if ($ehlo_error) {
689 do_err('SMTP EHLO failed. You need ESMTP support for SMTP STARTTLS');
690 } elseif (!array_key_exists('STARTTLS',$ehlo)) {
691 do_err('STARTTLS support is not declared by SMTP server.');
692 }
693
694 fwrite($stream,"STARTTLS\r\n");
695 $starttls_response=fgets($stream, 1024);
696 if ($starttls_response[0]!=2) {
697 $starttls_cmd_err = 'SMTP STARTTLS failed. Server replied: '
3047e291 698 .sm_encode_html_special_chars($starttls_response);
a15f9d93 699 do_err($starttls_cmd_err);
700 } elseif(! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
701 do_err('Failed to enable encryption on SMTP STARTTLS connection.');
702 } else {
703 echo $IND . "SMTP STARTTLS extension looks OK.<br />\n";
704 }
705 // According to RFC we should second ehlo call here.
706 }
707
d1ae9d4c 708 fputs($stream, 'QUIT');
709 fclose($stream);
9c941728 710 echo $IND . 'SMTP server OK (<tt><small>'.
3047e291 711 trim(sm_encode_html_special_chars($smtpline))."</small></tt>)<br />\n";
d1ae9d4c 712
713 /* POP before SMTP */
714 if($pop_before_smtp) {
783e926e 715 if (empty($pop_before_smtp_host)) $pop_before_smtp_host = $smtpServerAddress;
716 $stream = fsockopen($pop_before_smtp_host, 110, $err_no, $err_str);
d1ae9d4c 717 if (!$stream) {
783e926e 718 do_err("Error connecting to POP Server ($pop_before_smtp_host:110) "
3047e291 719 . $err_no . ' : ' . sm_encode_html_special_chars($err_str));
d1ae9d4c 720 }
721
722 $tmp = fgets($stream, 1024);
723 if (substr($tmp, 0, 3) != '+OK') {
783e926e 724 do_err("Error connecting to POP Server ($pop_before_smtp_host:110)"
3047e291 725 . ' '.sm_encode_html_special_chars($tmp));
d1ae9d4c 726 }
727 fputs($stream, 'QUIT');
728 fclose($stream);
729 echo $IND . "POP-before-SMTP OK.<br />\n";
730 }
731}
732
df758744 733/**
734 * Check the IMAP server
735 */
d1ae9d4c 736echo "Checking IMAP service....<br />\n";
737
df758744 738/** Can we open a connection? */
a15f9d93 739$stream = fsockopen( ($use_imap_tls==1?'tls://':'').$imapServerAddress, $imapPort,
f084f987 740 $errorNumber, $errorString);
d1ae9d4c 741if(!$stream) {
70b71161 742 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
f084f987 743 "Server error: ($errorNumber) ".
3047e291 744 sm_encode_html_special_chars($errorString));
d1ae9d4c 745}
746
df758744 747/** Is the first response 'OK'? */
d1ae9d4c 748$imapline = fgets($stream, 1024);
749if(substr($imapline, 0,4) != '* OK') {
f084f987 750 do_err('Error connecting to IMAP server. Server error: '.
3047e291 751 sm_encode_html_special_chars($imapline));
d1ae9d4c 752}
753
df758744 754echo $IND . 'IMAP server ready (<tt><small>'.
3047e291 755 sm_encode_html_special_chars(trim($imapline))."</small></tt>)<br />\n";
d1ae9d4c 756
df758744 757/** Check capabilities */
758fputs($stream, "A001 CAPABILITY\r\n");
a15f9d93 759$capline = '';
760while ($line=fgets($stream, 1024)){
f084f987 761 if (preg_match("/A001.*/",$line)) {
762 break;
763 } else {
764 $capline.=$line;
765 }
a15f9d93 766}
767
768/* don't display capabilities before STARTTLS */
1c4f110f 769if ($use_imap_tls===2 && stristr($capline, 'STARTTLS') === false) {
a15f9d93 770 do_err('Your server doesn\'t support STARTTLS.');
1c4f110f 771} elseif($use_imap_tls===2) {
a15f9d93 772 /* try starting starttls */
773 fwrite($stream,"A002 STARTTLS\r\n");
774 $starttls_line=fgets($stream, 1024);
775 if (! preg_match("/^A002 OK.*/i",$starttls_line)) {
776 $imap_starttls_err = 'IMAP STARTTLS failed. Server replied: '
3047e291 777 .sm_encode_html_special_chars($starttls_line);
a15f9d93 778 do_err($imap_starttls_err);
779 } elseif (! stream_socket_enable_crypto($stream,true,STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
780 do_err('Failed to enable encryption on IMAP connection.');
781 } else {
782 echo $IND . "IMAP STARTTLS extension looks OK.<br />\n";
783 }
784
785 // get new capability line
786 fwrite($stream,"A003 CAPABILITY\r\n");
787 $capline='';
788 while ($line=fgets($stream, 1024)){
789 if (preg_match("/A003.*/",$line)) {
790 break;
791 } else {
792 $capline.=$line;
793 }
794 }
795}
df758744 796
3047e291 797echo $IND . 'Capabilities: <tt>'.sm_encode_html_special_chars($capline)."</tt><br />\n";
df758744 798
799if($imap_auth_mech == 'login' && stristr($capline, 'LOGINDISABLED') !== FALSE) {
800 do_err('Your server doesn\'t allow plaintext logins. '.
f084f987 801 'Try enabling another authentication mechanism like CRAM-MD5, DIGEST-MD5 or TLS-encryption '.
802 'in the SquirrelMail configuration.', FALSE);
df758744 803}
df758744 804
ceb7ad3c 805if (stristr($capline, 'XMAGICTRASH') !== false) {
806 $magic_trash = 'It looks like IMAP_MOVE_EXPUNGE_TO_TRASH option is turned on '
807 .'in your Courier IMAP configuration. Courier does not provide tools that '
808 .'allow to detect folder used for Trash or commands are not documented. '
809 .'SquirrelMail can\'t detect special trash folder. SquirrelMail manages '
810 .'all message deletion or move operations internally and '
811 .'IMAP_MOVE_EXPUNGE_TO_TRASH option can cause errors in message and '
812 .'folder management operations. Please turn off IMAP_MOVE_EXPUNGE_TO_TRASH '
813 .'option in Courier imapd configuration.';
814 do_err($magic_trash,false);
815}
816
0fa9bde7 817/* add warning about IMAP delivery */
818if (stristr($capline, 'XCOURIEROUTBOX') !== false) {
819 $courier_outbox = 'OUTBOX setting is enabled in your Courier imapd '
820 .'configuration. SquirrelMail uses standard SMTP protocol or sendmail '
821 .'binary to send emails. Courier IMAP delivery method is not supported'
822 .' and can create duplicate email messages.';
823 do_err($courier_outbox,false);
824}
825
df758744 826/** OK, close connection */
a15f9d93 827fputs($stream, "A004 LOGOUT\r\n");
df758744 828fclose($stream);
829
17fca61d 830echo "Checking internationalization (i18n) settings...<br />\n";
0ed3bdc3 831echo "$IND gettext - ";
832if (function_exists('gettext')) {
8f186a2a 833 echo 'Gettext functions are available.'
834 .' On some systems you must have appropriate system locales compiled.'
835 ."<br />\n";
fd72907b 836
837 /* optional setlocale() tests. Should work only on glibc systems. */
838 if (sqgetGlobalVar('testlocales',$testlocales,SQ_GET)) {
867fed37 839 include_once(SM_PATH . 'include/languages.php');
fd72907b 840 echo $IND . $IND . 'Testing translations:<br>';
841 foreach ($languages as $lang_code => $lang_data) {
842 /* don't test aliases */
843 if (isset($lang_data['NAME'])) {
844 /* locale can be $lang_code or $lang_data['LOCALE'] */
845 if (isset($lang_data['LOCALE'])) {
846 $setlocale = $lang_data['LOCALE'];
847 } else {
848 $setlocale = $lang_code;
849 }
850 /* prepare information about tested locales */
851 if (is_array($setlocale)) {
852 $display_locale = implode(', ',$setlocale);
853 $locale_count = count($setlocale);
854 } else {
855 $display_locale = $setlocale;
856 $locale_count = 1;
857 }
3047e291 858 $tested_locales_msg = 'Tested '.sm_encode_html_special_chars($display_locale).' '
fd72907b 859 .($locale_count>1 ? 'locales':'locale'). '.';
860
861 echo $IND . $IND .$IND . $lang_data['NAME'].' (' .$lang_code. ') - ';
862 $retlocale = sq_setlocale(LC_ALL,$setlocale);
863 if (is_bool($retlocale)) {
864 echo '<font color="red">unsupported</font>. ';
865 echo $tested_locales_msg;
866 } else {
867 echo 'supported. '
868 .$tested_locales_msg
3047e291 869 .' setlocale() returned "'.sm_encode_html_special_chars($retlocale).'"';
fd72907b 870 }
871 echo "<br />\n";
872 }
873 }
874 echo $IND . $IND . '<a href="configtest.php">Don\'t test translations</a>';
875 } else {
876 echo $IND . $IND . '<a href="configtest.php?testlocales=1">Test translations</a>. '
877 .'This test is not accurate and might work only on some systems.'
878 ."\n";
879 }
880 echo "<br />\n";
881 /* end of translation tests */
0ed3bdc3 882} else {
8f186a2a 883 echo 'Gettext functions are unavailable.'
884 .' SquirrelMail will use slower internal gettext functions.'
885 ."<br />\n";
0ed3bdc3 886}
887echo "$IND mbstring - ";
888if (function_exists('mb_detect_encoding')) {
889 echo "Mbstring functions are available.<br />\n";
890} else {
8f186a2a 891 echo 'Mbstring functions are unavailable.'
892 ." Japanese translation won't work.<br />\n";
0ed3bdc3 893}
894echo "$IND recode - ";
895if (function_exists('recode')) {
896 echo "Recode functions are available.<br />\n";
ba17b6c7 897} elseif (isset($use_php_recode) && $use_php_recode) {
0ed3bdc3 898 echo "Recode functions are unavailable.<br />\n";
899 do_err('Your configuration requires recode support, but recode support is missing.');
900} else {
901 echo "Recode functions are unavailable.<br />\n";
902}
903echo "$IND iconv - ";
904if (function_exists('iconv')) {
905 echo "Iconv functions are available.<br />\n";
ba17b6c7 906} elseif (isset($use_php_iconv) && $use_php_iconv) {
0ed3bdc3 907 echo "Iconv functions are unavailable.<br />\n";
908 do_err('Your configuration requires iconv support, but iconv support is missing.');
909} else {
910 echo "Iconv functions are unavailable.<br />\n";
911}
867fed37 912// same test as in include/init.php + date_default_timezone_set check
0ed3bdc3 913echo "$IND timezone - ";
867fed37 914if ( (!ini_get('safe_mode')) || function_exists('date_default_timezone_set') ||
f084f987 915 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
916 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
fd72907b 917 echo "Webmail users can change their time zone settings. \n";
0ed3bdc3 918} else {
fd72907b 919 echo "Webmail users can't change their time zone settings. \n";
4764a7ff 920}
fd72907b 921if (isset($_ENV['TZ'])) {
3047e291 922 echo 'Default time zone is '.sm_encode_html_special_chars($_ENV['TZ']);
fd72907b 923} else {
924 echo 'Current time zone is '.date('T');
925}
926echo ".<br />\n";
d18703d3 927
4764a7ff 928// Pear DB tests
d18703d3 929echo "Checking database functions...<br />\n";
930if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) {
134e4174 931 @include_once('DB.php');
932 if (class_exists('DB')) {
933 echo "$IND PHP Pear DB support is present.<br />\n";
934 $db_functions=array(
f084f987 935 'dbase' => 'dbase_open',
936 'fbsql' => 'fbsql_connect',
937 'interbase' => 'ibase_connect',
938 'informix' => 'ifx_connect',
939 'msql' => 'msql_connect',
940 'mssql' => 'mssql_connect',
941 'mysql' => 'mysql_connect',
942 'mysqli' => 'mysqli_connect',
943 'oci8' => 'ocilogon',
944 'odbc' => 'odbc_connect',
945 'pgsql' => 'pg_connect',
946 'sqlite' => 'sqlite_open',
947 'sybase' => 'sybase_connect'
948 );
134e4174 949
950 $dsns = array();
951 if($prefs_dsn) {
952 $dsns['preferences'] = $prefs_dsn;
953 }
954 if($addrbook_dsn) {
955 $dsns['addressbook'] = $addrbook_dsn;
956 }
957 if($addrbook_global_dsn) {
958 $dsns['global addressbook'] = $addrbook_global_dsn;
959 }
960
961 foreach($dsns as $type => $dsn) {
ba17b6c7 962 $aDsn = explode(':', $dsn);
963 $dbtype = array_shift($aDsn);
d053c206 964
134e4174 965 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
966 echo "$IND$dbtype database support present.<br />\n";
d053c206 967 } elseif(!(bool)ini_get('enable_dl') || (bool)ini_get('safe_mode')) {
968 do_err($dbtype.' database support not present!');
969 } else {
970 // Non-fatal error
971 do_err($dbtype.' database support not present or not configured!
972 Trying to dynamically load '.$dbtype.' extension.
973 Please note that it is advisable to not rely on dynamic loading of extensions.', FALSE);
974 }
134e4174 975
134e4174 976
d053c206 977 // now, test this interface:
134e4174 978
d053c206 979 $dbh = DB::connect($dsn, true);
980 if (DB::isError($dbh)) {
3047e291 981 do_err('Database error: '. sm_encode_html_special_chars(DB::errorMessage($dbh)) .
d053c206 982 ' in ' .$type .' DSN.');
d18703d3 983 }
d053c206 984 $dbh->disconnect();
985 echo "$IND$type database connect successful.<br />\n";
134e4174 986 }
987 } else {
8f186a2a 988 $db_error='Required PHP PEAR DB support is not available.'
989 .' Is PEAR installed and is the include path set correctly to find <tt>DB.php</tt>?'
dc528046 990 .' The include path is now: "<tt>' . ini_get('include_path') . '</tt>".';
8f186a2a 991 do_err($db_error);
134e4174 992 }
4764a7ff 993} else {
d18703d3 994 echo $IND."not using database functionality.<br />\n";
0ed3bdc3 995}
7562c55b 996
997// LDAP DB tests
998echo "Checking LDAP functions...<br />\n";
999if( empty($ldap_server) ) {
134e4174 1000 echo $IND."not using LDAP functionality.<br />\n";
7562c55b 1001} else {
d0184454 1002 if ( !function_exists('ldap_connect') ) {
7562c55b 1003 do_err('Required LDAP support is not available.');
1004 } else {
134e4174 1005 echo "$IND LDAP support present.<br />\n";
7562c55b 1006 foreach ( $ldap_server as $param ) {
1007
d0184454 1008 $linkid = @ldap_connect($param['host'], (empty($param['port']) ? 389 : $param['port']) );
7562c55b 1009
1010 if ( $linkid ) {
f084f987 1011 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
91e0dccc 1012
7562c55b 1013 if ( !empty($param['protocol']) &&
f084f987 1014 !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION, $param['protocol']) ) {
7562c55b 1015 do_err('Unable to set LDAP protocol');
91e0dccc 1016 }
7562c55b 1017
1018 if ( empty($param['binddn']) ) {
d0184454 1019 $bind = @ldap_bind($linkid);
7562c55b 1020 } else {
eb2ae346 1021 $bind = @ldap_bind($linkid, $param['binddn'], $param['bindpw']);
7562c55b 1022 }
1023
1024 if ( $bind ) {
1025 echo "$IND LDAP Bind Successful <br />";
1026 } else {
1027 do_err('Unable to Bind to LDAP Server');
1028 }
91e0dccc 1029
d0184454 1030 @ldap_close($linkid);
7562c55b 1031 } else {
1032 do_err('Connection to LDAP failed');
1033 }
1034 }
1035 }
1036}
a2b193bc 1037
3a196538 1038echo '<hr width="75%" align="center">';
1039echo '<h2 align="center">Summary</h2>';
1040$footer = '<hr width="75%" align="center">';
1041if ($warnings) {
b00dce9b 1042 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 1043 echo $footer;
3a196538 1044} else {
f084f987 1045 print <<< EOF
d1ae9d4c 1046<p>Congratulations, your SquirrelMail setup looks fine to me!</p>
1047
13721b47 1048<p><a href="login.php">Login now</a></p>
d1ae9d4c 1049
1050</body>
3a196538 1051</html>
1052EOF;
f084f987 1053 echo $footer;
3a196538 1054}