From 6b9e4a21aada9ab70b9c6452957810fd1cd1114e Mon Sep 17 00:00:00 2001
From: till <till@php.net>
Date: Thu, 14 Feb 2008 18:11:43 -0500
Subject: [PATCH] * added check for loaded database modules * added MDB2 to lib check

---
 check.php-dist |   46 ++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/check.php-dist b/check.php-dist
index 8003390..49004cb 100644
--- a/check.php-dist
+++ b/check.php-dist
@@ -61,17 +61,26 @@
 
 error_reporting(E_ALL ^E_NOTICE);
 
-$include_path  = dirname(__FILE__) . '/program/lib/';
+$include_path  = dirname(__FILE__) . '/program/lib';
 $include_path .= PATH_SEPARATOR;
-$include_path .= dirname(__FILE__) . '/program/';
+$include_path .= dirname(__FILE__) . '/program';
 $include_path .= PATH_SEPARATOR;
 $include_path .= get_include_path();
 
 @ini_set('display_errors', 1);
 set_include_path($include_path);
 
-$create_files  = array('config/db.inc.php', 'config/main.inc.php');
-$required_libs = array('PEAR' => 'PEAR.php', 'DB' => 'DB.php', 'Net_SMTP' => 'Net/SMTP.php', 'Mail_mime' => 'Mail/mime.php', 'iilConnection' => 'lib/imap.inc');
+$create_files = array('config/db.inc.php', 'config/main.inc.php');
+
+$required_libs = array('PEAR' => 'PEAR.php', 'DB' => 'DB.php',
+    'Net_SMTP' => 'Net/SMTP.php', 'Mail_mime' => 'Mail/mime.php',
+    'MDB2' => 'MDB2.php', 'iilConnection' => 'lib/imap.inc');
+
+$supported_drivers = array('MDB2#mysql' => 'MDB2/Driver/mysql.php',
+    'MDB2#pgsql' => 'MDB2/Driver/pgsql.php', 'MDB2#sqlite' => 'MDB2/Driver/sqlite.php');
+
+$supported_dbs = array('MySQL' => 'mysql', 'MySQLi' => 'mysqli',
+    'PostgreSQL' => 'pgsql', 'SQLite (v2)' => 'sqlite');
 
 $path  = dirname(__FILE__) . '/';
 $check = basename(__FILE__);
@@ -105,16 +114,37 @@
     echo '<i>We do not check if this is a <b>valid</b> email address. Since this serves as from &amp; to, make sure it is correct!</i>';
 }
 
+echo '<h3>Checking available databases</h3>';
+echo '<p>Checks if the extension is loaded.</p>';
+
+$prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
+foreach ($supported_dbs AS $database => $ext) {
+    echo "$database: ";
+    if (extension_loaded($ext)) {
+        echo CHECK_OK;
+    } else {
+        $_ext = $prefix . $ext . '.' . PHP_SHLIB_SUFFIX;
+        echo CHECK_NOK;
+        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>Check for required 3rd party libs</h3>';
 echo '<p>This also checks if the include path is set correctly.</p>';
 
 foreach ($required_libs as $classname => $file) {
-    @include_once $file;
+    require_once $file;
     echo "$classname: ";
-    if (class_exists($classname))
+    if (class_exists($classname)) {
         echo CHECK_OK;
-    else
+    } else {
         echo CHECK_NOK . "; Failed to load $file";
+    }
     echo "<br />";
 }
 
@@ -360,4 +390,4 @@
 }
 ?>
 </body>
-</html>
\ No newline at end of file
+</html>

--
Gitblit v1.9.1