4 * SquirrelMail configtest script
6 * Copyright (c) 2003-2004 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
10 * @package squirrelmail
14 /************************************************************
15 * NOTE: you do not need to change this script! *
16 * If it throws errors you need to adjust your config. *
17 ************************************************************/
19 function do_err($str, $exit = TRUE) {
21 echo '<p>'.$IND.'<font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
23 echo '</body></html>';
28 $IND = str_repeat(' ',4);
32 define('SM_PATH', '../');
35 * Load config before output begins. functions/strings.php depends on
36 * functions/globals.php. functions/global.php needs to be run before
37 * any html output starts. If config.php is missing, error will be displayed
40 if (file_exists(SM_PATH
. 'config/config.php')) {
41 include(SM_PATH
. 'config/config.php');
42 include(SM_PATH
. 'functions/strings.php');
44 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
47 <title
>SquirrelMail configtest
</title
>
50 <h1
>SquirrelMail configtest
</h1
>
52 <p
>This script will
try to check some aspects of your SquirrelMail configuration
53 and point you to errors whereever it can find them
. You need to go run
<tt
>conf
.pl
</tt
>
54 in the
<tt
>config
/</tt
> directory first before you run this script
.</p
>
59 $included = array_map('basename', get_included_files() );
60 if(!in_array('config.php', $included)) {
61 if(!file_exists(SM_PATH
. 'config/config.php')) {
62 do_err('Config file '.SM_PATH
. 'config/config.php does not exist!<br />'.
63 'You need to run <tt>conf.pl</tt> first.');
65 do_err('Could not read '.SM_PATH
.'config/config.php! Check file permissions.');
67 if(!in_array('strings.php', $included)) {
68 do_err('Could not include '.SM_PATH
.'functions/strings.php!<br />'.
69 'Check permissions on that file.');
72 /* checking PHP specs */
74 echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" . $version . "</b></td></tr>\n" .
75 '<tr><td>Config file version:</td><td><b>' . $config_version . "</b></td></tr>\n" .
76 '<tr><td>Config file last modified:</td><td><b>' .
77 date ('d F Y H:i:s', filemtime(SM_PATH
. 'config/config.php')) .
78 "</b></td></tr>\n</table>\n</p>\n\n";
80 echo "Checking PHP configuration...<br />\n";
82 if(!check_php_version(4,1,0)) {
83 do_err('Insufficient PHP version: '. PHP_VERSION
. '! Minimum required: 4.1.0');
86 echo $IND . 'PHP version ' . PHP_VERSION
. " OK.<br />\n";
88 $php_exts = array('session','pcre');
89 $diff = array_diff($php_exts, get_loaded_extensions());
91 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
94 echo $IND . "PHP extensions OK.<br />\n";
99 echo "Checking paths...<br />\n";
101 if(!file_exists($data_dir)) {
102 do_err("Data dir ($data_dir) does not exist!");
104 if(!is_dir($data_dir)) {
105 do_err("Data dir ($data_dir) is not a directory!");
107 if(!is_readable($data_dir)) {
108 do_err("I cannot read from data dir ($data_dir)!");
110 if(!is_writable($data_dir)) {
111 do_err("I cannot write to data dir ($data_dir)!");
114 // todo_ornot: actually write something and read it back.
115 echo $IND . "Data dir OK.<br />\n";
118 if($data_dir == $attachment_dir) {
119 echo $IND . "Attachment dir is the same as data dir.<br />\n";
121 if(!file_exists($attachment_dir)) {
122 do_err("Attachment dir ($attachment_dir) does not exist!");
124 if (!is_dir($attachment_dir)) {
125 do_err("Attachment dir ($attachment_dir) is not a directory!");
127 if (!is_writable($attachment_dir)) {
128 do_err("I cannot write to attachment dir ($attachment_dir)!");
130 echo $IND . "Attachment dir OK.<br />\n";
134 /* check plugins and themes */
135 if (isset($plugins[0])) {
136 foreach($plugins as $plugin) {
137 if(!file_exists(SM_PATH
.'plugins/'.$plugin)) {
138 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
139 } elseif (!is_readable(SM_PATH
.'plugins/'.$plugin.'/setup.php')) {
140 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
143 echo $IND . "Plugins OK.<br />\n";
145 echo $IND . "Plugins are not enabled in config.<br />\n";
147 foreach($theme as $thm) {
148 if(!file_exists($thm['PATH'])) {
149 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
150 } elseif(!is_readable($thm['PATH'])) {
151 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
155 echo $IND . "Themes OK.<br />\n";
158 /* check outgoing mail */
160 if($use_smtp_tls ||
$use_imap_tls) {
161 if(!check_php_version(4,3,0)) {
162 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
164 if(!extension_loaded('openssl')) {
165 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
169 echo "Checking outgoing mail service....<br />\n";
172 // is_executable also checks for existance, but we want to be as precise as possible with the errors
173 if(!file_exists($sendmail_path)) {
174 do_err("Location of sendmail program incorrect ($sendmail_path)!");
176 if(!is_executable($sendmail_path)) {
177 do_err("I cannot execute the sendmail program ($sendmail_path)!");
180 echo $IND . "sendmail OK<br />\n";
182 $stream = fsockopen( ($use_smtp_tls?
'tls://':'').$smtpServerAddress, $smtpPort,
183 $errorNumber, $errorString);
185 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
186 "Server error: ($errorNumber) ".htmlspecialchars($errorString));
189 // check for SMTP code; should be 2xx to allow us access
190 $smtpline = fgets($stream, 1024);
191 if(((int) $smtpline{0}) > 3) {
192 do_err("Error connecting to SMTP server. Server error: ".
193 htmlspecialchars($smtpline));
196 fputs($stream, 'QUIT');
198 echo $IND . 'SMTP server OK (<tt><small>'.
199 trim(htmlspecialchars($smtpline))."</small></tt>)<br />\n";
201 /* POP before SMTP */
202 if($pop_before_smtp) {
203 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
205 do_err("Error connecting to POP Server ($smtpServerAddress:110) "
206 . $err_no . ' : ' . htmlspecialchars($err_str));
209 $tmp = fgets($stream, 1024);
210 if (substr($tmp, 0, 3) != '+OK') {
211 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
212 . ' '.htmlspecialchars($tmp));
214 fputs($stream, 'QUIT');
216 echo $IND . "POP-before-SMTP OK.<br />\n";
220 echo "Checking IMAP service....<br />\n";
222 $stream = fsockopen( ($use_imap_tls?
'tls://':'').$imapServerAddress, $imapPort,
223 $errorNumber, $errorString);
225 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
226 "Server error: ($errorNumber) ".
227 htmlspecialchars($errorString));
230 $imapline = fgets($stream, 1024);
231 if(substr($imapline, 0,4) != '* OK') {
232 do_err('Error connecting to IMAP server. Server error: '.
233 htmlspecialchars($imapline));
236 fputs($stream, '001 LOGOUT');
239 echo $IND . 'IMAP server OK (<tt><small>'.
240 htmlspecialchars(trim($imapline))."</small></tt>)<br />\n";
242 echo "Checking internationalization (i18n) settings...<br />\n";
243 echo "$IND gettext - ";
244 if (function_exists('gettext')) {
245 echo "Gettext functions are available. You must have appropriate system locales compiled.<br />\n";
247 echo "Gettext functions are unavailable. SquirrelMail will use slower internal gettext functions.<br />\n";
249 echo "$IND mbstring - ";
250 if (function_exists('mb_detect_encoding')) {
251 echo "Mbstring functions are available.<br />\n";
253 echo "Mbstring functions are unavailable. Japanese translation won't work.<br />\n";
255 echo "$IND recode - ";
256 if (function_exists('recode')) {
257 echo "Recode functions are available.<br />\n";
258 } elseif ($use_php_recode) {
259 echo "Recode functions are unavailable.<br />\n";
260 do_err('Your configuration requires recode support, but recode support is missing.');
262 echo "Recode functions are unavailable.<br />\n";
264 echo "$IND iconv - ";
265 if (function_exists('iconv')) {
266 echo "Iconv functions are available.<br />\n";
267 } elseif ($use_php_iconv) {
268 echo "Iconv functions are unavailable.<br />\n";
269 do_err('Your configuration requires iconv support, but iconv support is missing.');
271 echo "Iconv functions are unavailable.<br />\n";
273 // same test as in include/validate.php
274 echo "$IND timezone - ";
275 if ( (!ini_get('safe_mode')) ||
276 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
277 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
278 echo "Webmail users can change their time zone settings.<br />\n";
280 echo "Webmail users can't change their time zone settings.<br />\n";
285 echo "Checking database functions...<br />\n";
286 if($addrbook_dsn ||
$prefs_dsn ||
$addrbook_global_dsn) {
287 @include_once
('DB.php');
288 if (class_exists('DB')) {
289 echo "$IND PHP Pear DB support is present.<br />\n";
291 'dbase' => 'dbase_open',
292 'fbsql' => 'fbsql_connect',
293 'interbase' => 'ibase_connect',
294 'informix' => 'ifx_connect',
295 'msql' => 'msql_connect',
296 'mssql' => 'mssql_connect',
297 'mysql' => 'mysql_connect',
298 'mysqli' => 'mysqli_connect',
299 'oci8' => 'ocilogon',
300 'odbc' => 'odbc_connect',
301 'pgsql' => 'pgsql_connect',
302 'sqlite' => 'sqlite_open',
303 'sybase' => 'sybase_connect'
308 $dsns['preferences'] = $prefs_dsn;
311 $dsns['addressbook'] = $addrbook_dsn;
313 if($addrbook_global_dsn) {
314 $dsns['global addressbook'] = $addrbook_global_dsn;
317 foreach($dsns as $type => $dsn) {
318 $dbtype = array_shift(explode(':', $dsn));
319 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
320 echo "$IND$dbtype database support present.<br />\n";
322 // now, test this interface:
324 $dbh = DB
::connect($dsn, true);
325 if (DB
::isError($dbh)) {
326 do_err('Database error: '. htmlspecialchars(DB
::errorMessage($dbh)) .
327 ' in ' .$type .' DSN.');
330 echo "$IND$type database connect successful.<br />\n";
333 do_err($db.' database support not present!');
337 do_err('Required PHP PEAR DB support is not available. Is PEAR installed and is the
338 include path set correctly to find <tt>DB.php</tt>? The include path is now:
339 "<tt>' . ini_get('include_path') . '</tt>".');
342 echo $IND."not using database functionality.<br />\n";
346 echo "Checking LDAP functions...<br />\n";
347 if( empty($ldap_server) ) {
348 echo $IND."not using LDAP functionality.<br />\n";
350 if ( !function_exists(ldap_connect
) ) {
351 do_err('Required LDAP support is not available.');
353 echo "$IND LDAP support present.<br />\n";
354 foreach ( $ldap_server as $param ) {
356 $linkid = ldap_connect($param['host'], (empty($param['port']) ?
389 : $param['port']) );
359 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
361 if ( !empty($param['protocol']) &&
362 !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION
, $param['protocol']) ) {
363 do_err('Unable to set LDAP protocol');
366 if ( empty($param['binddn']) ) {
367 $bind = ldap_bind($linkid);
369 $bind = ldap_bind($param['binddn'], $param['bindpw']);
373 echo "$IND LDAP Bind Successful <br />";
375 do_err('Unable to Bind to LDAP Server');
380 do_err('Connection to LDAP failed');
387 <p
>Congratulations
, your SquirrelMail setup looks fine to me
!</p
>
389 <p
><a href
="login.php">Login now
</a
></p
>