2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
13 require './libraries/server_common.inc.php';
15 include './libraries/replication.inc.php';
17 $replication_types = array();
18 $replication_info = null;
20 require './libraries/build_html_for_db.lib.php';
23 * avoids 'undefined index' errors
25 if (empty($_REQUEST['sort_by'])) {
26 $sort_by = 'SCHEMA_NAME';
28 $sort_by_whitelist = array(
30 'DEFAULT_COLLATION_NAME',
34 'SCHEMA_INDEX_LENGTH',
38 if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
39 $sort_by = $_REQUEST['sort_by'];
41 $sort_by = 'SCHEMA_NAME';
45 if (isset($_REQUEST['sort_order'])
46 && strtolower($_REQUEST['sort_order']) == 'desc') {
52 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
53 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
57 * Drops multiple databases
60 // workaround for IE behavior (it returns some coordinates based on where
61 // the mouse was on the Drop image):
62 if (isset($_REQUEST['drop_selected_dbs_x'])) {
63 $_REQUEST['drop_selected_dbs'] = true;
66 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
67 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
68 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
69 $message = PMA_Message
::error(__('No databases selected.'));
71 $action = 'server_databases.php';
72 $submit_mult = 'drop_db' ;
73 $err_url = 'server_databases.php?' . PMA_generate_common_url();
74 if (isset($_REQUEST['selected_dbs'])) {
75 $selected_db = $_REQUEST['selected_dbs'];
77 include './libraries/mult_submits.inc.php';
78 unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
79 if (empty($message)) {
80 $message = PMA_Message
::success(__('%s databases have been dropped successfully.'));
81 if ($mult_btn == __('Yes')) {
82 $message->addParam(count($selected));
84 $message->addParam(0);
94 require './libraries/server_links.inc.php';
98 * Displays the sub-page heading
101 . ($GLOBALS['cfg']['MainPageIconic']
102 ?
PMA_getImage('s_db.png')
104 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
110 if ($cfg['ShowCreateDb']) {
111 echo '<ul><li id="li_create_database">' . "\n";
112 include './libraries/display_create_database.lib.php';
113 echo ' </li>' . "\n";
118 * Gets the databases list
121 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
122 $sort_order, $pos, true);
123 $databases_count = count($GLOBALS['pma']->databases
);
125 $databases_count = 0;
132 if ($databases_count > 0) {
133 echo '<div id="tableslistcontainer">';
135 $first_database = current($databases);
137 $column_order = PMA_getColumnOrder();
139 $_url_params = array(
141 'dbstats' => $dbstats,
142 'sort_by' => $sort_by,
143 'sort_order' => $sort_order,
146 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
148 $_url_params['pos'] = $pos;
150 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
151 . PMA_generate_common_hidden_inputs($_url_params);
153 $_url_params['sort_by'] = 'SCHEMA_NAME';
154 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
156 echo '<table id="tabledatabases" class="data">' . "\n"
159 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
160 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
161 . ' ' . __('Database') . "\n"
162 . ($sort_by == 'SCHEMA_NAME' ?
' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ?
__('Ascending') : __('Descending'))) . "\n" : '')
163 . ' </a></th>' . "\n";
165 foreach ($column_order as $stat_name => $stat) {
166 if (array_key_exists($stat_name, $first_database)) {
167 if ($stat['format'] === 'byte') {
169 $colspan = ' colspan="2"';
174 $_url_params['sort_by'] = $stat_name;
175 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
176 echo ' <th' . $colspan . '>'
177 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
178 .' ' . $stat['disp_name'] . "\n"
179 .($sort_by == $stat_name ?
' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ?
__('Ascending') : __('Descending'))) . "\n" : '')
180 .' </a></th>' . "\n";
184 foreach ($replication_types as $type) {
186 $name = __('Master replication');
187 elseif ($type == "slave")
188 $name = __('Slave replication');
189 if ($
{"server_{$type}_status"})
190 echo ' <th>'. $name .'</th>' . "\n";
193 if ($is_superuser && !PMA_DRIZZLE
) {
194 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
202 foreach ($databases as $current) {
203 $tr_class = $odd_row ?
'odd' : 'even';
204 if (PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
205 $tr_class .= ' noclick';
207 echo '<tr class="' . $tr_class . '">' . "\n";
208 $odd_row = ! $odd_row;
210 list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ?
$checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
212 echo $generated_html;
215 } // end foreach ($databases as $key => $current)
216 unset($current, $odd_row);
218 echo '<tr id="db_summary_row">' . "\n";
219 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
220 echo ' <th></th>' . "\n";
222 echo ' <th>' . __('Total') . ': <span id="databases_count">' . $databases_count . '</span></th>' . "\n";
223 foreach ($column_order as $stat_name => $stat) {
224 if (array_key_exists($stat_name, $first_database)) {
225 if ($stat['format'] === 'byte') {
226 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
227 } elseif ($stat['format'] === 'number') {
228 $value = PMA_formatNumber($stat['footer'], 0);
230 $value = htmlentities($stat['footer'], 0);
232 echo ' <th class="value">';
233 if (isset($stat['description_function'])) {
234 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
237 if (isset($stat['description_function'])) {
241 if ($stat['format'] === 'byte') {
242 echo ' <th class="unit">' . $unit . '</th>' . "\n";
247 foreach ($replication_types as $type) {
248 if ($
{"server_{$type}_status"}) {
249 echo ' <th></th>' . "\n";
254 echo ' <th></th>' . "\n";
257 echo '</tbody>' . "\n"
259 unset($column_order, $stat_name, $stat, $databases, $table_columns);
261 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
262 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
263 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
264 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
265 . ' ' . __('Check All') . '</a> / ' . "\n"
266 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
267 . ' ' . __('Uncheck All') . '</a>' . "\n"
268 . '<i>' . __('With selected:') . '</i>' . "\n";
269 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
272 if (empty($dbstats)) {
273 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
274 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
275 .' title="' . __('Enable Statistics') . '">' . "\n"
276 .' ' . __('Enable Statistics');
277 echo '</a></strong><br />' . "\n";
278 PMA_Message
::notice(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
279 echo '</li>' . "\n" . '</ul>' . "\n";
284 echo __('No databases');
286 unset($databases_count);
291 require './libraries/footer.inc.php';