Tried to fix bug #520282 - mysql safe_show_database=on support

This commit is contained in:
Loïc Chapeaux
2002-03-03 17:25:16 +00:00
parent 16843c684b
commit 6b5c405014
2 changed files with 29 additions and 8 deletions

View File

@@ -10,6 +10,8 @@ $Source$
- feature request #503015 - No "xxxtext" button on vertical mode;
- extended the "relation" feature to PHP3.
* Documentation.html, line 557: extended the "relation" feature to PHP3.
* libraries/common.lib.php3: tried to fix bug #520282 - mysql
safe_show_database=on support. Must be fully tested now.
2002-03-01 Olivier M<>ller <om@omnis.ch>
* created the phpmyadmin-cvs mailing list, following the instructions

View File

@@ -526,16 +526,35 @@ if (!defined('PMA_COMMON_LIB_INCLUDED')){
unset($true_dblist);
} // end if
// 'only_db' is empty for the current user -> checks for available
// databases in the "mysql" db
// 'only_db' is empty for the current user...
else {
$auth_query = 'SELECT User, Select_priv '
. 'FROM mysql.user '
. 'WHERE User = \'' . PMA_sqlAddslashes($cfgServer['user']) . '\'';
$rs = mysql_query($auth_query, $dbh); // Debug: or PMA_mysqlDie('', $auth_query, FALSE);
} // end if
// ... first checks whether the "safe_show_database" is on or not
$local_query = 'SHOW VARIABLES LIKE \'safe_show_database\'';
$rs = mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
$is_safe_show_dbs = mysql_result($rs, 0, 'Value');
// Access to "mysql" db allowed -> gets the usable db list
// ... and if on, try get the available dbs list,....
if ($is_safe_show_dbs && strtoupper($is_safe_show_dbs) != 'OFF') {
$uva_alldbs = mysql_list_dbs($userlink);
while ($uva_row = mysql_fetch_array($uva_alldbs)) {
$dblist[] = $uva_row[0];
} // end while
$dblist_cnt = count($dblist);
unset($uva_alldbs);
mysql_free_result($rs);
} // end if ($is_safe_show_dbs)
// ... else checks for available databases in the "mysql" db
if (!$dblist_cnt) {
$auth_query = 'SELECT User, Select_priv '
. 'FROM mysql.user '
. 'WHERE User = \'' . PMA_sqlAddslashes($cfgServer['user']) . '\'';
$rs = mysql_query($auth_query, $dbh); // Debug: or PMA_mysqlDie('', $auth_query, FALSE);
} // end
} // end if (!$dblist_cnt)
// Access to "mysql" db allowed and dblist still empty -> gets the
// usable db list
if (!$dblist_cnt && @mysql_numrows($rs)) {
$row = mysql_fetch_array($rs);
mysql_free_result($rs);