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

@@ -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('<tr><td[^>]*>[^>]*GD Version[^<]*</td><td[^>]*>\([^<]*\)</td></tr>', $a, $v)) {
if (ereg('GD Version[[:space:]]*\(.*\)', $a, $v)) {
if (strstr($v, '2.')) {
define('PMA_IS_GD2', 1);
} else {