From 2d90978ca972824e844602292e108dd9929aa711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Fri, 13 Jun 2003 07:37:26 +0000 Subject: [PATCH] GD autodetection should now work on all systems --- ChangeLog | 7 ++++ libraries/charset_conversion.lib.php3 | 24 +++--------- libraries/common.lib.php3 | 21 ++-------- libraries/dbg/setup.php3 | 41 ++++++++------------ libraries/defines_php.lib.php3 | 56 ++++++++++++++++++++------- 5 files changed, 74 insertions(+), 75 deletions(-) diff --git a/ChangeLog b/ChangeLog index d4557797a..afe8028f6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2003-06-13 Michal Cihar + * libraries/charset_conversion.lib.php3, libraries/common.lib.php3, + libraries/defines_php.lib.php3, libraries/dbg/setup.php3: Use new PMA_dl + function, that checks true dl availability (fixes #747717). All checks + are based on php 4.3.1 source, so if this gets changed, we will need to + change checks also. + 2003-06-12 Marc Delisle * libraries/relation.lib.php3: bug 751787: should not disable all the features, when the relation feature is broken diff --git a/libraries/charset_conversion.lib.php3 b/libraries/charset_conversion.lib.php3 index d93303bfb..959cfb87f 100644 --- a/libraries/charset_conversion.lib.php3 +++ b/libraries/charset_conversion.lib.php3 @@ -13,24 +13,10 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ /** * Loads the recode or iconv extensions if any of it is not loaded yet - * - * (do not put a "@" before the dl() because we want to see the error - * message: multithreaded web servers don't support dl() but we cannot - * detect if the server is multithreaded, and under PHP 4.2.1 at least, - * it reports that the function dl exists...) */ if (isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] - && $allow_recoding - && ((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) - || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) - && @function_exists('dl')) { - - if (PMA_IS_WINDOWS) { - $suffix = '.dll'; - } else { - $suffix = '.so'; - } + && $allow_recoding) { // Initializes configuration for default, if not set: if (!isset($cfg['RecodingEngine'])) { @@ -39,7 +25,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ if ($cfg['RecodingEngine'] == 'recode') { if (!@extension_loaded('recode')) { - @dl('recode' . $suffix); + PMA_dl('recode'); if (!@extension_loaded('recode')) { echo $strCantLoadRecodeIconv; exit(); @@ -48,7 +34,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ $PMA_recoding_engine = 'recode'; } else if ($cfg['RecodingEngine'] == 'iconv') { if (!@extension_loaded('iconv')) { - @dl('iconv' . $suffix); + PMA_dl('iconv'); if (!@extension_loaded('iconv')) { echo $strCantLoadRecodeIconv; exit(); @@ -61,9 +47,9 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){ } else if (@extension_loaded('recode')) { $PMA_recoding_engine = 'recode'; } else { - @dl('iconv' . $suffix); + PMA_dl('iconv'); if (!@extension_loaded('iconv')) { - @dl('recode' . $suffix); + PMA_dl('recode'); if (!@extension_loaded('recode')) { echo $strCantLoadRecodeIconv; exit(); diff --git a/libraries/common.lib.php3 b/libraries/common.lib.php3 index 2715e47e1..ccfebc97b 100644 --- a/libraries/common.lib.php3 +++ b/libraries/common.lib.php3 @@ -250,30 +250,15 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold} /** * Loads the mysql extensions if it is not loaded yet - * staybyte - 26. June 2001 */ - if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) - || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) - && @function_exists('dl')) { + if (!@function_exists('mysql_connect')) { if (PMA_PHP_INT_VERSION < 40000) { $extension = 'MySQL'; } else { $extension = 'mysql'; } - if (PMA_IS_WINDOWS) { - $suffix = '.dll'; - } else { - $suffix = '.so'; - } - if (!@extension_loaded($extension)) { - @dl($extension . $suffix); - } - if (!@extension_loaded($extension)) { - echo $strCantLoadMySQL . '
' . "\n" - . '' . $GLOBALS['strDocu'] . '' . "\n"; - exit(); - } - } // end load mysql extension + PMA_dl($extension . $suffix); + } // check whether mysql is available if (!@function_exists('mysql_connect')) { diff --git a/libraries/dbg/setup.php3 b/libraries/dbg/setup.php3 index 995fa6dbb..4c6d3a9bb 100644 --- a/libraries/dbg/setup.php3 +++ b/libraries/dbg/setup.php3 @@ -3,31 +3,24 @@ // vim: expandtab sw=4 ts=4 sts=4: if (!defined('PMA_DBG_SETUP_INCLUDED')) { - define('PMA_DBG_SETUP_INCLUDED', 1); + define('PMA_DBG_SETUP_INCLUDED', 1); - if (isset($GLOBALS['cfg']['DBG']['enable']) && $GLOBALS['cfg']['DBG']['enable']) { - /** - * Loads the DBG extension if needed - */ - if ( (PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) - && @function_exists('dl')) { - $extension = 'dbg'; - if (PMA_IS_WINDOWS) { - $suffix = '.dll'; - } else { - $suffix = '.so'; - } - if (!@extension_loaded($extension)) { - @dl($extension . $suffix); - } - if (!@extension_loaded($extension)) { - echo sprintf($strCantLoad, 'DBG') . '
' . "\n" - . '' . $GLOBALS['strDocu'] . '' . "\n"; - exit(); - } - $GLOBALS['DBG'] = true; - } // end load mysql extension - } + if (isset($GLOBALS['cfg']['DBG']['enable']) && $GLOBALS['cfg']['DBG']['enable']) { + /** + * Loads the DBG extension if needed + */ + if (PMA_PHP_INT_VERSION >= 40000) { + if (!@extension_loaded('dbg')) { + PMA_dl('dbg'); + } + if (!@extension_loaded('dbg')) { + echo sprintf($strCantLoad, 'DBG') . '
' . "\n" + . '' . $GLOBALS['strDocu'] . '' . "\n"; + exit(); + } + $GLOBALS['DBG'] = true; + } + } } ?> diff --git a/libraries/defines_php.lib.php3 b/libraries/defines_php.lib.php3 index 9a8f3812f..cfdc0ae54 100644 --- a/libraries/defines_php.lib.php3 +++ b/libraries/defines_php.lib.php3 @@ -62,6 +62,43 @@ if (!defined('PMA_IS_WINDOWS')) { } } +function PMA_dl($module) { + if (!isset($GLOBALS['PMA_dl_allowed'])) { + if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) + || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) + && @function_exists('dl')) { + + ob_start(); + phpinfo(INFO_GENERAL); /* Only general info */ + $a = strip_tags(ob_get_contents()); + ob_end_clean(); + /* Get GD version string from phpinfo output */ + if (ereg('Thread Safety[[:space:]]*enabled', $a)) { + if (ereg('Server API[[:space:]]*\(CGI\|CLI\)', $a)) { + $GLOBALS['PMA_dl_allowed'] = TRUE; + } else { + $GLOBALS['PMA_dl_allowed'] = FALSE; + } + } else { + $GLOBALS['PMA_dl_allowed'] = TRUE; + } + } else { + $GLOBALS['PMA_dl_allowed'] = FALSE; + } + } + if (PMA_IS_WINDOWS) { + $suffix = '.dll'; + } else { + $suffix = '.so'; + } + if ($GLOBALS['PMA_dl_allowed']) { + return @dl($module . $suffix); + } else { + return FALSE; + } + +} + // Whether GD2 is present if (!defined('PMA_IS_GD2')) { if ($cfg['GD2Available'] == 'yes') { @@ -69,17 +106,8 @@ if (!defined('PMA_IS_GD2')) { } elseif ($cfg['GD2Available'] == 'no') { define('PMA_IS_GD2', 0); } else { - if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) - || (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) - && @function_exists('dl')) { - if (PMA_IS_WINDOWS) { - $suffix = '.dll'; - } else { - $suffix = '.so'; - } - if (!@extension_loaded('gd')) { - @dl('gd' . $suffix); - } + if (!@extension_loaded('gd')) { + PMA_dl('gd'); } if (!@function_exists('imagecreatetruecolor')) { define('PMA_IS_GD2', 0); @@ -94,11 +122,11 @@ if (!defined('PMA_IS_GD2')) { } else { /* We must do hard way... */ ob_start(); - phpinfo(8); /* Only modules */ - $a = ob_get_contents(); + phpinfo(INFO_MODULES); /* Only modules */ + $a = strip_tags(ob_get_contents()); ob_end_clean(); /* Get GD version string from phpinfo output */ - if (ereg(']*>[^>]*GD Version[^<]*]*>\([^<]*\)', $a, $v)) { + if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) { if (strstr($v, '2.')) { define('PMA_IS_GD2', 1); } else {