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>SquirrelMail version: '.$version.'<br />'.
74 'Config file version: '.$config_version . '<br />'.
75 'Config file last modified: '.date ('d F Y H:i:s', filemtime(SM_PATH
. 'config/config.php')).'</p>';
77 echo "Checking PHP configuration...<br />\n";
79 if(!check_php_version(4,1,0)) {
80 do_err('Insufficient PHP version: '. PHP_VERSION
. '! Minimum required: 4.1.0');
83 echo $IND . 'PHP version '.PHP_VERSION
.' OK.<br />';
85 $php_exts = array('session','pcre');
86 $diff = array_diff($php_exts, get_loaded_extensions());
88 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
91 echo $IND . 'PHP extensions OK.<br />';
96 echo "Checking paths...<br />\n";
98 if(!file_exists($data_dir)) {
99 do_err("Data dir ($data_dir) does not exist!");
101 if(!is_dir($data_dir)) {
102 do_err("Data dir ($data_dir) is not a directory!");
104 if(!is_readable($data_dir)) {
105 do_err("I cannot read from data dir ($data_dir)!");
107 if(!is_writable($data_dir)) {
108 do_err("I cannot write to data dir ($data_dir)!");
111 // todo_ornot: actually write something and read it back.
112 echo $IND . "Data dir OK.<br />\n";
115 if($data_dir == $attachment_dir) {
116 echo $IND . "Attachment dir is the same as data dir.<br />\n";
118 if(!file_exists($attachment_dir)) {
119 do_err("Attachment dir ($attachment_dir) does not exist!");
121 if (!is_dir($attachment_dir)) {
122 do_err("Attachment dir ($attachment_dir) is not a directory!");
124 if (!is_writable($attachment_dir)) {
125 do_err("I cannot write to attachment dir ($attachment_dir)!");
127 echo $IND . "Attachment dir OK.<br />\n";
131 /* check plugins and themes */
132 if (isset($plugins[0])) {
133 foreach($plugins as $plugin) {
134 if(!file_exists(SM_PATH
.'plugins/'.$plugin)) {
135 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
136 } elseif (!is_readable(SM_PATH
.'plugins/'.$plugin.'/setup.php')) {
137 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
140 echo $IND . "Plugins OK.<br />\n";
142 echo $IND . "Plugins are not enabled in config.<br />\n";
144 foreach($theme as $thm) {
145 if(!file_exists($thm['PATH'])) {
146 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
147 } elseif(!is_readable($thm['PATH'])) {
148 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
152 echo $IND . "Themes OK.<br />\n";
155 /* check outgoing mail */
157 if($use_smtp_tls ||
$use_imap_tls) {
158 if(!check_php_version(4,3,0)) {
159 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
161 if(!extension_loaded('openssl')) {
162 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
166 echo "Checking outgoing mail service....<br />\n";
169 // is_executable also checks for existance, but we want to be as precise as possible with the errors
170 if(!file_exists($sendmail_path)) {
171 do_err("Location of sendmail program incorrect ($sendmail_path)!");
173 if(!is_executable($sendmail_path)) {
174 do_err("I cannot execute the sendmail program ($sendmail_path)!");
177 echo $IND . "sendmail OK<br />\n";
179 $stream = fsockopen( ($use_smtp_tls?
'tls://':'').$smtpServerAddress, $smtpPort,
180 $errorNumber, $errorString);
182 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
183 "Server error: ($errorNumber) ".htmlspecialchars($errorString));
186 // check for SMTP code; should be 2xx to allow us access
187 $smtpline = fgets($stream, 1024);
188 if(((int) $smtpline{0}) > 3) {
189 do_err("Error connecting to SMTP server. Server error: ".
190 htmlspecialchars($smtpline));
193 fputs($stream, 'QUIT');
195 echo $IND . 'SMTP server OK (<tt><small>'.
196 trim(htmlspecialchars($smtpline))."</small></tt>)<br />\n";
198 /* POP before SMTP */
199 if($pop_before_smtp) {
200 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
202 do_err("Error connecting to POP Server ($smtpServerAddress:110) "
203 . $err_no . ' : ' . htmlspecialchars($err_str));
206 $tmp = fgets($stream, 1024);
207 if (substr($tmp, 0, 3) != '+OK') {
208 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
209 . ' '.htmlspecialchars($tmp));
211 fputs($stream, 'QUIT');
213 echo $IND . "POP-before-SMTP OK.<br />\n";
217 echo "Checking IMAP service....<br />\n";
219 $stream = fsockopen( ($use_imap_tls?
'tls://':'').$imapServerAddress, $imapPort,
220 $errorNumber, $errorString);
222 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
223 "Server error: ($errorNumber) ".
224 htmlspecialchars($errorString));
227 $imapline = fgets($stream, 1024);
228 if(substr($imapline, 0,4) != '* OK') {
229 do_err('Error connecting to IMAP server. Server error: '.
230 htmlspecialchars($imapline));
233 fputs($stream, '001 LOGOUT');
236 echo $IND . 'IMAP server OK (<tt><small>'.
237 htmlspecialchars(trim($imapline))."</small></tt>)<br />\n";
239 echo "Checking internationalization (i18n) settings:<br />\n";
240 echo "$IND gettext - ";
241 if (function_exists('gettext')) {
242 echo "Gettext functions are available. You must have appropriate system locales compiled.<br />\n";
244 echo "Gettext functions are unavailable. SquirrelMail will use slower internal gettext functions.<br />\n";
246 echo "$IND mbstring - ";
247 if (function_exists('mb_detect_encoding')) {
248 echo "Mbstring functions are available.<br />\n";
250 echo "Mbstring functions are unavailable. Japanese translation won't work.<br />\n";
252 echo "$IND recode - ";
253 if (function_exists('recode')) {
254 echo "Recode functions are available.<br />\n";
255 } elseif ($use_php_recode) {
256 echo "Recode functions are unavailable.<br />\n";
257 do_err('Your configuration requires recode support, but recode support is missing.');
259 echo "Recode functions are unavailable.<br />\n";
261 echo "$IND iconv - ";
262 if (function_exists('iconv')) {
263 echo "Iconv functions are available.<br />\n";
264 } elseif ($use_php_iconv) {
265 echo "Iconv functions are unavailable.<br />\n";
266 do_err('Your configuration requires iconv support, but iconv support is missing.');
268 echo "Iconv functions are unavailable.<br />\n";
270 // same test as in include/validate.php
271 echo "$IND timezone - ";
272 if ( (!ini_get('safe_mode')) ||
273 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
274 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
275 echo "Webmail users can change their time zone settings.<br />\n";
277 echo "Webmail users can't change their time zone settings.<br />\n";
282 echo "Checking database functions...<br />\n";
283 if($addrbook_dsn ||
$prefs_dsn ||
$addrbook_global_dsn) {
284 @include_once
('DB.php');
285 if (class_exists('DB')) {
286 echo "$IND PHP Pear DB support is present.<br />\n";
288 'dbase' => 'dbase_open',
289 'fbsql' => 'fbsql_connect',
290 'interbase' => 'ibase_connect',
291 'informix' => 'ifx_connect',
292 'msql' => 'msql_connect',
293 'mssql' => 'mssql_connect',
294 'mysql' => 'mysql_connect',
295 'mysqli' => 'mysqli_connect',
296 'oci8' => 'ocilogon',
297 'odbc' => 'odbc_connect',
298 'pgsql' => 'pgsql_connect',
299 'sqlite' => 'sqlite_open',
300 'sybase' => 'sybase_connect'
304 if($prefs_dsn) $dsns['preferences'] = $prefs_dsn;
305 if($addrbook_dsn) $dsns['addressbook'] = $addrbook_dsn;
306 if($addrbook_global_dsn) $dsns['global addressbook'] = $addrbook_global_dsn;
308 foreach($dsns as $type => $dsn) {
309 $dbtype = array_shift(explode(':', $dsn));
310 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
311 echo "$IND$dbtype database support present.<br />\n";
313 // now, test this interface:
315 $dbh = DB
::connect($dsn, true);
316 if (DB
::isError($dbh)) {
317 do_err('Database error: '. htmlspecialchars(DB
::errorMessage($dbh)) .
318 ' in ' .$type .' DSN.');
321 echo "$IND$type database connect successful.<br />\n";
324 do_err($db.' database support not present!');
328 do_err('Required PHP Pear DB support is not available.');;
331 echo $IND."not using database functionality.<br />\n";
335 <p
>Congratulations
, your SquirrelMail setup looks fine to me
!</p
>
337 <p
><a href
="login.php">Login now
</a
></p
>