6 * Prepares the tables list if the user where not redirected to this script
7 * because there is no table in the database ($is_info is TRUE)
10 include('./db_details_common.php3');
11 $url_query .= '&goto=db_details_structure.php3';
13 // Drops/deletes multiple tables if required
14 if ((!empty($submit_mult) && isset($selected_tbl))
15 ||
isset($mult_btn)) {
16 $action = 'db_details_structure.php3';
17 include('./mult_submits.inc.php3');
20 // Gets the database structure
21 $sub_part = '_structure';
22 include('./db_details_db_info.php3');
28 * Settings for relations stuff
30 require('./libraries/relation.lib.php3');
31 $cfgRelation = PMA_getRelationsParam();
36 * Displays the tables list
44 if ($num_tables == 0) {
45 echo $strNoTablesFound . "\n";
48 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
49 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
51 <form method
="post" action
="db_details_structure.php3" name
="tablesForm">
52 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
53 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
54 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
55 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
57 <table border
="<?php echo $cfg['Border']; ?>">
60 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
61 <th colspan
="6"><?php
echo ucfirst($strAction); ?
></th
>
62 <th
><?php
echo ucfirst($strRecords); ?
></th
>
63 <th
><?php
echo ucfirst($strType); ?
></th
>
65 if ($cfg['ShowStats']) {
66 echo '<th>' . ucfirst($strSize) . '</th>';
72 $i = $sum_entries = 0;
73 (double) $sum_size = 0;
74 $checked = (!empty($checkall) ?
' checked="checked"' : '');
75 while (list($keyname, $sts_data) = each($tables)) {
76 $table = $sts_data['Name'];
77 $table_encoded = urlencode($table);
78 $table_name = htmlspecialchars($table);
80 // Sets parameters for links
81 $tbl_url_query = $url_query . '&table=' . $table_encoded;
82 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
86 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
87 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
89 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
90  
;<b
><label
for="checkbox_tbl_<?php echo $i; ?>"><?php
echo $table_name; ?
></label
> 
;</b
> 
;
92 <td bgcolor
="<?php echo $bgcolor; ?>">
94 if (!empty($sts_data['Rows'])) {
95 echo '<a href="sql.php3?' . $tbl_url_query . '&sql_query='
96 . urlencode('SELECT * FROM ' . PMA_backquote($table))
97 . '&pos=0">' . $strBrowse . '</a>';
103 <td bgcolor
="<?php echo $bgcolor; ?>">
105 if (!empty($sts_data['Rows'])) {
106 echo '<a href="tbl_select.php3?' . $tbl_url_query . '">'
107 . $strSelect . '</a>';
113 <td bgcolor
="<?php echo $bgcolor; ?>">
114 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>">
115 <?php
echo $strInsert; ?
></a
>
117 <td bgcolor
="<?php echo $bgcolor; ?>">
118 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>">
119 <?php
echo $strProperties; ?
></a
>
121 <td bgcolor
="<?php echo $bgcolor; ?>">
122 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
123 onclick
="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
124 <?php
echo $strDrop; ?
></a
>
126 <td bgcolor
="<?php echo $bgcolor; ?>">
128 if (!empty($sts_data['Rows'])) {
129 echo '<a href="sql.php3?' . $tbl_url_query
131 if (PMA_MYSQL_INT_VERSION
>= 40000) {
132 echo urlencode('TRUNCATE ' . PMA_backquote($table))
134 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
135 . '" onclick="return confirmLink(this, \'TRUNCATE ';
137 echo urlencode('DELETE FROM ' . PMA_backquote($table))
139 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
140 . '" onclick="return confirmLink(this, \'DELETE FROM ';
142 echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
151 // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
152 // statistics whatever is the table type
153 if (isset($sts_data['Rows'])) {
154 // MyISAM, ISAM or Heap table: Row count, data size and index size
156 if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
157 if ($cfg['ShowStats']) {
158 $tblsize = doubleval($sts_data['Data_length']) +
doubleval($sts_data['Index_length']);
159 $sum_size +
= $tblsize;
160 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
162 $sum_entries +
= $sts_data['Rows'];
163 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
166 // InnoDB table: Row count is not accurate but data and index
168 else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
169 if ($cfg['ShowStats']) {
170 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
171 $sum_size +
= $tblsize;
172 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
174 $display_rows = ' - ';
177 // Merge or BerkleyDB table: Only row count is accurate.
178 else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
179 if ($cfg['ShowStats']) {
180 $formated_size = ' - ';
183 $sum_entries +
= $sts_data['Rows'];
184 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
187 // Unknown table type.
189 if ($cfg['ShowStats']) {
190 $formated_size = 'unknown';
193 $display_rows = 'unknown';
196 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
198 echo "\n" . ' ' . $display_rows . "\n";
201 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
202  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
205 if ($cfg['ShowStats']) {
208 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
210 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php
echo $formated_size . ' ' . $unit; ?
></a
>
217 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
218 <?php
echo $strInUse . "\n"; ?
>
228 if ($cfg['ShowStats']) {
229 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
235 <th align
="center" nowrap
="nowrap">
236  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
238 <th colspan
="6" align
="center">
239 <b
><?php
echo $strSum; ?
></b
>
241 <th align
="right" nowrap
="nowrap">
242 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
248 if ($cfg['ShowStats']) {
251 <th align
="right" nowrap
="nowrap">
253 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
262 // Check all tables url
263 $checkall_url = 'db_details_structure.php3'
265 . '&convcharset=' . $convcharset
266 . '&server=' . $server
267 . '&db=' . urlencode($db);
271 <td colspan
="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign
="bottom">
272 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
273 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
274 <?php
echo $strCheckAll; ?
></a
>
276 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
277 <?php
echo $strUncheckAll; ?
></a
>
279 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
280 <select name
="submit_mult" dir
="ltr" onchange
="this.form.submit();">
283 echo ' <option value="' . $strWithChecked . '" selected="selected">'
284 . $strWithChecked . '</option>' . "\n";
285 echo ' <option value="' . $strDrop . '" >'
286 . $strDrop . '</option>' . "\n";
287 echo ' <option value="' . $strEmpty . '" >'
288 . $strEmpty . '</option>' . "\n";
289 echo ' <option value="' . $strPrintView . '" >'
290 . $strPrintView . '</option>' . "\n";
291 echo ' <option value="' . $strOptimizeTable . '" >'
292 . $strOptimizeTable . '</option>' . "\n";
293 echo ' <option value="' . $strRepairTable . '" >'
294 . $strRepairTable . '</option>' . "\n";
297 <script type
="text/javascript" language
="javascript">
299 // Fake js to allow the use of the <noscript> tag
303 <input type
="submit" value
="<?php echo $strGo; ?>" />
311 } // end case mysql >= 3.23.03
313 // 3. Shows tables list mysql < 3.23.03
318 <form action
="db_details_structure.php3">
319 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
320 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
321 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
322 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
324 <table border
="<?php echo $cfg['Border']; ?>">
327 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
328 <th colspan
="6"><?php
echo ucfirst($strAction); ?
></th
>
329 <th
><?php
echo ucfirst($strRecords); ?
></th
>
332 $checked = (!empty($checkall) ?
' checked="checked"' : '');
333 while ($i < $num_tables) {
334 $table = $tables[$i];
335 $table_encoded = urlencode($table);
336 $table_name = htmlspecialchars($table);
338 // Sets parameters for links
339 $tbl_url_query = $url_query . '&table=' . $table_encoded;
340 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
344 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
345 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
347 <td bgcolor
="<?php echo $bgcolor; ?>" class="data">
348 <b
> 
;<label
for="checkbox_tbl_<?php echo $i; ?>"><?php
echo $table_name; ?
></label
> 
;</b
>
350 <td bgcolor
="<?php echo $bgcolor; ?>">
351 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0"><?php
echo $strBrowse; ?
></a
>
353 <td bgcolor
="<?php echo $bgcolor; ?>">
354 <a href
="tbl_select.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strSelect; ?
></a
>
356 <td bgcolor
="<?php echo $bgcolor; ?>">
357 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strInsert; ?
></a
>
359 <td bgcolor
="<?php echo $bgcolor; ?>">
360 <a href
="tbl_properties.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strProperties; ?
></a
>
362 <td bgcolor
="<?php echo $bgcolor; ?>">
363 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php
echo $strDrop; ?
></a
>
365 <td bgcolor
="<?php echo $bgcolor; ?>">
366 <a href
="sql.php3?<?php echo $tbl_url_query; ?>&sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php
echo $strEmpty; ?
></a
>
368 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
369 <?php
PMA_countRecords($db, $table); echo "\n"; ?
>
377 // Check all tables url
378 $checkall_url = 'db_details_structure.php3'
380 . '&convcharset=' . $convcharset
381 . '&server=' . $server
382 . '&db=' . urlencode($db);
386 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
387 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
388 <?php
echo $strCheckAll; ?
></a
>
390 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
391 <?php
echo $strUncheckAll; ?
></a
>
397 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
398 <i
><?php
echo $strWithChecked; ?
></i
> 
; 
;
399 <input type
="submit" name
="submit_mult" value
="<?php echo $strDrop; ?>" />
400  
;<?php
$strOr . "\n"; ?
> 
;
401 <input type
="submit" name
="submit_mult" value
="<?php echo $strEmpty; ?>" />
408 } // end case mysql < 3.23.03
417 * Work on the database
420 <!-- DATABASE WORK
-->
424 if ($num_tables > 0) {
426 <!-- Printable view of a table
-->
428 <div style
="margin-bottom: 10px"><a href
="db_printview.php3?<?php echo $url_query; ?>"><?php
echo $strPrintView; ?
></a
></div
>
434 <!-- Create a
new table
-->
436 <form method
="post" action
="tbl_create.php3"
437 onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
438 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
439 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
440 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
441 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
443 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . ' :<br />' . "\n";
444 echo ' ' . $strName . ' : ' . "\n";
445 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
446 echo ' ' . '<br />' . "\n";
447 echo ' ' . $strFields . ' : ' . "\n";
448 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
449 echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
456 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
458 echo ' <div style="margin-bottom: 10px">' . "\n";
459 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
460 $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php3?' . $url_query . '">';
461 echo ' ' . sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
462 echo ' </div>' . "\n";
463 echo ' </li>' . "\n";
466 // is this OK to check for 'class' support?
467 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
468 $takeaway = $url_query . '&table=' . urlencode($table);
470 <!-- Work on PDF Pages
-->
472 <div style
="margin-bottom: 10px"><a href
="pdf_pages.php3?<?php echo $takeaway; ?>"><?php
echo $strEditPDFPages; ?
></a
></div
>
477 // We only show this if we find something in the new pdf_pages table
478 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
479 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
480 $test_rs = PMA_query_as_cu($test_query);
481 if ($test_rs && mysql_num_rows($test_rs) > 0) {
485 <form method
="post" action
="pdf_schema.php3">
486 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
487 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
488 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
489 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
490 <?php
echo $strDisplayPDF; ?
> 
;:<br
/>
491 <?php
echo $strPageNumber; ?
> 
;
492 <select name
="pdf_page_number">
494 while ($pages = @PMA_mysql_fetch_array
($test_rs)) {
496 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
501 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
502 <label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
503 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
504 <label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
505 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
506 <label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
507 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" />
508 <label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
>
509  
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" />
520 * Displays the footer
523 require('./footer.inc.php3');