' . "\n";
$user_host_condition =
' WHERE ' . PMA_convert_using('User')
. ' = ' . PMA_convert_using(PMA_sqlAddslashes($username), 'quoted')
. ' AND ' . PMA_convert_using('Host')
. ' = ' . PMA_convert_using($hostname, 'quoted');
// table body
// get data
if (empty($dbname)) {
$sql_query = 'SELECT * FROM `mysql`.`db`' . $user_host_condition . ' ORDER BY `Db` ASC;';
} else {
$sql_query =
'SELECT `Table_name`,'
.' `Table_priv`,'
.' IF(`Column_priv` = ' . (PMA_MYSQL_INT_VERSION >= 40100 ? '_latin1 ' : '') . ' \'\', 0, 1)'
.' AS \'Column_priv\''
.' FROM `mysql`.`tables_priv`'
. $user_host_condition
.' AND ' . PMA_convert_using('`Db`')
.' LIKE ' . PMA_convert_using($dbname, 'quoted')
.' ORDER BY `Table_name` ASC;';
}
$res = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_STORE);
// display rows
if (PMA_DBI_affected_rows() == 0) {
echo '' . "\n"
. ' ' . $GLOBALS['strNone'] . ' | ' . "\n"
. '
' . "\n";
} else {
$odd_row = true;
if (empty($dbname)) {
$res2 = PMA_DBI_query('SELECT `Db` FROM `mysql`.`tables_priv`' . $user_host_condition . ' GROUP BY `Db` ORDER BY `Db` ASC;');
$row2 = PMA_DBI_fetch_assoc($res2);
if ( $row2 ) {
$row2['Db'] = PMA_escape_mysql_wildcards( $row2['Db'] );
}
}
$found_rows = array();
while ($row = PMA_DBI_fetch_assoc($res)) {
while (empty($dbname) && $row2 && $row['Db'] > $row2['Db']) {
$found_rows[] = $row2['Db'];
echo '' . "\n"
. ' ' . htmlspecialchars( $row2['Db'] ) . ' | ' . "\n"
. ' ' . "\n"
. ' USAGE' . "\n"
. ' | ' . "\n"
. ' ' . $GLOBALS['strNo'] . ' | ' . "\n"
. ' ' . $GLOBALS['strYes'] . ' | ' . "\n"
. ' ';
printf( $link_edit, urlencode( $username ),
urlencode( $hostname ),
urlencode( $row2['Db'] ),
'' );
echo ' | ' . "\n"
. ' ';
printf( $link_revoke, urlencode( $username ),
urlencode( $hostname ), urlencode( $row2['Db'] ), '' );
echo ' | ' . "\n"
. '
' . "\n";
$row2 = PMA_DBI_fetch_assoc($res2);
if ( $row2 ) {
$row2['Db'] = PMA_escape_mysql_wildcards( $row2['Db'] );
}
$odd_row = ! $odd_row;
} // end while
$found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name'];
echo '' . "\n"
. ' ' . htmlspecialchars(empty($dbname) ? $row['Db'] : $row['Table_name']) . ' | ' . "\n"
. ' ' . "\n"
. ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($row, TRUE)) . "\n"
. ' | ' . "\n"
. ' ' . (((empty($dbname) && $row['Grant_priv'] == 'Y') || (!empty($dbname) && in_array('Grant', explode(',', $row['Table_priv'])))) ? $GLOBALS['strYes'] : $GLOBALS['strNo']) . ' | ' . "\n"
. ' ';
if ((empty($dbname) && $row2 && $row['Db'] == $row2['Db'])
|| (!empty($dbname) && $row['Column_priv'])) {
echo $GLOBALS['strYes'];
if (empty($dbname)) {
$row2 = PMA_DBI_fetch_assoc($res2);
if ( $row2 ) {
$row2['Db'] = PMA_escape_mysql_wildcards( $row2['Db'] );
}
}
} else {
echo $GLOBALS['strNo'];
}
echo ' | ' . "\n"
. ' ';
printf( $link_edit, urlencode( $username ),
urlencode( $hostname ),
urlencode( empty($dbname) ? $row['Db'] : $dbname ),
urlencode( empty($dbname) ? '' : $row['Table_name'] ) );
echo ' | ' . "\n"
. ' ';
printf( $link_revoke, urlencode( $username ),
urlencode( $hostname ),
urlencode( empty( $dbname ) ? $row['Db'] : $dbname ),
urlencode( empty( $dbname ) ? '' : $row['Table_name'] ) );
echo ' | ' . "\n"
. '
' . "\n";
$odd_row = ! $odd_row;
} // end while
while (empty($dbname) && $row2) {
$found_rows[] = $row2['Db'];
echo '' . "\n"
. ' ' . htmlspecialchars( $row2['Db']) . ' | ' . "\n"
. ' ' . "\n"
. ' USAGE' . "\n"
. ' | ' . "\n"
. ' ' . $GLOBALS['strNo'] . ' | ' . "\n"
. ' ' . $GLOBALS['strYes'] . ' | ' . "\n"
. ' ';
printf( $link_edit, urlencode( $username ),
urlencode( $hostname ),
urlencode( $row2['Db'] ),
'' );
echo ' | ' . "\n"
. ' ';
printf( $link_revoke, urlencode( $username ),
urlencode( $hostname ), urlencode( $row2['Db'] ), '' );
echo ' | ' . "\n"
. '
' . "\n";
$row2 = PMA_DBI_fetch_assoc($res2);
if ( $row2 ) {
$row2['Db'] = PMA_escape_mysql_wildcards( $row2['Db'] );
}
$odd_row = ! $odd_row;
} // end while
if (empty($dbname)) {
PMA_DBI_free_result($res2);
unset($res2);
unset($row2);
}
}
PMA_DBI_free_result($res);
unset($res);
unset($row);
echo '' . "\n"
. '