diff --git a/ChangeLog b/ChangeLog index 0e251cb08..7f30352ed 100755 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,8 @@ $Source$ * tbl_change.php3; tbl_replace.php3: fixed bugs in function field name with special characters and no-parameter functions. * config.inc.php3: added the "UNIX_TIMESTAMP" function. + * sql.php3; main.php3; db_readdump.php3; db_details.php3: optimized the + test for super user privileges. 2001-08-28 Olivier Müller * db_stats.php3: fixed the sql query so that the script won't die, even if diff --git a/db_details.php3 b/db_details.php3 index b17279f91..c298222a4 100755 --- a/db_details.php3 +++ b/db_details.php3 @@ -546,11 +546,10 @@ echo ' ' . ' ' . "\n"; 0 with ceratin php3 releases -$is_superuser = (!empty($rows) || $rows != 0); - +// loic1: optimized query +$result = @mysql_query('USE mysql'); +$is_superuser = (!mysql_error()); + // Display the DROP DATABASE link only if allowed to do so if ($cfgAllowUserDropDatabase || $is_superuser) { ?> diff --git a/db_readdump.php3 b/db_readdump.php3 index 2e63bebc4..b5035d4ac 100755 --- a/db_readdump.php3 +++ b/db_readdump.php3 @@ -75,10 +75,9 @@ if (!$cfgAllowUserDropDatabase && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE ', $sql_query)) { // Checks if the user is a Superuser // TODO: set a global variable with this information - $result = mysql_query('SELECT * FROM mysql.user'); - $rows = @mysql_num_rows($result); - // empty <> 0 for certain php3 releases - if (empty($rows) || $rows == 0) { + // loic1: optimized query + $result = @mysql_query('USE mysql'); + if (mysql_error()) { include('./header.inc.php3'); mysql_die($strNoDropDatabases); } diff --git a/main.php3 b/main.php3 index a93ccb1f7..568c82e16 100755 --- a/main.php3 +++ b/main.php3 @@ -275,9 +275,8 @@ if ($server > 0 echo "\n"; } - $result = mysql_query('SELECT * FROM mysql.user'); - $rows = @mysql_num_rows($result); - if (!empty($rows)) { + $result = @mysql_query('USE mysql'); + if (!mysql_error()) { ?> item @@ -367,9 +366,8 @@ if ($server > 0 diff --git a/sql.php3 b/sql.php3 index bc9aa51bf..32c73772a 100755 --- a/sql.php3 +++ b/sql.php3 @@ -17,10 +17,9 @@ if (!defined('PMA_CHK_DROP') && eregi('DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE ', $sql_query)) { // Checks if the user is a Superuser // TODO: set a global variable with this information - $result = mysql_query('SELECT * FROM mysql.user'); - $rows = @mysql_num_rows($result); - // empty <> 0 for certain php3 releases - if (empty($rows) || $rows == 0) { + // loic1: optimized query + $result = @mysql_query('USE mysql'); + if (mysql_error()) { include('./header.inc.php3'); mysql_die($strNoDropDatabases); } // end if