Translation update done using Pootle.
[phpmyadmin/madhuracj.git] / server_databases.php
blobc709f83525ed1f4ae3c24eb80e6c82468abafa63
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 require './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 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));
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 ? '<img class="icon ic_s_db" src="themes/dot.gif" alt="" />'
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 require './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' ? ' <img class="icon ic_s_' . $sort_order . '" src="themes/dot.gif" alt="' . ($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 ? ' <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)
186 if ($type=="master")
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"
196 . ' </th>' . "\n";
198 echo '</tr>' . "\n"
199 . '</thead>' . "\n"
200 . '<tbody>' . "\n";
202 $odd_row = true;
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;
215 echo '</tr>' . "\n";
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);
230 } else {
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']) . '">';
237 echo $value;
238 if (isset($stat['description_function'])) {
239 echo '</dfn>';
241 echo '</th>' . "\n";
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";
254 if ($is_superuser) {
255 echo ' <th></th>' . "\n";
257 echo '</tr>' . "\n";
258 echo '</tbody>' . "\n"
259 .'</table>' . "\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 . '&amp;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 . '&amp;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";
282 echo '</form>';
283 echo '</div>';
284 } else {
285 echo __('No databases');
287 unset($databases_count);
290 * Sends the footer
292 require './libraries/footer.inc.php';