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.
11 /************************************************************
12 * NOTE: you do not need to change this script! *
13 * If it throws errors you need to adjust your config. *
14 ************************************************************/
16 function do_err($str, $exit = TRUE) {
18 echo '<p>'.$IND.'<font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
20 echo '</body></html>';
25 $IND = str_repeat(' ',4);
28 define('SM_PATH', '../');
31 * Load config before output begins. functions/strings.php depends on
32 * functions/globals.php. functions/global.php needs to be run before
33 * any html output starts. If config.php is missing, error will be displayed
36 if (file_exists(SM_PATH
. 'config/config.php')) {
37 include(SM_PATH
. 'config/config.php');
38 include(SM_PATH
. 'functions/strings.php');
40 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
43 <title
>SquirrelMail configtest
</title
>
46 <h1
>SquirrelMail configtest
</h1
>
48 <p
>This script will
try to check some aspects of your SquirrelMail configuration
49 and point you to errors whereever it can find them
. You need to go run
<tt
>conf
.pl
</tt
>
50 in the
<tt
>config
/</tt
> directory first before you run this script
.</p
>
55 $included = array_map('basename', get_included_files() );
56 if(!in_array('config.php', $included)) {
57 if(!file_exists(SM_PATH
. 'config/config.php')) {
58 do_err('Config file '.SM_PATH
. 'config/config.php does not exist!<br />'.
59 'You need to run <tt>conf.pl</tt> first.');
61 do_err('Could not read '.SM_PATH
.'config/config.php! Check file permissions.');
63 if(!in_array('strings.php', $included)) {
64 do_err('Could not include '.SM_PATH
.'functions/strings.php!<br />'.
65 'Check permissions on that file.');
68 /* checking PHP specs */
70 echo '<p>SquirrelMail version: '.$version.'<br />'.
71 'Config file version: '.$config_version . '<br />'.
72 'Config file last modified: '.date ('d F Y H:i:s', filemtime(SM_PATH
. 'config/config.php')).'</p>';
74 echo "Checking PHP configuration...<br />\n";
76 if(!check_php_version(4,1,0)) {
77 do_err('Insufficient PHP version: '. PHP_VERSION
. '! Minimum required: 4.1.0');
80 echo $IND . 'PHP version '.PHP_VERSION
.' OK.<br />';
82 $php_exts = array('session','pcre');
83 $diff = array_diff($php_exts, get_loaded_extensions());
85 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
88 echo $IND . 'PHP extensions OK.<br />';
93 echo "Checking paths...<br />\n";
95 if(!file_exists($data_dir)) {
96 do_err("Data dir ($data_dir) does not exist!");
98 if(!is_dir($data_dir)) {
99 do_err("Data dir ($data_dir) is not a directory!");
101 if(!is_readable($data_dir)) {
102 do_err("I cannot read from data dir ($data_dir)!");
104 if(!is_writable($data_dir)) {
105 do_err("I cannot write to data dir ($data_dir)!");
108 // todo_ornot: actually write something and read it back.
109 echo $IND . "Data dir OK.<br />\n";
112 if($data_dir == $attachment_dir) {
113 echo $IND . "Attachment dir is the same as data dir.<br />\n";
115 if(!file_exists($attachment_dir)) {
116 do_err("Attachment dir ($attachment_dir) does not exist!");
118 if (!is_dir($attachment_dir)) {
119 do_err("Attachment dir ($attachment_dir) is not a directory!");
121 if (!is_writable($attachment_dir)) {
122 do_err("I cannot write to attachment dir ($attachment_dir)!");
124 echo $IND . "Attachment dir OK.<br />\n";
128 /* check plugins and themes */
129 if (isset($plugins[0])) {
130 foreach($plugins as $plugin) {
131 if(!file_exists(SM_PATH
.'plugins/'.$plugin)) {
132 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
133 } elseif (!is_readable(SM_PATH
.'plugins/'.$plugin.'/setup.php')) {
134 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
137 echo $IND . "Plugins OK.<br />\n";
139 echo $IND . "Plugins are not enabled in config.<br />\n";
141 foreach($theme as $thm) {
142 if(!file_exists($thm['PATH'])) {
143 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
144 } elseif(!is_readable($thm['PATH'])) {
145 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
149 echo $IND . "Themes OK.<br />\n";
152 /* check outgoing mail */
154 if($use_smtp_tls ||
$use_imap_tls) {
155 if(!check_php_version(4,3,0)) {
156 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
158 if(!extension_loaded('openssl')) {
159 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
163 echo "Checking outgoing mail service....<br />\n";
166 // is_executable also checks for existance, but we want to be as precise as possible with the errors
167 if(!file_exists($sendmail_path)) {
168 do_err("Location of sendmail program incorrect ($sendmail_path)!");
170 if(!is_executable($sendmail_path)) {
171 do_err("I cannot execute the sendmail program ($sendmail_path)!");
174 echo $IND . "sendmail OK<br />\n";
176 $stream = fsockopen( ($use_smtp_tls?
'tls://':'').$smtpServerAddress, $smtpPort,
177 $errorNumber, $errorString);
179 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
180 "Server error: ($errorNumber) $errorString");
183 // check for SMTP code; should be 2xx to allow us access
184 $smtpline = fgets($stream, 1024);
185 if(((int) $smtpline{0}) > 3) {
186 do_err("Error connecting to SMTP server. Server error: ".$smtpline);
189 fputs($stream, 'QUIT');
191 echo $IND . 'SMTP server OK (<tt><small>'.trim($smtpline)."</small></tt>)<br />\n";
193 /* POP before SMTP */
194 if($pop_before_smtp) {
195 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
197 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
198 . " $err_no : $err_str");
201 $tmp = fgets($stream, 1024);
202 if (substr($tmp, 0, 3) != '+OK') {
203 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
206 fputs($stream, 'QUIT');
208 echo $IND . "POP-before-SMTP OK.<br />\n";
212 echo "Checking IMAP service....<br />\n";
214 $stream = fsockopen( ($use_imap_tls?
'tls://':'').$imapServerAddress, $imapPort,
215 $errorNumber, $errorString);
217 do_err("Error connecting to IMAP server \"$imapServerAddress:$imapPort\".".
218 "Server error: ($errorNumber) $errorString");
221 $imapline = fgets($stream, 1024);
222 if(substr($imapline, 0,4) != '* OK') {
223 do_err('Error connecting to IMAP server. Server error: '.$imapline);
226 fputs($stream, '001 LOGOUT');
229 echo $IND . 'IMAP server OK (<tt><small>'.trim($imapline)."</small></tt>)<br />\n";
231 echo "Checking internationalization (i18n) settings:<br />\n";
232 echo "$IND gettext - ";
233 if (function_exists('gettext')) {
234 echo "Gettext functions are available. You must have appropriate system locales compiled.<br />\n";
236 echo "Gettext functions are unavailable. SquirrelMail will use slower internal gettext functions.<br />\n";
238 echo "$IND mbstring - ";
239 if (function_exists('mb_detect_encoding')) {
240 echo "Mbstring functions are available.<br />\n";
242 echo "Mbstring functions are unavailable. Japanese translation won't work.<br />\n";
244 echo "$IND recode - ";
245 if (function_exists('recode')) {
246 echo "Recode functions are available.<br />\n";
247 } elseif ($use_php_recode) {
248 echo "Recode functions are unavailable.<br />\n";
249 do_err('Your configuration requires recode support, but recode support is missing.');
251 echo "Recode functions are unavailable.<br />\n";
253 echo "$IND iconv - ";
254 if (function_exists('iconv')) {
255 echo "Iconv functions are available.<br />\n";
256 } elseif ($use_php_iconv) {
257 echo "Iconv functions are unavailable.<br />\n";
258 do_err('Your configuration requires iconv support, but iconv support is missing.');
260 echo "Iconv functions are unavailable.<br />\n";
262 // same test as in include/validate.php
263 echo "$IND timezone - ";
264 if ( (!ini_get('safe_mode')) ||
265 !strcmp(ini_get('safe_mode_allowed_env_vars'),'') ||
266 preg_match('/^([\w_]+,)*TZ/', ini_get('safe_mode_allowed_env_vars')) ) {
267 echo "Webmail users can change their time zone settings.<br />\n";
269 echo "Webmail users can't change their time zone settings.<br />\n";
274 echo "Checking database functions...<br />\n";
275 if($addrbook_dsn ||
$prefs_dsn ||
$addrbook_global_dsn) {
276 @include_once
('DB.php');
277 if (class_exists('DB')) {
278 echo "$IND PHP Pear DB support is present.<br />\n";
280 'dbase' => 'dbase_open',
281 'fbsql' => 'fbsql_connect',
282 'interbase' => 'ibase_connect',
283 'informix' => 'ifx_connect',
284 'msql' => 'msql_connect',
285 'mssql' => 'mssql_connect',
286 'mysql' => 'mysql_connect',
287 'mysqli' => 'mysqli_connect',
288 'oci8' => 'ocilogon',
289 'odbc' => 'odbc_connect',
290 'pgsql' => 'pgsql_connect',
291 'sqlite' => 'sqlite_open',
292 'sybase' => 'sybase_connect'
296 if($prefs_dsn) $dsns['preferences'] = $prefs_dsn;
297 if($addrbook_dsn) $dsns['addressbook'] = $addrbook_dsn;
298 if($addrbook_global_dsn) $dsns['global addressbook'] = $addrbook_global_dsn;
300 foreach($dsns as $type => $dsn) {
301 $dbtype = array_shift(explode(':', $dsn));
302 if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
303 echo "$IND$dbtype database support present.<br />\n";
305 // now, test this interface:
307 $dbh = DB
::connect($dsn, true);
308 if (DB
::isError($dbh)) {
309 do_err('Database error: '. DB
::errorMessage($dbh) . ' in ' .$type .' DSN.');
312 echo "$IND$type database connect successful.<br />\n";
315 do_err($db.' database support not present!');
319 do_err('Required PHP Pear DB support is not available.');;
322 echo $IND."not using database functionality.<br />\n";
326 <p
>Congratulations
, your SquirrelMail setup looks fine to me
!</p
>
328 <p
><a href
="login.php">Login now
</a
></p
>