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';
17 * avoids 'undefined index' errors
19 if (empty($_REQUEST['sort_by'])) {
20 $sort_by = 'SCHEMA_NAME';
22 $sort_by_whitelist = array(
24 'DEFAULT_COLLATION_NAME',
28 'SCHEMA_INDEX_LENGTH',
32 if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
33 $sort_by = $_REQUEST['sort_by'];
35 $sort_by = 'SCHEMA_NAME';
39 if (isset($_REQUEST['sort_order'])
40 && strtolower($_REQUEST['sort_order']) == 'desc') {
46 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
47 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
51 * Drops multiple databases
54 // workaround for IE behavior (it returns some coordinates based on where
55 // the mouse was on the Drop image):
56 if (isset($_REQUEST['drop_selected_dbs_x'])) {
57 $_REQUEST['drop_selected_dbs'] = true;
60 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
61 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
62 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
63 $message = PMA_Message
::error(__('No databases selected.'));
65 $action = 'server_databases.php';
66 $submit_mult = 'drop_db' ;
67 $err_url = 'server_databases.php?' . PMA_generate_common_url();
68 if (isset($_REQUEST['selected_dbs'])) {
69 $selected_db = $_REQUEST['selected_dbs'];
71 require './libraries/mult_submits.inc.php';
72 unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
73 if (empty($message)) {
74 $message = PMA_Message
::success(__('%s databases have been dropped successfully.'));
75 if ($mult_btn == __('Yes')) {
76 $message->addParam(count($selected));
78 $message->addParam(0);
88 require './libraries/server_links.inc.php';
92 * Displays the sub-page heading
95 . ($GLOBALS['cfg']['MainPageIconic']
96 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
97 .' height="16" alt="" />'
99 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
103 * Gets the databases list
106 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
107 $sort_order, $pos, true);
108 $databases_count = count($GLOBALS['pma']->databases
);
110 $databases_count = 0;
117 if ($databases_count > 0) {
119 $first_database = current($databases);
121 $column_order['DEFAULT_COLLATION_NAME'] = array(
122 'disp_name' => __('Collation'),
123 'description_function' => 'PMA_getCollationDescr',
124 'format' => 'string',
125 'footer' => PMA_getServerCollation(),
127 $column_order['SCHEMA_TABLES'] = array(
128 'disp_name' => __('Tables'),
129 'format' => 'number',
132 $column_order['SCHEMA_TABLE_ROWS'] = array(
133 'disp_name' => __('Rows'),
134 'format' => 'number',
137 $column_order['SCHEMA_DATA_LENGTH'] = array(
138 'disp_name' => __('Data'),
142 $column_order['SCHEMA_INDEX_LENGTH'] = array(
143 'disp_name' => __('Indexes'),
147 $column_order['SCHEMA_LENGTH'] = array(
148 'disp_name' => __('Total'),
152 $column_order['SCHEMA_DATA_FREE'] = array(
153 'disp_name' => __('Overhead'),
158 $_url_params = array(
160 'dbstats' => $dbstats,
161 'sort_by' => $sort_by,
162 'sort_order' => $sort_order,
165 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
167 $_url_params['pos'] = $pos;
169 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
170 . PMA_generate_common_hidden_inputs($_url_params);
172 $_url_params['sort_by'] = 'SCHEMA_NAME';
173 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
175 echo '<table id="tabledatabases" class="data">' . "\n"
178 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
179 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
180 . ' ' . __('Database') . "\n"
181 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
182 . ' </a></th>' . "\n";
184 foreach ($column_order as $stat_name => $stat) {
185 if (array_key_exists($stat_name, $first_database)) {
186 if ($stat['format'] === 'byte') {
188 $colspan = ' colspan="2"';
193 $_url_params['sort_by'] = $stat_name;
194 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
195 echo ' <th' . $colspan . '>'
196 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
197 .' ' . $stat['disp_name'] . "\n"
198 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
199 .' </a></th>' . "\n";
203 foreach ($replication_types as $type)
206 $name = __('Master replication');
207 elseif($type == "slave")
208 $name = __('Slave replication');
209 if ($
{"server_{$type}_status"})
210 echo ' <th>'. $name .'</th>' . "\n";
214 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
222 foreach ($databases as $current) {
223 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
224 $odd_row = ! $odd_row;
226 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
227 echo ' <td class="tool">' . "\n";
228 if ($current['SCHEMA_NAME'] != 'mysql'
229 && $current['SCHEMA_NAME'] != 'information_schema') {
230 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
232 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
234 echo ' </td>' . "\n";
236 echo ' <td class="name">' . "\n"
238 . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
239 . '" href="index.php?' . $url_query . '&db='
240 . urlencode($current['SCHEMA_NAME']) . '" title="'
241 . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
242 . '" target="_parent">' . "\n"
243 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
247 foreach ($column_order as $stat_name => $stat) {
248 if (array_key_exists($stat_name, $current)) {
249 if (is_numeric($stat['footer'])) {
250 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
252 if ($stat['format'] === 'byte') {
253 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
254 } elseif ($stat['format'] === 'number') {
255 $value = PMA_formatNumber($current[$stat_name], 0);
257 $value = htmlentities($current[$stat_name], 0);
259 echo ' <td class="value">';
260 if (isset($stat['description_function'])) {
261 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
264 if (isset($stat['description_function'])) {
268 if ($stat['format'] === 'byte') {
269 echo ' <td class="unit">' . $unit . '</td>' . "\n";
273 foreach ($replication_types as $type) {
274 if ($
{"server_{$type}_status"}) {
275 echo '<td class="tool" style="text-align: center;">' . "\n";
277 if (strlen(array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Ignore_DB"}))>0) {
278 echo '<img class="icon" src="' . $pmaThemeImage . 's_cancel.png" width="16" height="16" alt="' . __('Not replicated') . '" />' . "\n";
280 $key = array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Do_DB"});
282 if (strlen($key) > 0 ||
($
{"server_{$type}_Do_DB"}[0] == "" && count($
{"server_{$type}_Do_DB"}) == 1)) {
283 // if ($key != null) did not work for index "0"
284 echo '<img class="icon" src="' . $pmaThemeImage . 's_success.png" width="16" height="16" alt="' . __('Replicated') . '" />' . "\n";
295 echo ' <td class="tool">' . "\n"
297 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
298 . '" href="./server_privileges.php?' . $url_query
299 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
300 . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME']))
303 . ($cfg['PropertiesIconic']
304 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
305 : __('Check Privileges')) . "\n"
306 . ' </a></td>' . "\n";
309 } // end foreach ($databases as $key => $current)
310 unset($current, $odd_row);
313 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
314 echo ' <th></th>' . "\n";
316 echo ' <th>' . __('Total') . ': ' . $databases_count . '</th>' . "\n";
317 foreach ($column_order as $stat_name => $stat) {
318 if (array_key_exists($stat_name, $first_database)) {
319 if ($stat['format'] === 'byte') {
320 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
321 } elseif ($stat['format'] === 'number') {
322 $value = PMA_formatNumber($stat['footer'], 0);
324 $value = htmlentities($stat['footer'], 0);
326 echo ' <th class="value">';
327 if (isset($stat['description_function'])) {
328 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
331 if (isset($stat['description_function'])) {
335 if ($stat['format'] === 'byte') {
336 echo ' <th class="unit">' . $unit . '</th>' . "\n";
341 foreach ($replication_types as $type)
343 if ($
{"server_{$type}_status"})
344 echo ' <th></th>' . "\n";
348 echo ' <th></th>' . "\n";
351 echo '</tbody>' . "\n"
353 unset($column_order, $stat_name, $stat, $databases, $table_columns);
355 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
356 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
357 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
358 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
359 . ' ' . __('Check All') . '</a> / ' . "\n"
360 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
361 . ' ' . __('Uncheck All') . '</a>' . "\n"
362 . '<i>' . __('With selected:') . '</i>' . "\n";
363 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
366 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
367 if (empty($dbstats)) {
368 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
369 .' title="' . __('Enable Statistics') . '">' . "\n"
370 .' ' . __('Enable Statistics');
372 echo ' <a href="./server_databases.php?' . $url_query . '"'
373 .' title="' . __('Disable Statistics') . '">' . "\n"
374 .' ' . __('Disable Statistics');
376 echo '</a></strong><br />' . "\n";
377 PMA_Message
::warning(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
382 echo __('No databases');
384 unset($databases_count);
387 * Create new database.
389 if ($cfg['ShowCreateDb']) {
390 echo '<ul><li id="li_create_database">' . "\n";
391 require './libraries/display_create_database.lib.php';
392 echo ' </li>' . "\n";
399 require './libraries/footer.inc.php';