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';
17 require './libraries/replication.inc.php';
20 * avoids 'undefined index' errors
22 if (empty($_REQUEST['sort_by'])) {
23 $sort_by = 'SCHEMA_NAME';
25 $sort_by_whitelist = array(
27 'DEFAULT_COLLATION_NAME',
31 'SCHEMA_INDEX_LENGTH',
35 if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
36 $sort_by = $_REQUEST['sort_by'];
38 $sort_by = 'SCHEMA_NAME';
42 if (isset($_REQUEST['sort_order'])
43 && strtolower($_REQUEST['sort_order']) == 'desc') {
49 $dbstats = empty($_REQUEST['dbstats']) ?
0 : 1;
50 $pos = empty($_REQUEST['pos']) ?
0 : (int) $_REQUEST['pos'];
54 * Drops multiple databases
57 // workaround for IE behavior (it returns some coordinates based on where
58 // the mouse was on the Drop image):
59 if (isset($_REQUEST['drop_selected_dbs_x'])) {
60 $_REQUEST['drop_selected_dbs'] = true;
63 if ((isset($_REQUEST['drop_selected_dbs']) ||
isset($_REQUEST['query_type']))
64 && ($is_superuser ||
$cfg['AllowUserDropDatabase'])) {
65 if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
66 $message = PMA_Message
::error('strNoDatabasesSelected');
68 $action = 'server_databases.php';
69 $submit_mult = 'drop_db' ;
70 $err_url = 'server_databases.php?' . PMA_generate_common_url();
71 if (isset($_REQUEST['selected_dbs'])) {
72 $selected_db = $_REQUEST['selected_dbs'];
74 require './libraries/mult_submits.inc.php';
75 unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
76 if (empty($message)) {
77 $message = PMA_Message
::success('strDatabasesDropped');
78 if ($mult_btn == $strYes) {
79 $message->addParam(count($selected));
81 $message->addParam(0);
91 require './libraries/server_links.inc.php';
95 * Displays the sub-page heading
98 . ($GLOBALS['cfg']['MainPageIconic']
99 ?
'<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
100 .' height="16" alt="" />'
102 . ($dbstats ?
$strDatabasesStats : $strDatabases) . "\n"
106 * Gets the databases list
109 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
110 $sort_order, $pos, true);
111 $databases_count = count($GLOBALS['pma']->databases
);
113 $databases_count = 0;
120 if ($databases_count > 0) {
122 $first_database = current($databases);
124 $column_order['DEFAULT_COLLATION_NAME'] = array(
125 'disp_name' => $strCollation,
126 'description_function' => 'PMA_getCollationDescr',
127 'format' => 'string',
128 'footer' => PMA_getServerCollation(),
130 $column_order['SCHEMA_TABLES'] = array(
131 'disp_name' => $strNumTables,
132 'format' => 'number',
135 $column_order['SCHEMA_TABLE_ROWS'] = array(
136 'disp_name' => $strRows,
137 'format' => 'number',
140 $column_order['SCHEMA_DATA_LENGTH'] = array(
141 'disp_name' => $strData,
145 $column_order['SCHEMA_INDEX_LENGTH'] = array(
146 'disp_name' => $strIndexes,
150 $column_order['SCHEMA_LENGTH'] = array(
151 'disp_name' => $strTotalUC,
155 $column_order['SCHEMA_DATA_FREE'] = array(
156 'disp_name' => $strOverhead,
161 $_url_params = array(
163 'dbstats' => $dbstats,
164 'sort_by' => $sort_by,
165 'sort_order' => $sort_order,
168 PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
170 $_url_params['pos'] = $pos;
172 echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
173 . PMA_generate_common_hidden_inputs($_url_params);
175 $_url_params['sort_by'] = 'SCHEMA_NAME';
176 $_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ?
'desc' : 'asc';
178 echo '<table id="tabledatabases" class="data">' . "\n"
181 . ($is_superuser ||
$cfg['AllowUserDropDatabase'] ?
' <th></th>' . "\n" : '')
182 . ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
183 . ' ' . $strDatabase . "\n"
184 . ($sort_by == 'SCHEMA_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";
187 foreach ($column_order as $stat_name => $stat) {
188 if (array_key_exists($stat_name, $first_database)) {
189 if ($stat['format'] === 'byte') {
191 $colspan = ' colspan="2"';
196 $_url_params['sort_by'] = $stat_name;
197 $_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ?
'asc' : 'desc';
198 echo ' <th' . $colspan . '>'
199 .'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
200 .' ' . $stat['disp_name'] . "\n"
201 .($sort_by == $stat_name ?
' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ?
$strAscending : $strDescending) . '" />' . "\n" : '')
202 .' </a></th>' . "\n";
206 foreach ($replication_types as $type)
209 $name = "strReplicationMaster";
210 elseif($type == "slave")
211 $name = "strReplicationSlave";
212 if ($
{"server_{$type}_status"})
213 echo ' <th>'.$GLOBALS[$name].'</th>' . "\n";
217 echo ' <th>' . ($cfg['PropertiesIconic'] ?
'' : $strAction) . "\n"
225 foreach ($databases as $current) {
226 echo '<tr class="' . ($odd_row ?
'odd' : 'even') . '">' . "\n";
227 $odd_row = ! $odd_row;
229 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
230 echo ' <td class="tool">' . "\n";
231 if ($current['SCHEMA_NAME'] != 'mysql'
232 && $current['SCHEMA_NAME'] != 'information_schema') {
233 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ?
'' : 'checked="checked" ') . '/>' . "\n";
235 echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
237 echo ' </td>' . "\n";
239 echo ' <td class="name">' . "\n"
241 . 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
242 . '" href="index.php?' . $url_query . '&db='
243 . urlencode($current['SCHEMA_NAME']) . '" title="'
244 . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME']))
245 . '" target="_parent">' . "\n"
246 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
250 foreach ($column_order as $stat_name => $stat) {
251 if (array_key_exists($stat_name, $current)) {
252 if (is_numeric($stat['footer'])) {
253 $column_order[$stat_name]['footer'] +
= $current[$stat_name];
255 if ($stat['format'] === 'byte') {
256 list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
257 } elseif ($stat['format'] === 'number') {
258 $value = PMA_formatNumber($current[$stat_name], 0);
260 $value = htmlentities($current[$stat_name], 0);
262 echo ' <td class="value">';
263 if (isset($stat['description_function'])) {
264 echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
267 if (isset($stat['description_function'])) {
271 if ($stat['format'] === 'byte') {
272 echo ' <td class="unit">' . $unit . '</td>' . "\n";
276 foreach ($replication_types as $type) {
277 if ($
{"server_{$type}_status"}) {
278 echo '<td class="tool" style="text-align: center;">' . "\n";
280 if (strlen(array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Ignore_DB"}))>0) {
281 echo '<img class="icon" src="' . $pmaThemeImage . 's_cancel.png" width="16" height="16" alt="NOT REPLICATED" />' . "\n";
283 $key = array_search($current["SCHEMA_NAME"], $
{"server_{$type}_Do_DB"});
285 if (strlen($key) > 0 ||
($
{"server_{$type}_Do_DB"}[0] == "" && count($
{"server_{$type}_Do_DB"}) == 1)) {
286 // if ($key != null) did not work for index "0"
287 echo '<img class="icon" src="' . $pmaThemeImage . 's_success.png" width="16" height="16" alt="REPLICATED" />' . "\n";
298 echo ' <td class="tool">' . "\n"
300 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
301 . '" href="./server_privileges.php?' . $url_query
302 . '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
303 . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME']))
306 . ($cfg['PropertiesIconic']
307 ?
'<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . $strCheckPrivs . '" /> '
308 : $strCheckPrivs) . "\n"
309 . ' </a></td>' . "\n";
312 } // end foreach ($databases as $key => $current)
313 unset($current, $odd_row);
316 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
317 echo ' <th></th>' . "\n";
319 echo ' <th>' . $strTotalUC . ': ' . $databases_count . '</th>' . "\n";
320 foreach ($column_order as $stat_name => $stat) {
321 if (array_key_exists($stat_name, $first_database)) {
322 if ($stat['format'] === 'byte') {
323 list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
324 } elseif ($stat['format'] === 'number') {
325 $value = PMA_formatNumber($stat['footer'], 0);
327 $value = htmlentities($stat['footer'], 0);
329 echo ' <th class="value">';
330 if (isset($stat['description_function'])) {
331 echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
334 if (isset($stat['description_function'])) {
338 if ($stat['format'] === 'byte') {
339 echo ' <th class="unit">' . $unit . '</th>' . "\n";
344 foreach ($replication_types as $type)
346 if ($
{"server_{$type}_status"})
347 echo ' <th></th>' . "\n";
351 echo ' <th></th>' . "\n";
354 echo '</tbody>' . "\n"
356 unset($column_order, $stat_name, $stat, $databases, $table_columns);
358 if ($is_superuser ||
$cfg['AllowUserDropDatabase']) {
359 $common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
360 echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . $strWithChecked . '" />' . "\n"
361 . '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
362 . ' ' . $strCheckAll . '</a> / ' . "\n"
363 . '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
364 . ' ' . $strUncheckAll . '</a>' . "\n"
365 . '<i>' . $strWithChecked . '</i>' . "\n";
366 PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', $strDrop, 'b_deltbl.png');
369 echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
370 if (empty($dbstats)) {
371 echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
372 .' title="' . $strDatabasesStatsEnable . '">' . "\n"
373 .' ' . $strDatabasesStatsEnable;
375 echo ' <a href="./server_databases.php?' . $url_query . '"'
376 .' title="' . $strDatabasesStatsDisable . '">' . "\n"
377 .' ' . $strDatabasesStatsDisable;
379 echo '</a></strong><br />' . "\n";
380 PMA_Message
::warning('strDatabasesStatsHeavyTraffic')->display();
385 echo $strNoDatabases;
387 unset($databases_count);
390 * Create new database.
392 if ($cfg['ShowCreateDb']) {
393 echo '<ul><li id="li_create_database">' . "\n";
394 require './libraries/display_create_database.lib.php';
395 echo ' </li>' . "\n";
402 require_once './libraries/footer.inc.php';