2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
14 $GLOBALS['js_include'][] = 'functions.js';
15 require './libraries/server_common.inc.php';
18 * avoids 'undefined index' errors
20 if (empty($_REQUEST['sort_by'])) {
21 $sort_by = 'SCHEMA_NAME';
23 $sort_by = PMA_sanitize($_REQUEST['sort_by']);
26 if (isset($_REQUEST['sort_order'])
27 && strtolower($_REQUEST['sort_order']) == 'desc') {
33 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
34 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
38 * Drops multiple databases
41 // workaround for IE behavior (it returns some coordinates based on where
42 // the mouse was on the Drop image):
43 if (isset($_REQUEST['drop_selected_dbs_x'])) {
44 $_REQUEST['drop_selected_dbs'] = true;
47 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
48 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
49 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
50 $message = PMA_Message
::error('strNoDatabasesSelected');
52 $action = 'server_databases.php';
53 $submit_mult = 'drop_db' ;
54 $err_url = 'server_databases.php?' . PMA_generate_common_url();
55 if (isset($_REQUEST['selected_dbs'])) {
56 $selected_db = $_REQUEST['selected_dbs'];
58 require './libraries/mult_submits.inc.php';
59 unset($action, $submit_mult, $err_url, $selected_db);
60 if (empty($message)) {
61 $message = PMA_Message
::success('strDatabasesDropped');
62 if ($mult_btn == $strYes) {
63 $message->addParam(count($selected));
65 $message->addParam(0);
75 require './libraries/server_links.inc.php';
79 * Displays the sub-page heading
82 . ($GLOBALS['cfg']['MainPageIconic']
83 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
84 .' height="16" alt="" />'
86 . ($dbstats ?
$strDatabasesStats : $strDatabases) . "\n"
90 * Gets the databases list
93 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
94 $sort_order, $pos, true);
95 $databases_count = $PMA_List_Database->count();
104 if ($databases_count > 0) {
106 $first_database = current($databases);
108 $column_order['DEFAULT_COLLATION_NAME'] = array(
109 'disp_name' => $strCollation,
110 'description_function' => 'PMA_getCollationDescr',
111 'format' => 'string',
112 'footer' => PMA_getServerCollation(),
114 $column_order['SCHEMA_TABLES'] = array(
115 'disp_name' => $strNumTables,
116 'format' => 'number',
119 $column_order['SCHEMA_TABLE_ROWS'] = array(
120 'disp_name' => $strRows,
121 'format' => 'number',
124 $column_order['SCHEMA_DATA_LENGTH'] = array(
125 'disp_name' => $strData,
129 $column_order['SCHEMA_INDEX_LENGTH'] = array(
130 'disp_name' => $strIndexes,
134 $column_order['SCHEMA_LENGTH'] = array(
135 'disp_name' => $strTotalUC,
139 $column_order['SCHEMA_DATA_FREE'] = array(
140 'disp_name' => $strOverhead,
145 $_url_params = array(
147 'dbstats' => $dbstats,
148 'sort_by' => $sort_by,
149 'sort_order' => $sort_order,
152 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
154 $_url_params['pos'] = $pos;
156 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
157 . PMA_generate_common_hidden_inputs($_url_params);
159 $_url_params['sort_by'] = 'SCHEMA_NAME';
160 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
162 echo '<table id="tabledatabases" class="data">' . "\n"
165 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th> </th>' . "\n" : '')
166 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
167 . ' ' . $strDatabase . "\n"
168 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
169 . ' </a></th>' . "\n";
171 foreach ($column_order as $stat_name => $stat) {
172 if (array_key_exists($stat_name, $first_database)) {
173 if ($stat['format'] === 'byte') {
175 $colspan = ' colspan="2"';
180 $_url_params['sort_by'] = $stat_name;
181 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
182 echo ' <th' . $colspan . '>'
183 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
184 .' ' . $stat['disp_name'] . "\n"
185 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
186 .' </a></th>' . "\n";
190 echo ' <th>' . ($cfg['PropertiesIconic'] ?
' ' : $strAction) . "\n"
198 foreach ($databases as $current) {
199 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
200 $odd_row = ! $odd_row;
202 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
203 echo ' <td class="tool">' . "\n";
204 if ($current['SCHEMA_NAME'] != 'mysql'
205 && $current['SCHEMA_NAME'] != 'information_schema') {
206 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
208 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
210 echo ' </td>' . "\n";
212 echo ' <td class="name">' . "\n"
214 . 'if (window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
215 . '" href="index.php?' . $url_query . '&db='
216 . urlencode($current['SCHEMA_NAME']) . '" title="'
217 . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME']))
218 . '" target="_parent">' . "\n"
219 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
223 if (window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\', true)) return false;
228 foreach ($column_order as $stat_name => $stat) {
229 if (array_key_exists($stat_name, $current)) {
230 if (is_numeric($stat['footer'])) {
231 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
233 if ($stat['format'] === 'byte') {
234 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
235 } elseif ($stat['format'] === 'number') {
236 $value = PMA_formatNumber($current[$stat_name], 0);
238 $value = htmlentities($current[$stat_name], 0);
240 echo ' <td class="value">';
241 if (isset($stat['description_function'])) {
242 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
245 if (isset($stat['description_function'])) {
249 if ($stat['format'] === 'byte') {
250 echo ' <td class="unit">' . $unit . '</td>' . "\n";
256 echo ' <td class="tool">' . "\n"
259 window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');
260 // ]]>" href="./server_privileges.php?' . $url_query
261 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
262 . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME']))
265 . ($cfg['PropertiesIconic']
266 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . $strCheckPrivs . '" /> '
267 : $strCheckPrivs) . "\n"
268 . ' </a></td>' . "\n";
271 } // end foreach ($databases as $key => $current)
272 unset($current, $odd_row);
275 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
276 echo ' <th> </th>' . "\n";
278 echo ' <th>' . $strTotalUC . ': ' . $databases_count . '</th>' . "\n";
279 foreach ($column_order as $stat_name => $stat) {
280 if (array_key_exists($stat_name, $first_database)) {
281 if ($stat['format'] === 'byte') {
282 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
283 } elseif ($stat['format'] === 'number') {
284 $value = PMA_formatNumber($stat['footer'], 0);
286 $value = htmlentities($stat['footer'], 0);
288 echo ' <th class="value">';
289 if (isset($stat['description_function'])) {
290 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
293 if (isset($stat['description_function'])) {
297 if ($stat['format'] === 'byte') {
298 echo ' <th class="unit">' . $unit . '</th>' . "\n";
303 echo ' <th> </th>' . "\n";
306 echo '</tbody>' . "\n"
308 unset($column_order, $stat_name, $stat, $databases, $table_columns);
310 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
311 $common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats;
312 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
313 . '<a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
314 . ' ' . $strCheckAll . '</a> / ' . "\n"
315 . '<a href="./server_databases.php?' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
316 . ' ' . $strUncheckAll . '</a>' . "\n"
317 . '<i>' . $strWithChecked . '</i>' . "\n";
318 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png');
321 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
322 if (empty($dbstats)) {
323 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
324 .' title="' . $strDatabasesStatsEnable . '">' . "\n"
325 .' ' . $strDatabasesStatsEnable;
327 echo ' <a href="./server_databases.php?' . $url_query . '"'
328 .' title="' . $strDatabasesStatsDisable . '">' . "\n"
329 .' ' . $strDatabasesStatsDisable;
331 echo '</a></strong><br />' . "\n";
332 PMA_Message
::warning('strDatabasesStatsHeavyTraffic')->display();
337 echo $strNoDatabases;
339 unset($databases_count);
342 * Create new database.
344 if ($cfg['ShowCreateDb']) {
345 echo '<ul><li id="li_create_database">' . "\n";
346 require './libraries/display_create_database.lib.php';
347 echo ' </li>' . "\n";
354 require_once './libraries/footer.inc.php';