3 // vim: expandtab sw=4 ts=4 sts=4:
7 * Prepares the tables list if the user where not redirected to this script
8 * because there is no table in the database ($is_info is TRUE)
10 if (empty($is_info)) {
11 include('./db_details_common.php3');
12 $url_query .= '&goto=db_details_structure.php3';
14 // Drops/deletes multiple tables if required
15 if ((!empty($submit_mult) && isset($selected_tbl))
16 ||
isset($mult_btn)) {
17 $action = 'db_details_structure.php3';
18 include('./mult_submits.inc.php3');
21 // Gets the database structure
22 $sub_part = '_structure';
23 include('./db_details_db_info.php3');
29 * Settings for relations stuff
31 require('./libraries/relation.lib.php3');
32 $cfgRelation = PMA_getRelationsParam();
37 * Displays the tables list
45 if ($num_tables == 0) {
46 echo $strNoTablesFound . "\n";
49 // 2. Shows table informations on mysql >= 3.23.03 - staybyte - 11 June 2001
50 else if (PMA_MYSQL_INT_VERSION
>= 32303) {
52 <form method
="post" action
="db_details_structure.php3" name
="tablesForm">
53 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
55 <table border
="<?php echo $cfg['Border']; ?>">
58 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
59 <th colspan
="6"><?php
echo $strAction; ?
></th
>
60 <th
><?php
echo $strRecords; ?
></th
>
61 <th
><?php
echo $strType; ?
></th
>
63 if ($cfg['ShowStats']) {
64 echo '<th>' . $strSize . '</th>';
70 $i = $sum_entries = 0;
71 (double) $sum_size = 0;
72 $checked = (!empty($checkall) ?
' checked="checked"' : '');
73 while (list($keyname, $sts_data) = each($tables)) {
74 $table = $sts_data['Name'];
75 $table_encoded = urlencode($table);
76 $table_name = htmlspecialchars($table);
78 // Sets parameters for links
79 $tbl_url_query = $url_query . '&table=' . $table_encoded;
80 $bgcolor = ($i++ %
2) ?
$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
84 <td align
="center" bgcolor
="<?php echo $bgcolor; ?>">
85 <input type
="checkbox" name
="selected_tbl[]" value
="<?php echo $table_encoded; ?>" id
="checkbox_tbl_<?php echo $i; ?>"<?php
echo $checked; ?
> />
87 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
88  
;<b
><label
for="checkbox_tbl_<?php echo $i; ?>"><?php
echo $table_name; ?
></label
> 
;</b
> 
;
90 <td bgcolor
="<?php echo $bgcolor; ?>">
92 if (!empty($sts_data['Rows'])) {
93 echo '<a href="sql.php3?' . $tbl_url_query . '&sql_query='
94 . urlencode('SELECT * FROM ' . PMA_backquote($table))
95 . '&pos=0">' . $strBrowse . '</a>';
101 <td bgcolor
="<?php echo $bgcolor; ?>">
103 if (!empty($sts_data['Rows'])) {
104 echo '<a href="tbl_select.php3?' . $tbl_url_query . '">'
105 . $strSelect . '</a>';
111 <td bgcolor
="<?php echo $bgcolor; ?>">
112 <a href
="tbl_change.php3?<?php echo $tbl_url_query; ?>">
113 <?php
echo $strInsert; ?
></a
>
115 <td bgcolor
="<?php echo $bgcolor; ?>">
116 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>">
117 <?php
echo $strProperties; ?
></a
>
119 <td bgcolor
="<?php echo $bgcolor; ?>">
120 <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))); ?>"
121 onclick
="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
122 <?php
echo $strDrop; ?
></a
>
124 <td bgcolor
="<?php echo $bgcolor; ?>">
126 if (!empty($sts_data['Rows'])) {
127 echo '<a href="sql.php3?' . $tbl_url_query
129 if (PMA_MYSQL_INT_VERSION
>= 40000) {
130 echo urlencode('TRUNCATE ' . PMA_backquote($table))
132 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
133 . '" onclick="return confirmLink(this, \'TRUNCATE ';
135 echo urlencode('DELETE FROM ' . PMA_backquote($table))
137 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
138 . '" onclick="return confirmLink(this, \'DELETE FROM ';
140 echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
149 // loic1: Patch from Joshua Nye <josh at boxcarmedia.com> to get valid
150 // statistics whatever is the table type
151 if (isset($sts_data['Rows'])) {
152 // MyISAM, ISAM or Heap table: Row count, data size and index size
154 if (isset($sts_data['Type']) && ereg('^(MyISAM|ISAM|HEAP)$', $sts_data['Type'])) {
155 if ($cfg['ShowStats']) {
156 $tblsize = doubleval($sts_data['Data_length']) +
doubleval($sts_data['Index_length']);
157 $sum_size +
= $tblsize;
158 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
160 $sum_entries +
= $sts_data['Rows'];
161 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
164 // InnoDB table: Row count is not accurate but data and index
166 else if (isset($sts_data['Type']) && $sts_data['Type'] == 'InnoDB') {
167 if ($cfg['ShowStats']) {
168 $tblsize = $sts_data['Data_length'] +
$sts_data['Index_length'];
169 $sum_size +
= $tblsize;
170 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ?
1 : 0);
172 //$display_rows = ' - ';
173 // get row count with another method
174 $local_query = 'SELECT COUNT(*) AS count FROM '
175 . PMA_backquote($db) . '.'
176 . PMA_backquote($table);
177 $table_info_result = PMA_mysql_query($local_query)
178 or PMA_mysqlDie('', $local_query, '', $err_url_0);
179 $row_count = PMA_mysql_result($table_info_result, 0, 'count');
180 $sum_entries +
= $row_count;
181 $display_rows = number_format($row_count, 0, $number_decimal_separator, $number_thousands_separator);
184 // Merge or BerkleyDB table: Only row count is accurate.
185 else if (isset($sts_data['Type']) && ereg('^(MRG_MyISAM|BerkeleyDB)$', $sts_data['Type'])) {
186 if ($cfg['ShowStats']) {
187 $formated_size = ' - ';
190 $sum_entries +
= $sts_data['Rows'];
191 $display_rows = number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator);
194 // Unknown table type.
196 if ($cfg['ShowStats']) {
197 $formated_size = 'unknown';
200 $display_rows = 'unknown';
203 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>">
205 echo "\n" . ' ' . $display_rows . "\n";
208 <td bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
209  
;<?php
echo (isset($sts_data['Type']) ?
$sts_data['Type'] : ' '); ?
> 
;
212 if ($cfg['ShowStats']) {
215 <td align
="right" bgcolor
="<?php echo $bgcolor; ?>" nowrap
="nowrap">
217 <a href
="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php
echo $formated_size . ' ' . $unit; ?
></a
>
224 <td colspan
="3" align
="center" bgcolor
="<?php echo $bgcolor; ?>">
225 <?php
echo $strInUse . "\n"; ?
>
235 if ($cfg['ShowStats']) {
236 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
242 <th align
="center" nowrap
="nowrap">
243  
;<b
><?php
echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?
></b
> 
;
245 <th colspan
="6" align
="center">
246 <b
><?php
echo $strSum; ?
></b
>
248 <th align
="right" nowrap
="nowrap">
249 <b
><?php
echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?
></b
>
255 if ($cfg['ShowStats']) {
258 <th align
="right" nowrap
="nowrap">
260 <b
><?php
echo $sum_formated . ' ' . $unit; ?
></b
>
269 // Check all tables url
270 $checkall_url = 'db_details_structure.php3?' . PMA_generate_common_url($db);
274 <td colspan
="<?php echo (($cfg['ShowStats']) ? '11' : '10'); ?>" valign
="bottom">
275 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
276 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
277 <?php
echo $strCheckAll; ?
></a
>
279 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
280 <?php
echo $strUncheckAll; ?
></a
>
282 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
283 <select name
="submit_mult" dir
="ltr" onchange
="this.form.submit();">
286 echo ' <option value="' . $strWithChecked . '" selected="selected">'
287 . $strWithChecked . '</option>' . "\n";
288 echo ' <option value="' . $strDrop . '" >'
289 . $strDrop . '</option>' . "\n";
290 echo ' <option value="' . $strEmpty . '" >'
291 . $strEmpty . '</option>' . "\n";
292 echo ' <option value="' . $strPrintView . '" >'
293 . $strPrintView . '</option>' . "\n";
294 echo ' <option value="' . $strOptimizeTable . '" >'
295 . $strOptimizeTable . '</option>' . "\n";
296 echo ' <option value="' . $strRepairTable . '" >'
297 . $strRepairTable . '</option>' . "\n";
300 <script type
="text/javascript" language
="javascript">
302 // Fake js to allow the use of the <noscript> tag
306 <input type
="submit" value
="<?php echo $strGo; ?>" />
314 } // end case mysql >= 3.23.03
316 // 3. Shows tables list mysql < 3.23.03
321 <form action
="db_details_structure.php3">
322 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
324 <table border
="<?php echo $cfg['Border']; ?>">
327 <th
> 
;<?php
echo $strTable; ?
> 
;</th
>
328 <th colspan
="6"><?php
echo $strAction; ?
></th
>
329 <th
><?php
echo $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?' . PMA_generate_common_url($db);
382 <img src
="./images/arrow_<?php echo $text_dir; ?>.gif" border
="0" width
="38" height
="22" alt
="<?php echo $strWithChecked; ?>" />
383 <a href
="<?php echo $checkall_url; ?>&checkall=1" onclick
="setCheckboxes('tablesForm', true); return false;">
384 <?php
echo $strCheckAll; ?
></a
>
386 <a href
="<?php echo $checkall_url; ?>" onclick
="setCheckboxes('tablesForm', false); return false;">
387 <?php
echo $strUncheckAll; ?
></a
>
393 <img src
="./images/spacer.gif" border
="0" width
="38" height
="1" alt
="" />
394 <i
><?php
echo $strWithChecked; ?
></i
> 
; 
;
395 <input type
="submit" name
="submit_mult" value
="<?php echo $strDrop; ?>" />
396  
;<?php
$strOr . "\n"; ?
> 
;
397 <input type
="submit" name
="submit_mult" value
="<?php echo $strEmpty; ?>" />
404 } // end case mysql < 3.23.03
413 * Work on the database
416 <!-- DATABASE WORK
-->
420 if ($num_tables > 0) {
422 <!-- Printable view of a table
-->
424 <div style
="margin-bottom: 10px"><a href
="db_printview.php3?<?php echo $url_query; ?>"><?php
echo $strPrintView; ?
></a
></div
>
427 <div style
="margin-bottom: 10px"><a href
="./db_datadict.php3?<?php echo $url_query; ?>"><?php
echo $strDataDict; ?
></a
></div
>
433 <!-- Create a
new table
-->
435 <form method
="post" action
="tbl_create.php3"
436 onsubmit
="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
437 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
439 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . ' :<br />' . "\n";
440 echo ' ' . $strName . ' : ' . "\n";
441 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
442 echo ' ' . '<br />' . "\n";
443 echo ' ' . $strFields . ' : ' . "\n";
444 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
445 echo ' ' . ' <input type="submit" value="' . $strGo . '" />' . "\n";
452 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
454 echo ' <div style="margin-bottom: 10px">' . "\n";
455 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
456 $url_to_goto = '<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php3?' . $url_query . '">';
457 echo ' ' . sprintf($strRelationNotWorking, $url_to_goto, '</a>') . "\n";
458 echo ' </div>' . "\n";
459 echo ' </li>' . "\n";
462 // is this OK to check for 'class' support?
463 $takeaway = $url_query . '&table=' . urlencode($table);
464 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
466 <!-- Work on PDF Pages
-->
468 <div style
="margin-bottom: 10px"><a href
="pdf_pages.php3?<?php echo $takeaway; ?>"><?php
echo $strEditPDFPages; ?
></a
></div
>
473 // We only show this if we find something in the new pdf_pages table
475 // Note the trailing slash in the action target, this is intentional
477 $test_query = 'SELECT * FROM ' . PMA_backquote($cfgRelation['pdf_pages'])
478 . ' WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'';
479 $test_rs = PMA_query_as_cu($test_query);
480 if ($test_rs && mysql_num_rows($test_rs) > 0) {
484 <form method
="post" action
="pdf_schema.php3/">
485 <?php
echo PMA_generate_common_hidden_inputs($db); ?
>
486 <?php
echo $strDisplayPDF; ?
> 
;:<br
/>
487 <?php
echo $strPageNumber; ?
> 
;
488 <select name
="pdf_page_number">
490 while ($pages = @PMA_mysql_fetch_array
($test_rs)) {
492 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
497 <input type
="checkbox" name
="show_grid" id
="show_grid_opt" />
498 <label
for="show_grid_opt"><?php
echo $strShowGrid; ?
></label
><br
/>
499 <input type
="checkbox" name
="show_color" id
="show_color_opt" checked
="checked" />
500 <label
for="show_color_opt"><?php
echo $strShowColor; ?
></label
><br
/>
501 <input type
="checkbox" name
="show_table_dimension" id
="show_table_dim_opt" />
502 <label
for="show_table_dim_opt"><?php
echo $strShowTableDimension; ?
></label
><br
/>
503 <input type
="checkbox" name
="all_tab_same_wide" id
="all_tab_same_wide" />
504 <label
for="all_tab_same_wide"><?php
echo $strAllTableSameWidth; ?
></label
> <br
/>
505 <input type
="checkbox" name
="with_doc" id
="with_doc" checked
="checked" />
506 <label
for="with_doc"><?php
echo $strDataDict; ?
></label
> <br
/>
507 <?php
echo $strShowDatadictAs; ?
>
508 <select name
="orientation">
509 <option value
="L"><?php
echo $strLandscape;?
></option
>
510 <option value
="P"><?php
echo $strPortrait;?
></option
>
512  
; 
;<input type
="submit" value
="<?php echo $strGo; ?>" />
520 && $cfgRelation['relwork'] && $cfgRelation['commwork']) {
522 <!-- import docSQL files
-->
524 <div style
="margin-bottom: 10px"><a href
="db_details_importdocsql.php3?<?php echo $takeaway . '">' . $strImportDocSQL; ?></a></div>
532 * Displays the footer
535 require('./footer
.inc
.php3
');