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 = PMA_sanitize($_REQUEST['sort_by']);
25 if (isset($_REQUEST['sort_order'])
26 && strtolower($_REQUEST['sort_order']) == 'desc') {
32 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
33 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
37 * Drops multiple databases
40 // workaround for IE behavior (it returns some coordinates based on where
41 // the mouse was on the Drop image):
42 if (isset($_REQUEST['drop_selected_dbs_x'])) {
43 $_REQUEST['drop_selected_dbs'] = true;
46 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
47 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
48 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
49 $message = PMA_Message
::error(__('No databases selected.'));
51 $action = 'server_databases.php';
52 $submit_mult = 'drop_db' ;
53 $err_url = 'server_databases.php?' . PMA_generate_common_url();
54 if (isset($_REQUEST['selected_dbs'])) {
55 $selected_db = $_REQUEST['selected_dbs'];
57 require './libraries/mult_submits.inc.php';
58 unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
59 if (empty($message)) {
60 $message = PMA_Message
::success(__('%s databases have been dropped successfully.'));
61 if ($mult_btn == __('Yes')) {
62 $message->addParam(count($selected));
64 $message->addParam(0);
74 require './libraries/server_links.inc.php';
78 * Displays the sub-page heading
81 . ($GLOBALS['cfg']['MainPageIconic']
82 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
83 .' height="16" alt="" />'
85 . ($dbstats ?
__('Databases statistics') : __('Databases')) . "\n"
89 * Gets the databases list
92 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
93 $sort_order, $pos, true);
94 $databases_count = count($GLOBALS['pma']->databases
);
103 if ($databases_count > 0) {
105 $first_database = current($databases);
107 $column_order['DEFAULT_COLLATION_NAME'] = array(
108 'disp_name' => __('Collation'),
109 'description_function' => 'PMA_getCollationDescr',
110 'format' => 'string',
111 'footer' => PMA_getServerCollation(),
113 $column_order['SCHEMA_TABLES'] = array(
114 'disp_name' => __('Tables'),
115 'format' => 'number',
118 $column_order['SCHEMA_TABLE_ROWS'] = array(
119 'disp_name' => __('Rows'),
120 'format' => 'number',
123 $column_order['SCHEMA_DATA_LENGTH'] = array(
124 'disp_name' => __('Data'),
128 $column_order['SCHEMA_INDEX_LENGTH'] = array(
129 'disp_name' => __('Indexes'),
133 $column_order['SCHEMA_LENGTH'] = array(
134 'disp_name' => __('Total'),
138 $column_order['SCHEMA_DATA_FREE'] = array(
139 'disp_name' => __('Overhead'),
144 $_url_params = array(
146 'dbstats' => $dbstats,
147 'sort_by' => $sort_by,
148 'sort_order' => $sort_order,
151 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
153 $_url_params['pos'] = $pos;
155 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
156 . PMA_generate_common_hidden_inputs($_url_params);
158 $_url_params['sort_by'] = 'SCHEMA_NAME';
159 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
161 echo '<table id="tabledatabases" class="data">' . "\n"
164 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
165 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
166 . ' ' . __('Database') . "\n"
167 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
168 . ' </a></th>' . "\n";
170 foreach ($column_order as $stat_name => $stat) {
171 if (array_key_exists($stat_name, $first_database)) {
172 if ($stat['format'] === 'byte') {
174 $colspan = ' colspan="2"';
179 $_url_params['sort_by'] = $stat_name;
180 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
181 echo ' <th' . $colspan . '>'
182 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
183 .' ' . $stat['disp_name'] . "\n"
184 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
__('Ascending') : __('Descending')) . '" />' . "\n" : '')
185 .' </a></th>' . "\n";
189 foreach ($replication_types as $type)
192 $name = __('Master replication');
193 elseif($type == "slave")
194 $name = __('Slave replication');
195 if ($
{"server_{$type}_status"})
196 echo ' <th>'. $name .'</th>' . "\n";
200 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : __('Action')) . "\n"
208 foreach ($databases as $current) {
209 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
210 $odd_row = ! $odd_row;
212 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
213 echo ' <td class="tool">' . "\n";
214 if ($current['SCHEMA_NAME'] != 'mysql'
215 && $current['SCHEMA_NAME'] != 'information_schema') {
216 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
218 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
220 echo ' </td>' . "\n";
222 echo ' <td class="name">' . "\n"
224 . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
225 . '" href="index.php?' . $url_query . '&db='
226 . urlencode($current['SCHEMA_NAME']) . '" title="'
227 . sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
228 . '" target="_parent">' . "\n"
229 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
233 foreach ($column_order as $stat_name => $stat) {
234 if (array_key_exists($stat_name, $current)) {
235 if (is_numeric($stat['footer'])) {
236 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
238 if ($stat['format'] === 'byte') {
239 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
240 } elseif ($stat['format'] === 'number') {
241 $value = PMA_formatNumber($current[$stat_name], 0);
243 $value = htmlentities($current[$stat_name], 0);
245 echo ' <td class="value">';
246 if (isset($stat['description_function'])) {
247 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
250 if (isset($stat['description_function'])) {
254 if ($stat['format'] === 'byte') {
255 echo ' <td class="unit">' . $unit . '</td>' . "\n";
259 foreach ($replication_types as $type) {
260 if ($
{"server_{$type}_status"}) {
261 echo '<td class="tool" style="text-align: center;">' . "\n";
263 if (strlen(array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Ignore_DB"}))>0) {
264 echo '<img class="icon" src="' . $pmaThemeImage . 's_cancel.png" width="16" height="16" alt="' . __('Not replicated') . '" />' . "\n";
266 $key = array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Do_DB"});
268 if (strlen($key) > 0 ||
($
{"server_{$type}_Do_DB"}[0] == "" && count($
{"server_{$type}_Do_DB"}) == 1)) {
269 // if ($key != null) did not work for index "0"
270 echo '<img class="icon" src="' . $pmaThemeImage . 's_success.png" width="16" height="16" alt="' . __('Replicated') . '" />' . "\n";
281 echo ' <td class="tool">' . "\n"
283 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
284 . '" href="./server_privileges.php?' . $url_query
285 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
286 . '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME']))
289 . ($cfg['PropertiesIconic']
290 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
291 : __('Check Privileges')) . "\n"
292 . ' </a></td>' . "\n";
295 } // end foreach ($databases as $key => $current)
296 unset($current, $odd_row);
299 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
300 echo ' <th></th>' . "\n";
302 echo ' <th>' . __('Total') . ': ' . $databases_count . '</th>' . "\n";
303 foreach ($column_order as $stat_name => $stat) {
304 if (array_key_exists($stat_name, $first_database)) {
305 if ($stat['format'] === 'byte') {
306 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
307 } elseif ($stat['format'] === 'number') {
308 $value = PMA_formatNumber($stat['footer'], 0);
310 $value = htmlentities($stat['footer'], 0);
312 echo ' <th class="value">';
313 if (isset($stat['description_function'])) {
314 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
317 if (isset($stat['description_function'])) {
321 if ($stat['format'] === 'byte') {
322 echo ' <th class="unit">' . $unit . '</th>' . "\n";
327 foreach ($replication_types as $type)
329 if ($
{"server_{$type}_status"})
330 echo ' <th></th>' . "\n";
334 echo ' <th></th>' . "\n";
337 echo '</tbody>' . "\n"
339 unset($column_order, $stat_name, $stat, $databases, $table_columns);
341 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
342 $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats;
343 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
344 . '<a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
345 . ' ' . __('Check All') . '</a> / ' . "\n"
346 . '<a href="./server_databases.php?' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
347 . ' ' . __('Uncheck All') . '</a>' . "\n"
348 . '<i>' . __('With selected:') . '</i>' . "\n";
349 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
352 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
353 if (empty($dbstats)) {
354 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
355 .' title="' . __('Enable Statistics') . '">' . "\n"
356 .' ' . __('Enable Statistics');
358 echo ' <a href="./server_databases.php?' . $url_query . '"'
359 .' title="' . __('Disable Statistics') . '">' . "\n"
360 .' ' . __('Disable Statistics');
362 echo '</a></strong><br />' . "\n";
363 PMA_Message
::warning(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
368 echo __('No databases');
370 unset($databases_count);
373 * Create new database.
375 if ($cfg['ShowCreateDb']) {
376 echo '<ul><li id="li_create_database">' . "\n";
377 require './libraries/display_create_database.lib.php';
378 echo ' </li>' . "\n";
385 require './libraries/footer.inc.php';