Fix left frame reloading after dropping table (bug #1034531).
[phpmyadmin/crack.git] / db_details_structure.php
blob4e4f5b8fc9c78bf6589d04acd2b406868a3e3670
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 require_once('./libraries/grab_globals.lib.php');
6 require_once('./libraries/common.lib.php');
7 require_once('./libraries/mysql_charsets.lib.php');
9 /**
10 * Rename database
12 if (isset($db) && isset($db_rename) && $db_rename == 'true') {
13 if (!isset($newname) || empty($newname)) {
14 $message = $strDatabaseEmpty;
15 } else {
16 $local_query = 'CREATE DATABASE ' . PMA_backquote($newname) . ';';
17 $sql_query = $local_query;
18 PMA_DBI_query($local_query);
19 $tables = PMA_DBI_get_tables($db);
20 foreach ($tables as $table) {
21 $local_query = 'RENAME TABLE '
22 . PMA_backquote($db) . '.' . PMA_backquote($table)
23 . ' TO '
24 . PMA_backquote($newname) . '.' . PMA_backquote($table)
25 . ';';
26 $sql_query .= "\n" . $local_query;
27 PMA_DBI_query($local_query);
29 $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
30 $sql_query .= "\n" . $local_query;
31 PMA_DBI_query($local_query);
32 $reload = TRUE;
33 $message = sprintf($strRenameDatabaseOK, htmlspecialchars($db), htmlspecialchars($newname));
35 /* Update relations */
36 require_once('./libraries/relation.lib.php');
37 $cfgRelation = PMA_getRelationsParam();
39 if ($cfgRelation['commwork']) {
40 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['column_info'])
41 . ' SET db_name = \'' . PMA_sqlAddslashes($newname) . '\''
42 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'');
44 if ($cfgRelation['bookmarkwork']) {
45 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['bookmark'])
46 . ' SET dbase = \'' . PMA_sqlAddslashes($newname) . '\''
47 . ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\'');
49 if ($cfgRelation['displaywork']) {
50 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['table_info'])
51 . ' SET db_name = \'' . PMA_sqlAddslashes($newname) . '\''
52 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'');
55 if ($cfgRelation['relwork']) {
56 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['relation'])
57 . ' SET foreign_db = \'' . PMA_sqlAddslashes($newname) . '\''
58 . ' WHERE foreign_db = \'' . PMA_sqlAddslashes($db) . '\'');
59 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['relation'])
60 . ' SET master_db = \'' . PMA_sqlAddslashes($newname) . '\''
61 . ' WHERE master_db = \'' . PMA_sqlAddslashes($db) . '\'');
63 if ($cfgRelation['historywork']) {
64 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['history'])
65 . ' SET db = \'' . PMA_sqlAddslashes($newname) . '\''
66 . ' WHERE db = \'' . PMA_sqlAddslashes($db) . '\'');
68 if ($cfgRelation['pdfwork']) {
69 PMA_query_as_cu('UPDATE ' . PMA_backquote($cfgRelation['table_info'])
70 . ' SET db_name = \'' . PMA_sqlAddslashes($newname) . '\''
71 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'');
74 /* Change database to be used */
75 $db = $newname;
78 /**
79 * Prepares the tables list if the user where not redirected to this script
80 * because there is no table in the database ($is_info is TRUE)
82 if (empty($is_info)) {
83 // Drops/deletes/etc. multiple tables if required
84 if ((!empty($submit_mult) && isset($selected_tbl))
85 || isset($mult_btn)) {
86 $action = 'db_details_structure.php';
87 $err_url = 'db_details_structure.php?'. PMA_generate_common_url($db);
88 require('./mult_submits.inc.php');
89 $message = $strSuccess;
91 require('./db_details_common.php');
92 $url_query .= '&amp;goto=db_details_structure.php';
94 // Gets the database structure
95 $sub_part = '_structure';
96 require('./db_details_db_info.php');
97 echo "\n";
100 if (PMA_MYSQL_INT_VERSION >= 40101) {
101 $db_collation = PMA_getDbCollation($db);
105 // Display function
106 function pma_TableHeader($alternate = FALSE) {
107 echo ' <table border="' . $GLOBALS['cfg']['Border'] . '" cellpadding="2" cellspacing="1">' . "\n"
108 . ' <tr>' . "\n"
109 . ' <td></td>' . "\n"
110 . ' <th>' . "\n"
111 . ' &nbsp;' . $GLOBALS['strTable'] . '&nbsp;' . "\n"
112 . ' </th>' . "\n"
113 . ' <th colspan="6">' . "\n"
114 . ' &nbsp;' . $GLOBALS['strAction'] . '&nbsp;' . "\n"
115 . ' </th>' . "\n"
116 . ' <th>' . "\n"
117 . ' &nbsp;' . $GLOBALS['strRecords'] . '&nbsp;' . "\n"
118 . ' </th>' . "\n";
119 if (!$alternate) {
120 if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
121 echo ' <th>' . "\n"
122 . ' &nbsp;' . $GLOBALS['strType'] . '&nbsp;' . "\n"
123 . ' </th>' . "\n";
124 if (PMA_MYSQL_INT_VERSION >= 40100) {
125 echo ' <th>' . "\n"
126 . ' &nbsp;' . $GLOBALS['strCollation'] . '&nbsp;' . "\n"
127 . ' </th>' . "\n";
130 if ($GLOBALS['cfg']['ShowStats']) {
131 echo ' <th>' . "\n"
132 . ' &nbsp;' . $GLOBALS['strSize'] . '&nbsp;' . "\n"
133 . ' </th>' . "\n"
134 . ' <th>' . "\n"
135 . ' &nbsp;' . $GLOBALS['strOverhead'] . '&nbsp;' . "\n"
136 . ' </th>' . "\n";
138 echo "\n";
140 echo ' </tr>' . "\n";
145 * Settings for relations stuff
147 require_once('./libraries/relation.lib.php');
148 $cfgRelation = PMA_getRelationsParam();
151 * Check if comments were updated
153 if ($cfgRelation['commwork'] && isset($db_comment) && $db_comment == 'true') {
154 PMA_SetComment($db, '', '(db_comment)', $comment);
158 * Displays the tables list
162 <!-- TABLE LIST -->
164 <?php
165 $titles = array();
166 if ($cfg['PropertiesIconic'] == true) {
167 // We need to copy the value or else the == 'both' check will always return true
168 $propicon = (string)$cfg['PropertiesIconic'];
170 if ($propicon == 'both') {
171 $iconic_spacer = '<div class="nowrap">';
172 } else {
173 $iconic_spacer = '';
176 $titles['Browse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
177 $titles['Search'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />';
178 $titles['NoBrowse'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_browse.png" alt="' . $strBrowse . '" title="' . $strBrowse . '" border="0" />';
179 $titles['NoSearch'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_select.png" alt="' . $strSearch . '" title="' . $strSearch . '" border="0" />';
180 $titles['Insert'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_insrow.png" alt="' . $strInsert . '" title="' . $strInsert . '" border="0" />';
181 $titles['Properties'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_props.png" alt="' . $strProperties . '" title="' . $strProperties . '" border="0" />';
182 $titles['Drop'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
183 $titles['Empty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'b_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
184 $titles['NoEmpty'] = $iconic_spacer . '<img hspace="2" width="16" height="16" src="' .$pmaThemeImage . 'bd_empty.png" alt="' . $strEmpty . '" title="' . $strEmpty . '" border="0" />';
186 if ($propicon == 'both') {
187 $titles['Browse'] .= '&nbsp;' . $strBrowse . '</div>';
188 $titles['Search'] .= '&nbsp;' . $strSearch . '</div>';
189 $titles['NoBrowse'] .= '&nbsp;' . $strBrowse . '</div>';
190 $titles['NoSearch'] .= '&nbsp;' . $strSearch . '</div>';
191 $titles['Insert'] .= '&nbsp;' . $strInsert . '</div>';
192 $titles['Properties'] .= '&nbsp;' . $strProperties . '</div>';
193 $titles['Drop'] .= '&nbsp;' . $strDrop . '</div>';
194 $titles['Empty'] .= '&nbsp;' . $strEmpty . '</div>';
195 $titles['NoEmpty'] .= '&nbsp;' . $strEmpty . '</div>';
197 } else {
198 $titles['Browse'] = $strBrowse;
199 $titles['Search'] = $strSearch;
200 $titles['NoBrowse'] = $strBrowse;
201 $titles['NoSearch'] = $strSearch;
202 $titles['Insert'] = $strInsert;
203 $titles['Properties'] = $strProperties;
204 $titles['Drop'] = $strDrop;
205 $titles['Empty'] = $strEmpty;
206 $titles['NoEmpty'] = $strEmpty;
209 // 1. No tables
210 if ($num_tables == 0) {
211 echo $strNoTablesFound . "\n";
213 // 2. Shows table informations - staybyte - 11 June 2001
214 else {
215 // Get additional information about tables for tooltip is done in db_details_db_info.php only once
216 if ($cfgRelation['commwork']) {
217 $comment = PMA_getComments($db);
220 * Displays table comment
222 if (is_array($comment)) {
224 <!-- DB comment -->
225 <p id="dbComment"><i>
226 <?php echo htmlspecialchars(implode(' ', $comment)) . "\n"; ?>
227 </i></p>
228 <?php
229 } // end if
232 <form method="post" action="db_details_structure.php" name="tablesForm">
233 <?php echo PMA_generate_common_hidden_inputs($db); ?>
235 <?php
236 if ($cfg['PropertiesNumColumns'] > 1) {
238 <table cellspacing="0" cellpadding="0" border="0">
239 <tr>
240 <td valign="top">
241 <?php
244 pma_TableHeader();
246 $i = $sum_entries = 0;
247 (double) $sum_size = 0;
248 (double) $overhead_size = 0;
249 $overhead_check = '';
250 $checked = (!empty($checkall) ? ' checked="checked"' : '');
251 $num_columns = ($cfg['PropertiesNumColumns'] > 1 ? (ceil($num_tables / $cfg['PropertiesNumColumns']) + 1) : 0);
252 $row_count = 0;
254 if ($cfg['NaturalOrder']) {
255 $tables_temp = $tables;
256 foreach (array_keys($tables_temp) as $each) {
257 $tables_sort[$each] = $tables_temp[$each]['Name'];
259 natsort($tables_sort);
260 $sort_i = 0;
261 foreach (array_keys($tables_sort) as $each) {
262 $tables_temp[$sort_i] = $tables[$each];
263 $sort_i++;
265 $tables = $tables_temp;
268 foreach ($tables AS $keyname => $sts_data) {
269 $table = $sts_data['Name'];
270 $table_encoded = urlencode($table);
271 $table_name = htmlspecialchars($table);
273 $alias = (!empty($tooltip_aliasname) && isset($tooltip_aliasname[$table]))
274 ? htmlspecialchars($tooltip_aliasname[$table])
275 : htmlspecialchars($sts_data['Name']);
276 $truename = (!empty($tooltip_truename) && isset($tooltip_truename[$table]))
277 ? htmlspecialchars($tooltip_truename[$table])
278 : htmlspecialchars($sts_data['Name']);
280 // Sets parameters for links
281 $tbl_url_query = $url_query . '&amp;table=' . $table_encoded;
282 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
283 echo "\n";
285 if ($GLOBALS['cfg']['BrowsePointerEnable'] == TRUE) {
286 $on_mouse = ' onmouseover="setPointer(this, ' . $i . ', \'over\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"'
287 . ' onmouseout="setPointer(this, ' . $i . ', \'out\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
288 } else {
289 $on_mouse = '';
291 if ($GLOBALS['cfg']['BrowseMarkerEnable'] == TRUE) {
292 $on_mouse .= ' onmousedown="setPointer(this, ' . $i . ', \'click\', \'' . $bgcolor . '\', \'' . $GLOBALS['cfg']['BrowsePointerColor'] . '\', \'' . $GLOBALS['cfg']['BrowseMarkerColor'] . '\');"';
295 $click_mouse = ' onmousedown="document.getElementById(\'checkbox_tbl_' . $i . '\').checked = (document.getElementById(\'checkbox_tbl_' . $i . '\').checked ? false : true);" ';
297 $row_count++;
298 if ($num_columns > 0 && $num_tables > $num_columns && (($row_count % ($num_columns)) == 0)) {
299 $bgcolor = $cfg['BgcolorTwo'];
300 $row_count = 1;
302 </tr>
303 </table>
304 </td>
305 <td><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="10" height="1" alt="" /></td>
306 <td valign="top">
307 <?php
308 pma_TableHeader();
311 <tr <?php echo $on_mouse; ?>>
312 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
313 <input type="checkbox" name="selected_tbl[]" value="<?php echo $table_encoded; ?>" id="checkbox_tbl_<?php echo $i; ?>"<?php echo $checked; ?> />
314 </td>
315 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
316 &nbsp;<b><label onclick="javascript: return (document.getElementById('checkbox_tbl_<?php echo $i; ?>') ? false : true)" for="checkbox_tbl_<?php echo $i; ?>" title="<?php echo $alias; ?>"><?php echo $truename; ?></label>&nbsp;</b>&nbsp;
317 </td>
318 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
319 <?php
320 require_once('./libraries/bookmark.lib.php');
321 $book_sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], '\'' . PMA_sqlAddslashes($table) . '\'', 'label');
323 if (!empty($sts_data['Rows'])) {
324 echo '<a href="sql.php?' . $tbl_url_query . '&amp;sql_query='
325 . (isset($book_sql_query) && $book_sql_query != FALSE ? urlencode($book_sql_query) : urlencode('SELECT * FROM ' . PMA_backquote($table)))
326 . '&amp;pos=0">' . $titles['Browse'] . '</a>';
327 } else {
328 echo $titles['NoBrowse'];
331 </td>
332 <td bgcolor="<?php echo $bgcolor; ?>">
333 <?php
334 if (!empty($sts_data['Rows'])) {
335 echo '<a href="tbl_select.php?' . $tbl_url_query . '">'
336 . $titles['Search'] . '</a>';
337 } else {
338 echo $titles['NoSearch'];
341 </td>
342 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
343 <a href="tbl_change.php?<?php echo $tbl_url_query; ?>">
344 <?php echo $titles['Insert']; ?></a>
345 </td>
346 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
347 <a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>">
348 <?php echo $titles['Properties']; ?></a>
349 </td>
350 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
351 <?php
352 if (!empty($sts_data['Rows'])) {
353 echo '<a href="sql.php?' . $tbl_url_query
354 . '&amp;sql_query=';
355 if (PMA_MYSQL_INT_VERSION >= 40000) {
356 echo urlencode('TRUNCATE ' . PMA_backquote($table))
357 . '&amp;zero_rows='
358 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
359 . '" onclick="return confirmLink(this, \'TRUNCATE ';
360 } else {
361 echo urlencode('DELETE FROM ' . PMA_backquote($table))
362 . '&amp;zero_rows='
363 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
364 . '" onclick="return confirmLink(this, \'DELETE FROM ';
366 echo PMA_jsFormat($table) . '\')">' . $titles['Empty'] . '</a>';
367 } else {
368 echo $titles['NoEmpty'];
371 </td>
372 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
373 <a href="sql.php?<?php echo $tbl_url_query; ?>&amp;reload=1&amp;purge=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
374 onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
375 <?php echo $titles['Drop']; ?></a>
376 </td>
377 <?php
378 echo "\n";
380 // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
381 // statistics whatever is the table type
382 if (isset($sts_data['Rows'])) {
383 // MyISAM, ISAM or Heap table: Row count, data size and index size
384 // is accurate.
385 if (isset($sts_data['Type']) && preg_match('@^(MyISAM|ISAM|HEAP)$@', $sts_data['Type'])) {
386 if ($cfg['ShowStats']) {
387 $tblsize = doubleval($sts_data['Data_length']) + doubleval($sts_data['Index_length']);
388 $sum_size += $tblsize;
389 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
390 if (isset($sts_data['Data_free']) && $sts_data['Data_free'] > 0) {
391 list($formated_overhead, $overhead_unit) = PMA_formatByteDown($sts_data['Data_free']);
392 $overhead_size += $sts_data['Data_free'];
395 $sum_entries += $sts_data['Rows'];
396 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
399 // InnoDB table: Row count is not accurate but data and index
400 // sizes are.
401 else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
402 if ($cfg['ShowStats']) {
403 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
404 $sum_size += $tblsize;
405 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0);
407 //$display_rows = '&nbsp;-&nbsp;';
408 // get row count with another method
409 if ($sts_data['Rows'] < $cfg['MaxExactCount']) {
410 $local_query = 'SELECT COUNT(*) AS count FROM '
411 . PMA_backquote($db) . '.'
412 . PMA_backquote($table);
413 $table_info_result = PMA_DBI_query($local_query);
414 list($row_count) = PMA_DBI_fetch_row($table_info_result);
415 PMA_DBI_free_result($table_info_result);
416 unset($table_info_result);
417 $sum_entries += $row_count;
418 } else {
419 $row_count = $sts_data['Rows'];
420 $sum_entries += $sts_data['Rows'];
422 $display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator);
425 // Merge or BerkleyDB table: Only row count is accurate.
426 else if (isset($sts_data['Type']) && preg_match('@^(MRG_MyISAM|BerkeleyDB)$@', $sts_data['Type'])) {
427 if ($cfg['ShowStats']) {
428 $formated_size = '&nbsp;-&nbsp;';
429 $unit = '';
431 $sum_entries += $sts_data['Rows'];
432 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
435 // Unknown table type.
436 else {
437 if ($cfg['ShowStats']) {
438 $formated_size = 'unknown';
439 $unit = '';
441 $display_rows = 'unknown';
444 <td align="right" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
445 <?php
446 echo "\n" . ' ' . $display_rows . "\n";
448 </td>
449 <?php
450 if (!($cfg['PropertiesNumColumns'] > 1)) {
451 echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
452 . ' &nbsp;' . (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;') . '&nbsp;' . "\n"
453 . ' </td>' . "\n";
454 if (PMA_MYSQL_INT_VERSION >= 40100) {
455 echo ' <td bgcolor="' . $bgcolor . '" nowrap="nowrap" ' . $click_mouse . '>' . "\n"
456 . ' &nbsp;' . (isset($sts_data['Collation']) ? '<dfn title="' . PMA_getCollationDescr($sts_data['Collation']) . '">' . $sts_data['Collation'] . '</dfn>' : '---') . '&nbsp;' . "\n"
457 . ' </td>' . "\n";
461 if ($cfg['ShowStats']) {
462 echo "\n";
464 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
465 &nbsp;&nbsp;
466 <a href="tbl_properties_structure.php?<?php echo $tbl_url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
467 </td>
468 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap" <?php echo $click_mouse; ?>>
469 &nbsp;&nbsp;
470 <?php
471 if (isset($formated_overhead)) {
472 echo '<a href="tbl_properties_structure.php?' . $tbl_url_query . '#showusage">' . $formated_overhead . ' ' . $overhead_unit . '</a>' . "\n";
473 unset($formated_overhead);
474 $overhead_check .= "document.getElementById('checkbox_tbl_$i').checked = true;";
475 } else {
476 echo "&nbsp;-&nbsp;\n";
479 </td>
480 <?php
481 echo "\n";
482 } // end if
483 } else {
485 <td colspan="4" align="center" bgcolor="<?php echo $bgcolor; ?>" <?php echo $click_mouse; ?>>
486 <?php echo $strInUse . "\n"; ?>
487 </td>
488 <?php
490 echo "\n";
492 </tr>
493 <?php
495 // Show Summary
496 if ($cfg['ShowStats']) {
497 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
498 list($overhead_formated, $overhead_unit) = PMA_formatByteDown($overhead_size, 3, 1);
500 echo "\n";
502 <tr>
503 <td></td>
504 <th align="center" nowrap="nowrap">
505 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
506 </th>
507 <th colspan="6" align="center">
508 <b><?php echo $strSum; ?></b>
509 </th>
510 <th align="right" nowrap="nowrap">
511 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
512 </th>
513 <?php
514 if (!($cfg['PropertiesNumColumns'] > 1)) {
515 echo ' <th align="center">' . "\n"
516 . ' <b>--</b>' . "\n"
517 . ' </th>' . "\n";
518 if (PMA_MYSQL_INT_VERSION >= 40100) {
519 echo ' <th align="center">' . "\n"
520 . ' &nbsp;<b><dfn title="' . PMA_getCollationDescr($db_collation) . '">' . $db_collation . '</dfn></b>&nbsp;' . "\n"
521 . ' </th>' . "\n";
525 if ($cfg['ShowStats']) {
526 echo "\n";
528 <th align="right" nowrap="nowrap">
529 &nbsp;
530 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
531 </th>
532 <th align="right" nowrap="nowrap">
533 &nbsp;
534 <b><?php echo $overhead_formated . ' ' . $overhead_unit; ?></b>
535 </th>
536 <?php
538 echo "\n";
540 </tr>
542 <?php
543 // Check all tables url
544 $checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db);
545 echo "\n";
547 $basecolspan = 9;
548 if (!($cfg['PropertiesNumColumns'] > 1)) {
549 $basecolspan++;
550 if (PMA_MYSQL_INT_VERSION >= 40100) {
551 $basecolspan++;
555 if ($cfg['ShowStats']) {
556 $basecolspan += 2;
559 <tr>
560 <td colspan="<?php echo $basecolspan; ?>" valign="bottom">
561 <img src="<?php echo $pmaThemeImage .'arrow_'.$text_dir.'.png'; ?>" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
562 <a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
563 <?php echo $strCheckAll; ?></a>
564 &nbsp;/&nbsp;
565 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
566 <?php echo $strUncheckAll; ?></a>
567 <?php if ($overhead_check != '') { ?>
568 &nbsp;/&nbsp;
569 <a href="#" onclick="setCheckboxes('tablesForm', false); <?php echo $overhead_check; ?> return false;">
570 <?php echo $strCheckOverhead; ?></a>
571 <?php } ?>
572 &nbsp;&nbsp;&nbsp;
573 <img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" border="0" width="38" height="1" alt="" />
574 <select name="submit_mult" dir="ltr" onchange="this.form.submit();">
575 <?php
576 echo "\n";
577 echo ' <option value="' . $strWithChecked . '" selected="selected">'
578 . $strWithChecked . '</option>' . "\n";
579 echo ' <option value="' . $strDrop . '" >'
580 . $strDrop . '</option>' . "\n";
581 echo ' <option value="' . $strEmpty . '" >'
582 . $strEmpty . '</option>' . "\n";
583 echo ' <option value="' . $strPrintView . '" >'
584 . $strPrintView . '</option>' . "\n";
585 echo ' <option value="' . $strCheckTable . '" >'
586 . $strCheckTable . '</option>' . "\n";
587 echo ' <option value="' . $strOptimizeTable . '" >'
588 . $strOptimizeTable . '</option>' . "\n";
589 echo ' <option value="' . $strRepairTable . '" >'
590 . $strRepairTable . '</option>' . "\n";
591 echo ' <option value="' . $strAnalyzeTable . '" >'
592 . $strAnalyzeTable . '</option>' . "\n";
594 </select>
595 <script type="text/javascript" language="javascript">
596 <!--
597 // Fake js to allow the use of the <noscript> tag
598 //-->
599 </script>
600 <noscript>
601 <input type="submit" value="<?php echo $strGo; ?>" />
602 </noscript>
603 </td>
604 </tr>
605 </table>
606 <?php
607 if ($cfg['PropertiesNumColumns'] > 1) {
609 </td>
610 </tr>
611 </table>
612 <?php
615 </form>
616 <?php
617 } // end if more than one table
619 echo "\n";
621 <hr />
623 <?php
625 * Work on the database
626 * redesigned 2004-05-08 by mkkeck
629 <!-- DATABASE WORK -->
631 <?php
632 if ($num_tables > 0) {
634 <!-- Printable view of a table -->
635 <table border="0" cellpadding="2" cellspacing="0">
636 <tr><td nowrap="nowrap" colspan="3"><?php
637 echo '<a href="db_printview.php?' . $url_query . '">';
638 if ($cfg['PropertiesIconic']) {
639 echo '<img src="' . $pmaThemeImage . 'b_print.png" border="0" width="16" height="16" hspace="2" align="middle" />';
641 echo $strPrintView . '</a>';
642 ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
643 <?php
644 echo '<a href="./db_datadict.php?' . $url_query . '">';
645 if($cfg['PropertiesIconic']){
646 echo '<img src="' . $pmaThemeImage . 'b_tblanalyse.png" border="0" width="16" height="16" hspace="2" align="middle" />';
648 echo $strDataDict . '</a>';
649 ?></td></tr>
650 <tr><td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr></table>
651 <?php
652 } // end if
654 <table border="0" cellpadding="2" cellspacing="0">
655 <!-- Create a new table -->
656 <form method="post" action="tbl_create.php" onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
657 <tr>
658 <td class="tblHeaders" colspan="3" nowrap="nowrap"><?php
659 echo PMA_generate_common_hidden_inputs($db);
660 if($cfg['PropertiesIconic']){ echo '<img src="' . $pmaThemeImage . 'b_newtbl.png" border="0" width="16" height="16" hspace="2" align="middle" />'; }
661 // if you want navigation:
662 $strDBLink = '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url() . '&amp;db=' . urlencode($GLOBALS['db']) . '">'
663 . htmlspecialchars($GLOBALS['db']) . '</a>';
664 // else use
665 // $strDBLink = htmlspecialchars($db);
666 echo ' ' . sprintf($strCreateNewTable, $strDBLink) . ':&nbsp;' . "\n";
667 echo ' </td></tr>';
668 echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
669 echo ' ' . $strName . ':&nbsp;' . "\n";
670 echo ' </td>';
671 echo ' <td nowrap="nowrap">';
672 echo ' ' . '<input type="text" name="table" maxlength="64" size="30" class="textfield" />';
673 echo ' </td><td>&nbsp;</td></tr>';
674 echo ' <tr bgcolor="'.$cfg['BgcolorOne'].'"><td nowrap="nowrap">';
675 echo ' ' . $strFields . ':&nbsp;' . "\n";
676 echo ' </td>';
677 echo ' <td nowrap="nowrap">';
678 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
679 echo ' </td>';
680 echo ' <td align="right">';
681 echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
683 </td> </tr>
684 </form>
688 <?php
689 if ($cfgRelation['commwork']) {
691 <!-- Alter/Enter db-comment -->
692 <tr><td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr>
694 <tr>
695 <td colspan="3" class="tblHeaders"><?php
696 if ($cfg['PropertiesIconic']) {
697 echo '<img src="' . $pmaThemeImage . 'b_comment.png" border="0" width="16" height="16" hspace="2" align="middle" />';
699 echo $strDBComment;
700 ?></td></tr>
701 <form method="post" action="db_details_structure.php">
702 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
703 <td colspan="2" nowrap="nowrap">
704 <input type="hidden" name="db_comment" value="true" />
705 <?php echo PMA_generate_common_hidden_inputs($db); ?>
706 <input type="text" name="comment" class="textfield" size="30" value="<?php echo (isset($comment) && is_array($comment) ? htmlspecialchars(implode(' ', $comment)) : ''); ?>" /></td><td align="right">
707 <input type="submit" value="<?php echo $strGo; ?>" />
708 </td></tr>
709 </form>
710 <?php
713 <!-- Rename database -->
714 <tr><td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td></tr>
715 <tr><td colspan="3" class="tblHeaders"><?php
716 if ($cfg['PropertiesIconic']) {
717 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
719 echo $strDBRename.':&nbsp;';
720 ?></td></tr>
721 <form method="post" action="db_details_structure.php"
722 onsubmit="return emptyFormElements(this, 'newname')">
723 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><td colspan="2"><?php
724 echo '<input type="hidden" name="db_rename" value="true" />'
725 . PMA_generate_common_hidden_inputs($db);
726 ?><input type="text" name="newname" size="30" class="textfield" value="" /></td>
727 <td align="right"><input type="submit" value="<?php echo $strGo; ?>" /></td>
728 </form></tr>
730 <?php
732 if (PMA_MYSQL_INT_VERSION >= 40101) {
733 // MySQL supports setting default charsets / collations for databases since
734 // version 4.1.1.
735 echo ' <!-- Change database charset -->' . "\n"
736 . ' <tr><td colspan="3"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>' . "\n"
737 . ' <tr><td colspan="3" class="tblHeaders">';
738 if ($cfg['PropertiesIconic']) {
739 echo '<img src="' . $pmaThemeImage . 's_asci.png" border="0" width="16" height="16" hspace="2" align="middle" />';
741 echo ' <label for="select_db_collation">' . $strCollation . '</label>:&nbsp;' . "\n"
742 . ' </td></tr>' . "\n"
743 . ' <form method="post" action="./db_details_structure.php">' . "\n"
744 . ' <tr bgcolor="' . $cfg['BgcolorOne'] . '"><td colspan="2" nowrap="nowrap">'
745 . PMA_generate_common_hidden_inputs($db, $table, 3)
746 . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', 'select_db_collation', $db_collation, FALSE, 3)
747 . ' </td><td align="right">'
748 . ' <input type="submit" name="submitcollation" value="' . $strGo . '" style="vertical-align: middle" />' . "\n"
749 . ' </td></tr>' . "\n"
750 . ' </form>' . "\n"
751 . ' ' . "\n\n";
754 if ($num_tables > 0
755 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
756 echo '<tr><td colspan="3"><img src="' . $GLOBALS['pmaThemeImage'] . 'spacer.png' . '" width="1" height="1" border="0" alt="" /></td></tr>'
757 . '<tr><th colspan="3" class="tblHeadError"><div class="errorhead">' . $strError . '</div></th></tr>'
758 . '<tr><td colspan="3" class="tblError">'
759 . sprintf(wordwrap($strRelationNotWorking,65,'<br />'), '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php?' . $url_query . '">', '</a>')
760 . '</td></tr>';
761 } // end if
763 </table>
765 <form method="post" action="pdf_schema.php">
766 <?php
767 // is this OK to check for 'class' support?
768 if ($num_tables > 0) {
769 $takeaway = $url_query . '&amp;table=' . urlencode($table);
772 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
773 ($num_tables > 0
774 && $cfgRelation['relwork'] && $cfgRelation['commwork']
775 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
776 )) { ?>
777 <hr /><table border="0" cellpadding="2" cellspacing="0">
778 <?php
781 if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
782 <!-- Work on PDF Pages -->
783 <tr>
784 <td colspan="3" class="tblHeaders">
785 <?php
786 if ($cfg['PropertiesIconic']) {
787 echo '<img src="' . $pmaThemeImage . 'b_pdfdoc.png" border="0" width="16" height="16" hspace="2" align="middle" />';
788 } ?>PDF</td>
789 </tr>
791 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
792 <td colspan="3">
793 <?php
794 echo '<a href="pdf_pages.php?' . $takeaway . '">';
795 if ($cfg['PropertiesIconic']) {
796 echo '<img src="' . $pmaThemeImage . 'b_edit.png" border="0" width="16" height="16" hspace="2" align="middle" />';
798 echo ''. $strEditPDFPages . '</a>';
800 </td>
801 </tr>
803 <!-- PDF schema -->
804 <?php
805 // We only show this if we find something in the new pdf_pages table
807 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
808 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
809 $test_rs = PMA_query_as_cu($test_query, NULL, PMA_DBI_QUERY_STORE);
811 if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { ?>
812 <tr bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
813 <td colspan="3">
814 <?php
815 echo PMA_generate_common_hidden_inputs($db);
816 if ($cfg['PropertiesIconic']) {
817 echo '<img src="' . $pmaThemeImage . 'b_view.png" border="0" width="16" height="16" hspace="2" align="middle" />';
819 echo $strDisplayPDF; ?>:&nbsp;
820 </td>
821 </tr>
823 <tr bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
824 <td width="20">&nbsp;</td>
825 <td colspan="2">
826 <label for="pdf_page_number_opt"><?php echo $strPageNumber; ?></label>
827 <select name="pdf_page_number" id="pdf_page_number_opt">
828 <?php
829 while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
830 echo ' <option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>' . "\n";
831 } // end while
832 PMA_DBI_free_result($test_rs);
833 unset($test_rs);
835 </select><br />
837 <input type="checkbox" name="show_grid" id="show_grid_opt" /><label for="show_grid_opt"><?php echo $strShowGrid; ?></label><br />
838 <input type="checkbox" name="show_color" id="show_color_opt" checked="checked" /><label for="show_color_opt"><?php echo $strShowColor; ?></label><br />
839 <input type="checkbox" name="show_table_dimension" id="show_table_dim_opt" /><label for="show_table_dim_opt"><?php echo $strShowTableDimension; ?></label><br />
840 <input type="checkbox" name="all_tab_same_wide" id="all_tab_same_wide" /><label for="all_tab_same_wide"><?php echo $strAllTableSameWidth; ?></label><br />
841 <input type="checkbox" name="with_doc" id="with_doc" checked="checked" /><label for="with_doc"><?php echo $strDataDict; ?></label><br />
843 <label for="orientation_opt"><?php echo $strShowDatadictAs; ?></label>
844 <select name="orientation" id="orientation_opt">
845 <option value="L"><?php echo $strLandscape;?></option>
846 <option value="P"><?php echo $strPortrait;?></option>
847 </select><br />
849 <label for="paper_opt"><?php echo $strPaperSize; ?></label>
850 <select name="paper" id="paper_opt">
851 <?php
852 foreach ($cfg['PDFPageSizes'] AS $key => $val) {
853 echo '<option value="' . $val . '"';
854 if ($val == $cfg['PDFDefaultPageSize']) {
855 echo ' selected="selected"';
857 echo ' >' . $val . '</option>' . "\n";
860 </select>
861 </td>
862 </tr>
864 <tr bgcolor="<?php echo $cfg['BgcolorTwo']; ?>">
865 <td width="20">&nbsp;</td>
866 <td colspan="3" align="right">&nbsp;&nbsp;<input type="submit" value="<?php echo $strGo; ?>" /></td>
867 </tr>
868 <tr>
869 <td colspan="3"><img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>" width="1" height="1" border="0" alt="" /></td>
870 </tr>
871 <?php
872 } // end if
873 } // end if
875 if ($num_tables > 0
876 && $cfgRelation['relwork'] && $cfgRelation['commwork']
877 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
880 <!-- import docSQL files -->
881 <tr bgcolor="<?php echo $cfg['BgcolorOne']; ?>">
882 <td colspan="3">
883 <?php
884 echo '<a href="db_details_importdocsql.php?' . $takeaway . '">';
885 if ($cfg['PropertiesIconic']) {
886 echo '<img src="' . $pmaThemeImage . 'b_docsql.png" border="0" width="16" height="16" hspace="2" align="middle" />';
888 echo $strImportDocSQL . '</a>';
890 </td>
891 </tr>
892 <?php
894 echo "\n";
895 if (($cfgRelation['pdfwork'] && $num_tables > 0) ||
896 ($num_tables > 0
897 && $cfgRelation['relwork'] && $cfgRelation['commwork']
898 && isset($cfg['docSQLDir']) && !empty($cfg['docSQLDir'])
899 )) { ?>
900 </table>
901 </form>
902 <?php
906 * Displays the footer
908 echo "\n";
909 require_once('./footer.inc.php');