' . "\n"
. ($GLOBALS['cfg']['MainPageIconic'] ? '
' : '')
. $GLOBALS['strPrivileges'] . "\n"
. '' . "\n"
. $GLOBALS['strNoPrivileges'] . "\n";
require_once './libraries/footer.inc.php';
}
/**
* Checks if a dropdown box has been used for selecting a database / table
*/
if (isset($_REQUEST['pred_dbname']) && strlen($_REQUEST['pred_dbname'])) {
$dbname = $_REQUEST['pred_dbname'];
unset($_REQUEST['pred_dbname']);
} elseif (isset($_REQUEST['dbname']) && strlen($_REQUEST['dbname'])) {
$dbname = $_REQUEST['dbname'];
unset($_REQUEST['dbname']);
} else {
$dbname = '';
}
if (isset($_REQUEST['pred_tablename']) && strlen($_REQUEST['pred_tablename'])) {
$tablename = $_REQUEST['pred_tablename'];
unset($_REQUEST['pred_tablename']);
} else {
$tablename = '';
}
/**
* check if given $dbname is a wildcard or not
*/
//if (preg_match('/\\\\(?:_|%)/i', $dbname)) {
//if (preg_match('/(? tag with tooltips
*
* @global ressource $user_link the database connection
*
* @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['strPrivDescCreateDb']),
array('Drop_priv', 'DROP', $GLOBALS['strPrivDescDropDb']),
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('Repl_slave_priv', 'REPLICATION SLAVE', $GLOBALS['strPrivDescReplSlave']),
array('Repl_client_priv', 'REPLICATION CLIENT', $GLOBALS['strPrivDescReplClient']),
array('Create_view_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']),
// for table privs:
array('Create View_priv', 'CREATE VIEW', $GLOBALS['strPrivDescCreateView']),
array('Show_view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']),
// for table privs:
array('Show view_priv', 'SHOW VIEW', $GLOBALS['strPrivDescShowView']),
array('Create_routine_priv', 'CREATE ROUTINE', $GLOBALS['strPrivDescCreateRoutine']),
array('Alter_routine_priv', 'ALTER ROUTINE', $GLOBALS['strPrivDescAlterRoutine']),
array('Create_user_priv', 'CREATE USER', $GLOBALS['strPrivDescCreateUser'])
);
if (PMA_MYSQL_INT_VERSION >= 40002 && PMA_MYSQL_INT_VERSION <50003) {
$grants[] = array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute']);
} else {
$grants[] = array('Execute_priv', 'EXECUTE', $GLOBALS['strPrivDescExecute5']);
}
PMA_addUSerTablePrivs($row);
$privs = array();
$allPrivileges = true;
foreach ($grants as $current_grant) {
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' || (is_array($GLOBALS[$current_grant[0]]) && count($GLOBALS[$current_grant[0]]) == $GLOBALS['column_count'] && empty($GLOBALS[$current_grant[0] . '_none']))))) {
if ($enableHTML) {
$privs[] = '' . $current_grant[1] . '';
} else {
$privs[] = $current_grant[1];
}
} elseif (!empty($GLOBALS[$current_grant[0]]) && is_array($GLOBALS[$current_grant[0]]) && empty($GLOBALS[$current_grant[0] . '_none'])) {
if ($enableHTML) {
$priv_string = '' . $current_grant[1] . '';
} else {
$priv_string = $current_grant[1];
}
$privs[] = $priv_string . ' (`' . join('`, `', $GLOBALS[$current_grant[0]]) . '`)';
} else {
$allPrivileges = false;
}
}
}
if (empty($privs)) {
if ($enableHTML) {
$privs[] = 'USAGE';
} else {
$privs[] = 'USAGE';
}
} elseif ($allPrivileges && (!isset($GLOBALS['grant_count']) || count($privs) == $GLOBALS['grant_count'])) {
if ($enableHTML) {
$privs = array('ALL PRIVILEGES');
} else {
$privs = array('ALL PRIVILEGES');
}
}
return $privs;
} // end of the 'PMA_extractPrivInfo()' function
/**
* Displays on which column(s) a table-specific privilege is granted
*/
function PMA_display_column_privs($spaces, $columns, $row, $name_for_select,
$priv_for_header, $name, $name_for_dfn, $name_for_current)
{
$spaces .= ' ';
echo $spaces . '
' . "\n"
. $spaces . ' ' . "\n"
. $spaces . ' ' . "\n"
. $spaces . ' ' . $GLOBALS['strOr'] . '' . "\n"
. $spaces . ' ' . "\n"
. $spaces . '
' . "\n";
} // end function
/**
* Displays the privileges form table
*
* @param string $db the database
* @param string $table the table
* @param boolean $submit wheather to display the submit button or not
* @param int $indent the indenting level of the code
*
* @global array $cfg the phpMyAdmin configuration
* @global ressource $user_link the database connection
*
* @return void
*/
function PMA_displayPrivTable($db = '*', $table = '*', $submit = true, $indent = 0)
{
if ($db == '*') {
$table = '*';
}
$spaces = str_repeat(' ', $indent);
if (isset($_REQUEST['username'])) {
if ($db == '*') {
$sql_query =
'SELECT * FROM `mysql`.`user`'
.' WHERE ' . PMA_convert_using('User')
.' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
.' AND ' . PMA_convert_using('Host')
.' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted') . ';';
} elseif ($table == '*') {
$sql_query =
'SELECT * FROM `mysql`.`db`'
.' WHERE ' . PMA_convert_using('`User`')
.' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
.' AND ' . PMA_convert_using('`Host`')
.' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
.' AND ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
.' LIKE ' . PMA_convert_using('`Db`') . ';';
} else {
$sql_query =
'SELECT `Table_priv`'
.' FROM `mysql`.`tables_priv`'
.' WHERE ' . PMA_convert_using('`User`')
.' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
.' AND ' .PMA_convert_using('`Host`')
.' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
.' AND ' .PMA_convert_using('`Db`')
.' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
.' AND ' . PMA_convert_using('`Table_name`')
.' = ' . PMA_convert_using($table, 'quoted') . ';';
}
$row = PMA_DBI_fetch_single_row($sql_query);
}
if (empty($row)) {
if ($table == '*') {
if ($db == '*') {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`user`;';
} else {
$sql_query = 'SHOW COLUMNS FROM `mysql`.`db`;';
}
$res = PMA_DBI_query($sql_query);
while ($row1 = PMA_DBI_fetch_row($res)) {
if (substr($row1[0], 0, 4) == 'max_') {
$row[$row1[0]] = 0;
} else {
$row[$row1[0]] = 'N';
}
}
PMA_DBI_free_result($res);
} else {
$row = array('Table_priv' => '');
}
}
if (isset($row['Table_priv'])) {
PMA_addUSerTablePrivs($row);
// get collumns
$res = PMA_DBI_try_query('SHOW COLUMNS FROM `' . PMA_unescape_mysql_wildcards($db) . '`.`' . $table . '`;');
$columns = array();
if ($res) {
while ($row1 = PMA_DBI_fetch_row($res)) {
$columns[$row1[0]] = array(
'Select' => false,
'Insert' => false,
'Update' => false,
'References' => false
);
}
PMA_DBI_free_result($res);
}
unset($res, $row1);
}
// t a b l e - s p e c i f i c p r i v i l e g e s
if (! empty($columns)) {
$res = PMA_DBI_query(
'SELECT `Column_name`, `Column_priv`'
.' FROM `mysql`.`columns_priv`'
.' WHERE ' . PMA_convert_using('`User`')
.' = ' . PMA_convert_using(PMA_sqlAddslashes($_REQUEST['username']), 'quoted')
.' AND ' . PMA_convert_using('`Host`')
.' = ' . PMA_convert_using($_REQUEST['hostname'], 'quoted')
.' AND ' . PMA_convert_using('`Db`')
.' = ' . PMA_convert_using(PMA_unescape_mysql_wildcards($db), 'quoted')
.' AND ' . PMA_convert_using('`Table_name`')
.' = ' . PMA_convert_using($table, 'quoted') . ';');
while ($row1 = PMA_DBI_fetch_row($res)) {
$row1[1] = explode(',', $row1[1]);
foreach ($row1[1] as $current) {
$columns[$row1[0]][$current] = true;
}
}
PMA_DBI_free_result($res);
unset($res, $row1, $current);
echo $spaces . '' . "\n"
. $spaces . '' . "\n"
. $spaces . '