. $GLOBALS['strDatabases'] . ') ...</option>'
."\n";
foreach ($dblist as $group => $dbs) {
if (count($dbs) > 1) {
$return .= '<optgroup label="' . htmlspecialchars($group)
. '">' . "\n";
// wether display db_name cuted by the group part
$cut = true;
} else {
// .. or full
$cut = false;
}
foreach ($dbs as $db) {
$return .= '<option value="' . $db['name'] . '"'
.' title="' . $db['comment'] . '"';
if ($db['name'] == $selected) {
$return .= ' selected="selected"';
}
$return .= '>' . ($cut ? $db['disp_name_cut'] : $db['disp_name'])
.' (' . $db['num_tables'] . ')</option>' . "\n";
}
if (count($dbs) > 1) {
$return .= '</optgroup>' . "\n";
}
}
$return .= '</select>';
return $return;
}
/**
* returns count of tables in given db
*
* @param string $db database to count tables for
* @return integer count of tables in $db
*/
function PMA_getTableCount($db)
{
$tables = PMA_DBI_try_query(
'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
null, PMA_DBI_QUERY_STORE);
if ($tables) {
$num_tables = PMA_DBI_num_rows($tables);
PMA_DBI_free_result($tables);
} else {
$num_tables = 0;
}
return $num_tables;
}
/**
* Get the complete list of Databases a user can access
*
* @param boolean whether to include check on failed 'only_db' operations
* @param resource database handle (superuser)
* @param integer amount of databases inside the 'only_db' container
* @param resource possible resource from a failed previous query
* @param resource database handle (user)
* @param array configuration
* @param array previous list of databases
*
* @return array all databases a user has access to
*
* @access private
*/
function PMA_safe_db_list($only_db_check, $controllink, $dblist_cnt, $userlink,
$cfg, $dblist)
{
if ($only_db_check == false) {
// try to get the available dbs list
// use userlink by default
$dblist = PMA_DBI_get_dblist();
$dblist_cnt = count($dblist);
// PMA_DBI_get_dblist() relies on the ability to run "SHOW DATABASES".
// On servers started with --skip-show-database, this is not possible
// so we have here a fallback method, which relies on the controluser
// being able to access the "my
sql" db, as explained in the doc.
if (!$dblist_cnt) {
$auth_query = 'SELECT User, Select_priv '
. 'FROM mysql.user '
. 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
$rs = PMA_DBI_try_query($auth_query, $controllink);
} // end
}
// Access to "mysql" db allowed and dblist still empty -> gets the
// usable db list
if (!$dblist_cnt && ($rs && @PMA_DBI_num_rows($rs))) {
$