2 /* vim: set expandtab sw=4 ts=4 sts=4: */
10 * Does the common work
12 require_once './libraries/common.inc.php';
15 $GLOBALS['js_include'][] = 'functions.js';
16 require './libraries/server_common.inc.php';
17 require './libraries/replication.inc.php';
20 * avoids 'undefined index' errors
22 if (empty($_REQUEST['sort_by'])) {
23 $sort_by = 'SCHEMA_NAME';
25 $sort_by = PMA_sanitize($_REQUEST['sort_by']);
28 if (isset($_REQUEST['sort_order'])
29 && strtolower($_REQUEST['sort_order']) == 'desc') {
35 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
36 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
40 * Drops multiple databases
43 // workaround for IE behavior (it returns some coordinates based on where
44 // the mouse was on the Drop image):
45 if (isset($_REQUEST['drop_selected_dbs_x'])) {
46 $_REQUEST['drop_selected_dbs'] = true;
49 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
50 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
51 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
52 $message = PMA_Message
::error(__('No databases selected.'));
54 $action = 'server_databases.php';
55 $submit_mult = 'drop_db' ;
56 $err_url = 'server_databases.php?' . PMA_generate_common_url();
57 if (isset($_REQUEST['selected_dbs'])) {
58 $selected_db = $_REQUEST['selected_dbs'];
60 require './libraries/mult_submits.inc.php';
61 unset($action, $submit_mult, $err_url, $selected_db);
62 if (empty($message)) {
63 $message = PMA_Message
::success(__('%s databases have been dropped successfully.'));
64 if ($mult_btn == __('Yes')) {
65 $message->addParam(count($selected));
67 $message->addParam(0);
77 require './libraries/server_links.inc.php';
81 * Displays the sub-page heading
84 . ($GLOBALS['cfg']['MainPageIconic']
85 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
86 .' height="16" alt="" />'
88 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
92 * Gets the databases list
95 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
96 $sort_order, $pos, true);
97 $databases_count = count($GLOBALS['pma']->databases
);
106 if ($databases_count > 0) {
108 $first_database = current($databases);
110 $column_order['DEFAULT_COLLATION_NAME'] = array(
111 'disp_name' => __('Collation'),
112 'description_function' => 'PMA_getCollationDescr',
113 'format' => 'string',
114 'footer' => PMA_getServerCollation(),
116 $column_order['SCHEMA_TABLES'] = array(
117 'disp_name' => __('Tables'),
118 'format' => 'number',
121 $column_order['SCHEMA_TABLE_ROWS'] = array(
122 'disp_name' => __('Rows'),
123 'format' => 'number',
126 $column_order['SCHEMA_DATA_LENGTH'] = array(
127 'disp_name' => __('Data'),
131 $column_order['SCHEMA_INDEX_LENGTH'] = array(
132 'disp_name' => __('Indexes'),
136 $column_order['SCHEMA_LENGTH'] = array(
137 'disp_name' => __('Total'),
141 $column_order['SCHEMA_DATA_FREE'] = array(
142 'disp_name' => __('Overhead'),
147 $_url_params = array(
149 'dbstats' => $dbstats,
150 'sort_by' => $sort_by,
151 'sort_order' => $sort_order,
154 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
156 $_url_params['pos'] = $pos;
158 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
159 . PMA_generate_common_hidden_inputs($_url_params);
161 $_url_params['sort_by'] = 'SCHEMA_NAME';
162 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
164 echo '<table id="tabledatabases" class="data">' . "\n"
167 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
168 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
169 . ' ' . __('Database') . "\n"
170 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
171 . ' </a></th>' . "\n";
173 foreach ($column_order as $stat_name => $stat) {
174 if (array_key_exists($stat_name, $first_database)) {
175 if ($stat['format'] === 'byte') {
177 $colspan = ' colspan="2"';
182 $_url_params['sort_by'] = $stat_name;
183 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
184 echo ' <th' . $colspan . '>'
185 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
186 .' ' . $stat['disp_name'] . "\n"
187 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
188 .' </a></th>' . "\n";
192 foreach ($replication_types as $type)
195 $name = "strReplicationMaster";
196 elseif($type == "slave")
197 $name = "strReplicationSlave";
198 if ($
{"server_{$type}_status"})
199 echo ' <th>'.$GLOBALS[$name].'</th>' . "\n";
203 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
211 foreach ($databases as $current) {
212 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
213 $odd_row = ! $odd_row;
215 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
216 echo ' <td class="tool">' . "\n";
217 if ($current['SCHEMA_NAME'] != 'mysql'
218 && $current['SCHEMA_NAME'] != 'information_schema') {
219 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
221 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
223 echo ' </td>' . "\n";
225 echo ' <td class="name">' . "\n"
227 . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
228 . '" href="index.php?' . $url_query . '&db='
229 . urlencode($current['SCHEMA_NAME']) . '" title="'
230 . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
231 . '" target="_parent">' . "\n"
232 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
236 foreach ($column_order as $stat_name => $stat) {
237 if (array_key_exists($stat_name, $current)) {
238 if (is_numeric($stat['footer'])) {
239 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
241 if ($stat['format'] === 'byte') {
242 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
243 } elseif ($stat['format'] === 'number') {
244 $value = PMA_formatNumber($current[$stat_name], 0);
246 $value = htmlentities($current[$stat_name], 0);
248 echo ' <td class="value">';
249 if (isset($stat['description_function'])) {
250 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
253 if (isset($stat['description_function'])) {
257 if ($stat['format'] === 'byte') {
258 echo ' <td class="unit">' . $unit . '</td>' . "\n";
262 foreach ($replication_types as $type) {
263 if ($
{"server_{$type}_status"}) {
264 echo '<td class="tool" style="text-align: center;">' . "\n";
266 if (strlen(array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Ignore_DB"}))>0) {
267 echo '<img class="icon" src="' . $pmaThemeImage . 's_cancel.png" width="16" height="16" alt="NOT REPLICATED" />' . "\n";
269 $key = array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Do_DB"});
271 if (strlen($key) > 0 ||
($
{"server_{$type}_Do_DB"}[0] == "" && count($
{"server_{$type}_Do_DB"}) == 1)) {
272 // if ($key != null) did not work for index "0"
273 echo '<img class="icon" src="' . $pmaThemeImage . 's_success.png" width="16" height="16" alt="REPLICATED" />' . "\n";
284 echo ' <td class="tool">' . "\n"
286 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
287 . '" href="./server_privileges.php?' . $url_query
288 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
289 . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME']))
292 . ($cfg['PropertiesIconic']
293 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
294 : __('Check Privileges')) . "\n"
295 . ' </a></td>' . "\n";
298 } // end foreach ($databases as $key => $current)
299 unset($current, $odd_row);
302 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
303 echo ' <th></th>' . "\n";
305 echo ' <th>' . __('Total') . ': ' . $databases_count . '</th>' . "\n";
306 foreach ($column_order as $stat_name => $stat) {
307 if (array_key_exists($stat_name, $first_database)) {
308 if ($stat['format'] === 'byte') {
309 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
310 } elseif ($stat['format'] === 'number') {
311 $value = PMA_formatNumber($stat['footer'], 0);
313 $value = htmlentities($stat['footer'], 0);
315 echo ' <th class="value">';
316 if (isset($stat['description_function'])) {
317 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
320 if (isset($stat['description_function'])) {
324 if ($stat['format'] === 'byte') {
325 echo ' <th class="unit">' . $unit . '</th>' . "\n";
330 foreach ($replication_types as $type)
332 if ($
{"server_{$type}_status"})
333 echo ' <th></th>' . "\n";
337 echo ' <th></th>' . "\n";
340 echo '</tbody>' . "\n"
342 unset($column_order, $stat_name, $stat, $databases, $table_columns);
344 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
345 $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats;
346 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
347 . '<a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
348 . ' ' . __('Check All') . '</a> / ' . "\n"
349 . '<a href="./server_databases.php?' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
350 . ' ' . __('Uncheck All') . '</a>' . "\n"
351 . '<i>' . __('With selected:') . '</i>' . "\n";
352 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
355 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
356 if (empty($dbstats)) {
357 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
358 .' title="' . __('Enable Statistics') . '">' . "\n"
359 .' ' . __('Enable Statistics');
361 echo ' <a href="./server_databases.php?' . $url_query . '"'
362 .' title="' . __('Disable Statistics') . '">' . "\n"
363 .' ' . __('Disable Statistics');
365 echo '</a></strong><br />' . "\n";
366 PMA_Message
::warning(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
371 echo __('No databases');
373 unset($databases_count);
376 * Create new database.
378 if ($cfg['ShowCreateDb']) {
379 echo '<ul><li id="li_create_database">' . "\n";
380 require './libraries/display_create_database.lib.php';
381 echo ' </li>' . "\n";
388 require_once './libraries/footer.inc.php';