bug #2046883 [core] Notices about deprecated dl() (so stop using it)

This commit is contained in:
Marc Delisle
2008-08-16 14:06:27 +00:00
parent 9d739fdd46
commit 1bd7ec70e2
10 changed files with 25 additions and 143 deletions

View File

@@ -6,6 +6,7 @@ $Id$
$HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyAdmin/ChangeLog $
3.1.0.0 (not yet released)
- bug #2046883 [core] Notices about deprecated dl() (so stop using it)
3.0.0.0 (not yet released)
+ [export] properly handle line breaks for YAML, thanks to Dan Barry -

View File

@@ -200,9 +200,6 @@ class PMA_Config
} elseif ($this->get('GD2Available') == 'no') {
$this->set('PMA_IS_GD2', 0);
} else {
if (!@extension_loaded('gd')) {
PMA_dl('gd');
}
if (!@function_exists('imagecreatetruecolor')) {
$this->set('PMA_IS_GD2', 0);
} else {
@@ -214,7 +211,7 @@ class PMA_Config
$this->set('PMA_IS_GD2', 0);
}
} else {
/* We must do hard way... */
/* We must do hard way... but almost no chance to execute this */
ob_start();
phpinfo(INFO_MODULES); /* Only modules */
$a = strip_tags(ob_get_contents());

View File

@@ -14,7 +14,7 @@ if (! defined('PHPMYADMIN')) {
require './libraries/auth/swekey/swekey.auth.lib.php';
if (function_exists('mcrypt_encrypt') || PMA_dl('mcrypt')) {
if (function_exists('mcrypt_encrypt')) {
/**
* Uses faster mcrypt library if available
* (as this is not called from anywhere else, put the code in-line

View File

@@ -17,22 +17,16 @@ if (isset($cfg['AllowAnywhereRecoding'])
&& $allow_recoding) {
if ($cfg['RecodingEngine'] == 'recode') {
if (!@extension_loaded('recode')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'recode';
} elseif ($cfg['RecodingEngine'] == 'iconv') {
if (!@extension_loaded('iconv')) {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
echo $strCantLoadRecodeIconv;
exit;
}
}
$PMA_recoding_engine = 'iconv';
} else {
if (@extension_loaded('iconv')) {
@@ -40,18 +34,8 @@ if (isset($cfg['AllowAnywhereRecoding'])
} elseif (@extension_loaded('recode')) {
$PMA_recoding_engine = 'recode';
} else {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
echo $strCantLoadRecodeIconv;
exit;
} else {
$PMA_recoding_engine = 'recode';
}
} else {
$PMA_recoding_engine = 'iconv';
}
}
}
} // end load recode/iconv extension

View File

@@ -1729,7 +1729,7 @@ $cfg['DefaultCharset'] = 'utf-8';
* Allow character set recoding of MySQL queries, must be also enabled in language
* file to make harder using other language files than Unicode.
* Default value is false to avoid problems on servers without the iconv
* extension and where dl() is not supported
* extension
*
* @global boolean $cfg['AllowAnywhereRecoding']
*/
@@ -2247,8 +2247,7 @@ $cfg['TempDir'] = '';
/**
* Is GD >= 2 available? Set to yes/no/auto. 'auto' does auto-detection,
* which is a bit expensive for PHP < 4.3.0, but it is the only safe way how to
* determine GD version.
* which is the only safe way to determine GD version.
*
* @global string $cfg['GD2Available']
*/

View File

@@ -341,71 +341,6 @@ function PMA_get_real_size($size = 0)
return $size;
} // end function PMA_get_real_size()
/**
* loads php module
*
* @uses PHP_OS
* @uses extension_loaded()
* @uses ini_get()
* @uses function_exists()
* @uses ob_start()
* @uses phpinfo()
* @uses strip_tags()
* @uses ob_get_contents()
* @uses ob_end_clean()
* @uses preg_match()
* @uses strtoupper()
* @uses substr()
* @uses dl()
* @param string $module name if module to load
* @return boolean success loading module
*/
function PMA_dl($module)
{
static $dl_allowed = null;
if (extension_loaded($module)) {
return true;
}
if (null === $dl_allowed) {
if (!@ini_get('safe_mode')
&& @ini_get('enable_dl')
&& @function_exists('dl')) {
ob_start();
phpinfo(INFO_GENERAL); /* Only general info */
$a = strip_tags(ob_get_contents());
ob_end_clean();
if (preg_match('@Thread Safety[[:space:]]*enabled@', $a)) {
if (preg_match('@Server API[[:space:]]*\(CGI\|CLI\)@', $a)) {
$dl_allowed = true;
} else {
$dl_allowed = false;
}
} else {
$dl_allowed = true;
}
} else {
$dl_allowed = false;
}
}
if (!$dl_allowed) {
return false;
}
/* Once we require PHP >= 4.3, we might use PHP_SHLIB_SUFFIX here */
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$module_file = 'php_' . $module . '.dll';
} elseif (PHP_OS=='HP-UX') {
$module_file = $module . '.sl';
} else {
$module_file = $module . '.so';
}
return @dl($module_file);
}
/**
* merges array recursive like array_merge_recursive() but keyed-values are
* always overwritten.

View File

@@ -20,18 +20,14 @@ define('PMA_DBI_GETVAR_SESSION', 1);
define('PMA_DBI_GETVAR_GLOBAL', 2);
/**
* Loads the mysql extensions if it is not loaded yet
* Checks one of the mysql extensions
*
* @param string $extension mysql extension to load
* @param string $extension mysql extension to check
*/
function PMA_DBI_checkAndLoadMysqlExtension($extension = 'mysql') {
if (! function_exists($extension . '_connect')) {
PMA_dl($extension);
// check whether mysql is available
function PMA_DBI_checkMysqlExtension($extension = 'mysql') {
if (! function_exists($extension . '_connect')) {
return false;
}
}
return true;
}
@@ -40,14 +36,14 @@ function PMA_DBI_checkAndLoadMysqlExtension($extension = 'mysql') {
/**
* check for requested extension
*/
if (! PMA_DBI_checkAndLoadMysqlExtension($GLOBALS['cfg']['Server']['extension'])) {
if (! PMA_DBI_checkMysqlExtension($GLOBALS['cfg']['Server']['extension'])) {
// if it fails try alternative extension ...
// and display an error ...
/**
* @todo 2.7.1: add different messages for alternativ extension
* and complete fail (no alternativ extension too)
* @todo add different messages for alternative extension
* and complete fail (no alternative extension too)
*/
$error =
sprintf(PMA_sanitize($GLOBALS['strCantLoad']),
@@ -62,8 +58,8 @@ if (! PMA_DBI_checkAndLoadMysqlExtension($GLOBALS['cfg']['Server']['extension'])
$alternativ_extension = 'mysql';
}
if (! PMA_DBI_checkAndLoadMysqlExtension($alternativ_extension)) {
// if alternativ fails too ...
if (! PMA_DBI_checkMysqlExtension($alternativ_extension)) {
// if alternative fails too ...
PMA_fatalError(
sprintf($GLOBALS['strCantLoad'],
$GLOBALS['cfg']['Server']['extension'])

View File

@@ -8,7 +8,7 @@ if (! defined('PHPMYADMIN')) {
}
/**
* checks for DBG extension and tries to load if not loaded
* checks for DBG extension
*
* allways use $GLOBALS here, as this script is included by footer.inc.hp
* which can also be included from inside a function
@@ -17,7 +17,7 @@ if ($GLOBALS['cfg']['DBG']['php']) {
/**
* Loads the DBG extension if needed
*/
if (! @extension_loaded('dbg') && ! PMA_dl('dbg')) {
if (! @extension_loaded('dbg') ) {
$message = PMA_Message::error('strCantLoad');
$message->addParam('DBG');
$message->addMessage('<a href="./Documentation.html#faqdbg" target="documentation">', false);

View File

@@ -13,7 +13,6 @@
* The SQL Parser code relies heavily on these functions.
*
* @version $Id$
* @uses PMA_dl()
* @uses extension_loaded()
* @uses substr()
* @uses function_exists()
@@ -25,11 +24,6 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/* Try to load mbstring */
if (!@extension_loaded('mbstring')) {
PMA_dl('mbstring');
}
$GLOBALS['PMA_allow_mbstr'] = @function_exists('mb_strlen');
if ($GLOBALS['PMA_allow_mbstr']) {
@@ -53,10 +47,6 @@ if (defined('PMA_MULTIBYTE_ENCODING') || $GLOBALS['PMA_allow_mbstr']) {
require './libraries/string_native.lib.php';
}
if (!@extension_loaded('ctype')) {
PMA_dl('ctype');
}
if (@extension_loaded('ctype')) {
require './libraries/string_type_ctype.lib.php';
} else {

View File

@@ -13,7 +13,7 @@
* @version $Id$
*/
// Grab phpMyAdmin version and PMA_dl function
// Grab phpMyAdmin version
define('PMA_MINIMUM_COMMON', TRUE);
define('PMA_SETUP', TRUE);
chdir('..');
@@ -1448,12 +1448,6 @@ switch ($action) {
}
// Guess MySQL extension to use, prefer mysqli
if (!function_exists('mysql_get_client_info')) {
PMA_dl('mysql');
}
if (!function_exists('mysqli_get_client_info')) {
PMA_dl('mysqli');
}
if (function_exists('mysqli_get_client_info')) {
$defaults['extension'] = 'mysqli';
} elseif (function_exists('mysql_get_client_info')) {
@@ -1606,17 +1600,7 @@ switch ($action) {
} elseif (@extension_loaded('recode')) {
$d['RecodingEngine'] = 'recode';
} else {
PMA_dl('iconv');
if (!@extension_loaded('iconv')) {
PMA_dl('recode');
if (!@extension_loaded('recode')) {
message('warning', 'Neither recode nor iconv could be loaded so charset conversion will most likely not work.');
} else {
$d['RecodingEngine'] = 'recode';
}
} else {
$d['RecodingEngine'] = 'iconv';
}
}
if (isset($d['RecodingEngine'])) {
message('notice', 'Autodetected recoding engine: ' . $d['RecodingEngine']);
@@ -1644,10 +1628,7 @@ switch ($action) {
case 'feat_extensions':
$d = $configuration;
if (!@extension_loaded('mbstring')) {
PMA_dl('mbstring');
}
if (!@extension_loaded('mbstring')) {
message('warning', 'Could not load <code>mbstring</code> extension, which is required for work with multibyte strings like UTF-8 ones. Please consider installing it.');
message('warning', 'Could not find <code>mbstring</code> extension, which is required for work with multibyte strings like UTF-8 ones. Please consider installing it.');
}
if (!isset($d['GD2Available'])) {
if (PMA_IS_GD2 == 1) {
@@ -1871,7 +1852,6 @@ switch ($action) {
break;
*/
case 'versioncheck': // Check for latest available version
PMA_dl('curl');
$url = 'http://phpmyadmin.net/home_page/version.php';
$data = '';
$f = @fopen($url, 'r');