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 = ' - ';
175 // get row count with another method
176 $local_query = 'SELECT COUNT(*) AS count FROM '
177 . PMA_backquote($db) . '.'
178 . PMA_backquote($table);
179 $table_info_result = PMA_mysql_query($local_query)
180 or PMA_mysqlDie('', $local_query, '', $err_url_0);
181 $row_count = PMA_mysql_result($table_info_result, 0, 'count');
182 $sum_entries +
= $row_count;
183 $display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator);
186 // Merge or BerkleyDB table: Only row count is accurate.
187 else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
188 if ($cfg['ShowStats']) {
189 $formated_size = ' - ';
192 $sum_entries +
= $sts_data['Rows'];
193 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
196 // Unknown table type.
198 if ($cfg['ShowStats']) {
199 $formated_size = 'unknown';
202 $display_rows = 'unknown';
205 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
207 echo "\n" . ' ' . $display_rows . "\n";
210 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
211  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
214 if ($cfg['ShowStats']) {
217 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
219 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php
echo $formated_size . ' ' . $unit; ?
></a
>
226 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
227 <?php
echo $strInUse . "\n"; ?
>
237 if ($cfg['ShowStats']) {
238 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
244 <th align
="center" nowrap
="nowrap">
245  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
247 <th colspan
="6" align
="center">
248 <b
><?php
echo $strSum; ?
></b
>
250 <th align
="right" nowrap
="nowrap">
251 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
257 if ($cfg['ShowStats']) {
260 <th align
="right" nowrap
="nowrap">
262 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
271 // Check all tables url
272 $checkall_url = 'db_details_structure.php3'
274 . '&convcharset=' . $convcharset
275 . '&server=' . $server
276 . '&db=' . urlencode($db);
280 <td colspan
="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign
="bottom">
281 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
282 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
283 <?php
echo $strCheckAll; ?
></a
>
285 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
286 <?php
echo $strUncheckAll; ?
></a
>
288 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
289 <select name
="submit_mult" dir
="ltr" onchange
="this.form.submit();">
292 echo ' <option value="' . $strWithChecked . '" selected="selected">'
293 . $strWithChecked . '</option>' . "\n";
294 echo ' <option value="' . $strDrop . '" >'
295 . $strDrop . '</option>' . "\n";
296 echo ' <option value="' . $strEmpty . '" >'
297 . $strEmpty . '</option>' . "\n";
298 echo ' <option value="' . $strPrintView . '" >'
299 . $strPrintView . '</option>' . "\n";
300 echo ' <option value="' . $strOptimizeTable . '" >'
301 . $strOptimizeTable . '</option>' . "\n";
302 echo ' <option value="' . $strRepairTable . '" >'
303 . $strRepairTable . '</option>' . "\n";
306 <script type
="text/javascript" language
="javascript">
308 // Fake js to allow the use of the <noscript> tag
312 <input type
="submit" value
="<?php echo $strGo; ?>" />
320 } // end case mysql >= 3.23.03
322 // 3. Shows tables list mysql < 3.23.03
327 <form action
="db_details_structure.php3">
328 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
329 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
330 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
331 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
333 <table border
="<?php echo $cfg['Border']; ?>">
336 <th
> 
;<?php
echo ucfirst($strTable); ?
> 
;</th
>
337 <th colspan
="6"><?php
echo ucfirst($strAction); ?
></th
>
338 <th
><?php
echo ucfirst($strRecords); ?
></th
>
341 $checked = (!empty($checkall) ?
' checked="checked"' : '');
342 while ($i < $num_tables) {
343 $table = $tables[$i];
344 $table_encoded = urlencode($table);
345 $table_name = htmlspecialchars($table);
347 // Sets parameters for links
348 $tbl_url_query = $url_query . '&table=' . $table_encoded;
349 $bgcolor = ($i %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
353 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
354 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
356 <td bgcolor
="<?php echo $bgcolor; ?>" class="data">
357 <b
> 
;<label
for="checkbox_tbl_<?php echo $i; ?>"><?php
echo $table_name; ?
></label
> 
;</b
>
359 <td bgcolor
="<?php echo $bgcolor; ?>">
360 <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
>
362 <td bgcolor
="<?php echo $bgcolor; ?>">
363 <a href
="tbl_select.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strSelect; ?
></a
>
365 <td bgcolor
="<?php echo $bgcolor; ?>">
366 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strInsert; ?
></a
>
368 <td bgcolor
="<?php echo $bgcolor; ?>">
369 <a href
="tbl_properties.php3?<?php echo $tbl_url_query; ?>"><?php
echo $strProperties; ?
></a
>
371 <td bgcolor
="<?php echo $bgcolor; ?>">
372 <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
>
374 <td bgcolor
="<?php echo $bgcolor; ?>">
375 <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
>
377 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
378 <?php
PMA_countRecords($db, $table); echo "\n"; ?
>
386 // Check all tables url
387 $checkall_url = 'db_details_structure.php3'
389 . '&convcharset=' . $convcharset
390 . '&server=' . $server
391 . '&db=' . urlencode($db);
395 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
396 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
397 <?php
echo $strCheckAll; ?
></a
>
399 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
400 <?php
echo $strUncheckAll; ?
></a
>
406 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
407 <i
><?php
echo $strWithChecked; ?
></i
> 
; 
;
408 <input type
="submit" name
="submit_mult" value
="<?php echo $strDrop; ?>" />
409  
;<?php
$strOr . "\n"; ?
> 
;
410 <input type
="submit" name
="submit_mult" value
="<?php echo $strEmpty; ?>" />
417 } // end case mysql < 3.23.03
426 * Work on the database
429 <!-- DATABASE WORK
-->
433 if ($num_tables > 0) {
435 <!-- Printable view of a table
-->
437 <div style
="margin-bottom: 10px"><a href
="db_printview.php3?<?php echo $url_query; ?>"><?php
echo $strPrintView; ?
></a
></div
>
443 <!-- Create a
new table
-->
445 <form method
="post" action
="tbl_create.php3"
446 onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
447 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
448 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
449 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
450 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
452 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . ' :<br />' . "\n";
453 echo ' ' . $strName . ' : ' . "\n";
454 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
455 echo ' ' . '<br />' . "\n";
456 echo ' ' . $strFields . ' : ' . "\n";
457 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
458 echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
465 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
467 echo ' <div style="margin-bottom: 10px">' . "\n";
468 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
469 $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php3?' . $url_query . '">';
470 echo ' ' . sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
471 echo ' </div>' . "\n";
472 echo ' </li>' . "\n";
475 // is this OK to check for 'class' support?
476 $takeaway = $url_query . '&table=' . urlencode($table);
477 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
479 <!-- Work on PDF Pages
-->
481 <div style
="margin-bottom: 10px"><a href
="pdf_pages.php3?<?php echo $takeaway; ?>"><?php
echo $strEditPDFPages; ?
></a
></div
>
486 // We only show this if we find something in the new pdf_pages table
487 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
488 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
489 $test_rs = PMA_query_as_cu($test_query);
490 if ($test_rs && mysql_num_rows($test_rs) > 0) {
494 <form method
="post" action
="pdf_schema.php3">
495 <input type
="hidden" name
="server" value
="<?php echo $server; ?>" />
496 <input type
="hidden" name
="lang" value
="<?php echo $lang; ?>" />
497 <input type
="hidden" name
="convcharset" value
="<?php echo $convcharset; ?>" />
498 <input type
="hidden" name
="db" value
="<?php echo $db; ?>" />
499 <?php
echo $strDisplayPDF; ?
> 
;:<br
/>
500 <?php
echo $strPageNumber; ?
> 
;
501 <select name
="pdf_page_number">
503 while ($pages = @PMA_mysql_fetch_array
($test_rs)) {
505 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
510 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
511 <label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
512 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
513 <label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
514 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
515 <label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
516 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" />
517 <label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
>
518  
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" />
526 && $cfgRelation['relwork'] && $cfgRelation['commwork']) {
528 <!-- import docSQL files
-->
530 <div style
="margin-bottom: 10px"><a href
="db_details_importdocsql.php3?<?php echo $takeaway . '">' . $strImportDocSQL; ?></a></div>
538 * Displays the footer
541 require('./footer
.inc
.php3
');