GD autodetection should now work on all systems

This commit is contained in:
Michal Čihař
2003-06-13 07:37:26 +00:00
parent a32ffd69c3
commit 2d90978ca9
5 changed files with 74 additions and 75 deletions

View File

@@ -5,6 +5,13 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2003-06-13 Michal Cihar <nijel@users.sourceforge.net>
* 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 <lem9@users.sourceforge.net> 2003-06-12 Marc Delisle <lem9@users.sourceforge.net>
* libraries/relation.lib.php3: bug 751787: should not disable all * libraries/relation.lib.php3: bug 751787: should not disable all
the features, when the relation feature is broken the features, when the relation feature is broken

View File

@@ -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 * 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']) if (isset($cfg['AllowAnywhereRecoding'])
&& $cfg['AllowAnywhereRecoding'] && $cfg['AllowAnywhereRecoding']
&& $allow_recoding && $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';
}
// Initializes configuration for default, if not set: // Initializes configuration for default, if not set:
if (!isset($cfg['RecodingEngine'])) { if (!isset($cfg['RecodingEngine'])) {
@@ -39,7 +25,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
if ($cfg['RecodingEngine'] == 'recode') { if ($cfg['RecodingEngine'] == 'recode') {
if (!@extension_loaded('recode')) { if (!@extension_loaded('recode')) {
@dl('recode' . $suffix); PMA_dl('recode');
if (!@extension_loaded('recode')) { if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv; echo $strCantLoadRecodeIconv;
exit(); exit();
@@ -48,7 +34,7 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} else if ($cfg['RecodingEngine'] == 'iconv') { } else if ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
@dl('iconv' . $suffix); PMA_dl('iconv');
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv; echo $strCantLoadRecodeIconv;
exit(); exit();
@@ -61,9 +47,9 @@ if (!defined('PMA_CHARSET_CONVERSION_LIB_INCLUDED')){
} else if (@extension_loaded('recode')) { } else if (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode'; $PMA_recoding_engine = 'recode';
} else { } else {
@dl('iconv' . $suffix); PMA_dl('iconv');
if (!@extension_loaded('iconv')) { if (!@extension_loaded('iconv')) {
@dl('recode' . $suffix); PMA_dl('recode');
if (!@extension_loaded('recode')) { if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv; echo $strCantLoadRecodeIconv;
exit(); exit();

View File

@@ -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 * 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')) if (!@function_exists('mysql_connect')) {
|| (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode')))
&& @function_exists('dl')) {
if (PMA_PHP_INT_VERSION < 40000) { if (PMA_PHP_INT_VERSION < 40000) {
$extension = 'MySQL'; $extension = 'MySQL';
} else { } else {
$extension = 'mysql'; $extension = 'mysql';
} }
if (PMA_IS_WINDOWS) { PMA_dl($extension . $suffix);
$suffix = '.dll'; }
} else {
$suffix = '.so';
}
if (!@extension_loaded($extension)) {
@dl($extension . $suffix);
}
if (!@extension_loaded($extension)) {
echo $strCantLoadMySQL . '<br />' . "\n"
. '<a href="./Documentation.html#faqmysql" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
exit();
}
} // end load mysql extension
// check whether mysql is available // check whether mysql is available
if (!@function_exists('mysql_connect')) { if (!@function_exists('mysql_connect')) {

View File

@@ -3,31 +3,24 @@
// vim: expandtab sw=4 ts=4 sts=4: // vim: expandtab sw=4 ts=4 sts=4:
if (!defined('PMA_DBG_SETUP_INCLUDED')) { 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']) { if (isset($GLOBALS['cfg']['DBG']['enable']) && $GLOBALS['cfg']['DBG']['enable']) {
/** /**
* Loads the DBG extension if needed * Loads the DBG extension if needed
*/ */
if ( (PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) if (PMA_PHP_INT_VERSION >= 40000) {
&& @function_exists('dl')) { if (!@extension_loaded('dbg')) {
$extension = 'dbg'; PMA_dl('dbg');
if (PMA_IS_WINDOWS) { }
$suffix = '.dll'; if (!@extension_loaded('dbg')) {
} else { echo sprintf($strCantLoad, 'DBG') . '<br />' . "\n"
$suffix = '.so'; . '<a href="./Documentation.html#faqdbg" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
} exit();
if (!@extension_loaded($extension)) { }
@dl($extension . $suffix); $GLOBALS['DBG'] = true;
} }
if (!@extension_loaded($extension)) { }
echo sprintf($strCantLoad, 'DBG') . '<br />' . "\n"
. '<a href="./Documentation.html#faqdbg" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
exit();
}
$GLOBALS['DBG'] = true;
} // end load mysql extension
}
} }
?> ?>

View File

@@ -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 // Whether GD2 is present
if (!defined('PMA_IS_GD2')) { if (!defined('PMA_IS_GD2')) {
if ($cfg['GD2Available'] == 'yes') { if ($cfg['GD2Available'] == 'yes') {
@@ -69,17 +106,8 @@ if (!defined('PMA_IS_GD2')) {
} elseif ($cfg['GD2Available'] == 'no') { } elseif ($cfg['GD2Available'] == 'no') {
define('PMA_IS_GD2', 0); define('PMA_IS_GD2', 0);
} else { } else {
if (((PMA_PHP_INT_VERSION >= 40000 && !@ini_get('safe_mode') && @ini_get('enable_dl')) if (!@extension_loaded('gd')) {
|| (PMA_PHP_INT_VERSION < 40000 && PMA_PHP_INT_VERSION > 30009 && !@get_cfg_var('safe_mode'))) PMA_dl('gd');
&& @function_exists('dl')) {
if (PMA_IS_WINDOWS) {
$suffix = '.dll';
} else {
$suffix = '.so';
}
if (!@extension_loaded('gd')) {
@dl('gd' . $suffix);
}
} }
if (!@function_exists('imagecreatetruecolor')) { if (!@function_exists('imagecreatetruecolor')) {
define('PMA_IS_GD2', 0); define('PMA_IS_GD2', 0);
@@ -94,11 +122,11 @@ if (!defined('PMA_IS_GD2')) {
} else { } else {
/* We must do hard way... */ /* We must do hard way... */
ob_start(); ob_start();
phpinfo(8); /* Only modules */ phpinfo(INFO_MODULES); /* Only modules */
$a = ob_get_contents(); $a = strip_tags(ob_get_contents());
ob_end_clean(); ob_end_clean();
/* Get GD version string from phpinfo output */ /* Get GD version string from phpinfo output */
if (ereg('<tr><td[^>]*>[^>]*GD Version[^<]*</td><td[^>]*>\([^<]*\)</td></tr>', $a, $v)) { if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) {
if (strstr($v, '2.')) { if (strstr($v, '2.')) {
define('PMA_IS_GD2', 1); define('PMA_IS_GD2', 1);
} else { } else {