pdf_pages
[phpmyadmin/crack.git] / db_details_structure.php3
blob120837cdb33158c2d01e510e979f79e9ab734416
1 <?php
2 /* $Id$ */
5 /**
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)
8 */
9 if (empty($is_info)) {
10 include('./db_details_common.php3');
11 $url_query .= '&amp;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');
23 echo "\n";
27 /**
28 * Settings for relations stuff
30 require('./libraries/relation.lib.php3');
31 $cfgRelation = PMA_getRelationsParam();
35 /**
36 * Displays the tables list
40 <!-- TABLE LIST -->
42 <?php
43 // 1. No tables
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']; ?>">
58 <tr>
59 <td></td>
60 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
61 <th colspan="6"><?php echo ucfirst($strAction); ?></th>
62 <th><?php echo ucfirst($strRecords); ?></th>
63 <th><?php echo ucfirst($strType); ?></th>
64 <?php
65 if ($cfg['ShowStats']) {
66 echo '<th>' . ucfirst($strSize) . '</th>';
68 echo "\n";
70 </tr>
71 <?php
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 . '&amp;table=' . $table_encoded;
82 $bgcolor = ($i++ % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
83 echo "\n";
85 <tr>
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; ?> />
88 </td>
89 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
90 &nbsp;<b><label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>&nbsp;
91 </td>
92 <td bgcolor="<?php echo $bgcolor; ?>">
93 <?php
94 if (!empty($sts_data['Rows'])) {
95 echo '<a href="sql.php3?' . $tbl_url_query . '&amp;sql_query='
96 . urlencode('SELECT * FROM ' . PMA_backquote($table))
97 . '&amp;pos=0">' . $strBrowse . '</a>';
98 } else {
99 echo $strBrowse;
102 </td>
103 <td bgcolor="<?php echo $bgcolor; ?>">
104 <?php
105 if (!empty($sts_data['Rows'])) {
106 echo '<a href="tbl_select.php3?' . $tbl_url_query . '">'
107 . $strSelect . '</a>';
108 } else {
109 echo $strSelect;
112 </td>
113 <td bgcolor="<?php echo $bgcolor; ?>">
114 <a href="tbl_change.php3?<?php echo $tbl_url_query; ?>">
115 <?php echo $strInsert; ?></a>
116 </td>
117 <td bgcolor="<?php echo $bgcolor; ?>">
118 <a href="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>">
119 <?php echo $strProperties; ?></a>
120 </td>
121 <td bgcolor="<?php echo $bgcolor; ?>">
122 <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))); ?>"
123 onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
124 <?php echo $strDrop; ?></a>
125 </td>
126 <td bgcolor="<?php echo $bgcolor; ?>">
127 <?php
128 if (!empty($sts_data['Rows'])) {
129 echo '<a href="sql.php3?' . $tbl_url_query
130 . '&amp;sql_query=';
131 if (PMA_MYSQL_INT_VERSION >= 40000) {
132 echo urlencode('TRUNCATE ' . PMA_backquote($table))
133 . '&amp;zero_rows='
134 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
135 . '" onclick="return confirmLink(this, \'TRUNCATE ';
136 } else {
137 echo urlencode('DELETE FROM ' . PMA_backquote($table))
138 . '&amp;zero_rows='
139 . urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($table)))
140 . '" onclick="return confirmLink(this, \'DELETE FROM ';
142 echo PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
143 } else {
144 echo $strEmpty;
147 </td>
148 <?php
149 echo "\n";
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
155 // is accurate.
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
167 // sizes are.
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 = '&nbsp;-&nbsp;';
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 = '&nbsp;-&nbsp;';
190 $unit = '';
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.
197 else {
198 if ($cfg['ShowStats']) {
199 $formated_size = 'unknown';
200 $unit = '';
202 $display_rows = 'unknown';
205 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
206 <?php
207 echo "\n" . ' ' . $display_rows . "\n";
209 </td>
210 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
211 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
212 </td>
213 <?php
214 if ($cfg['ShowStats']) {
215 echo "\n";
217 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
218 &nbsp;&nbsp;
219 <a href="tbl_properties_structure.php3?<?php echo $tbl_url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
220 </td>
221 <?php
222 echo "\n";
223 } // end if
224 } else {
226 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
227 <?php echo $strInUse . "\n"; ?>
228 </td>
229 <?php
231 echo "\n";
233 </tr>
234 <?php
236 // Show Summary
237 if ($cfg['ShowStats']) {
238 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
240 echo "\n";
242 <tr>
243 <td></td>
244 <th align="center" nowrap="nowrap">
245 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
246 </th>
247 <th colspan="6" align="center">
248 <b><?php echo $strSum; ?></b>
249 </th>
250 <th align="right" nowrap="nowrap">
251 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
252 </th>
253 <th align="center">
254 <b>--</b>
255 </th>
256 <?php
257 if ($cfg['ShowStats']) {
258 echo "\n";
260 <th align="right" nowrap="nowrap">
261 &nbsp;
262 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
263 </th>
264 <?php
266 echo "\n";
268 </tr>
270 <?php
271 // Check all tables url
272 $checkall_url = 'db_details_structure.php3'
273 . '?lang=' . $lang
274 . '&amp;convcharset=' . $convcharset
275 . '&amp;server=' . $server
276 . '&amp;db=' . urlencode($db);
277 echo "\n";
279 <tr>
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; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
283 <?php echo $strCheckAll; ?></a>
284 &nbsp;/&nbsp;
285 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
286 <?php echo $strUncheckAll; ?></a>
287 &nbsp;&nbsp;&nbsp;
288 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
289 <select name="submit_mult" dir="ltr" onchange="this.form.submit();">
290 <?php
291 echo "\n";
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";
305 </select>
306 <script type="text/javascript" language="javascript">
307 <!--
308 // Fake js to allow the use of the <noscript> tag
309 //-->
310 </script>
311 <noscript>
312 <input type="submit" value="<?php echo $strGo; ?>" />
313 </noscript>
314 </td>
315 </tr>
316 </table>
318 </form>
319 <?php
320 } // end case mysql >= 3.23.03
322 // 3. Shows tables list mysql < 3.23.03
323 else {
324 $i = 0;
325 echo "\n";
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']; ?>">
334 <tr>
335 <td></td>
336 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
337 <th colspan="6"><?php echo ucfirst($strAction); ?></th>
338 <th><?php echo ucfirst($strRecords); ?></th>
339 </tr>
340 <?php
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 . '&amp;table=' . $table_encoded;
349 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
350 echo "\n";
352 <tr>
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; ?> />
355 </td>
356 <td bgcolor="<?php echo $bgcolor; ?>" class="data">
357 <b>&nbsp;<label for="checkbox_tbl_<?php echo $i; ?>"><?php echo $table_name; ?></label>&nbsp;</b>
358 </td>
359 <td bgcolor="<?php echo $bgcolor; ?>">
360 <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>
361 </td>
362 <td bgcolor="<?php echo $bgcolor; ?>">
363 <a href="tbl_select.php3?<?php echo $tbl_url_query; ?>"><?php echo $strSelect; ?></a>
364 </td>
365 <td bgcolor="<?php echo $bgcolor; ?>">
366 <a href="tbl_change.php3?<?php echo $tbl_url_query; ?>"><?php echo $strInsert; ?></a>
367 </td>
368 <td bgcolor="<?php echo $bgcolor; ?>">
369 <a href="tbl_properties.php3?<?php echo $tbl_url_query; ?>"><?php echo $strProperties; ?></a>
370 </td>
371 <td bgcolor="<?php echo $bgcolor; ?>">
372 <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>
373 </td>
374 <td bgcolor="<?php echo $bgcolor; ?>">
375 <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>
376 </td>
377 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
378 <?php PMA_countRecords($db, $table); echo "\n"; ?>
379 </td>
380 </tr>
381 <?php
382 $i++;
383 } // end while
384 echo "\n";
386 // Check all tables url
387 $checkall_url = 'db_details_structure.php3'
388 . '?lang=' . $lang
389 . '&amp;convcharset=' . $convcharset
390 . '&amp;server=' . $server
391 . '&amp;db=' . urlencode($db);
393 <tr>
394 <td colspan="9">
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; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
397 <?php echo $strCheckAll; ?></a>
398 &nbsp;/&nbsp;
399 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
400 <?php echo $strUncheckAll; ?></a>
401 </td>
402 </tr>
404 <tr>
405 <td colspan="9">
406 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
407 <i><?php echo $strWithChecked; ?></i>&nbsp;&nbsp;
408 <input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
409 &nbsp;<?php $strOr . "\n"; ?>&nbsp;
410 <input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" />
411 </td>
412 </tr>
413 </table>
415 </form>
416 <?php
417 } // end case mysql < 3.23.03
419 echo "\n";
421 <hr />
424 <?php
426 * Work on the database
429 <!-- DATABASE WORK -->
430 <ul>
432 <?php
433 if ($num_tables > 0) {
435 <!-- Printable view of a table -->
436 <li>
437 <div style="margin-bottom: 10px"><a href="db_printview.php3?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
438 </li>
439 <?php
440 } // end if
443 <!-- Create a new table -->
444 <li>
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; ?>" />
451 <?php
452 echo ' ' . sprintf($strCreateNewTable, htmlspecialchars($db)) . '&nbsp;:<br />' . "\n";
453 echo ' ' . $strName . '&nbsp;:&nbsp;' . "\n";
454 echo ' ' . '<input type="text" name="table" maxlength="64" class="textfield" />' . "\n";
455 echo ' ' . '<br />' . "\n";
456 echo ' ' . $strFields . '&nbsp;:&nbsp;' . "\n";
457 echo ' ' . '<input type="text" name="num_fields" size="2" class="textfield" />' . "\n";
458 echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
460 </form>
461 </li>
463 <?php
464 if ($num_tables > 0
465 && !$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == FALSE) {
466 echo ' <li>' . "\n";
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";
473 } // end if
475 // is this OK to check for 'class' support?
476 $takeaway = $url_query . '&amp;table=' . urlencode($table);
477 if ($cfgRelation['pdfwork'] && $num_tables > 0) {
479 <!-- Work on PDF Pages -->
480 <li>
481 <div style="margin-bottom: 10px"><a href="pdf_pages.php3?<?php echo $takeaway; ?>"><?php echo $strEditPDFPages; ?></a></div>
482 </li>
484 <!-- PDF schema -->
485 <?php
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) {
491 echo "\n";
493 <li>
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; ?>&nbsp;:<br />
500 <?php echo $strPageNumber; ?>&nbsp;
501 <select name="pdf_page_number">
502 <?php
503 while ($pages = @PMA_mysql_fetch_array($test_rs)) {
504 echo "\n" . ' '
505 . '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
506 } // end while
507 echo "\n";
509 </select><br />
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 &nbsp;&nbsp;<input type="submit" value="<?php echo $strGo; ?>" />
519 </form>
520 </li>
521 <?php
522 } // end if
523 } // end if
525 if ($num_tables > 0
526 && $cfgRelation['relwork'] && $cfgRelation['commwork']) {
528 <!-- import docSQL files -->
529 <li>
530 <div style="margin-bottom: 10px"><a href="db_details_importdocsql.php3?<?php echo $takeaway . '">' . $strImportDocSQL; ?></a></div>
531 </li>
532 <?php
534 echo "\n" . '</ul>';
538 * Displays the footer
540 echo "\n";
541 require('./footer.inc.php3');