tag with tooltips * * @return array */ function PMA_extractPrivInfo($row = '', $enableHTML = FALSE) { $grants = array( array('Select_priv', 'SELECT', $GLOBALS['strPrivDescSelect']), array('Insert_priv', 'INSERT', $GLOBALS['strPrivDescInsert']), array('Update_priv', 'UPDATE', $GLOBALS['strPrivDescUpdate']), array('Delete_priv', 'DELETE', $GLOBALS['strPrivDescDelete']), array('Create_priv', 'CREATE', $GLOBALS['strPrivDescCreate' . (isset($GOLBALS['tablename']) ? 'Tbl' : 'Db')]), array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDrop' . (isset($GOLBALS['tablename']) ? 'Tbl' : 'Db')]), array('Reload_priv', 'RELOAD', $GLOBALS['strPrivDescReload']), array('Shutdown_priv', 'SHUTDOWN', $GLOBALS['strPrivDescShutdown']), array('Process_priv', 'PROCESS', $GLOBALS['strPrivDescProcess' . ((!empty($row) && isset($row['Super_priv'])) || (empty($row) && isset($GLOBALS['Super_priv'])) ? '4' : '3')]), array('File_priv', 'FILE', $GLOBALS['strPrivDescFile']), array('References_priv', 'REFERENCES', $GLOBALS['strPrivDescReferences']), array('Index_priv', 'INDEX', $GLOBALS['strPrivDescIndex']), array('Alter_priv', 'ALTER', $GLOBALS['strPrivDescAlter']), array('Show_db_priv', 'SHOW DATABASES', $GLOBALS['strPrivDescShowDb']), array('Super_priv', 'SUPER', $GLOBALS['strPrivDescSuper']), array('Create_tmp_table_priv', 'CREATE TEMPORARY TABLES', $GLOBALS['strPrivDescCreateTmpTable']), array('Lock_tables_priv', 'LOCK TABLES', $GLOBALS['strPrivDescLockTables']), array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']), array('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']), array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']) ); $privs = array(); $allPrivileges = TRUE; while (list(, $current_grant) = each($grants)) { if ((!empty($row) && isset($row[$current_grant[0]])) || (empty($row) && isset($GLOBALS[$current_grant[0]]))) { if ((!empty($row) && $row[$current_grant[0]] == 'Y') || (empty($row) && $GLOBALS[$current_grant[0]] == 'Y')) { if ($enableHTML) { $privs[] = '' . str_replace(' ', ' ', $current_grant[1]) . ''; } else { $privs[] = $current_grant[1]; } } else { $allPrivileges = FALSE; } } } if (empty($privs)) { if ($enableHTML) { $privs[] = 'USAGE'; } else { $privs[] = 'USAGE'; } } else if ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) { if ($enableHTML) { $privs = array('ALL PRIVILEGES'); } else { $privs = array('ALL PRIVILEGES'); } } return $privs; } /** * Updates privileges */ if (!empty($update_privs)) { $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 . '"'; if (isset($Grant_priv) || isset($max_questions) || isset($max_connections) || isset($max_updates)) { $sql_query2 .= 'WITH'; if (isset($Grant_priv) && $Grant_priv == 'Y') { $sql_query2 .= ' GRANT OPTION'; } if (isset($max_questions)) { $sql_query2 .= ' MAX_QUERIES_PER_HOUR ' . (int)$max_questions; } if (isset($max_connections)) { $sql_query2 .= ' MAX_CONNECTIONS_PER_HOUR ' . (int)$max_connections; } if (isset($max_updates)) { $sql_query2 .= ' MAX_UPDATES_PER_HOUR ' . (int)$max_updates; } } $sql_query2 .= ';'; if (!@PMA_mysql_query($sql_query0, $userlink)) { PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query0); } if (!@PMA_mysql_query($sql_query1, $userlink)) { PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query1); } if (!@PMA_mysql_query($sql_query2, $userlink)) { PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query2); } $sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2; $message = sprintf($strUpdatePrivMessage, '\'' . $username . '\'@\'' . $hostname . '\''); } /** * Reloads the privilege tables into memory */ if (!empty($flush_privileges)) { $sql_query = 'FLUSH PRIVILEGES'; if (@PMA_mysql_query($sql_query, $userlink)) { $message = $strPrivilegesReloaded; } else { PMA_mysqlDie(PMA_mysql_error($userlink)); } } /** * Does the common work */ require('./server_common.inc.php3'); /** * Displays the links */ require('./server_links.inc.php3'); /** * Checks if the user is allowed to do what he tries to... */ if (!$is_superuser) { echo '
' . "\n" . ' | ' . $strUser . ' | ' . "\n" . '' . $strHost . ' | ' . "\n" . '' . $strPassword . ' | ' . "\n" . '' . $strGlobalPrivileges . ' | ' . "\n" . '' . $strGrantOption . ' | ' . "\n" . '' . $strAction . ' | ' . "\n"; echo '
---|---|---|---|---|---|---|
' . "\n" . ' | ' . (empty($row['User']) ? '' . $strAny . '' : htmlspecialchars($row['User'])) . ' | ' . "\n" . '' . htmlspecialchars($row['Host']) . ' | ' . "\n"; $privs = PMA_extractPrivInfo($row, TRUE); echo '' . ($row['Password'] == 'Y' ? $strYes : '' . $strNo . '') . ' | ' . "\n" . '' . "\n" . ' ' . join(',' . "\n" . ' ', $privs) . "\n" . ' | ' . "\n" . '' . ($row['Grant_priv'] == 'Y' ? $strYes : $strNo) . ' | ' . "\n" . '' . $strEdit . ' | ' . "\n" . '
' . "\n" . ' ' . $strEnglishPrivileges . ' ' . "\n" . ' | ' . "\n" . '