GIF -> PNG
[phpmyadmin/crack.git] / db_details_structure.php3
blob44f4d22cbfac4249b5c7d75e54a9d3f11cb9e23f
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
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)
9 */
10 if (empty($is_info)) {
11 include('./db_details_common.php3');
12 $url_query .= '&amp;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');
24 echo "\n";
28 /**
29 * Settings for relations stuff
31 require('./libraries/relation.lib.php3');
32 $cfgRelation = PMA_getRelationsParam();
36 /**
37 * Displays the tables list
41 <!-- TABLE LIST -->
43 <?php
44 // 1. No tables
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']; ?>">
56 <tr>
57 <td></td>
58 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
59 <th colspan="6"><?php echo $strAction; ?></th>
60 <th><?php echo $strRecords; ?></th>
61 <th><?php echo $strType; ?></th>
62 <?php
63 if ($cfg['ShowStats']) {
64 echo '<th>' . $strSize . '</th>';
66 echo "\n";
68 </tr>
69 <?php
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 . '&amp;table=' . $table_encoded;
80 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
81 echo "\n";
83 <tr>
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; ?> />
86 </td>
87 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
88 &nbsp;<b><label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>&nbsp;
89 </td>
90 <td bgcolor="<?php echo $bgcolor; ?>">
91 <?php
92 if (!empty($sts_data['Rows'])) {
93 echo '<a href="sql.php3?' . $tbl_url_query . '&amp;sql_query='
94 . urlencode('SELECT * FROM ' . PMA_backquote($table))
95 . '&amp;pos=0">' . $strBrowse . '</a>';
96 } else {
97 echo $strBrowse;
100 </td>
101 <td bgcolor="<?php echo $bgcolor; ?>">
102 <?php
103 if (!empty($sts_data['Rows'])) {
104 echo '<a href="tbl_select.php3?' . $tbl_url_query . '">'
105 . $strSelect . '</a>';
106 } else {
107 echo $strSelect;
110 </td>
111 <td bgcolor="<?php echo $bgcolor; ?>">
112 <a href="tbl_change.php3?<?php echo $tbl_url_query; ?>">
113 <?php echo $strInsert; ?></a>
114 </td>
115 <td bgcolor="<?php echo $bgcolor; ?>">
116 <a href="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>">
117 <?php echo $strProperties; ?></a>
118 </td>
119 <td bgcolor="<?php echo $bgcolor; ?>">
120 <a href="sql.php3?<?php echo $tbl_url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;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>
123 </td>
124 <td bgcolor="<?php echo $bgcolor; ?>">
125 <?php
126 if (!empty($sts_data['Rows'])) {
127 echo '<a href="sql.php3?' . $tbl_url_query
128 . '&amp;sql_query=';
129 if (PMA_MYSQL_INT_VERSION >= 40000) {
130 echo urlencode('TRUNCATE ' . PMA_backquote($table))
131 . '&amp;zero_rows='
132 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
133 . '" onclick="return confirmLink(this, \'TRUNCATE ';
134 } else {
135 echo urlencode('DELETE FROM ' . PMA_backquote($table))
136 . '&amp;zero_rows='
137 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
138 . '" onclick="return confirmLink(this, \'DELETE FROM ';
140 echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
141 } else {
142 echo $strEmpty;
145 </td>
146 <?php
147 echo "\n";
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
153 // is accurate.
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
165 // sizes are.
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 = '&nbsp;-&nbsp;';
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 = '&nbsp;-&nbsp;';
188 $unit = '';
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.
195 else {
196 if ($cfg['ShowStats']) {
197 $formated_size = 'unknown';
198 $unit = '';
200 $display_rows = 'unknown';
203 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
204 <?php
205 echo "\n" . ' ' . $display_rows . "\n";
207 </td>
208 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
209 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
210 </td>
211 <?php
212 if ($cfg['ShowStats']) {
213 echo "\n";
215 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
216 &nbsp;&nbsp;
217 <a href="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
218 </td>
219 <?php
220 echo "\n";
221 } // end if
222 } else {
224 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
225 <?php echo $strInUse . "\n"; ?>
226 </td>
227 <?php
229 echo "\n";
231 </tr>
232 <?php
234 // Show Summary
235 if ($cfg['ShowStats']) {
236 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
238 echo "\n";
240 <tr>
241 <td></td>
242 <th align="center" nowrap="nowrap">
243 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
244 </th>
245 <th colspan="6" align="center">
246 <b><?php echo $strSum; ?></b>
247 </th>
248 <th align="right" nowrap="nowrap">
249 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
250 </th>
251 <th align="center">
252 <b>--</b>
253 </th>
254 <?php
255 if ($cfg['ShowStats']) {
256 echo "\n";
258 <th align="right" nowrap="nowrap">
259 &nbsp;
260 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
261 </th>
262 <?php
264 echo "\n";
266 </tr>
268 <?php
269 // Check all tables url
270 $checkall_url = 'db_details_structure.php3?' . PMA_generate_common_url($db);
271 echo "\n";
273 <tr>
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; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
277 <?php echo $strCheckAll; ?></a>
278 &nbsp;/&nbsp;
279 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
280 <?php echo $strUncheckAll; ?></a>
281 &nbsp;&nbsp;&nbsp;
282 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
283 <select name="submit_mult" dir="ltr" onchange="this.form.submit();">
284 <?php
285 echo "\n";
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";
299 </select>
300 <script type="text/javascript" language="javascript">
301 <!--
302 // Fake js to allow the use of the <noscript> tag
303 //-->
304 </script>
305 <noscript>
306 <input type="submit" value="<?php echo $strGo; ?>" />
307 </noscript>
308 </td>
309 </tr>
310 </table>
312 </form>
313 <?php
314 } // end case mysql >= 3.23.03
316 // 3. Shows tables list mysql < 3.23.03
317 else {
318 $i = 0;
319 echo "\n";
321 <form action="db_details_structure.php3">
322 <?php echo PMA_generate_common_hidden_inputs($db); ?>
324 <table border="<?php echo $cfg['Border']; ?>">
325 <tr>
326 <td></td>
327 <th>&nbsp;<?php echo $strTable; ?>&nbsp;</th>
328 <th colspan="6"><?php echo $strAction; ?></th>
329 <th><?php echo $strRecords; ?></th>
330 </tr>
331 <?php
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 . '&amp;table=' . $table_encoded;
340 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
341 echo "\n";
343 <tr>
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; ?> />
346 </td>
347 <td bgcolor="<?php echo $bgcolor; ?>" class="data">
348 <b>&nbsp;<label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>
349 </td>
350 <td bgcolor="<?php echo $bgcolor; ?>">
351 <a href="sql.php3?<?php echo $tbl_url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&amp;pos=0"><?php echo $strBrowse; ?></a>
352 </td>
353 <td bgcolor="<?php echo $bgcolor; ?>">
354 <a href="tbl_select.php3?<?php echo $tbl_url_query; ?>"><?php echo $strSelect; ?></a>
355 </td>
356 <td bgcolor="<?php echo $bgcolor; ?>">
357 <a href="tbl_change.php3?<?php echo $tbl_url_query; ?>"><?php echo $strInsert; ?></a>
358 </td>
359 <td bgcolor="<?php echo $bgcolor; ?>">
360 <a href="tbl_properties.php3?<?php echo $tbl_url_query; ?>"><?php echo $strProperties; ?></a>
361 </td>
362 <td bgcolor="<?php echo $bgcolor; ?>">
363 <a href="sql.php3?<?php echo $tbl_url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, $table_name)); ?>"><?php echo $strDrop; ?></a>
364 </td>
365 <td bgcolor="<?php echo $bgcolor; ?>">
366 <a href="sql.php3?<?php echo $tbl_url_query; ?>&amp;sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($table)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, $table_name)); ?>"><?php echo $strEmpty; ?></a>
367 </td>
368 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
369 <?php PMA_countRecords($db, $table); echo "\n"; ?>
370 </td>
371 </tr>
372 <?php
373 $i++;
374 } // end while
375 echo "\n";
377 // Check all tables url
378 $checkall_url = 'db_details_structure.php3?' . PMA_generate_common_url($db);
380 <tr>
381 <td colspan="9">
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; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
384 <?php echo $strCheckAll; ?></a>
385 &nbsp;/&nbsp;
386 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
387 <?php echo $strUncheckAll; ?></a>
388 </td>
389 </tr>
391 <tr>
392 <td colspan="9">
393 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
394 <i><?php echo $strWithChecked; ?></i>&nbsp;&nbsp;
395 <input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
396 &nbsp;<?php $strOr . "\n"; ?>&nbsp;
397 <input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" />
398 </td>
399 </tr>
400 </table>
402 </form>
403 <?php
404 } // end case mysql < 3.23.03
406 echo "\n";
408 <hr />
411 <?php
413 * Work on the database
416 <!-- DATABASE WORK -->
417 <ul>
419 <?php
420 if ($num_tables > 0) {
422 <!-- Printable view of a table -->
423 <li>
424 <div style="margin-bottom: 10px"><a href="db_printview.php3?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
425 </li>
426 <li>
427 <div style="margin-bottom: 10px"><a href="./db_datadict.php3?<?php echo $url_query; ?>"><?php echo $strDataDict; ?></a></div>
428 </li>
429 <?php
430 } // end if
433 <!-- Create a new table -->
434 <li>
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); ?>
438 <?php
439 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . '&nbsp;:<br />' . "\n";
440 echo ' ' . $strName . '&nbsp;:&nbsp;' . "\n";
441 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
442 echo ' ' . '<br />' . "\n";
443 echo ' ' . $strFields . '&nbsp;:&nbsp;' . "\n";
444 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
445 echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
447 </form>
448 </li>
450 <?php
451 if ($num_tables > 0
452 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
453 echo ' <li>' . "\n";
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";
460 } // end if
462 // is this OK to check for 'class' support?
463 $takeaway = $url_query . '&amp;table=' . urlencode($table);
464 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
466 <!-- Work on PDF Pages -->
467 <li>
468 <div style="margin-bottom: 10px"><a href="pdf_pages.php3?<?php echo $takeaway; ?>"><?php echo $strEditPDFPages; ?></a></div>
469 </li>
471 <!-- PDF schema -->
472 <?php
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) {
481 echo "\n";
483 <li>
484 <form method="post" action="pdf_schema.php3/">
485 <?php echo PMA_generate_common_hidden_inputs($db); ?>
486 <?php echo $strDisplayPDF; ?>&nbsp;:<br />
487 <?php echo $strPageNumber; ?>&nbsp;
488 <select name="pdf_page_number">
489 <?php
490 while ($pages = @PMA_mysql_fetch_array($test_rs)) {
491 echo "\n" . ' '
492 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
493 } // end while
494 echo "\n";
496 </select><br />
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>
511 </select>
512 &nbsp;&nbsp;<input type="submit" value="<?php echo $strGo; ?>" />
513 </form>
514 </li>
515 <?php
516 } // end if
517 } // end if
519 if ($num_tables > 0
520 && $cfgRelation['relwork'] && $cfgRelation['commwork']) {
522 <!-- import docSQL files -->
523 <li>
524 <div style="margin-bottom: 10px"><a href="db_details_importdocsql.php3?<?php echo $takeaway . '">' . $strImportDocSQL; ?></a></div>
525 </li>
526 <?php
528 echo "\n" . '</ul>';
532 * Displays the footer
534 echo "\n";
535 require('./footer.inc.php3');