Ticket #276: configtest.php-patch

File configtest.php-patch, 11.5 kB (added by rjl, 6 years ago)

Stephan Wentz's patch for configtest.php

Line 
1Index: configtest.php
2===================================================================
3--- configtest.php      (revision 968)
4+++ configtest.php      (working copy)
5@@ -93,13 +93,13 @@
6 
7        return $match;
8     }
9-   
10-   
11+
12+
13     define('OK', "ok");
14     define('WARN', "warn");
15     define('ERROR', "error");
16     define('UPDATE', "update");
17-   
18+
19     function print_row($left, $right, $err = OK) {
20         switch ($err) {
21             case OK:
22@@ -123,7 +123,7 @@
23         print("<td bgcolor=\"$color\" width=\"75%\">$status $right </td>");
24         print("</tr>\n");
25     }
26-   
27+
28     print("<div align=\"center\">");
29     print("<table border=\"0\" cellspacing=\"2\" cellpadding=\"2\" width=\"100%\">\n");
30 
31@@ -131,12 +131,12 @@
32     print("<h1>Maia Mailguard Configuration Tester</h1></td></tr>\n");
33 
34     $status = OK;
35-   
36+
37     //smarty compile dirs file permissions.
38     $smarty_base = "../themes"; // this assumes configtest.php is located in webroot/admin/
39-    $result = "";   
40+    $result = "";
41     $dir = opendir($smarty_base); #open directory
42-    while ($f = readdir($dir)) { #read one file name 
43+    while ($f = readdir($dir)) { #read one file name
44       if (!eregi("\.svn",$f) && $f!=='.' && $f!=='..'){
45         if (is_writable($smarty_base . "/" . $f . "/compiled")) {
46           continue;
47@@ -152,19 +152,19 @@
48                  "user can write to the above directories. ";
49     }
50     print_row("File Permissions", $result, $status);
51-   
52+
53     // PHP
54     $php_version = phpversion();
55     $include_path = ini_get("include_path");
56     $path_list = explode(":", $include_path);
57     $path_list[] = "../libs/";
58-   
59+
60     if ($php_version >= "4.0.2") {
61         if ($php_version == "5.0.3") {
62            $status = WARN;
63            $result = "PHP 5.0.3 has a bug that causes errors with PEAR::DB.  It is fixed in the current snapshots.";
64         } else {
65-     
66+
67           $result = $php_version;
68           $status = OK;
69         }
70@@ -176,7 +176,7 @@
71     }
72     print_row("PHP", $result, $status);
73 
74-   
75+
76     // PHP Modules
77     ob_start();
78     phpinfo(INFO_MODULES);
79@@ -195,8 +195,8 @@
80       $status = OK;
81     }
82     print_row("register_globals", $result, $status);
83-   
84-   
85+
86+
87     // SMARTY
88     if (!($smarty_dir = find_path($path_list, "Smarty"))) {
89        $result = "Not installed.  The Smarty templating engine is required. " .
90@@ -216,11 +216,11 @@
91       $result = "MySQL support available";
92       $status= OK;
93     } else {
94-      $result = "MySQL support not available";
95+      $result = "MySQL support not available";
96       $status = WARN;
97     }
98     print_row("MySQL Support", $result, $status);
99-   
100+
101     // PostgreSQL  support
102     $have_psql = false;
103     if(function_exists( 'pg_connect' )) {
104@@ -228,21 +228,21 @@
105       $result = "PostgreSQL support available";
106       $status= OK;
107     } else {
108-      $result = "PostgreSQL support not available";
109+      $result = "PostgreSQL support not available";
110       $status = WARN;
111     }
112     print_row("PostgreSQL Support", $result, $status);
113-   
114+
115     // Database support
116     if(!($have_mysql || $have_psql)) {
117       $result = "No supported databases are available!";
118-      $status = ERROR;
119+      $status = ERROR;
120     } else {
121       $result = "Database support is ok";
122       $status = OK;
123     }
124     print_row("Database Support", $result, $status);
125-   
126+
127     // PEAR
128     $have_pear = false;
129     if (!($pear_dir = find_path($path_list, "PEAR"))) {
130@@ -258,7 +258,8 @@
131        $pear = new PEAR_Config();
132         $pear_reg = new PEAR_Registry($pear->get('php_dir'));
133         $pear_info = $pear_reg->packageInfo("PEAR");
134-        $pear_version = $pear_info["version"];
135+        $pear_list = $pear_reg->listPackages();
136+        $pear_version = is_array($pear_info["version"])?$pear_info["version"]["release"]:$pear_info["version"];
137         $result = $pear_version;
138         $status = OK;
139     }
140@@ -267,14 +268,14 @@
141 
142     // PEAR::Mail_Mime
143     if ($have_pear) {
144-      $info = $pear_reg->packageInfo("Mail_Mime");
145-      if (strlen($info["package"]) < 2) {
146+      if (!in_array("mail_mime", $pear_list)) {
147         $result = "Not installed.  This PHP extension is required to decode " .
148                   "MIME-structured e-mail.  Use <b>pear install Mail_Mime</b> to " .
149                   "install this.";
150         $status = ERROR;
151       } else {
152-        $result = $info["version"];
153+        $info = $pear_reg->packageInfo("Mail_Mime");
154+        $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
155         if (version_compare($result,"1.3.0") < 0) {
156           $version = $result;
157           $result = "Version $version installed.  Versions of Mail_Mime below 1.3.0  " .
158@@ -291,8 +292,8 @@
159     }
160     print_row("PEAR::Mail_Mime", $result, $status);
161 
162-   
163 
164+
165   function strip_tailing_slash($path) {
166     return rtrim($path, '/');
167   }
168@@ -300,12 +301,12 @@
169 
170     // PEAR::DB
171     if ($have_pear) {
172-        $db_info = $pear_reg->packageInfo("DB");
173-        if (strlen($db_info["package"]) < 2) {
174+        if (!in_array("db", $pear_list)) {
175             $result = "Not installed.  This PHP extension is required in order to provide " .
176                       "database abstraction.  Use <b>pear install DB</b> to install this.";
177             $status = ERROR;
178         } else {
179+          $db_info = $pear_reg->packageInfo("DB");
180           $pathArray = explode( PATH_SEPARATOR, get_include_path() );
181           $pathArray = array_map('strip_tailing_slash', $pathArray);
182           $db_path = dirname($db_info['filelist']['DB.php']['installed_as']);
183@@ -316,7 +317,7 @@
184                $result = "Could not connect to database.  Check the $maia_sql_dsn setting in config.php.";
185                   $status = ERROR;
186            } else {
187-               $result = $db_version = $db_info["version"];
188+               $result = $db_version = is_array($db_info["version"])?$db_info["version"]["release"]:$db_info["version"];
189                $result .= " DB.php installed as: " . $db_info['filelist']['DB.php']['installed_as'];
190                 $status = OK;
191             }
192@@ -334,14 +335,14 @@
193 
194     // PEAR::DB_Pager
195     if ($have_pear) {
196-        $pager_info = $pear_reg->packageInfo("DB_Pager");
197-        if (strlen($pager_info["package"]) < 2) {
198+        if (!in_array("db_pager", $pear_list)) {
199             $result = "Not installed.  This PHP extension is required in order to paginate " .
200                       "the list of mail items in the quarantines and the ham cache.  Use " .
201                       "<b>pear install DB_Pager</b> to install this.";
202             $status = ERROR;
203         } else {
204-           $result = $pager_info["version"];
205+            $pager_info = $pear_reg->packageInfo("DB_Pager");
206+           $result = is_array($pager_info["version"])?$pager_info["version"]["release"]:$pager_info["version"];
207             $status = OK;
208         }
209     } else {
210@@ -349,16 +350,16 @@
211         $status = WARN;
212     }
213     print_row("PEAR::DB_Pager", $result, $status);
214-       
215-       
216+
217+
218          // PEAR::Net_Socket
219     if ($have_pear) {
220-        $info = $pear_reg->packageInfo("Net_Socket");
221-        if (strlen($info["package"]) < 2) {
222+        if (!in_array("net_socket", $pear_list)) {
223             $result = "Not installed.  This PHP extension is required for Net_SMTP to send mail when rescuing email";
224             $status = ERROR;
225         } else {
226-           $result = $info["version"];
227+           $info = $pear_reg->packageInfo("Net_Socket");
228+           $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
229             $status = OK;
230         }
231     } else {
232@@ -370,18 +371,17 @@
233 
234     // PEAR::Net_SMTP
235     if ($have_pear) {
236-      $info = $pear_reg->packageInfo("Net_SMTP");
237-      if (strlen($info["package"]) < 2) {
238+      if (!in_array("net_smtp", $pear_list)) {
239         $result = "Not installed.  This PHP extension is required to send mail when rescuing email";
240         $status = ERROR;
241       } else {
242-        $result = $info["version"];
243+        $info = $pear_reg->packageInfo("Net_SMTP");
244+        $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
245         if (version_compare($result,"1.1.0") < 0) {
246           $version = $result;
247           $result = "Version $version installed.  Need at least 1.1.0";
248           $status = ERROR;
249         } else {
250-          $result = $info["version"];
251           $status = OK;
252         }
253       }
254@@ -393,15 +393,15 @@
255 
256     // PEAR::Auth_SASL
257     if ($have_pear) {
258-        $info = $pear_reg->packageInfo("Auth_SASL");
259-        if (strlen($info["package"]) < 2) {
260+        if (!in_array("auth_sasl", $pear_list)) {
261             $result = "Not installed.  Optional package. If it is available, " .
262                       "the Net_SMTP package will be able to support the DIGEST-MD5 " .
263                       "and CRAM-MD5 SMTP authentication methods. Otherwise, only " .
264                       "the LOGIN and PLAIN methods will be available.";
265             $status = WARN;
266         } else {
267-            $result = $info["version"];
268+            $info = $pear_reg->packageInfo("Auth_SASL");
269+            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
270             $status = OK;
271         }
272     } else {
273@@ -409,15 +409,15 @@
274         $status = WARN;
275     }
276     print_row("PEAR::Auth_SASL", $result, $status);
277-   
278+
279     // PEAR::Net_IMAP
280     if ($have_pear) {
281-        $info = $pear_reg->packageInfo("Net_IMAP");
282-        if (strlen($info["package"]) < 2) {
283+        if (!in_array("net_imap", $pear_list)) {
284             $result = "Not installed.  This PHP extension is required to authenticate maia against IMAP.";
285             $status = WARN;
286         } else {
287-          $result = $info["version"];
288+            $info = $pear_reg->packageInfo("Net_IMAP");
289+            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
290           if ($result == "1.0.3" && $php_version >= "5.0.0") {
291              $result = "A bug exists in Net_IMAP 1.0.3 when run under PHP 5, see <a href=\"https://secure.renaissoft.com/maia/ticket/266\">https://secure.renaissoft.com/maia/ticket/266</a> for more details.";
292              $status = WARN;     
293@@ -430,15 +430,15 @@
294         $status = WARN;
295     }
296     print_row("PEAR::Net_IMAP", $result, $status);
297-   
298+
299     // PEAR::Net_POP3
300     if ($have_pear) {
301-        $info = $pear_reg->packageInfo("Net_POP3");
302-        if (strlen($info["package"]) < 2) {
303+        if (!in_array("net_pop3", $pear_list)) {
304             $result = "Not installed.  This PHP extension is required to authenticate maia against POP3.";
305             $status = WARN;
306         } else {
307-          $result = $info["version"];
308+            $info = $pear_reg->packageInfo("Net_POP3");
309+            $result = is_array($info["version"])?$info["version"]["release"]:$info["version"];
310             $status = OK;
311         }
312     } else {
313@@ -449,14 +449,14 @@
314 
315     // PEAR::Log
316     if ($have_pear) {
317-        $log_info = $pear_reg->packageInfo("Log");
318-        if (strlen($log_info["package"]) < 2) {
319+        if (!in_array("log", $pear_list)) {
320             $result = "Not installed, but only required if you want to be able to log user " .
321                       "and administrator activity.  Use <b>pear install Log</b> to install " .
322                       "this PHP extension.";
323             $status = ERROR;
324         } else {
325-           $result = $log_info["version"];
326+           $log_info = $pear_reg->packageInfo("Log");
327+           $result = is_array($log_info["version"])?$log_info["version"]["release"]:$log_info["version"];
328             $status = OK;
329         }
330     } else {