2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
13 require './libraries/server_common.inc.php';
14 require './libraries/replication.inc.php';
15 require './libraries/build_html_for_db.lib.php';
18 * avoids 'undefined index' errors
20 if (empty($_REQUEST['sort_by'])) {
21 $sort_by = 'SCHEMA_NAME';
23 $sort_by_whitelist = array(
25 'DEFAULT_COLLATION_NAME',
29 'SCHEMA_INDEX_LENGTH',
33 if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
34 $sort_by = $_REQUEST['sort_by'];
36 $sort_by = 'SCHEMA_NAME';
40 if (isset($_REQUEST['sort_order'])
41 && strtolower($_REQUEST['sort_order']) == 'desc') {
47 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
48 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
52 * Drops multiple databases
55 // workaround for IE behavior (it returns some coordinates based on where
56 // the mouse was on the Drop image):
57 if (isset($_REQUEST['drop_selected_dbs_x'])) {
58 $_REQUEST['drop_selected_dbs'] = true;
61 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
62 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
63 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
64 $message = PMA_Message
::error(__('No databases selected.'));
66 $action = 'server_databases.php';
67 $submit_mult = 'drop_db' ;
68 $err_url = 'server_databases.php?' . PMA_generate_common_url();
69 if (isset($_REQUEST['selected_dbs'])) {
70 $selected_db = $_REQUEST['selected_dbs'];
72 require './libraries/mult_submits.inc.php';
73 unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
74 if (empty($message)) {
75 $message = PMA_Message
::success(__('%s databases have been dropped successfully.'));
76 if ($mult_btn == __('Yes')) {
77 $message->addParam(count($selected));
79 $message->addParam(0);
89 require './libraries/server_links.inc.php';
93 * Displays the sub-page heading
96 . ($GLOBALS['cfg']['MainPageIconic']
97 ?
'<img class="icon ic_s_db" src="themes/dot.gif" alt="" />'
99 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
105 if ($cfg['ShowCreateDb']) {
106 echo '<ul><li id="li_create_database">' . "\n";
107 require './libraries/display_create_database.lib.php';
108 echo ' </li>' . "\n";
113 * Gets the databases list
116 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
117 $sort_order, $pos, true);
118 $databases_count = count($GLOBALS['pma']->databases
);
120 $databases_count = 0;
127 if ($databases_count > 0) {
128 echo '<div id="tableslistcontainer">';
130 $first_database = current($databases);
132 $column_order = PMA_getColumnOrder();
134 $_url_params = array(
136 'dbstats' => $dbstats,
137 'sort_by' => $sort_by,
138 'sort_order' => $sort_order,
141 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
143 $_url_params['pos'] = $pos;
145 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
146 . PMA_generate_common_hidden_inputs($_url_params);
148 $_url_params['sort_by'] = 'SCHEMA_NAME';
149 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
151 echo '<table id="tabledatabases" class="data">' . "\n"
154 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
155 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
156 . ' ' . __('Database') . "\n"
157 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon ic_s_' . $sort_order . '" src="themes/dot.gif" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
158 . ' </a></th>' . "\n";
160 foreach ($column_order as $stat_name => $stat) {
161 if (array_key_exists($stat_name, $first_database)) {
162 if ($stat['format'] === 'byte') {
164 $colspan = ' colspan="2"';
169 $_url_params['sort_by'] = $stat_name;
170 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
171 echo ' <th' . $colspan . '>'
172 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
173 .' ' . $stat['disp_name'] . "\n"
174 .($sort_by == $stat_name ?
' <img class="icon ic_s_' . $sort_order . '" src="themes/dot.gif" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
175 .' </a></th>' . "\n";
179 foreach ($replication_types as $type)
182 $name = __('Master replication');
183 elseif ($type == "slave")
184 $name = __('Slave replication');
185 if ($
{"server_{$type}_status"})
186 echo ' <th>'. $name .'</th>' . "\n";
190 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
198 foreach ($databases as $current) {
199 $tr_class = $odd_row ?
'odd' : 'even';
200 if ($current['SCHEMA_NAME'] == 'mysql' ||
$current['SCHEMA_NAME'] == 'information_schema') {
201 $tr_class .= ' noclick';
203 echo '<tr class="' . $tr_class . '">' . "\n";
204 $odd_row = ! $odd_row;
206 list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ?
$checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
208 echo $generated_html;
211 } // end foreach ($databases as $key => $current)
212 unset($current, $odd_row);
214 echo '<tr id="db_summary_row">' . "\n";
215 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
216 echo ' <th></th>' . "\n";
218 echo ' <th>' . __('Total') . ': <span id="databases_count">' . $databases_count . '</span></th>' . "\n";
219 foreach ($column_order as $stat_name => $stat) {
220 if (array_key_exists($stat_name, $first_database)) {
221 if ($stat['format'] === 'byte') {
222 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
223 } elseif ($stat['format'] === 'number') {
224 $value = PMA_formatNumber($stat['footer'], 0);
226 $value = htmlentities($stat['footer'], 0);
228 echo ' <th class="value">';
229 if (isset($stat['description_function'])) {
230 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
233 if (isset($stat['description_function'])) {
237 if ($stat['format'] === 'byte') {
238 echo ' <th class="unit">' . $unit . '</th>' . "\n";
243 foreach ($replication_types as $type)
245 if ($
{"server_{$type}_status"})
246 echo ' <th></th>' . "\n";
250 echo ' <th></th>' . "\n";
253 echo '</tbody>' . "\n"
255 unset($column_order, $stat_name, $stat, $databases, $table_columns);
257 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
258 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
259 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
260 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
261 . ' ' . __('Check All') . '</a> / ' . "\n"
262 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
263 . ' ' . __('Uncheck All') . '</a>' . "\n"
264 . '<i>' . __('With selected:') . '</i>' . "\n";
265 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
268 if (empty($dbstats)) {
269 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
270 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
271 .' title="' . __('Enable Statistics') . '">' . "\n"
272 .' ' . __('Enable Statistics');
273 echo '</a></strong><br />' . "\n";
274 PMA_Message
::notice(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
275 echo '</li>' . "\n" . '</ul>' . "\n";
280 echo __('No databases');
282 unset($databases_count);
287 require './libraries/footer.inc.php';