3 * SquirrelMail configtest script
5 * Copyright (c) 2003-2004 The SquirrelMail Project Team
6 * Licensed under the GNU GPL. For full terms see the file COPYING.
9 * @package squirrelmail
13 /************************************************************
14 * NOTE: you do not need to change this script! *
15 * If it throws errors you need to adjust your config. *
16 ************************************************************/
18 function do_err($str, $exit = TRUE) {
20 echo '<p>'.$IND.'<font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
22 echo '</body></html>';
27 $IND = str_repeat(' ',4);
31 define('SM_PATH', '../');
34 * Load config before output begins. functions/strings.php depends on
35 * functions/globals.php. functions/global.php needs to be run before
36 * any html output starts. If config.php is missing, error will be displayed
39 if (file_exists(SM_PATH
. 'config/config.php')) {
40 include(SM_PATH
. 'config/config.php');
41 include(SM_PATH
. 'functions/strings.php');
43 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
46 <title
>SquirrelMail configtest
</title
>
49 <h1
>SquirrelMail configtest
</h1
>
51 <p
>This script will
try to check some aspects of your SquirrelMail configuration
52 and point you to errors whereever it can find them
. You need to go run
<tt
>conf
.pl
</tt
>
53 in the
<tt
>config
/</tt
> directory first before you run this script
.</p
>
58 $included = array_map('basename', get_included_files() );
59 if(!in_array('config.php', $included)) {
60 if(!file_exists(SM_PATH
. 'config/config.php')) {
61 do_err('Config file '.SM_PATH
. 'config/config.php does not exist!<br />'.
62 'You need to run <tt>conf.pl</tt> first.');
64 do_err('Could not read '.SM_PATH
.'config/config.php! Check file permissions.');
66 if(!in_array('strings.php', $included)) {
67 do_err('Could not include '.SM_PATH
.'functions/strings.php!<br />'.
68 'Check permissions on that file.');
71 /* checking PHP specs */
73 echo "<p><table>\n<tr><td>SquirrelMail version:</td><td><b>" . $version . "</b></td></tr>\n" .
74 '<tr><td>Config file version:</td><td><b>' . $config_version . "</b></td></tr>\n" .
75 '<tr><td>Config file last modified:</td><td><b>' .
76 date ('d F Y H:i:s', filemtime(SM_PATH
. 'config/config.php')) .
77 "</b></td></tr>\n</table>\n</p>\n\n";
79 echo "Checking PHP configuration...<br />\n";
81 if(!check_php_version(4,1,0)) {
82 do_err('Insufficient PHP version: '. PHP_VERSION
. '! Minimum required: 4.1.0');
85 echo $IND . 'PHP version ' . PHP_VERSION
. " OK.<br />\n";
87 $php_exts = array('session','pcre');
88 $diff = array_diff($php_exts, get_loaded_extensions());
90 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
93 echo $IND . "PHP extensions OK.<br />\n";
98 echo "Checking paths...<br />\n";
100 if(!file_exists($data_dir)) {
101 do_err("Data dir ($data_dir) does not exist!");
103 if(!is_dir($data_dir)) {
104 do_err("Data dir ($data_dir) is not a directory!");
106 if(!is_readable($data_dir)) {
107 do_err("I cannot read from data dir ($data_dir)!");
109 if(!is_writable($data_dir)) {
110 do_err("I cannot write to data dir ($data_dir)!");
113 // todo_ornot: actually write something and read it back.
114 echo $IND . "Data dir OK.<br />\n";
117 if($data_dir == $attachment_dir) {
118 echo $IND . "Attachment dir is the same as data dir.<br />\n";
120 if(!file_exists($attachment_dir)) {
121 do_err("Attachment dir ($attachment_dir) does not exist!");
123 if (!is_dir($attachment_dir)) {
124 do_err("Attachment dir ($attachment_dir) is not a directory!");
126 if (!is_writable($attachment_dir)) {
127 do_err("I cannot write to attachment dir ($attachment_dir)!");
129 echo $IND . "Attachment dir OK.<br />\n";
133 /* check plugins and themes */
134 if (isset($plugins[0])) {
135 foreach($plugins as $plugin) {
136 if(!file_exists(SM_PATH
.'plugins/'.$plugin)) {
137 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
138 } elseif (!is_readable(SM_PATH
.'plugins/'.$plugin.'/setup.php')) {
139 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
142 echo $IND . "Plugins OK.<br />\n";
144 echo $IND . "Plugins are not enabled in config.<br />\n";
146 foreach($theme as $thm) {
147 if(!file_exists($thm['PATH'])) {
148 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
149 } elseif(!is_readable($thm['PATH'])) {
150 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
154 echo $IND . "Themes OK.<br />\n";
157 /* check outgoing mail */
159 if($use_smtp_tls ||
$use_imap_tls) {
160 if(!check_php_version(4,3,0)) {
161 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
163 if(!extension_loaded('openssl')) {
164 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
168 echo "Checking outgoing mail service....<br />\n";
171 // is_executable also checks for existance, but we want to be as precise as possible with the errors
172 if(!file_exists($sendmail_path)) {
173 do_err("Location of sendmail program incorrect ($sendmail_path)!");
175 if(!is_executable($sendmail_path)) {
176 do_err("I cannot execute the sendmail program ($sendmail_path)!");
179 echo $IND . "sendmail OK<br />\n";
181 $stream = fsockopen( ($use_smtp_tls?
'tls://':'').$smtpServerAddress, $smtpPort,
182 $errorNumber, $errorString);
184 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
185 "Server error: ($errorNumber) ".htmlspecialchars($errorString));
188 // check for SMTP code; should be 2xx to allow us access
189 $smtpline = fgets($stream, 1024);
190 if(((int) $smtpline{0}) > 3) {
191 do_err("Error connecting to SMTP server. Server error: ".
192 htmlspecialchars($smtpline));
195 fputs($stream, 'QUIT');
197 echo $IND . 'SMTP server OK (<tt><small>'.
198 trim(htmlspecialchars($smtpline))."</small></tt>)<br />\n";
200 /* POP before SMTP */
201 if($pop_before_smtp) {
202 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
204 do_err("Error connecting to POP Server ($smtpServerAddress:110) "
205 . $err_no . ' : ' . htmlspecialchars($err_str));
208 $tmp = fgets($stream, 1024);
209 if (substr($tmp, 0, 3) != '+OK') {
210 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
211 . ' '.htmlspecialchars($tmp));
213 fputs($stream, 'QUIT');
215 echo $IND . "POP-before-SMTP OK.<br />\n";
219 echo "Checking IMAP service....<br />\n";
221 $stream = fsockopen( ($use_imap_tls?
'tls://':'').$imapServerAddress, $imapPort,
222 $errorNumber, $errorString);
224 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
225 "Server error: ($errorNumber) ".
226 htmlspecialchars($errorString));
229 $imapline = fgets($stream, 1024);
230 if(substr($imapline, 0,4) != '* OK') {
231 do_err('Error connecting to IMAP server. Server error: '.
232 htmlspecialchars($imapline));
235 fputs($stream, '001 LOGOUT');
238 echo $IND . 'IMAP server OK (<tt><small>'.
239 htmlspecialchars(trim($imapline))."</small></tt>)<br />\n";
241 echo "Checking internationalization (i18n) settings...<br />\n";
242 echo "$IND gettext - ";
243 if (function_exists('gettext')) {
244 echo "Gettext functions are available. You must have appropriate system locales compiled.<br />\n";
246 echo "Gettext functions are unavailable. SquirrelMail will use slower internal gettext functions.<br />\n";
248 echo "$IND mbstring - ";
249 if (function_exists('mb_detect_encoding')) {
250 echo "Mbstring functions are available.<br />\n";
252 echo "Mbstring functions are unavailable. Japanese translation won't work.<br />\n";
254 echo "$IND recode - ";
255 if (function_exists('recode')) {
256 echo "Recode functions are available.<br />\n";
257 } elseif ($use_php_recode) {
258 echo "Recode functions are unavailable.<br />\n";
259 do_err('Your configuration requires recode support, but recode support is missing.');
261 echo "Recode functions are unavailable.<br />\n";
263 echo "$IND iconv - ";
264 if (function_exists('iconv')) {
265 echo "Iconv functions are available.<br />\n";
266 } elseif ($use_php_iconv) {
267 echo "Iconv functions are unavailable.<br />\n";
268 do_err('Your configuration requires iconv support, but iconv support is missing.');
270 echo "Iconv functions are unavailable.<br />\n";
272 // same test as in include/validate.php
273 echo "$IND timezone - ";
274 if ( (!ini_get('safe_mode')) ||
275 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
276 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
277 echo "Webmail users can change their time zone settings.<br />\n";
279 echo "Webmail users can't change their time zone settings.<br />\n";
284 echo "Checking database functions...<br />\n";
285 if($addrbook_dsn ||
$prefs_dsn ||
$addrbook_global_dsn) {
286 @include_once
('DB.php');
287 if (class_exists('DB')) {
288 echo "$IND PHP Pear DB support is present.<br />\n";
290 'dbase' => 'dbase_open',
291 'fbsql' => 'fbsql_connect',
292 'interbase' => 'ibase_connect',
293 'informix' => 'ifx_connect',
294 'msql' => 'msql_connect',
295 'mssql' => 'mssql_connect',
296 'mysql' => 'mysql_connect',
297 'mysqli' => 'mysqli_connect',
298 'oci8' => 'ocilogon',
299 'odbc' => 'odbc_connect',
300 'pgsql' => 'pgsql_connect',
301 'sqlite' => 'sqlite_open',
302 'sybase' => 'sybase_connect'
306 if($prefs_dsn) $dsns['preferences'] = $prefs_dsn;
307 if($addrbook_dsn) $dsns['addressbook'] = $addrbook_dsn;
308 if($addrbook_global_dsn) $dsns['global addressbook'] = $addrbook_global_dsn;
310 foreach($dsns as $type => $dsn) {
311 $dbtype = array_shift(explode(':', $dsn));
312 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
313 echo "$IND$dbtype database support present.<br />\n";
315 // now, test this interface:
317 $dbh = DB
::connect($dsn, true);
318 if (DB
::isError($dbh)) {
319 do_err('Database error: '. htmlspecialchars(DB
::errorMessage($dbh)) .
320 ' in ' .$type .' DSN.');
323 echo "$IND$type database connect successful.<br />\n";
326 do_err($db.' database support not present!');
330 do_err('Required PHP PEAR DB support is not available. Is PEAR installed and is the
331 include path set correctly to find <tt>DB.php</tt>? The include path is now:
332 "<tt>' . ini_get('include_path') . '</tt>".');
335 echo $IND."not using database functionality.<br />\n";
339 echo "Checking LDAP functions...<br />\n";
340 if( empty($ldap_server) ) {
341 echo $IND."not using LDAP functionality.<br />\n";
343 if ( !function_exists(ldap_connect
) ) {
344 do_err('Required LDAP support is not available.');
346 echo "$IND LDAP support present.<br />\n";
347 foreach ( $ldap_server as $param ) {
349 $linkid = ldap_connect($param['host'], (empty($param['port']) ?
389 : $param['port']) );
352 echo "$IND LDAP connect to ".$param['host']." successful: ".$linkid."<br />\n";
354 if ( !empty($param['protocol']) &&
355 !ldap_set_option($linkid, LDAP_OPT_PROTOCOL_VERSION
, $param['protocol']) ) {
356 do_err('Unable to set LDAP protocol');
359 if ( empty($param['binddn']) ) {
360 $bind = ldap_bind($linkid);
362 $bind = ldap_bind($param['binddn'], $param['bindpw']);
366 echo "$IND LDAP Bind Successful <br />";
368 do_err('Unable to Bind to LDAP Server');
373 do_err('Connection to LDAP failed');
380 <p
>Congratulations
, your SquirrelMail setup looks fine to me
!</p
>
382 <p
><a href
="login.php">Login now
</a
></p
>