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';
19 * avoids 'undefined index' errors
21 if (empty($_REQUEST['sort_by'])) {
22 $sort_by = 'SCHEMA_NAME';
24 $sort_by = PMA_sanitize($_REQUEST['sort_by']);
27 if (isset($_REQUEST['sort_order'])
28 && strtolower($_REQUEST['sort_order']) == 'desc') {
34 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
35 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
39 * Drops multiple databases
42 // workaround for IE behavior (it returns some coordinates based on where
43 // the mouse was on the Drop image):
44 if (isset($_REQUEST['drop_selected_dbs_x'])) {
45 $_REQUEST['drop_selected_dbs'] = true;
48 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
49 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
50 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
51 $message = PMA_Message
::error('strNoDatabasesSelected');
53 $action = 'server_databases.php';
54 $submit_mult = 'drop_db' ;
55 $err_url = 'server_databases.php?' . PMA_generate_common_url();
56 if (isset($_REQUEST['selected_dbs'])) {
57 $selected_db = $_REQUEST['selected_dbs'];
59 require './libraries/mult_submits.inc.php';
60 unset($action, $submit_mult, $err_url, $selected_db);
61 if (empty($message)) {
62 $message = PMA_Message
::success('strDatabasesDropped');
63 if ($mult_btn == $strYes) {
64 $message->addParam(count($selected));
66 $message->addParam(0);
76 require './libraries/server_links.inc.php';
80 * Displays the sub-page heading
83 . ($GLOBALS['cfg']['MainPageIconic']
84 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
85 .' height="16" alt="" />'
87 . ($dbstats ?
$strDatabasesStats : $strDatabases) . "\n"
91 * Gets the databases list
94 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
95 $sort_order, $pos, true);
96 $databases_count = count($GLOBALS['pma']->databases
);
105 if ($databases_count > 0) {
107 $first_database = current($databases);
109 $column_order['DEFAULT_COLLATION_NAME'] = array(
110 'disp_name' => $strCollation,
111 'description_function' => 'PMA_getCollationDescr',
112 'format' => 'string',
113 'footer' => PMA_getServerCollation(),
115 $column_order['SCHEMA_TABLES'] = array(
116 'disp_name' => $strNumTables,
117 'format' => 'number',
120 $column_order['SCHEMA_TABLE_ROWS'] = array(
121 'disp_name' => $strRows,
122 'format' => 'number',
125 $column_order['SCHEMA_DATA_LENGTH'] = array(
126 'disp_name' => $strData,
130 $column_order['SCHEMA_INDEX_LENGTH'] = array(
131 'disp_name' => $strIndexes,
135 $column_order['SCHEMA_LENGTH'] = array(
136 'disp_name' => $strTotalUC,
140 $column_order['SCHEMA_DATA_FREE'] = array(
141 'disp_name' => $strOverhead,
146 $_url_params = array(
148 'dbstats' => $dbstats,
149 'sort_by' => $sort_by,
150 'sort_order' => $sort_order,
153 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
155 $_url_params['pos'] = $pos;
157 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
158 . PMA_generate_common_hidden_inputs($_url_params);
160 $_url_params['sort_by'] = 'SCHEMA_NAME';
161 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
163 echo '<table id="tabledatabases" class="data">' . "\n"
166 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
167 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
168 . ' ' . $strDatabase . "\n"
169 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
170 . ' </a></th>' . "\n";
172 foreach ($column_order as $stat_name => $stat) {
173 if (array_key_exists($stat_name, $first_database)) {
174 if ($stat['format'] === 'byte') {
176 $colspan = ' colspan="2"';
181 $_url_params['sort_by'] = $stat_name;
182 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
183 echo ' <th' . $colspan . '>'
184 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
185 .' ' . $stat['disp_name'] . "\n"
186 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
187 .' </a></th>' . "\n";
191 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : $strAction) . "\n"
199 foreach ($databases as $current) {
200 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
201 $odd_row = ! $odd_row;
203 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
204 echo ' <td class="tool">' . "\n";
205 if ($current['SCHEMA_NAME'] != 'mysql'
206 && $current['SCHEMA_NAME'] != 'information_schema') {
207 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
209 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
211 echo ' </td>' . "\n";
213 echo ' <td class="name">' . "\n"
215 . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
216 . '" href="index.php?' . $url_query . '&db='
217 . urlencode($current['SCHEMA_NAME']) . '" title="'
218 . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME']))
219 . '" target="_parent">' . "\n"
220 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
224 foreach ($column_order as $stat_name => $stat) {
225 if (array_key_exists($stat_name, $current)) {
226 if (is_numeric($stat['footer'])) {
227 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
229 if ($stat['format'] === 'byte') {
230 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
231 } elseif ($stat['format'] === 'number') {
232 $value = PMA_formatNumber($current[$stat_name], 0);
234 $value = htmlentities($current[$stat_name], 0);
236 echo ' <td class="value">';
237 if (isset($stat['description_function'])) {
238 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
241 if (isset($stat['description_function'])) {
245 if ($stat['format'] === 'byte') {
246 echo ' <td class="unit">' . $unit . '</td>' . "\n";
252 echo ' <td class="tool">' . "\n"
254 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
255 . '" href="./server_privileges.php?' . $url_query
256 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
257 . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME']))
260 . ($cfg['PropertiesIconic']
261 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . $strCheckPrivs . '" /> '
262 : $strCheckPrivs) . "\n"
263 . ' </a></td>' . "\n";
266 } // end foreach ($databases as $key => $current)
267 unset($current, $odd_row);
270 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
271 echo ' <th></th>' . "\n";
273 echo ' <th>' . $strTotalUC . ': ' . $databases_count . '</th>' . "\n";
274 foreach ($column_order as $stat_name => $stat) {
275 if (array_key_exists($stat_name, $first_database)) {
276 if ($stat['format'] === 'byte') {
277 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
278 } elseif ($stat['format'] === 'number') {
279 $value = PMA_formatNumber($stat['footer'], 0);
281 $value = htmlentities($stat['footer'], 0);
283 echo ' <th class="value">';
284 if (isset($stat['description_function'])) {
285 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
288 if (isset($stat['description_function'])) {
292 if ($stat['format'] === 'byte') {
293 echo ' <th class="unit">' . $unit . '</th>' . "\n";
298 echo ' <th></th>' . "\n";
301 echo '</tbody>' . "\n"
303 unset($column_order, $stat_name, $stat, $databases, $table_columns);
305 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
306 $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats;
307 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
308 . '<a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
309 . ' ' . $strCheckAll . '</a> / ' . "\n"
310 . '<a href="./server_databases.php?' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
311 . ' ' . $strUncheckAll . '</a>' . "\n"
312 . '<i>' . $strWithChecked . '</i>' . "\n";
313 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png');
316 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
317 if (empty($dbstats)) {
318 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
319 .' title="' . $strDatabasesStatsEnable . '">' . "\n"
320 .' ' . $strDatabasesStatsEnable;
322 echo ' <a href="./server_databases.php?' . $url_query . '"'
323 .' title="' . $strDatabasesStatsDisable . '">' . "\n"
324 .' ' . $strDatabasesStatsDisable;
326 echo '</a></strong><br />' . "\n";
327 PMA_Message
::warning('strDatabasesStatsHeavyTraffic')->display();
332 echo $strNoDatabases;
334 unset($databases_count);
337 * Create new database.
339 if ($cfg['ShowCreateDb']) {
340 echo '<ul><li id="li_create_database">' . "\n";
341 require './libraries/display_create_database.lib.php';
342 echo ' </li>' . "\n";
349 require_once './libraries/footer.inc.php';