From 46c625039f83142b7baaba86829f1084927ebfa2 Mon Sep 17 00:00:00 2001 From: Marc Delisle Date: Fri, 30 Sep 2005 20:12:10 +0000 Subject: [PATCH] MySQL < 4.1.x and super-user, better fix --- libraries/check_user_privileges.lib.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php index 768270ddc..550c3f21a 100644 --- a/libraries/check_user_privileges.lib.php +++ b/libraries/check_user_privileges.lib.php @@ -50,7 +50,7 @@ function PMA_analyseShowGrant($rs_usr, &$is_create_db_priv, &$db_to_create, &$is // TODO: collect $db_to_create into an array, to display a drop-down // in the "Create new database" dialog // - // now we don't break, we want all possible databases + // we don't break, we want all possible databases //break; } // end if } // end elseif @@ -95,6 +95,9 @@ if (PMA_MYSQL_INT_VERSION >= 40102) { } // end while PMA_DBI_free_result($rs_usr); unset($rs_usr, $result_usr); + if ($is_create_db_priv) { + $dbs_where_create_table_allowed[] = '*'; + } } // end if } // end if @@ -103,11 +106,13 @@ if (PMA_MYSQL_INT_VERSION >= 40102) { // the one he just dropped :) if (!$is_create_db_priv) { $local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE ' . PMA_convert_using('Create_priv') . ' = ' . PMA_convert_using('Y', 'quoted') . ' AND (' . PMA_convert_using('User') . ' = ' .PMA_convert_using(PMA_sqlAddslashes($mysql_cur_user), 'quoted') . ' OR ' . PMA_convert_using('User') . ' = ' . PMA_convert_using('', 'quoted') . ');'; + $rs_usr = PMA_DBI_try_query($local_query, $dbh, PMA_DBI_QUERY_STORE); if ($rs_usr) { $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards $re1 = '(^|[^\])(\\\)+'; // escaped wildcards while ($row = PMA_DBI_fetch_assoc($rs_usr)) { + $dbs_where_create_table_allowed[] = $row['Db']; if (ereg($re0 . '(%|_)', $row['Db']) || (!PMA_DBI_try_query('USE ' . ereg_replace($re1 . '(%|_)', '\\1\\3', $row['Db'])) && substr(PMA_DBI_getError(), 1, 4) != 1044)) { $db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $row['Db'])); @@ -137,14 +142,10 @@ if (PMA_MYSQL_INT_VERSION >= 40102) { } // end if } // end elseif } // end if - if ($is_create_db_priv) { - $dbs_where_create_table_allowed[] = '*'; - } } // end else (MySQL < 4.1.2) // If disabled, don't show it if (!$cfg['SuggestDBName']) { $db_to_create = ''; } - ?>