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 require './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 require './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 ?
'<img class="icon ic_s_db" src="themes/dot.gif" alt="" />'
104 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
110 if ($cfg['ShowCreateDb']) {
111 echo '<ul><li id="li_create_database">' . "\n";
112 require './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' ?
' <img class="icon ic_s_' . $sort_order . '" src="themes/dot.gif" alt="' . ($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 ?
' <img class="icon ic_s_' . $sort_order . '" src="themes/dot.gif" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
180 .' </a></th>' . "\n";
184 foreach ($replication_types as $type)
187 $name = __('Master replication');
188 elseif ($type == "slave")
189 $name = __('Slave replication');
190 if ($
{"server_{$type}_status"})
191 echo ' <th>'. $name .'</th>' . "\n";
194 if ($is_superuser && !PMA_DRIZZLE
) {
195 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
203 foreach ($databases as $current) {
204 $tr_class = $odd_row ?
'odd' : 'even';
205 if (PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
206 $tr_class .= ' noclick';
208 echo '<tr class="' . $tr_class . '">' . "\n";
209 $odd_row = ! $odd_row;
211 list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ?
$checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
213 echo $generated_html;
216 } // end foreach ($databases as $key => $current)
217 unset($current, $odd_row);
219 echo '<tr id="db_summary_row">' . "\n";
220 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
221 echo ' <th></th>' . "\n";
223 echo ' <th>' . __('Total') . ': <span id="databases_count">' . $databases_count . '</span></th>' . "\n";
224 foreach ($column_order as $stat_name => $stat) {
225 if (array_key_exists($stat_name, $first_database)) {
226 if ($stat['format'] === 'byte') {
227 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
228 } elseif ($stat['format'] === 'number') {
229 $value = PMA_formatNumber($stat['footer'], 0);
231 $value = htmlentities($stat['footer'], 0);
233 echo ' <th class="value">';
234 if (isset($stat['description_function'])) {
235 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
238 if (isset($stat['description_function'])) {
242 if ($stat['format'] === 'byte') {
243 echo ' <th class="unit">' . $unit . '</th>' . "\n";
248 foreach ($replication_types as $type)
250 if ($
{"server_{$type}_status"})
251 echo ' <th></th>' . "\n";
255 echo ' <th></th>' . "\n";
258 echo '</tbody>' . "\n"
260 unset($column_order, $stat_name, $stat, $databases, $table_columns);
262 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
263 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
264 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
265 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
266 . ' ' . __('Check All') . '</a> / ' . "\n"
267 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
268 . ' ' . __('Uncheck All') . '</a>' . "\n"
269 . '<i>' . __('With selected:') . '</i>' . "\n";
270 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
273 if (empty($dbstats)) {
274 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
275 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
276 .' title="' . __('Enable Statistics') . '">' . "\n"
277 .' ' . __('Enable Statistics');
278 echo '</a></strong><br />' . "\n";
279 PMA_Message
::notice(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
280 echo '</li>' . "\n" . '</ul>' . "\n";
285 echo __('No databases');
287 unset($databases_count);
292 require './libraries/footer.inc.php';