diff --git a/ChangeLog b/ChangeLog index 988a8c5e4..20dd8e09e 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,15 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-10-28 Sebastian Mendel + * server_privilegs.php, libraries/common.lib.php, + themes/*/theme_right.css.php: + - minor tweak in display + - added PMA_unescape_mysql_wildcards() + - bug #1144110 Unable to escape "_" + - now every user from every mysql table is displayed + - no table specific rights for db wildcards + 2005-10-27 Sebastian Mendel * libraries/common.lib.php::PMA_formatNumber(), db_details_structure.php: do not truncate rowcount diff --git a/libraries/common.lib.php b/libraries/common.lib.php index e2e4e9976..48500340f 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -433,6 +433,21 @@ if ($is_minimum_common == FALSE) { return $name; } // end of the 'PMA_escape_mysql_wildcards()' function + /** + * removes slashes before "_" and "%" characters + * Note: This function does not unescape backslashes! + * + * @param string $name the string to escape + * @return string the escaped string + * @access public + */ + function PMA_unescape_mysql_wildcards( $name ) + { + $name = str_replace('\\_', '_', $name); + $name = str_replace('\\%', '%', $name); + + return $name; + } // end of the 'PMA_unescape_mysql_wildcards()' function /** * format sql strings diff --git a/server_privileges.php b/server_privileges.php index 25efe4a31..5a38156b4 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -21,6 +21,16 @@ if (!empty($pred_tablename)) { unset($pred_tablename); } +// check if given $dbanem is a wildcard or not +if ( isset( $dbname ) ) { + //if ( preg_match( '°\\\\(?:_|%)°i', $dbname ) ) { + if ( preg_match( '°(?' . "\n" . ($GLOBALS['cfg']['PropertiesIconic'] ? '' : '' ) . $GLOBALS['strUser'] . ' \'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'' . "\n"; - if (!empty($dbname)) { - echo ' - ' . $GLOBALS['strDatabase'] . ' ' . htmlspecialchars($dbname) . '' . "\n"; - if (!empty($tablename)) { + if ( ! empty( $dbname ) ) { + if ( $dbname_is_wildcard ) { + echo ' - ' . $GLOBALS['strDatabases']; + } else { + echo ' - ' . $GLOBALS['strDatabase']; + } + echo ' ' . htmlspecialchars($dbname) . '' . "\n"; + if ( ! empty( $tablename ) ) { echo ' - ' . $GLOBALS['strTable'] . ' ' . htmlspecialchars($tablename) . '' . "\n"; } } @@ -1510,7 +1534,12 @@ if (empty($adduser) && empty($checkprivs)) { PMA_displayPrivTable((empty($dbname) ? '*' : $dbname), ((empty($dbname) || empty($tablename)) ? '*' : $tablename), TRUE, 3); echo '' . "\n"; - if (empty($tablename)) { + if ( empty( $tablename ) && ! $dbname_is_wildcard ) { + + // na table name was given, display all table specific rights + // but only if $dbname contains no wildcards + + // table header echo '
' . "\n" . PMA_generate_common_hidden_inputs('', '', 6) . '' . "\n" @@ -1532,6 +1561,9 @@ if (empty($adduser) && empty($checkprivs)) { . ' = ' . 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 { @@ -1543,10 +1575,12 @@ if (empty($adduser) && empty($checkprivs)) { .' FROM `mysql`.`tables_priv`' . $user_host_condition .' AND ' . PMA_convert_using('`Db`') - .' = ' . PMA_convert_using($dbname, 'quoted') + .' 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" @@ -1556,11 +1590,13 @@ if (empty($adduser) && empty($checkprivs)) { 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']) { - $row2['Db'] = str_replace( '\\_', '_', $row2['Db'] ); $found_rows[] = $row2['Db']; echo '' . "\n" . ' ' . htmlspecialchars( $row2['Db'] ) . '' . "\n" @@ -1581,11 +1617,11 @@ if (empty($adduser) && empty($checkprivs)) { 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( $row['Db'] ) ) { - $row['Db'] = str_replace( '\\_', '_', $row['Db'] ); - } $found_rows[] = empty($dbname) ? $row['Db'] : $row['Table_name']; echo '' . "\n" @@ -1600,6 +1636,9 @@ if (empty($adduser) && empty($checkprivs)) { 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']; @@ -1623,7 +1662,6 @@ if (empty($adduser) && empty($checkprivs)) { while (empty($dbname) && $row2) { - $row2['Db'] = str_replace( '\\_', '_', $row2['Db'] ); $found_rows[] = $row2['Db']; echo '' . "\n" @@ -1645,6 +1683,9 @@ if (empty($adduser) && empty($checkprivs)) { 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 @@ -1659,23 +1700,27 @@ if (empty($adduser) && empty($checkprivs)) { unset($row); echo '' . "\n" . '' . "\n"; + if (empty($dbname)) { - echo ' ' . "\n"; - $res = PMA_DBI_query('SHOW DATABASES;'); - $pred_db_array = array(); - while ($row = PMA_DBI_fetch_row($res)) { - if (!isset($found_rows) || !in_array( $row[0], $found_rows )) { - $pred_db_array[] = $row[0]; - } + + // no database name was give, display select db + + if ( ! empty( $found_rows ) ) { + $pred_db_array = array_diff( + PMA_DBI_fetch_result( 'SHOW DATABASES;' ), + $found_rows ); + } else { + $pred_db_array =PMA_DBI_fetch_result( 'SHOW DATABASES;' ); } - PMA_DBI_free_result($res); - unset($res); - unset($row); + + echo ' ' . "\n"; if (!empty($pred_db_array)) { echo ' ' . "\n"; } @@ -1707,6 +1752,9 @@ if (empty($adduser) && empty($checkprivs)) { echo ' ' . "\n"; } echo ' ' . PMA_showHint($GLOBALS['strEscapeWildcards']) . "\n" + . '' . "\n"; + echo '
' . "\n" + . ' ' . PMA_showHint($GLOBALS['strEscapeWildcards']) . "\n" . '
' . "\n" . '
' . "\n"; } @@ -1837,8 +1885,8 @@ if (empty($adduser) && empty($checkprivs)) { . PMA_convert_using('`Db`') . ' AS `Db`, ' . $list_of_privileges .' FROM `mysql`.`db`' - .' WHERE ' . PMA_convert_using($checkprivs, 'quoted') - .' LIKE REPLACE( ' . PMA_convert_using('Db') . ', \'\\_\', \'_\' )' + .' WHERE ' . PMA_convert_using( $checkprivs, 'quoted' ) + .' LIKE ' . PMA_convert_using('`Db`') .' AND NOT (' . $list_of_compared_privileges. ')) ' .'UNION ' .'(SELECT ' . PMA_convert_using('`User`') . ' AS `User`, ' @@ -1863,7 +1911,7 @@ if (empty($adduser) && empty($checkprivs)) { $sql_query = 'SELECT * FROM `mysql`.`db`' .' WHERE \'' . $checkprivs . '\'' - .' LIKE REPLACE( `Db`, \'\\_\', \'_\' )' + .' LIKE `Db`' .' AND NOT (`Select_priv` = \'N\'' .' AND `Insert_priv` = \'N\'' .' AND `Update_priv` = \'N\'' @@ -1924,7 +1972,7 @@ if (empty($adduser) && empty($checkprivs)) { . ' '; if (!isset($current['Db']) || $current['Db'] == '*') { echo $GLOBALS['strGlobal']; - } elseif ( str_replace( '\\_', '_', $current['Db'] ) == $checkprivs ) { + } elseif ( $current['Db'] == PMA_escape_mysql_wildcards( $checkprivs ) ) { echo $GLOBALS['strDbSpecific']; } else { echo $GLOBALS['strWildcard'], ': ' . htmlspecialchars($current['Db']) . ''; diff --git a/themes/original/css/theme_right.css.php b/themes/original/css/theme_right.css.php index bd8109f17..56dea3f83 100644 --- a/themes/original/css/theme_right.css.php +++ b/themes/original/css/theme_right.css.php @@ -429,7 +429,7 @@ fieldset.tblFooters { #fieldset_user_priv div.item { float: left; - width: 8em; + width: 9em; max-width: 100%; }