optionally make use of dynamic mysql extension loading done by PEAR.
authorkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 16 Dec 2007 16:34:55 +0000 (16:34 +0000)
committerkink <kink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 16 Dec 2007 16:34:55 +0000 (16:34 +0000)
Thanks Walter Huijbers. (#1833123)

git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12826 7612ce4b-ef26-0410-bec9-ea0150e637f0

src/configtest.php

index 431904bc072f64324f0f8d2875ec338dcca6ceb4..967ac11a05969ecd322c338da7370e744d5ebca7 100644 (file)
@@ -275,7 +275,14 @@ if(count($diff)) {
     do_err('Required PHP extensions missing: '.implode(', ',$diff) );
 }
 
-echo $IND . "PHP extensions OK.<br />\n";
+echo $IND . "PHP extensions OK. Dynamic loading is ";
+
+if (!(bool)ini_get('enable_dl') || (bool)ini_get('safe_mode')) {
+    echo "disabled.<br />\n";
+} else {
+    echo "enabled.<br />\n";
+}
+
 
 /* dangerous php settings */
 /**
@@ -866,22 +873,28 @@ if($addrbook_dsn || $prefs_dsn || $addrbook_global_dsn) {
         foreach($dsns as $type => $dsn) {
             $aDsn = explode(':', $dsn);
             $dbtype = array_shift($aDsn);
+
             if(isset($db_functions[$dbtype]) && function_exists($db_functions[$dbtype])) {
                 echo "$IND$dbtype database support present.<br />\n";
+            } elseif(!(bool)ini_get('enable_dl') || (bool)ini_get('safe_mode')) {
+                do_err($dbtype.' database support not present!');
+            } else {
+                // Non-fatal error
+                do_err($dbtype.' database support not present or not configured!
+                    Trying to dynamically load '.$dbtype.' extension.
+                    Please note that it is advisable to not rely on dynamic loading of extensions.', FALSE);
+            }
 
-                // now, test this interface:
 
-                $dbh = DB::connect($dsn, true);
-                if (DB::isError($dbh)) {
-                    do_err('Database error: '. htmlspecialchars(DB::errorMessage($dbh)) .
-                            ' in ' .$type .' DSN.');
-                }
-                $dbh->disconnect();
-                echo "$IND$type database connect successful.<br />\n";
+            // now, test this interface:
 
-            } else {
-                do_err($dbtype.' database support not present!');
+            $dbh = DB::connect($dsn, true);
+            if (DB::isError($dbh)) {
+                do_err('Database error: '. htmlspecialchars(DB::errorMessage($dbh)) .
+                        ' in ' .$type .' DSN.');
             }
+            $dbh->disconnect();
+            echo "$IND$type database connect successful.<br />\n";
         }
     } else {
         $db_error='Required PHP PEAR DB support is not available.'