0) {
// Get user's global privileges ($dbh and $userlink are links to MySQL
// defined in the "common.lib.php" library)
// Note: if no controluser is defined, $dbh contains $userlink
$is_create_priv = FALSE;
$is_process_priv = TRUE;
$is_reload_priv = FALSE;
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables)
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $userlink, PMA_DBI_QUERY_STORE);
if ($dbh) {
$local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\'';
$rs_usr = PMA_DBI_try_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
if ($rs_usr) {
while ($result_usr = PMA_DBI_fetch_assoc($rs_usr)) {
if (!$is_create_priv) {
$is_create_priv = ($result_usr['Create_priv'] == 'Y');
}
if (!$is_reload_priv) {
$is_reload_priv = ($result_usr['Reload_priv'] == 'Y');
}
} // end while
PMA_DBI_free_result($rs_usr);
unset($rs_usr, $result_usr);
} // end if
} // end if
// If the user has Create priv on a inexistant db, show him in the dialog
// the first inexistant db name that we find, in most cases it's probably
// the one he just dropped :)
if (!$is_create_priv) {
$rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh, PMA_DBI_QUERY_STORE);
if ($rs_usr) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_DBI_fetch_assoc($rs_usr)) {
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']));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_priv = TRUE;
break;
} // end if
} // end while
PMA_DBI_free_result($rs_usr);
unset($rs_usr, $row, $re0, $re1);
} // end if
else {
// Finally, let's try to get the user's privileges by using SHOW
// GRANTS...
// Maybe we'll find a little CREATE priv there :)
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh, PMA_DBI_QUERY_STORE);
if (!$rs_usr) {
// OK, now we'd have to guess the user's hostname, but we
// only try out the 'username'@'%' case.
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh, PMA_DBI_QUERY_STORE);
}
unset($local_query);
if ($rs_usr) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_DBI_fetch_row($rs_usr)) {
$show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4,(strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4));
$show_grants_dbname = ereg_replace('^`(.*)`','\\1', $show_grants_dbname);
$show_grants_str = substr($row[0],6,(strpos($row[0],' ON ')-6));
if (($show_grants_str == 'ALL') || ($show_grants_str == 'ALL PRIVILEGES') || ($show_grants_str == 'CREATE') || strpos($show_grants_str, 'CREATE')) {
if ($show_grants_dbname == '*') {
$is_create_priv = TRUE;
$db_to_create = '';
break;
} // end if
else if ( (ereg($re0 . '%|_', $show_grants_dbname)
&& !ereg('\\\\%|\\\\_', $show_grants_dbname))
|| (!PMA_DBI_try_query('USE ' . ereg_replace($re1 .'(%|_)', '\\1\\3', $show_grants_dbname)) && substr(PMA_DBI_getError(), 1, 4) != 1044)
) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_priv = TRUE;
break;
} // end elseif
} // end if
} // end while
unset($show_grants_dbname, $show_grants_str, $re0, $re1);
PMA_DBI_free_result($rs_usr);
unset($rs_usr);
} // end if
} // end elseif
} // end if
else {
$db_to_create = '';
} // end else
if (!$cfg['SuggestDBName']) {
$db_to_create = '';
}
$common_url_query = PMA_generate_common_url();
if ($is_superuser) {
$cfg['ShowMysqlInfo'] = TRUE;
$cfg['ShowMysqlVars'] = TRUE;
$cfg['ShowChgPassword'] = TRUE;
}
if ($cfg['Server']['auth_type'] == 'config') {
$cfg['ShowChgPassword'] = FALSE;
}
// loic1: Displays the MySQL column only if at least one feature has to be
// displayed
if ($is_superuser || $is_create_priv || $is_process_priv || $is_reload_priv
|| $cfg['ShowMysqlInfo'] || $cfg['ShowMysqlVars'] || $cfg['ShowChgPassword']
|| $cfg['Server']['auth_type'] != 'config') {
?>
'
. ($cfg['ErrorIconic'] ? ' ' : '')
. '' . $strNoPrivileges .'';
} // end create db form or message
?>
|
','s_status.png',$strMySQLShowStatus,'') : $str_normal_list);
?>
|
','s_vars.png',$strMySQLShowVars,'') : $str_normal_list);
?>
|
','s_process.png',$strMySQLShowProcess,'') : $str_normal_list);
?>
|
= 40100) {
echo "\n";
?>
','s_asci.png',$strCharsetsAndCollations,'') : $str_normal_list);
?>
|
','s_reload.png',$strReloadMySQL,'') : $str_normal_list);
?>
|
','s_rights.png',$strPrivileges,'') : $str_normal_list);
?>
|
','s_db.png',$strDatabases,'') : $str_normal_list);
?>
|
','b_export.png',$strExport,'') : $str_normal_list);
?>
|
','s_passwd.png',$strChangePassword,'') : $str_normal_list);
?>
|
'
. ($cfg['ReplaceHelpImg'] ? ' ' : '(*)') . ''
: '';
echo "\n";
?>
','s_loggoff.png',$strChangePassword,'') : $str_normal_list);
?>
|
0)
echo "\n";
?>
|
|
','s_lang.png','Language','') : $str_normal_list);
?>
|
|
= 40100) {
echo ' ' . "\n"
. ' ' . "\n"
.' ' . ($str_iconic_list != '' ? sprintf($str_iconic_list,'','s_asci.png',$strMySQLCharset,'') : $str_normal_list) . "\n"
. ' ' . "\n"
. ' ' . $strMySQLCharset . ': '
. ' '
. ' ' . $mysql_charsets_descriptions[$mysql_charset_map[strtolower($charset)]] . "\n"
. ' (' . $mysql_charset_map[strtolower($charset)] . ')' . "\n"
. ' | ' . "\n"
. ' ' . "\n";
}
echo "\n";
// added by Michael Keck
// ThemeManager if available
if (isset($available_themes_choices) && $available_themes_choices > 1) {
$theme_selected = FALSE;
$theme_preview_path= './themes.php';
$theme_preview_href = '';
?>
') : $str_normal_list) . "\n";
?>
|
','b_docs.png',$strPmaDocumentation,'') : $str_normal_list);
?>
|
','php_sym.png',$strShowPHPInfo,'') : $str_normal_list);
?>
|
','b_home.png',$strHomepageOfficial,'') : $str_normal_list);
?>
|
';
?>
[ChangeLog]
[CVS]
[Lists]
|
|