1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
|
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
*
* @package phpMyAdmin
*/
/**
* Does the common work
*/
require_once './libraries/common.inc.php';
require './libraries/server_common.inc.php';
require './libraries/replication.inc.php';
/**
* avoids 'undefined index' errors
*/
if (empty($_REQUEST['sort_by'])) {
$sort_by = 'SCHEMA_NAME';
} else {
$sort_by_whitelist = array(
'SCHEMA_NAME',
'DEFAULT_COLLATION_NAME',
'SCHEMA_TABLES',
'SCHEMA_TABLE_ROWS',
'SCHEMA_DATA_LENGTH',
'SCHEMA_INDEX_LENGTH',
'SCHEMA_LENGTH',
'SCHEMA_DATA_FREE'
);
if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
$sort_by = $_REQUEST['sort_by'];
} else {
$sort_by = 'SCHEMA_NAME';
}
}
if (isset($_REQUEST['sort_order'])
&& strtolower($_REQUEST['sort_order']) == 'desc') {
$sort_order = 'desc';
} else {
$sort_order = 'asc';
}
$dbstats = empty($_REQUEST['dbstats']) ? 0 : 1;
$pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
/**
* Drops multiple databases
*/
// workaround for IE behavior (it returns some coordinates based on where
// the mouse was on the Drop image):
if (isset($_REQUEST['drop_selected_dbs_x'])) {
$_REQUEST['drop_selected_dbs'] = true;
}
if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
&& ($is_superuser || $cfg['AllowUserDropDatabase'])) {
if (! isset($_REQUEST['selected_dbs']) && ! isset($_REQUEST['query_type'])) {
$message = PMA_Message::error(__('No databases selected.'));
} else {
$action = 'server_databases.php';
$submit_mult = 'drop_db' ;
$err_url = 'server_databases.php?' . PMA_generate_common_url();
if (isset($_REQUEST['selected_dbs'])) {
$selected_db = $_REQUEST['selected_dbs'];
}
require './libraries/mult_submits.inc.php';
unset($action, $submit_mult, $err_url, $selected_db, $GLOBALS['db']);
if (empty($message)) {
$message = PMA_Message::success(__('%s databases have been dropped successfully.'));
if ($mult_btn == __('Yes')) {
$message->addParam(count($selected));
} else {
$message->addParam(0);
}
}
}
}
/**
* Displays the links
*/
require './libraries/server_links.inc.php';
/**
* Displays the sub-page heading
*/
echo '<h2>' . "\n"
. ($GLOBALS['cfg']['MainPageIconic']
? '<img class="icon" src="' . $pmaThemeImage . 's_db.png" width="16"'
.' height="16" alt="" />'
: '')
. ($dbstats ? __('Databases statistics') : __('Databases')) . "\n"
.'</h2>' . "\n";
/**
* Gets the databases list
*/
if ($server > 0) {
$databases = PMA_DBI_get_databases_full(null, $dbstats, null, $sort_by,
$sort_order, $pos, true);
$databases_count = count($GLOBALS['pma']->databases);
} else {
$databases_count = 0;
}
/**
* Displays the page
*/
if ($databases_count > 0) {
reset($databases);
$first_database = current($databases);
// table col order
$column_order['DEFAULT_COLLATION_NAME'] = array(
'disp_name' => __('Collation'),
'description_function' => 'PMA_getCollationDescr',
'format' => 'string',
'footer' => PMA_getServerCollation(),
);
$column_order['SCHEMA_TABLES'] = array(
'disp_name' => __('Tables'),
'format' => 'number',
'footer' => 0,
);
$column_order['SCHEMA_TABLE_ROWS'] = array(
'disp_name' => __('Rows'),
'format' => 'number',
'footer' => 0,
);
$column_order['SCHEMA_DATA_LENGTH'] = array(
'disp_name' => __('Data'),
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_INDEX_LENGTH'] = array(
'disp_name' => __('Indexes'),
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_LENGTH'] = array(
'disp_name' => __('Total'),
'format' => 'byte',
'footer' => 0,
);
$column_order['SCHEMA_DATA_FREE'] = array(
'disp_name' => __('Overhead'),
'format' => 'byte',
'footer' => 0,
);
$_url_params = array(
'pos' => $pos,
'dbstats' => $dbstats,
'sort_by' => $sort_by,
'sort_order' => $sort_order,
);
PMA_listNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
$_url_params['pos'] = $pos;
echo '<form action="./server_databases.php" method="post" name="dbStatsForm" id="dbStatsForm">' . "\n"
. PMA_generate_common_hidden_inputs($_url_params);
$_url_params['sort_by'] = 'SCHEMA_NAME';
$_url_params['sort_order'] = ($sort_by == 'SCHEMA_NAME' && $sort_order == 'asc') ? 'desc' : 'asc';
echo '<table id="tabledatabases" class="data">' . "\n"
. '<thead>' . "\n"
. '<tr>' . "\n"
. ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th></th>' . "\n" : '')
. ' <th><a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
. ' ' . __('Database') . "\n"
. ($sort_by == 'SCHEMA_NAME' ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? __('Ascending') : __('Descending')) . '" />' . "\n" : '')
. ' </a></th>' . "\n";
$table_columns = 3;
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] === 'byte') {
$table_columns += 2;
$colspan = ' colspan="2"';
} else {
$table_columns++;
$colspan = '';
}
$_url_params['sort_by'] = $stat_name;
$_url_params['sort_order'] = ($sort_by == $stat_name && $sort_order == 'desc') ? 'asc' : 'desc';
echo ' <th' . $colspan . '>'
.'<a href="./server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\n"
.' ' . $stat['disp_name'] . "\n"
.($sort_by == $stat_name ? ' <img class="icon" src="' . $pmaThemeImage . 's_' . $sort_order . '.png" width="11" height="9" alt="' . ($sort_order == 'asc' ? __('Ascending') : __('Descending')) . '" />' . "\n" : '')
.' </a></th>' . "\n";
}
}
foreach ($replication_types as $type)
{
if ($type=="master")
$name = __('Master replication');
elseif($type == "slave")
$name = __('Slave replication');
if (${"server_{$type}_status"})
echo ' <th>'. $name .'</th>' . "\n";
}
if ($is_superuser) {
echo ' <th>' . ($cfg['PropertiesIconic'] ? '' : __('Action')) . "\n"
. ' </th>' . "\n";
}
echo '</tr>' . "\n"
. '</thead>' . "\n"
. '<tbody>' . "\n";
$odd_row = true;
foreach ($databases as $current) {
echo '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n";
$odd_row = ! $odd_row;
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' <td class="tool">' . "\n";
if ($current['SCHEMA_NAME'] != 'mysql'
&& $current['SCHEMA_NAME'] != 'information_schema') {
echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" ' . (empty($checkall) ? '' : 'checked="checked" ') . '/>' . "\n";
} else {
echo ' <input type="checkbox" name="selected_dbs[]" title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" value="' . htmlspecialchars($current['SCHEMA_NAME']) . '" disabled="disabled"/>' . "\n";
}
echo ' </td>' . "\n";
}
echo ' <td class="name">' . "\n"
. ' <a onclick="'
. 'if (window.parent.openDb && window.parent.openDb(\'' . PMA_jsFormat($current['SCHEMA_NAME'], false) . '\')) return false;'
. '" href="index.php?' . $url_query . '&db='
. urlencode($current['SCHEMA_NAME']) . '" title="'
. sprintf(__('Jump to database'), htmlspecialchars($current['SCHEMA_NAME']))
. '" target="_parent">' . "\n"
. ' ' . htmlspecialchars($current['SCHEMA_NAME']) . "\n"
. ' </a>' . "\n"
. ' </td>' . "\n";
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $current)) {
if (is_numeric($stat['footer'])) {
$column_order[$stat_name]['footer'] += $current[$stat_name];
}
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
} elseif ($stat['format'] === 'number') {
$value = PMA_formatNumber($current[$stat_name], 0);
} else {
$value = htmlentities($current[$stat_name], 0);
}
echo ' <td class="value">';
if (isset($stat['description_function'])) {
echo '<dfn title="' . $stat['description_function']($current[$stat_name]) . '">';
}
echo $value;
if (isset($stat['description_function'])) {
echo '</dfn>';
}
echo '</td>' . "\n";
if ($stat['format'] === 'byte') {
echo ' <td class="unit">' . $unit . '</td>' . "\n";
}
}
}
foreach ($replication_types as $type) {
if (${"server_{$type}_status"}) {
echo '<td class="tool" style="text-align: center;">' . "\n";
if (strlen(array_search($current["SCHEMA_NAME"], ${"server_{$type}_Ignore_DB"}))>0) {
echo '<img class="icon" src="' . $pmaThemeImage . 's_cancel.png" width="16" height="16" alt="' . __('Not replicated') . '" />' . "\n";
} else {
$key = array_search($current["SCHEMA_NAME"], ${"server_{$type}_Do_DB"});
if (strlen($key) > 0 || (${"server_{$type}_Do_DB"}[0] == "" && count(${"server_{$type}_Do_DB"}) == 1)) {
// if ($key != null) did not work for index "0"
echo '<img class="icon" src="' . $pmaThemeImage . 's_success.png" width="16" height="16" alt="' . __('Replicated') . '" />' . "\n";
} else {
echo '';
}
}
echo '</td>';
}
}
if ($is_superuser) {
echo ' <td class="tool">' . "\n"
. ' <a onclick="'
. 'if (window.parent.setDb) window.parent.setDb(\'' . PMA_jsFormat($current['SCHEMA_NAME']) . '\');'
. '" href="./server_privileges.php?' . $url_query
. '&checkprivs=' . urlencode($current['SCHEMA_NAME'])
. '" title="' . sprintf(__('Check privileges for database "%s".'), htmlspecialchars($current['SCHEMA_NAME']))
. '">'. "\n"
. ' '
. ($cfg['PropertiesIconic']
? '<img class="icon" src="' . $pmaThemeImage . 's_rights.png" width="16" height="16" alt=" ' . __('Check Privileges') . '" /> '
: __('Check Privileges')) . "\n"
. ' </a></td>' . "\n";
}
echo '</tr>' . "\n";
} // end foreach ($databases as $key => $current)
unset($current, $odd_row);
echo '<tr id="db_summary_row">' . "\n";
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
echo ' <th></th>' . "\n";
}
echo ' <th>' . __('Total') . ': ' . $databases_count . '</th>' . "\n";
foreach ($column_order as $stat_name => $stat) {
if (array_key_exists($stat_name, $first_database)) {
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1);
} elseif ($stat['format'] === 'number') {
$value = PMA_formatNumber($stat['footer'], 0);
} else {
$value = htmlentities($stat['footer'], 0);
}
echo ' <th class="value">';
if (isset($stat['description_function'])) {
echo '<dfn title="' . $stat['description_function']($stat['footer']) . '">';
}
echo $value;
if (isset($stat['description_function'])) {
echo '</dfn>';
}
echo '</th>' . "\n";
if ($stat['format'] === 'byte') {
echo ' <th class="unit">' . $unit . '</th>' . "\n";
}
}
}
foreach ($replication_types as $type)
{
if (${"server_{$type}_status"})
echo ' <th></th>' . "\n";
}
if ($is_superuser) {
echo ' <th></th>' . "\n";
}
echo '</tr>' . "\n";
echo '</tbody>' . "\n"
.'</table>' . "\n";
unset($column_order, $stat_name, $stat, $databases, $table_columns);
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
$common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
. '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
. ' ' . __('Check All') . '</a> / ' . "\n"
. '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
. ' ' . __('Uncheck All') . '</a>' . "\n"
. '<i>' . __('With selected:') . '</i>' . "\n";
PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
}
echo '<ul><li id="li_switch_dbstats"><strong>' . "\n";
if (empty($dbstats)) {
echo ' <a href="./server_databases.php?' . $url_query . '&dbstats=1"'
.' title="' . __('Enable Statistics') . '">' . "\n"
.' ' . __('Enable Statistics');
} else {
echo ' <a href="./server_databases.php?' . $url_query . '"'
.' title="' . __('Disable Statistics') . '">' . "\n"
.' ' . __('Disable Statistics');
}
echo '</a></strong><br />' . "\n";
PMA_Message::warning(__('Note: Enabling the database statistics here might cause heavy traffic between the web server and the MySQL server.'))->display();
echo '</li>' . "\n"
.'</ul>' . "\n";
echo '</form>';
} else {
echo __('No databases');
}
unset($databases_count);
/**
* Create new database.
*/
if ($cfg['ShowCreateDb']) {
echo '<ul><li id="li_create_database">' . "\n";
require './libraries/display_create_database.lib.php';
echo ' </li>' . "\n";
echo '</ul>' . "\n";
}
/**
* Sends the footer
*/
require './libraries/footer.inc.php';
?>
|