Translated using Weblate.
[phpmyadmin.git] / server_databases.php
blobddab0d457f862c99442b1d33ee4a67d62c949f6d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package PhpMyAdmin
6 */
8 /**
9 * Does the common work
11 require_once './libraries/common.inc.php';
13 require './libraries/server_common.inc.php';
14 if (!PMA_DRIZZLE) {
15 include_once './libraries/replication.inc.php';
16 } else {
17 $replication_types = array();
18 $replication_info = null;
20 require './libraries/build_html_for_db.lib.php';
22 /**
23 * avoids 'undefined index' errors
25 if (empty($_REQUEST['sort_by'])) {
26 $sort_by = 'SCHEMA_NAME';
27 } else {
28 $sort_by_whitelist = array(
29 'SCHEMA_NAME',
30 'DEFAULT_COLLATION_NAME',
31 'SCHEMA_TABLES',
32 'SCHEMA_TABLE_ROWS',
33 'SCHEMA_DATA_LENGTH',
34 'SCHEMA_INDEX_LENGTH',
35 'SCHEMA_LENGTH',
36 'SCHEMA_DATA_FREE'
38 if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
39 $sort_by = $_REQUEST['sort_by'];
40 } else {
41 $sort_by = 'SCHEMA_NAME';
45 if (isset($_REQUEST['sort_order'])
46 && strtolower($_REQUEST['sort_order']) == 'desc') {
47 $sort_order = 'desc';
48 } else {
49 $sort_order = 'asc';
52 $dbstats = empty($_REQUEST['dbstats']) ? 0 : 1;
53 $pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
56 /**
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.'));
70 } else {
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 include './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));
83 } else {
84 $message->addParam(0);
91 /**
92 * Displays the links
94 require './libraries/server_links.inc.php';
97 /**
98 * Displays the sub-page heading
100 echo '<h2>' . "\n"
101 . ($GLOBALS['cfg']['MainPageIconic']
102 ? PMA_getImage('s_db.png')
103 : '')
104 . ($dbstats ? __('Databases statistics') : __('Databases')) . "\n"
105 .'</h2>' . "\n";
108 * Create database.
110 if ($cfg['ShowCreateDb']) {
111 echo '<ul><li id="li_create_database">' . "\n";
112 include './libraries/display_create_database.lib.php';
113 echo ' </li>' . "\n";
114 echo '</ul>' . "\n";
118 * Gets the databases list
120 if ($server > 0) {
121 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
122 $sort_order, $pos, true);
123 $databases_count = count($GLOBALS['pma']->databases);
124 } else {
125 $databases_count = 0;
130 * Displays the page
132 if ($databases_count > 0) {
133 echo '<div id="tableslistcontainer">';
134 reset($databases);
135 $first_database = current($databases);
136 // table col order
137 $column_order = PMA_getColumnOrder();
139 $_url_params = array(
140 'pos' => $pos,
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"
157 . '<thead>' . "\n"
158 . '<tr>' . "\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' ? ' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
163 . ' </a></th>' . "\n";
164 $table_columns = 3;
165 foreach ($column_order as $stat_name => $stat) {
166 if (array_key_exists($stat_name, $first_database)) {
167 if ($stat['format'] === 'byte') {
168 $table_columns += 2;
169 $colspan = ' colspan="2"';
170 } else {
171 $table_columns++;
172 $colspan = '';
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 ? ' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '')
180 .' </a></th>' . "\n";
184 foreach ($replication_types as $type) {
185 if ($type=="master")
186 $name = __('Master replication');
187 elseif ($type == "slave")
188 $name = __('Slave replication');
189 if (${"server_{$type}_status"})
190 echo ' <th>'. $name .'</th>' . "\n";
193 if ($is_superuser && !PMA_DRIZZLE) {
194 echo ' <th>' . ($cfg['PropertiesIconic'] ? '' : __('Action')) . "\n"
195 . ' </th>' . "\n";
197 echo '</tr>' . "\n"
198 . '</thead>' . "\n"
199 . '<tbody>' . "\n";
201 $odd_row = true;
202 foreach ($databases as $current) {
203 $tr_class = $odd_row ? 'odd' : 'even';
204 if (PMA_is_system_schema($current['SCHEMA_NAME'], true)) {
205 $tr_class .= ' noclick';
207 echo '<tr class="' . $tr_class . '">' . "\n";
208 $odd_row = ! $odd_row;
210 list($column_order, $generated_html) = PMA_buildHtmlForDb($current, $is_superuser, (isset($checkall) ? $checkall : ''), $url_query, $column_order, $replication_types, $replication_info);
212 echo $generated_html;
214 echo '</tr>' . "\n";
215 } // end foreach ($databases as $key => $current)
216 unset($current, $odd_row);
218 echo '<tr id="db_summary_row">' . "\n";
219 if ($is_superuser || $cfg['AllowUserDropDatabase']) {
220 echo ' <th></th>' . "\n";
222 echo ' <th>' . __('Total') . ': <span id="databases_count">' . $databases_count . '</span></th>' . "\n";
223 foreach ($column_order as $stat_name => $stat) {
224 if (array_key_exists($stat_name, $first_database)) {
225 if ($stat['format'] === 'byte') {
226 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
227 } elseif ($stat['format'] === 'number') {
228 $value = PMA_formatNumber($stat['footer'], 0);
229 } else {
230 $value = htmlentities($stat['footer'], 0);
232 echo ' <th class="value">';
233 if (isset($stat['description_function'])) {
234 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
236 echo $value;
237 if (isset($stat['description_function'])) {
238 echo '</dfn>';
240 echo '</th>' . "\n";
241 if ($stat['format'] === 'byte') {
242 echo ' <th class="unit">' . $unit . '</th>' . "\n";
247 foreach ($replication_types as $type) {
248 if (${"server_{$type}_status"}) {
249 echo ' <th></th>' . "\n";
253 if ($is_superuser) {
254 echo ' <th></th>' . "\n";
256 echo '</tr>' . "\n";
257 echo '</tbody>' . "\n"
258 .'</table>' . "\n";
259 unset($column_order, $stat_name, $stat, $databases, $table_columns);
261 if ($is_superuser || $cfg['AllowUserDropDatabase']) {
262 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
263 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
264 . '<a href="./server_databases.php' . $common_url_query . '&amp;checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
265 . ' ' . __('Check All') . '</a> / ' . "\n"
266 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
267 . ' ' . __('Uncheck All') . '</a>' . "\n"
268 . '<i>' . __('With selected:') . '</i>' . "\n";
269 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
272 if (empty($dbstats)) {
273 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
274 echo ' <a href="./server_databases.php?' . $url_query . '&amp;dbstats=1"'
275 .' title="' . __('Enable Statistics') . '">' . "\n"
276 .' ' . __('Enable Statistics');
277 echo '</a></strong><br />' . "\n";
278 PMA_Message::notice(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
279 echo '</li>' . "\n" . '</ul>' . "\n";
281 echo '</form>';
282 echo '</div>';
283 } else {
284 echo __('No databases');
286 unset($databases_count);
289 * Sends the footer
291 require './libraries/footer.inc.php';