2 /* vim: set expandtab sw=4 ts=4 sts=4: */
11 require_once './libraries/common.inc.php';
14 $js_to_run = '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 = $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 ($mult_btn == $strYes) {
61 $message = sprintf($strDatabasesDropped, count($selected));
63 $message = sprintf($strDatabasesDropped, 0);
71 require './libraries/server_links.inc.php';
75 * Displays the sub-page heading
78 . ($GLOBALS['cfg']['MainPageIconic']
79 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
80 .' height="16" alt="" />'
82 . ($dbstats ?
$strDatabasesStats : $strDatabases) . "\n"
86 * Gets the databases list
89 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
90 $sort_order, $pos, true);
91 $databases_count = $PMA_List_Database->count();
100 if ($databases_count > 0) {
102 $first_database = current($databases);
104 // there is no db specific collation or charset prior 4.1.0
105 if (PMA_MYSQL_INT_VERSION
>= 40100) {
106 $column_order['DEFAULT_COLLATION_NAME'] = array(
107 'disp_name' => $strCollation,
108 'description_function' => 'PMA_getCollationDescr',
109 'format' => 'string',
110 'footer' => PMA_getServerCollation(),
113 $column_order['SCHEMA_TABLES'] = array(
114 'disp_name' => $strNumTables,
115 'format' => 'number',
118 $column_order['SCHEMA_TABLE_ROWS'] = array(
119 'disp_name' => $strRows,
120 'format' => 'number',
123 $column_order['SCHEMA_DATA_LENGTH'] = array(
124 'disp_name' => $strData,
128 $column_order['SCHEMA_INDEX_LENGTH'] = array(
129 'disp_name' => $strIndexes,
133 $column_order['SCHEMA_LENGTH'] = array(
134 'disp_name' => $strTotalUC,
138 $column_order['SCHEMA_DATA_FREE'] = array(
139 'disp_name' => $strOverhead,
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 . ' ' . $strDatabase . "\n"
167 . ($sort_by == 'SCHEMA_NAME' ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\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' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
185 .' </a></th>' . "\n";
189 echo ' <th>' . ($cfg['PropertiesIconic'] ?
' ' : $strAction) . "\n"
197 foreach ($databases as $current) {
198 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
199 $odd_row = ! $odd_row;
201 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
202 echo ' <td class="tool">' . "\n";
203 if ($current['SCHEMA_NAME'] != 'mysql' && (PMA_MYSQL_INT_VERSION
< 50002 ||
$current['SCHEMA_NAME'] != 'information_schema')) {
204 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
206 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
208 echo ' </td>' . "\n";
210 echo ' <td class="name">' . "\n"
211 . ' <a onclick="if (window.parent.openDb(\'' . urlencode($current['SCHEMA_NAME']) . '\')) return false;" href="index.php?' . $url_query . '&db=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME'])) . '" target="_parent">' . "\n"
212 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
216 foreach ($column_order as $stat_name => $stat) {
217 if (array_key_exists($stat_name, $current)) {
218 if (is_numeric($stat['footer'])) {
219 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
221 if ($stat['format'] === 'byte') {
222 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
223 } elseif ($stat['format'] === 'number') {
224 $value = PMA_formatNumber($current[$stat_name], 0);
226 $value = htmlentities($current[$stat_name], 0);
228 echo ' <td class="value">';
229 if (isset($stat['description_function'])) {
230 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
233 if (isset($stat['description_function'])) {
237 if ($stat['format'] === 'byte') {
238 echo ' <td class="unit">' . $unit . '</td>' . "\n";
244 echo ' <td class="tool">' . "\n"
245 . ' <a onclick="window.parent.setDb(\'' . urlencode($current['SCHEMA_NAME']) . '\');" href="./server_privileges.php?' . $url_query . '&checkprivs=' . urlencode($current['SCHEMA_NAME']) . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME'])) . '">'. "\n"
246 . ' ' .($cfg['PropertiesIconic'] ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' .$strCheckPrivs . '" /> ' : $strCheckPrivs). "\n"
247 . ' </a></td>' . "\n";
250 } // end foreach ($databases as $key => $current)
251 unset($current, $odd_row);
254 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
255 echo ' <th> </th>' . "\n";
257 echo ' <th>' . $strTotalUC . ': ' . $databases_count . '</th>' . "\n";
258 foreach ($column_order as $stat_name => $stat) {
259 if (array_key_exists($stat_name, $first_database)) {
260 if ($stat['format'] === 'byte') {
261 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
262 } elseif ($stat['format'] === 'number') {
263 $value = PMA_formatNumber($stat['footer'], 0);
265 $value = htmlentities($stat['footer'], 0);
267 echo ' <th class="value">';
268 if (isset($stat['description_function'])) {
269 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
272 if (isset($stat['description_function'])) {
276 if ($stat['format'] === 'byte') {
277 echo ' <th class="unit">' . $unit . '</th>' . "\n";
282 echo ' <th> </th>' . "\n";
285 echo '</tbody>' . "\n"
287 unset($column_order, $stat_name, $stat, $databases, $table_columns);
289 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
290 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
291 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
292 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
293 . ' ' . $strCheckAll . '</a> / ' . "\n"
294 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
295 . ' ' . $strUncheckAll . '</a>' . "\n"
296 . '<i>' . $strWithChecked . '</i>' . "\n";
297 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png');
300 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
301 if (empty($dbstats)) {
302 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
303 .' title="' . $strDatabasesStatsEnable . '">' . "\n"
304 .' ' . $strDatabasesStatsEnable;
306 echo ' <a href="./server_databases.php?' . $url_query . '"'
307 .' title="' . $strDatabasesStatsDisable . '">' . "\n"
308 .' ' . $strDatabasesStatsDisable;
310 echo '</a></strong><br />' . "\n"
311 .' <div class="warning">'
312 . $strDatabasesStatsHeavyTraffic . '</div></li>' . "\n"
316 echo $strNoDatabases;
318 unset($databases_count);
321 * Create new database.
323 if ($cfg['ShowCreateDb']) {
324 echo '<ul><li id="li_create_database">' . "\n";
325 require './libraries/display_create_database.lib.php';
326 echo ' </li>' . "\n";
333 require_once './libraries/footer.inc.php';