bug #2729191 [config] CheckConfigurationPermissions = false is worthless
[phpmyadmin/crack.git] / server_databases.php
blob6b29f774f3845cb148cf2ddadf4e4ca328c06188
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @version $Id$
6 * @package phpMyAdmin
7 */
9 /**
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';
18 /**
19 * avoids 'undefined index' errors
21 if (empty($_REQUEST['sort_by'])) {
22 $sort_by = 'SCHEMA_NAME';
23 } else {
24 $sort_by = PMA_sanitize($_REQUEST['sort_by']);
27 if (isset($_REQUEST['sort_order'])
28 && strtolower($_REQUEST['sort_order']) == 'desc') {
29 $sort_order = 'desc';
30 } else {
31 $sort_order = 'asc';
34 $dbstats = empty($_REQUEST['dbstats']) ? 0 : 1;
35 $pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
38 /**
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');
52 } else {
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));
65 } else {
66 $message->addParam(0);
73 /**
74 * Displays the links
76 require './libraries/server_links.inc.php';
79 /**
80 * Displays the sub-page heading
82 echo '<h2>' . "\n"
83 . ($GLOBALS['cfg']['MainPageIconic']
84 ? '<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
85 .' height="16" alt="" />'
86 : '')
87 . ($dbstats ? $strDatabasesStats : $strDatabases) . "\n"
88 .'</h2>' . "\n";
90 /**
91 * Gets the databases list
93 if ($server > 0) {
94 $databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
95 $sort_order, $pos, true);
96 $databases_count = count($GLOBALS['pma']->databases);
97 } else {
98 $databases_count = 0;
103 * Displays the page
105 if ($databases_count > 0) {
106 reset($databases);
107 $first_database = current($databases);
108 // table col order
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',
118 'footer' => 0,
120 $column_order['SCHEMA_TABLE_ROWS'] = array(
121 'disp_name' => $strRows,
122 'format' => 'number',
123 'footer' => 0,
125 $column_order['SCHEMA_DATA_LENGTH'] = array(
126 'disp_name' => $strData,
127 'format' => 'byte',
128 'footer' => 0,
130 $column_order['SCHEMA_INDEX_LENGTH'] = array(
131 'disp_name' => $strIndexes,
132 'format' => 'byte',
133 'footer' => 0,
135 $column_order['SCHEMA_LENGTH'] = array(
136 'disp_name' => $strTotalUC,
137 'format' => 'byte',
138 'footer' => 0,
140 $column_order['SCHEMA_DATA_FREE'] = array(
141 'disp_name' => $strOverhead,
142 'format' => 'byte',
143 'footer' => 0,
146 $_url_params = array(
147 'pos' => $pos,
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"
164 . '<thead>' . "\n"
165 . '<tr>' . "\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";
171 $table_columns = 3;
172 foreach ($column_order as $stat_name => $stat) {
173 if (array_key_exists($stat_name, $first_database)) {
174 if ($stat['format'] === 'byte') {
175 $table_columns += 2;
176 $colspan = ' colspan="2"';
177 } else {
178 $table_columns++;
179 $colspan = '';
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";
190 if ($is_superuser) {
191 echo ' <th>' . ($cfg['PropertiesIconic'] ? '' : $strAction) . "\n"
192 . ' </th>' . "\n";
194 echo '</tr>' . "\n"
195 . '</thead>' . "\n"
196 . '<tbody>' . "\n";
198 $odd_row = true;
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";
208 } else {
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"
214 . ' <a onclick="'
215 . 'if (window.parent.openDb &amp;&amp; window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
216 . '" href="index.php?' . $url_query . '&amp;db='
217 . urlencode($current['SCHEMA_NAME']) . '" title="'
218 . sprintf($strJumpToDB, htmlspecialchars($current['SCHEMA_NAME']))
219 . '" target="_parent">' . "\n"
220 . ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
221 . ' </a>' . "\n"
222 . ' </td>' . "\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);
233 } else {
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]) . '">';
240 echo $value;
241 if (isset($stat['description_function'])) {
242 echo '</dfn>';
244 echo '</td>' . "\n";
245 if ($stat['format'] === 'byte') {
246 echo ' <td class="unit">' . $unit . '</td>' . "\n";
251 if ($is_superuser) {
252 echo ' <td class="tool">' . "\n"
253 . ' <a onclick="'
254 . 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
255 . '" href="./server_privileges.php?' . $url_query
256 . '&amp;checkprivs=' . urlencode($current['SCHEMA_NAME'])
257 . '" title="' . sprintf($strCheckPrivsLong, htmlspecialchars($current['SCHEMA_NAME']))
258 . '">'. "\n"
259 . ' '
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";
265 echo '</tr>' . "\n";
266 } // end foreach ($databases as $key => $current)
267 unset($current, $odd_row);
269 echo '<tr>' . "\n";
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);
280 } else {
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']) . '">';
287 echo $value;
288 if (isset($stat['description_function'])) {
289 echo '</dfn>';
291 echo '</th>' . "\n";
292 if ($stat['format'] === 'byte') {
293 echo ' <th class="unit">' . $unit . '</th>' . "\n";
297 if ($is_superuser) {
298 echo ' <th></th>' . "\n";
300 echo '</tr>' . "\n";
301 echo '</tbody>' . "\n"
302 .'</table>' . "\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() . '&amp;sort_by=' . $sort_by . '&amp;sort_order=' . $sort_order . '&amp;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 . '&amp;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 . '&amp;dbstats=1"'
319 .' title="' . $strDatabasesStatsEnable . '">' . "\n"
320 .' ' . $strDatabasesStatsEnable;
321 } else {
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();
328 echo '</li>' . "\n"
329 .'</ul>' . "\n";
330 echo '</form>';
331 } else {
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";
343 echo '</ul>' . "\n";
347 * Sends the footer
349 require_once './libraries/footer.inc.php';