bug #1490193 and code simplification

This commit is contained in:
Marc Delisle
2006-05-18 16:53:40 +00:00
parent fde2f613ad
commit 6215a6d94a
6 changed files with 19 additions and 25 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog
$Id$
$Source$
2006-05-18 Marc Delisle <lem9@users.sourceforge.net>
* libraries/check_user_privileges.lib.php, /database_interface.lib.php, /db_details_links.inc.php,
/server_common.inc.php, /header.inc.php: bug #1490193 and code simplification
2006-05-17 Marc Delisle <lem9@users.sourceforge.net>
* server_privileges.php: bug #1478812, Add user (password containing
a backslash); also minor optimization

View File

@@ -6,17 +6,6 @@
// ($controllink and $userlink are links to MySQL defined in the "common.lib.php" library)
// Note: if no controluser is defined, $controllink contains $userlink
/**
* returns true (int > 0) if current user is superuser
* otherwise 0
*
* @return integer $is_superuser
*/
function PMA_isSuperuser() {
return PMA_DBI_try_query( 'SELECT COUNT(*) FROM mysql.user',
$GLOBALS['userlink'], PMA_DBI_QUERY_STORE );
}
$is_create_db_priv = false;
$is_process_priv = true;
$is_reload_priv = false;

View File

@@ -1167,4 +1167,15 @@ function PMA_DBI_getCompatibilities()
return $compats;
}
/**
* returns true (int > 0) if current user is superuser
* otherwise 0
*
* @return integer $is_superuser
*/
function PMA_isSuperuser() {
return PMA_DBI_try_query( 'SELECT COUNT(*) FROM mysql.user',
$GLOBALS['userlink'], PMA_DBI_QUERY_STORE );
}
?>

View File

@@ -15,11 +15,7 @@ if (empty($sub_part)) {
/**
* Checks for superuser privileges
*/
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables)
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', null, PMA_DBI_QUERY_STORE);
$is_superuser = PMA_isSuperuser();
/**
* Prepares links

View File

@@ -50,6 +50,7 @@ if (empty($GLOBALS['is_header_sent'])) {
(!empty($GLOBALS['cfg']['Server']['host']) ? $GLOBALS['cfg']['TitleServer'] :
$GLOBALS['cfg']['TitleDefault']))
);
$is_superuser = PMA_isSuperuser();
?>
<script type="text/javascript" language="javascript">
<!--

View File

@@ -35,19 +35,12 @@ require_once('./libraries/header.inc.php');
/**
* Checks for superuser privileges
*/
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables)
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user');
$is_superuser = PMA_isSuperuser();
// now, select the mysql db
if ($is_superuser) {
PMA_DBI_free_result($is_superuser);
PMA_DBI_select_db('mysql', $userlink);
$is_superuser = TRUE;
} else {
$is_superuser = FALSE;
}
$has_binlogs = FALSE;