From d4517648ad79cc62e590b851afa69858393cf8dc Mon Sep 17 00:00:00 2001
From: till <till@php.net>
Date: Wed, 20 Feb 2008 10:59:47 -0500
Subject: [PATCH] * fixing #1484792 (Thanks for the note!)

---
 check.php-dist |   76 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 72 insertions(+), 4 deletions(-)

diff --git a/check.php-dist b/check.php-dist
index dac2ae0..f308cc3 100644
--- a/check.php-dist
+++ b/check.php-dist
@@ -83,10 +83,35 @@
 $supported_dbs = array('MySQL' => 'mysql', 'MySQLi' => 'mysqli',
     'PostgreSQL' => 'pgsql', 'SQLite (v2)' => 'sqlite');
 
+$required_php_exts = array('Session' => 'session', 'PCRE' => 'pcre', 'Sockets' => 'sockets');
+
+$optional_php_exts = array('FileInfo' => 'fileinfo', 'Libiconv' => 'iconv', 'Multibyte' => 'mbstring', 'OpenSSL' => 'openssl');
+
+$source_urls = array(
+    'Socket' => 'http://www.php.net/manual/en/ref.sockets.php',
+    'Session' => 'http://www.php.net/manual/en/ref.session.php',
+    'PCRE' => 'http://www.php.net/manual/en/ref.pcre.php',
+    'FileInfo' => 'http://www.php.net/manual/en/ref.fileinfo.php',
+    'Libiconv' => 'http://www.php.net/manual/en/ref.iconv.php',
+    'Multibyte' => 'http://www.php.net/manual/en/ref.mbstring.php',
+    'OpenSSL' => 'http://www.php.net/manual/en/ref.openssl.php',
+    'PEAR' => 'http://pear.php.net',
+    'MDB2' => 'http://pear.php.net/package/MDB2',
+    'Net_SMTP' => 'http://pear.php.net/package/Net_SMTP',
+    'Mail_mime' => 'http://pear.php.net/package/Mail_mime'
+);
+
 $path  = dirname(__FILE__) . '/';
 $check = basename(__FILE__);
 
 require_once 'include/bugs.inc';
+
+function show_hint($key) {
+    global $source_urls;
+    if ($source_urls[$key])
+        echo '<span class="indent">(See <a href="' . $source_urls[$key] . '">' . $source_urls[$key] . '</a>)</span>';
+}
+
 ?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-transitional.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
@@ -121,6 +146,10 @@
 	color: #f60;
 	font-weight: bold;
 }
+
+.indent {
+	padding-left: 0.8em;
+}
 /* ]]> */
 </style>
 <title>RoundCube :: check</title>
@@ -141,7 +170,7 @@
 }
 
 echo '<h3>Checking available databases</h3>';
-echo '<p>Checks if the extension is loaded.</p>';
+echo '<p>Checks if the extension is loaded. At least one of them is required.</p>';
 
 $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
 foreach ($supported_dbs AS $database => $ext) {
@@ -151,10 +180,48 @@
     } else {
         $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
         echo CHECK_NA;
-        if (dl($_ext)) {
+        if (@dl($_ext)) {
             echo ' (<i>Could</i> be loaded. Please add in php.ini, if you plan on using it.)';
         } else {
             echo ' (<b>Not</b> installed.)';
+        }
+    }
+    echo '<br />';
+}
+
+echo '<h3>Checking PHP extensions</h3>';
+echo '<p>The following modules/extensions are <em>required</em> to run RoundCube</p>';
+    
+$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
+foreach ($required_php_exts AS $name => $ext) {
+    echo "$name: ";
+    if (extension_loaded($ext)) {
+        echo CHECK_OK;
+    } else {
+        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
+        echo CHECK_NA;
+        if (@dl($_ext)) {
+            echo ' (<i>Could</i> be loaded. Please add in php.ini.)';
+        } else {
+            show_hint($name);
+        }
+    }
+    echo '<br />';
+}
+
+echo '<p>These extensions are <em>optional</em> but recommended to get the best performance.</p>';
+
+foreach ($optional_php_exts AS $name => $ext) {
+    echo "$name: ";
+    if (extension_loaded($ext)) {
+        echo CHECK_OK;
+    } else {
+        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
+        echo CHECK_NA;
+        if (@dl($_ext)) {
+            echo ' (<i>Could</i> be loaded. Please add in php.ini, if you plan on using it.)';
+        } else {
+            show_hint($name);
         }
     }
     echo '<br />';
@@ -169,7 +236,8 @@
     if (class_exists($classname)) {
         echo CHECK_OK;
     } else {
-        echo CHECK_NOK . "; Failed to load $file";
+        echo CHECK_NOK . " (Failed to load $file.)";
+        show_hint($classname);
     }
     echo "<br />";
 }
@@ -433,4 +501,4 @@
 }
 ?>
 </body>
-</html>
\ No newline at end of file
+</html>

--
Gitblit v1.9.1