3 * SquirrelMail configtest script
5 * Copyright (c) 2003 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 ?
><!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
19 <title
>SquirrelMail configtest
</title
>
22 <h1
>SquirrelMail configtest
</h1
>
24 <p
>This script will
try to check some aspects of your SquirrelMail configuration
25 and point you to errors whereever it can find them
. You need to go run
<tt
>conf
.pl
</tt
>
26 in this directory first before you run this script
.</p
>
30 function do_err($str, $exit = TRUE) {
31 echo '<p><font color="red"><b>ERROR:</b></font> ' .$str. "</p>\n";
33 echo '</body></html>';
38 $IND = str_repeat(' ',4);
41 define('SM_PATH', '../');
43 include(SM_PATH
. 'config/config.php');
44 include(SM_PATH
. 'functions/strings.php');
46 $included = array_map('basename', get_included_files() );
47 if(!in_array('config.php', $included)) {
48 if(!file_exists(SM_PATH
. 'config/config.php')) {
49 do_err('Config file '.SM_PATH
. 'config/config.php does not exist!<br />'.
50 'You need to run <tt>conf.pl</tt> first.');
52 do_err('Could not read '.SM_PATH
.'config/config.php! Check file permissions.');
54 if(!in_array('strings.php', $included)) {
55 do_err('Could not include '.SM_PATH
.'functions/strings.php!<br />'.
56 'Check permissions on that file.');
59 /* checking PHP specs */
61 echo '<p>SquirrelMail version: '.$version.'<br />'.
62 'Config file version: '.$config_version . '<br />'.
63 'Config file last modified: '.date ('d F Y H:i:s', filemtime(SM_PATH
. 'config/config.php')).'</p>';
65 echo "Checking PHP configuration...<br />\n";
67 if(!check_php_version(4,0,6)) {
68 do_err('Insufficient PHP version: '. PHP_VERSION
. '! Minimum required: 4.0.6');
71 echo $IND . 'PHP version '.PHP_VERSION
.' OK.<br />';
73 $php_exts = array('session','pcre');
74 $diff = array_diff($php_exts, get_loaded_extensions());
76 do_err('Required PHP extensions missing: '.implode(', ',$diff) );
79 echo $IND . 'PHP extensions OK.<br />';
84 echo "Checking paths...<br />\n";
86 if(!file_exists($data_dir)) {
87 do_err("Data dir ($data_dir) does not exist!");
89 if(!is_dir($data_dir)) {
90 do_err("Data dir ($data_dir) is not a directory!");
92 if(!is_readable($data_dir)) {
93 do_err("I cannot read from data dir ($data_dir)!");
95 if(!is_writable($data_dir)) {
96 do_err("I cannot write to data dir ($data_dir)!");
99 // todo_ornot: actually write something and read it back.
100 echo $IND . "Data dir OK.<br />\n";
103 if($data_dir == $attachment_dir) {
104 echo $IND . "Attachment dir is the same as data dir.<br />\n";
106 if(!file_exists($attachment_dir)) {
107 do_err("Attachment dir ($attachment_dir) does not exist!");
109 if (!is_dir($attachment_dir)) {
110 do_err("Attachment dir ($attachment_dir) is not a directory!");
112 if (!is_readable($attachment_dir)) {
113 do_err("I cannot read from attachment dir ($attachment_dir)!");
115 if (!is_writable($attachment_dir)) {
116 do_err("I cannot write to attachment dir ($attachment_dir)!");
118 echo $IND . "Attachment dir OK.<br />\n";
122 /* check plugins and themes */
124 foreach($plugins as $plugin) {
125 if(!file_exists(SM_PATH
.'plugins/'.$plugin)) {
126 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot find it.', FALSE);
127 } elseif (!is_readable(SM_PATH
.'plugins/'.$plugin.'/setup.php')) {
128 do_err('You have enabled the <i>'.$plugin.'</i> plugin but I cannot read its setup.php file.', FALSE);
132 echo $IND . "Plugins OK.<br />\n";
134 foreach($theme as $thm) {
135 if(!file_exists($thm['PATH'])) {
136 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot find it ('.$thm['PATH'].').', FALSE);
137 } elseif(!is_readable($thm['PATH'])) {
138 do_err('You have enabled the <i>'.$thm['NAME'].'</i> theme but I cannot read it ('.$thm['PATH'].').', FALSE);
142 echo $IND . "Themes OK.<br />\n";
145 /* check outgoing mail */
147 if($use_smtp_tls ||
$use_imap_tls) {
148 if(!check_php_version(4,3,0)) {
149 do_err('You need at least PHP 4.3.0 for SMTP/IMAP TLS!');
151 if(!extension_loaded('openssl')) {
152 do_err('You need the openssl PHP extension to use SMTP/IMAP TLS!');
156 echo "Checking outgoing mail service....<br />\n";
159 // is_executable also checks for existance, but we want to be as precise as possible with the errors
160 if(!file_exists($sendmail_path)) {
161 do_err("Location of sendmail program incorrect ($sendmail_path)!");
163 if(!is_executable($sendmail_path)) {
164 do_err("I cannot execute the sendmail program ($sendmail_path)!");
167 echo $IND . "sendmail OK<br />\n";
169 $stream = fsockopen( ($use_smtp_tls?
'tls://':'').$smtpServerAddress, $smtpPort,
170 $errorNumber, $errorString);
172 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
173 "Server error: ($errorNumber) $errorString");
176 // check for SMTP code; should be 2xx to allow us access
177 $smtpline = fgets($stream, 1024);
178 if(((int) $smtpline{0}) > 3) {
179 do_err("Error connecting to SMTP server. Server error: ".$smtpline);
182 fputs($stream, 'QUIT');
184 echo $IND . 'SMTP server OK (<tt><small>'.trim($smtpline)."</small></tt>)<br />\n";
186 /* POP before SMTP */
187 if($pop_before_smtp) {
188 $stream = fsockopen($smtpServerAddress, 110, $err_no, $err_str);
190 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
191 . " $err_no : $err_str");
194 $tmp = fgets($stream, 1024);
195 if (substr($tmp, 0, 3) != '+OK') {
196 do_err("Error connecting to POP Server ($smtpServerAddress:110)"
199 fputs($stream, 'QUIT');
201 echo $IND . "POP-before-SMTP OK.<br />\n";
205 echo "Checking IMAP service....<br />\n";
207 $stream = fsockopen( ($use_imap_tls?
'tls://':'').$imapServerAddress, $imapPort,
208 $errorNumber, $errorString);
210 do_err("Error connecting to SMTP server \"$smtpServerAddress:$smtpPort\".".
211 "Server error: ($errorNumber) $errorString");
214 $imapline = fgets($stream, 1024);
215 if(substr($imapline, 0,4) != '* OK') {
216 do_err('Error connecting to IMAP server. Server error: '.$imapline);
219 fputs($stream, '001 LOGOUT');
222 echo $IND . 'IMAP server OK (<tt><small>'.trim($imapline)."</small></tt>)<br />\n";
224 // other possible checks:
227 // ? actually start a session to see if it works
231 <p
>Congratulations
, your SquirrelMail setup looks fine to me
!</p
>
233 <p
><a href
="<?php echo SM_PATH; ?>src/login.php">Login now
</a
></p
>