📄 pma_list_database.class.php
字号:
} if (! $this->_show_databases_disabled) { $this->items = array_merge($this->items, $this->_retrieve($each_only_db)); continue; } // @todo induce error, about not using wildcards with SHOW DATABASE disabled? } return true; } /** * returns default item * * @uses PMA_List::getEmpty() * @uses strlen() * @global string $db * @return string default item */ function getDefault() { if (strlen($GLOBALS['db'])) { return $GLOBALS['db']; } return $this->getEmpty(); } /** * returns array with dbs grouped with extended infos * * @uses $GLOBALS['PMA_List_Database'] * @uses $GLOBALS['cfgRelation']['commwork'] * @uses $GLOBALS['cfg']['ShowTooltip'] * @uses $GLOBALS['cfg']['LeftFrameDBTree'] * @uses $GLOBALS['cfg']['LeftFrameDBSeparator'] * @uses $GLOBALS['cfg']['ShowTooltipAliasDB'] * @uses PMA_getTableCount() * @uses PMA_getComments() * @uses is_array() * @uses implode() * @uses strstr() * @uses explode() * @return array db list */ function getGroupedDetails() { $dbgroups = array(); $parts = array(); foreach ($this->items as $key => $db) { // garvin: Get comments from PMA comments table $db_tooltip = ''; if ($GLOBALS['cfg']['ShowTooltip'] && $GLOBALS['cfgRelation']['commwork']) { $_db_tooltip = PMA_getComments($db); if (is_array($_db_tooltip)) { $db_tooltip = implode(' ', $_db_tooltip); } } if ($GLOBALS['cfg']['LeftFrameDBTree'] && $GLOBALS['cfg']['LeftFrameDBSeparator'] && strstr($db, $GLOBALS['cfg']['LeftFrameDBSeparator'])) { // use strpos instead of strrpos; it seems more common to // have the db name, the separator, then the rest which // might contain a separator // like dbname_the_rest $pos = strpos($db, $GLOBALS['cfg']['LeftFrameDBSeparator']); $group = substr($db, 0, $pos); $disp_name_cut = substr($db, $pos); } else { $group = $db; $disp_name_cut = $db; } $disp_name = $db; if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) { $disp_name = $db_tooltip; $disp_name_cut = $db_tooltip; $db_tooltip = $db; } $dbgroups[$group][$db] = array( 'name' => $db, 'disp_name_cut' => $disp_name_cut, 'disp_name' => $disp_name, 'comment' => $db_tooltip, 'num_tables' => PMA_getTableCount($db), ); } // end foreach ($GLOBALS['PMA_List_Database']->items as $db) return $dbgroups; } /** * returns html code for list with dbs * * @return string html code list */ function getHtmlListGrouped($selected = '') { if (true === $selected) { $selected = $this->getDefault(); } $return = '<ul id="databaseList" xml:lang="en" dir="ltr">' . "\n"; foreach ($this->getGroupedDetails() as $group => $dbs) { if (count($dbs) > 1) { $return .= '<li><ul>' . "\n"; // wether display db_name cuted by the group part $cut = true; } else { // .. or full $cut = false; } foreach ($dbs as $db) { $return .= '<li'; if ($db['name'] == $selected) { $return .= ' class="selected"'; } $return .= '><a title="' . $db['comment'] . ' "href="index.php?' . PMA_generate_common_url($db['name']) . '" target="_parent">'; $return .= ($cut ? $db['disp_name_cut'] : $db['disp_name']) .' (' . $db['num_tables'] . ')'; $return .= '</a></li>' . "\n"; } if (count($dbs) > 1) { $return .= '</ul></li>' . "\n"; } } $return .= '</ul>'; return $return; } /** * returns html code for select form element with dbs * * @todo IE can not handle different text directions in select boxes so, * as mostly names will be in english, we set the whole selectbox to LTR * and EN * * @return string html code select */ function getHtmlSelectGrouped($selected = '') { if (true === $selected) { $selected = $this->getDefault(); } $return = '<select name="db" id="lightm_db" xml:lang="en" dir="ltr"' . ' onchange="if (this.value != \'\') window.parent.openDb(this.value);">' . "\n" . '<option value="" dir="' . $GLOBALS['text_dir'] . '">' . '(' . $GLOBALS['strDatabases'] . ') ...</option>' . "\n"; foreach ($this->getGroupedDetails() 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="' . htmlspecialchars($db['name']) . '"' .' title="' . htmlspecialchars($db['comment']) . '"'; if ($db['name'] == $selected) { $return .= ' selected="selected"'; } $return .= '>' . htmlspecialchars($cut ? $db['disp_name_cut'] : $db['disp_name']) .' (' . $db['num_tables'] . ')</option>' . "\n"; } if (count($dbs) > 1) { $return .= '</optgroup>' . "\n"; } } $return .= '</select>'; return $return; } /** * this is just a backup, if all is fine this can be deleted later * * @deprecated * @access protected */ function _checkAgainstPrivTables() { // 1. get allowed dbs from the "mysql.db" table // lem9: User can be blank (anonymous user) $local_query = " SELECT DISTINCT `Db` FROM `mysql`.`db` WHERE `Select_priv` = 'Y' AND `User` IN ('" . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . "', '')"; $tmp_mydbs = PMA_DBI_fetch_result($local_query, null, null, $GLOBALS['controllink']); if ($tmp_mydbs) { // Will use as associative array of the following 2 code // lines: // the 1st is the only line intact from before // correction, // the 2nd replaces $dblist[] = $row['Db']; // Code following those 2 lines in correction continues // populating $dblist[], as previous code did. But it is // now populated with actual database names instead of // with regular expressions. var_dump($tmp_mydbs); $tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']); // loic1: all databases cases - part 2 if (isset($tmp_mydbs['%'])) { while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) { $dblist[] = $tmp_row[0]; } // end while } else { while ($tmp_row = PMA_DBI_fetch_row($tmp_alldbs)) { $tmp_db = $tmp_row[0]; if (isset($tmp_mydbs[$tmp_db]) && $tmp_mydbs[$tmp_db] == 1) { $dblist[] = $tmp_db; $tmp_mydbs[$tmp_db] = 0; } elseif (!isset($dblist[$tmp_db])) { foreach ($tmp_mydbs as $tmp_matchpattern => $tmp_value) { // loic1: fixed bad regexp // TODO: db names may contain characters // that are regexp instructions $re = '(^|(\\\\\\\\)+|[^\])'; $tmp_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $tmp_matchpattern)); // Fixed db name matching // 2000-08-28 -- Benjamin Gandon if (ereg('^' . $tmp_regex . '$', $tmp_db)) { $dblist[] = $tmp_db; break; } } // end while } // end if ... elseif ... } // end while } // end else PMA_DBI_free_result($tmp_alldbs); unset($tmp_mydbs); } // end if // 2. get allowed dbs from the "mysql.tables_priv" table $local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($GLOBALS['cfg']['Server']['user']) . '\''; $rs = PMA_DBI_try_query($local_query, $GLOBALS['controllink']); if ($rs && @PMA_DBI_num_rows($rs)) { while ($row = PMA_DBI_fetch_assoc($rs)) { if (!in_array($row['Db'], $dblist)) { $dblist[] = $row['Db']; } } // end while PMA_DBI_free_result($rs); } // end if }}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -