This commit is contained in:
Alexander M. Turek
2002-12-25 18:20:42 +00:00
parent f8065ad7c7
commit 2542ef0c81
2 changed files with 54 additions and 32 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$
$Source$
2002-12-25 Alexander M. Turek <rabus@users.sourceforge.net>
* server_privileges.php3:
- Made the script compatible to MySQL < 3.22.11;
- Fixed the missing "LOCK TABLES" option in the privilege editor.
2002-12-23 Alexander M. Turek <rabus@users.sourceforge.net>
* lang/italian-*.inc.php3: Updates, thanks again to Pietro Danesi (danone).

View File

@@ -66,7 +66,7 @@ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE)
} else {
$privs[] = 'USAGE';
}
} else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
} else if ($allPrivileges && isset($GLOBALS['grant_count']) && count($privs) == $GLOBALS['grant_count']) {
if ($enableHTML) {
$privs = array('<dfn title="' . $GLOBALS['strPrivDescAllPrivileges'] . '">ALL&nbsp;PRIVILEGES</dfn>');
} else {
@@ -83,6 +83,7 @@ if (!empty($update_privs)) {
if (empty($hostname)) {
$hostname = '%';
}
if (PMA_MYSQL_INT_VERSION >= 32211) {
$sql_query0 = 'REVOKE ALL PRIVILEGES ON *.* FROM "' . $username . '"@"' . $hostname . '";';
$sql_query1 = 'REVOKE GRANT OPTION ON *.* FROM "' . $username . '"@"' . $hostname . '";';
$sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO "' . $username . '"@"' . $hostname . '"';
@@ -113,6 +114,22 @@ if (!empty($update_privs)) {
}
$sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
$message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'');
} else {
$sql_query = 'SHOW COLUMNS FROM `user`;';
$res = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
$grants = array();
while ($row = PMA_mysql_fetch_row($res)) {
if (substr($row[0], -5) == '_priv') {
$grants[] = PMA_backquote($row[0]) . ' = "' . (empty($$row[0]) ? 'N' : 'Y') . '"';
}
}
mysql_free_result($res);
unset($res);
unset($row);
$sql_query = 'UPDATE `user` SET ' . join(', ', $grants) . ' WHERE `User` = "' . $username . '" AND `Host` = "' . $hostname . '";';
PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink));
$message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\'') . '<br />' . "\n" . $strRememberReload;
}
}
/**
@@ -356,9 +373,6 @@ if (!isset($username) && !isset($hostname)) {
array('Delete', 'DELETE', $strPrivDescDelete),
array('File', 'FILE', $strPrivDescFile)
);
if (isset($row['Lock_tables_priv'])) {
$privDataAccess[1][] = array('Lock_tables', 'LOCK&nbsp;TABLES', $strPrivDescLockTables);
}
$privTable[1] = array(
array('Create', 'CREATE', $strPrivDescCreateDb),
array('Alter', 'ALTER', $strPrivDescAlter),
@@ -383,6 +397,9 @@ if (!isset($username) && !isset($hostname)) {
if (isset($row['Show_db_priv'])) {
$privTable[2][] = array('Show_db', 'SHOW&nbsp;DATABASES', $strPrivDescShowDb);
}
if (isset($row['Lock_tables_priv'])) {
$privTable[2][] = array('Lock_tables', 'LOCK&nbsp;TABLES', $strPrivDescLockTables);
}
$privTable[2][] = array('References', 'REFERENCES', $strPrivDescReferences);
if (isset($row['Execute_priv'])) {
$privTable[2][] = array('Execute', 'EXECUTE', $strPrivDescExecute);
@@ -397,11 +414,11 @@ if (!isset($username) && !isset($hostname)) {
. ' <input type="hidden" name="lang" value="' . $lang . '" />' . "\n"
. ' <input type="hidden" name="convcharset" value="' . $convcharset . '" />' . "\n"
. ' <input type="hidden" name="server" value="' . $server . '" />' . "\n"
. ' <input type="hidden" name="username" value="' . urlencode($username) . '" />' . "\n";
. ' <input type="hidden" name="username" value="' . htmlspecialchars($username) . '" />' . "\n";
if ($hostname != '%') {
echo ' <input type="hidden" name="hostname" value="' . urlencode($hostname) . '" />' . "\n";
echo ' <input type="hidden" name="hostname" value="' . htmlspecialchars($hostname) . '" />' . "\n";
}
echo ' <input type="hidden" name="grant_count" value="' . (count($privTable[0]) + count($privTable[1]) + count($privTable[2])) . '" />' . "\n"
echo ' <input type="hidden" name="grant_count" value="' . (count($privTable[0]) + count($privTable[1]) + count($privTable[2]) - (isset($row['Grant_priv']) ? 1 : 0)) . '" />' . "\n"
. ' <b>' . $strEditPrivileges . '</b><br />' . "\n"
. ' <table border="0">' . "\n"
. ' <tr>' . "\n"