2.2.4
[phpmyadmin/arisferyanto.git] / db_details.php3
blob69a287a290dde1906e9792b0efe093918dce4193
1 <?php
2 /* $Id$ */
4 /**
5 * Gets some core libraries
6 */
7 require('./libraries/grab_globals.lib.php3');
8 require('./libraries/common.lib.php3');
9 require('./libraries/bookmark.lib.php3');
12 /**
13 * Defines the urls to return to in case of error in a sql statement
15 $err_url_0 = 'main.php3'
16 . '?lang=' . $lang
17 . '&amp;server=' . $server;
18 $err_url = 'db_details.php3'
19 . '?lang=' . $lang
20 . '&amp;server=' . $server
21 . '&amp;db=' . urlencode($db);
24 /**
25 * Ensures the database exists (else move to the "parent" script) and displays
26 * headers
28 if (!isset($is_db) || !$is_db) {
29 // Not a valid db name -> back to the welcome page
30 if (!empty($db)) {
31 $is_db = @mysql_select_db($db);
33 if (empty($db) || !$is_db) {
34 header('Location: ' . $cfgPmaAbsoluteUri . 'main.php3?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
35 exit();
37 } // end if (ensures db exists)
39 // Displays headers
40 if (!isset($message)) {
41 $js_to_run = 'functions.js';
42 include('./header.inc.php3');
43 // Reloads the navigation frame via JavaScript if required
44 if (isset($reload) && $reload) {
45 echo "\n";
47 <script type="text/javascript" language="javascript1.2">
48 <!--
49 window.parent.frames['nav'].location.replace('./left.php3?lang=<?php echo $lang; ?>&server=<?php echo $server; ?>&db=<?php echo urlencode($db); ?>');
50 //-->
51 </script>
52 <?php
54 echo "\n";
55 } else {
56 PMA_showMessage($message);
60 /**
61 * Drop/delete multiple tables if required
63 if ((!empty($submit_mult) && isset($selected_tbl))
64 || isset($mult_btn)) {
65 $action = 'db_details.php3';
66 include('./mult_submits.inc.php3');
70 /**
71 * Gets the list of the table in the current db and informations about these
72 * tables if possible
74 // staybyte: speedup view on locked tables - 11 June 2001
75 if (PMA_MYSQL_INT_VERSION >= 32303) {
76 // Special speedup for newer MySQL Versions (in 4.0 format changed)
77 if ($cfgSkipLockedTables == TRUE && PMA_MYSQL_INT_VERSION >= 32330) {
78 $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
79 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
80 // Blending out tables in use
81 if ($result != FALSE && mysql_num_rows($result) > 0) {
82 while ($tmp = mysql_fetch_row($result)) {
83 // if in use memorize tablename
84 if (eregi('in_use=[1-9]+', $tmp[1])) {
85 $sot_cache[$tmp[0]] = TRUE;
88 mysql_free_result($result);
90 if (isset($sot_cache)) {
91 $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
92 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
93 if ($result != FALSE && mysql_num_rows($result) > 0) {
94 while ($tmp = mysql_fetch_row($result)) {
95 if (!isset($sot_cache[$tmp[0]])) {
96 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
97 $sts_result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
98 $sts_tmp = mysql_fetch_array($sts_result);
99 $tables[] = $sts_tmp;
100 } else { // table in use
101 $tables[] = array('Name' => $tmp[0]);
104 mysql_free_result($result);
105 $sot_ready = TRUE;
110 if (!isset($sot_ready)) {
111 $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
112 $result = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
113 if ($result != FALSE && mysql_num_rows($result) > 0) {
114 while ($sts_tmp = mysql_fetch_array($result)) {
115 $tables[] = $sts_tmp;
117 mysql_free_result($result);
120 $num_tables = (isset($tables) ? count($tables) : 0);
121 } // end if (PMA_MYSQL_INT_VERSION >= 32303)
122 else {
123 $result = mysql_list_tables($db);
124 $num_tables = @mysql_numrows($result);
125 for ($i = 0; $i < $num_tables; $i++) {
126 $tables[] = mysql_tablename($result, $i);
128 mysql_free_result($result);
133 * Displays an html table with all the tables contained into the current
134 * database
138 <!-- TABLE LIST -->
140 <?php
141 // 1. No tables
142 if ($num_tables == 0) {
143 echo $strNoTablesFound . "\n";
146 // 2. Shows table informations on mysql >= 3.23 - staybyte - 11 June 2001
147 else if (PMA_MYSQL_INT_VERSION >= 32300) {
149 <form method="post" action="db_details.php3" name="tablesForm">
150 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
151 <input type="hidden" name="server" value="<?php echo $server; ?>" />
152 <input type="hidden" name="db" value="<?php echo $db; ?>" />
154 <table border="<?php echo $cfgBorder; ?>">
155 <tr>
156 <td></td>
157 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
158 <th colspan="6"><?php echo ucfirst($strAction); ?></th>
159 <th><?php echo ucfirst($strRecords); ?></th>
160 <th><?php echo ucfirst($strType); ?></th>
161 <?php
162 if ($cfgShowStats) {
163 echo '<th>' . ucfirst($strSize) . '</th>';
165 echo "\n";
167 </tr>
168 <?php
169 $i = $sum_entries = $sum_size = 0;
170 $checked = (!empty($checkall) ? ' checked="checked"' : '');
171 while (list($keyname, $sts_data) = each($tables)) {
172 $table = $sts_data['Name'];
173 // Sets parameters for links
174 $url_query = 'lang=' . $lang
175 . '&amp;server=' . $server
176 . '&amp;db=' . urlencode($db)
177 . '&amp;table=' . urlencode($table)
178 . '&amp;goto=db_details.php3';
179 $bgcolor = ($i++ % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
180 echo "\n";
182 <tr>
183 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
184 <input type="checkbox" name="selected_tbl[]" value="<?php echo urlencode($table); ?>"<?php echo $checked; ?> />
185 </td>
186 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
187 &nbsp;<b><?php echo htmlspecialchars($table); ?>&nbsp;</b>&nbsp;
188 </td>
189 <td bgcolor="<?php echo $bgcolor; ?>">
190 <?php
191 if ($sts_data['Rows']>0) {
192 echo '<a href="sql.php3?' . $url_query . '&amp;sql_query='
193 . urlencode('SELECT * FROM ' . PMA_backquote($table))
194 . '&amp;pos=0">' . $strBrowse . '</a>';
195 } else {
196 echo $strBrowse;
199 </td>
200 <td bgcolor="<?php echo $bgcolor; ?>">
201 <?php
202 if ($sts_data['Rows']>0) {
203 echo '<a href="tbl_select.php3?' . $url_query . '">'
204 . $strSelect . '</a>';
205 } else {
206 echo $strSelect;
209 </td>
210 <td bgcolor="<?php echo $bgcolor; ?>">
211 <a href="tbl_change.php3?<?php echo $url_query; ?>">
212 <?php echo $strInsert; ?></a>
213 </td>
214 <td bgcolor="<?php echo $bgcolor; ?>">
215 <a href="tbl_properties.php3?<?php echo $url_query; ?>">
216 <?php echo $strProperties; ?></a>
217 </td>
218 <td bgcolor="<?php echo $bgcolor; ?>">
219 <a href="sql.php3?<?php echo $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))); ?>"
220 onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
221 <?php echo $strDrop; ?></a>
222 </td>
223 <td bgcolor="<?php echo $bgcolor; ?>">
224 <?php
225 if ($sts_data['Rows']>0) {
226 echo '<a href="sql.php3?' . $url_query
227 . '&amp;sql_query='
228 . urlencode('DELETE FROM ' . PMA_backquote($table))
229 . '&amp;zero_rows='
230 . urlencode(sprintf($strTableHasBeenEmptied,
231 htmlspecialchars($table)))
232 . '" onclick="return confirmLink(this, \'DELETE FROM ' . PMA_jsFormat($table) . '\')">' . $strEmpty . '</a>';
233 } else {
234 echo $strEmpty;
237 </td>
238 <?php
239 echo "\n";
240 $mergetable = FALSE;
241 $nonisam = FALSE;
242 if (isset($sts_data['Type'])) {
243 if ($sts_data['Type'] == 'MRG_MyISAM') {
244 $mergetable = TRUE;
245 } else if (!eregi('ISAM|HEAP', $sts_data['Type'])) {
246 $nonisam = TRUE;
250 if (isset($sts_data['Rows'])) {
251 if ($mergetable == FALSE) {
252 if ($cfgShowStats && $nonisam == FALSE) {
253 $tblsize = $sts_data['Data_length'] + $sts_data['Index_length'];
254 $sum_size += $tblsize;
255 if ($tblsize > 0) {
256 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1);
257 } else {
258 list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 0);
260 } else if ($cfgShowStats) {
261 $formated_size = '&nbsp;-&nbsp;';
262 $unit = '';
264 $sum_entries += $sts_data['Rows'];
266 // MyISAM MERGE Table
267 else if ($cfgShowStats && $mergetable == TRUE) {
268 $formated_size = '&nbsp;-&nbsp;';
269 $unit = '';
271 else if ($cfgShowStats) {
272 $formated_size = 'unknown';
273 $unit = '';
276 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
277 <?php
278 echo "\n" . ' ';
279 if ($mergetable == TRUE) {
280 echo '<i>' . number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . '</i>' . "\n";
281 } else {
282 echo number_format($sts_data['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n";
285 </td>
286 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
287 &nbsp;<?php echo (isset($sts_data['Type']) ? $sts_data['Type'] : '&nbsp;'); ?>&nbsp;
288 </td>
289 <?php
290 if ($cfgShowStats) {
291 echo "\n";
293 <td align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
294 &nbsp;&nbsp;
295 <a href="tbl_properties.php3?<?php echo $url_query; ?>#showusage"><?php echo $formated_size . ' ' . $unit; ?></a>
296 </td>
297 <?php
298 echo "\n";
299 } // end if
300 } else {
302 <td colspan="3" align="center" bgcolor="<?php echo $bgcolor; ?>">
303 <?php echo $strInUse . "\n"; ?>
304 </td>
305 <?php
307 echo "\n";
309 </tr>
310 <?php
312 // Show Summary
313 if ($cfgShowStats) {
314 list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
316 echo "\n";
318 <tr>
319 <td></td>
320 <th align="center" nowrap="nowrap">
321 &nbsp;<b><?php echo sprintf($strTables, number_format($num_tables, 0, $number_decimal_separator, $number_thousands_separator)); ?></b>&nbsp;
322 </th>
323 <th colspan="6" align="center">
324 <b><?php echo $strSum; ?></b>
325 </th>
326 <th align="right" nowrap="nowrap">
327 <b><?php echo number_format($sum_entries, 0, $number_decimal_separator, $number_thousands_separator); ?></b>
328 </th>
329 <th align="center">
330 <b>--</b>
331 </th>
332 <?php
333 if ($cfgShowStats) {
334 echo "\n";
336 <th align="right" nowrap="nowrap">
337 &nbsp;
338 <b><?php echo $sum_formated . ' ' . $unit; ?></b>
339 </th>
340 <?php
342 echo "\n";
344 </tr>
346 <?php
347 // Check all tables url
348 $checkall_url = 'db_details.php3'
349 . '?lang=' . $lang
350 . '&amp;server=' . $server
351 . '&amp;db=' . urlencode($db);
352 echo "\n";
354 <tr>
355 <td colspan="<?php echo (($cfgShowStats) ? '11' : '10'); ?>" valign="bottom">
356 <img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
357 <a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
358 <?php echo $strCheckAll; ?></a>
359 &nbsp;/&nbsp;
360 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
361 <?php echo $strUncheckAll; ?></a>
362 &nbsp;&nbsp;&nbsp;
363 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
364 <select name="submit_mult" dir="ltr" onchange="this.form.submit();">
365 <?php
366 echo "\n";
367 echo ' <option value="' . $strWithChecked . '" selected="selected">'
368 . $strWithChecked . '</option>' . "\n";
369 echo ' <option value="' . $strDrop . '" >'
370 . $strDrop . '</option>' . "\n";
371 echo ' <option value="' . $strEmpty . '" >'
372 . $strEmpty . '</option>' . "\n";
373 echo ' <option value="' . $strPrintView . '" >'
374 . $strPrintView . '</option>' . "\n";
375 echo ' <option value="' . $strOptimizeTable . '" >'
376 . $strOptimizeTable . '</option>' . "\n";
378 </select>
379 <input type="submit" value="<?php echo $strGo; ?>" />
380 </td>
381 </tr>
382 </table>
384 </form>
385 <?php
386 } // end case mysql >= 3.23
388 // 3. Shows tables list mysql < 3.23
389 else {
390 $i = 0;
391 echo "\n";
393 <form action="db_details.php3">
394 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
395 <input type="hidden" name="server" value="<?php echo $server; ?>" />
396 <input type="hidden" name="db" value="<?php echo $db; ?>" />
398 <table border="<?php echo $cfgBorder; ?>">
399 <tr>
400 <td></td>
401 <th>&nbsp;<?php echo ucfirst($strTable); ?>&nbsp;</th>
402 <th colspan="6"><?php echo ucfirst($strAction); ?></th>
403 <th><?php echo ucfirst($strRecords); ?></th>
404 </tr>
405 <?php
406 $checked = (!empty($checkall) ? ' checked="checked"' : '');
407 while ($i < $num_tables) {
408 // Sets parameters for links
409 $url_query = 'lang=' . $lang
410 . '&amp;server=' . $server
411 . '&amp;db=' . urlencode($db)
412 . '&amp;table=' . urlencode($tables[$i])
413 . '&amp;goto=db_details.php3';
414 $bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
415 echo "\n";
417 <tr>
418 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
419 <input type="checkbox" name="selected_tbl[]" value="<?php echo urlencode($tables[$i]); ?>"<?php echo $checked; ?> />
420 </td>
421 <td bgcolor="<?php echo $bgcolor; ?>" class="data">
422 <b>&nbsp;<?php echo $tables[$i]; ?>&nbsp;</b>
423 </td>
424 <td bgcolor="<?php echo $bgcolor; ?>">
425 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($tables[$i])); ?>&amp;pos=0"><?php echo $strBrowse; ?></a>
426 </td>
427 <td bgcolor="<?php echo $bgcolor; ?>">
428 <a href="tbl_select.php3?<?php echo $url_query; ?>"><?php echo $strSelect; ?></a>
429 </td>
430 <td bgcolor="<?php echo $bgcolor; ?>">
431 <a href="tbl_change.php3?<?php echo $url_query; ?>"><?php echo $strInsert; ?></a>
432 </td>
433 <td bgcolor="<?php echo $bgcolor; ?>">
434 <a href="tbl_properties.php3?<?php echo $url_query; ?>"><?php echo $strProperties; ?></a>
435 </td>
436 <td bgcolor="<?php echo $bgcolor; ?>">
437 <a href="sql.php3?<?php echo $url_query; ?>&amp;reload=1&amp;sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($tables[$i])); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($tables[$i]))); ?>"><?php echo $strDrop; ?></a>
438 </td>
439 <td bgcolor="<?php echo $bgcolor; ?>">
440 <a href="sql.php3?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('DELETE FROM ' . PMA_backquote($tables[$i])); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strTableHasBeenEmptied, htmlspecialchars($tables[$i]))); ?>"><?php echo $strEmpty; ?></a>
441 </td>
442 <td align="right" bgcolor="<?php echo $bgcolor; ?>">
443 <?php PMA_countRecords($db, $tables[$i]); echo "\n"; ?>
444 </td>
445 </tr>
446 <?php
447 $i++;
448 } // end while
449 echo "\n";
451 // Check all tables url
452 $checkall_url = 'db_details.php3'
453 . '?lang=' . $lang
454 . '&amp;server=' . $server
455 . '&amp;db=' . urlencode($db);
457 <tr>
458 <td colspan="9">
459 <img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
460 <a href="<?php echo $checkall_url; ?>&amp;checkall=1" onclick="setCheckboxes('tablesForm', true); return false;">
461 <?php echo $strCheckAll; ?></a>
462 &nbsp;/&nbsp;
463 <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('tablesForm', false); return false;">
464 <?php echo $strUncheckAll; ?></a>
465 </td>
466 </tr>
468 <tr>
469 <td colspan="9">
470 <img src="./images/spacer.gif" border="0" width="38" height="1" alt="" />
471 <i><?php echo $strWithChecked; ?></i>&nbsp;&nbsp;
472 <input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
473 &nbsp;<?php $strOr . "\n"; ?>&nbsp;
474 <input type="submit" name="submit_mult" value="<?php echo $strEmpty; ?>" />
475 </td>
476 </tr>
477 </table>
479 </form>
480 <?php
481 } // end case mysql < 3.23
483 echo "\n";
485 <hr />
488 <?php
490 * Database work
492 $url_query = 'lang=' . $lang
493 . '&amp;server=' . $server
494 . '&amp;db=' . urlencode($db)
495 . '&amp;goto=db_details.php3';
496 if (isset($show_query) && $show_query == 'y') {
497 // This script has been called by read_dump.php3
498 if (isset($sql_query_cpy)) {
499 $query_to_display = $sql_query_cpy;
501 // Other cases
502 else if (get_magic_quotes_gpc()) {
503 $query_to_display = stripslashes($sql_query);
505 else {
506 $query_to_display = $sql_query;
508 } else {
509 $query_to_display = '';
512 <!-- DATABASE WORK -->
513 <ul>
514 <?php
515 if ($num_tables > 0) {
517 <!-- Printable view of a table -->
518 <li>
519 <div style="margin-bottom: 10px"><a href="db_printview.php3?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
520 </li>
521 <?php
524 // loic1: defines wether file upload is available or not
525 $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
526 ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
527 : (intval(@get_cfg_var('upload_max_filesize')));
530 <!-- Query box, sql file loader and bookmark support -->
531 <li>
532 <a name="querybox"></a>
533 <form method="post" action="read_dump.php3"<?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>
534 onsubmit="return checkSqlQuery(this)">
535 <input type="hidden" name="is_js_confirmed" value="0" />
536 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
537 <input type="hidden" name="server" value="<?php echo $server; ?>" />
538 <input type="hidden" name="db" value="<?php echo $db; ?>" />
539 <input type="hidden" name="pos" value="0" />
540 <input type="hidden" name="goto" value="db_details.php3" />
541 <input type="hidden" name="zero_rows" value="<?php echo htmlspecialchars($strSuccess); ?>" />
542 <input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
543 <?php echo sprintf($strRunSQLQuery, $db) . ' ' . PMA_showDocuShort('S/E/SELECT.html'); ?>&nbsp;:<br />
544 <div style="margin-bottom: 5px">
545 <textarea name="sql_query" cols="<?php echo $cfgTextareaCols; ?>" rows="<?php echo $cfgTextareaRows; ?>" wrap="virtual" onfocus="this.select()">
546 <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : ''); ?>
547 </textarea><br />
548 <input type="checkbox" name="show_query" value="y" checked="checked" />&nbsp;
549 <?php echo $strShowThisQuery; ?><br />
550 </div>
551 <?php
552 // loic1: displays import dump feature only if file upload available
553 if ($is_upload) {
554 echo ' <i>' . $strOr . '</i> ' . $strLocationTextfile . '&nbsp;:<br />' . "\n";
556 <div style="margin-bottom: 5px">
557 <input type="file" name="sql_file" /><br />
558 </div>
559 <?php
560 } // end if
561 echo "\n";
563 // Bookmark Support
564 if ($cfgBookmark['db'] && $cfgBookmark['table']) {
565 if (($bookmark_list = PMA_listBookmarks($db, $cfgBookmark)) && count($bookmark_list) > 0) {
566 echo " <i>$strOr</i> $strBookmarkQuery&nbsp;:<br />\n";
567 echo ' <div style="margin-bottom: 5px">' . "\n";
568 echo ' <select name="id_bookmark">' . "\n";
569 echo ' <option value=""></option>' . "\n";
570 while (list($key, $value) = each($bookmark_list)) {
571 echo ' <option value="' . $value . '">' . htmlentities($key) . '</option>' . "\n";
573 echo ' </select>' . "\n";
574 echo ' <input type="radio" name="action_bookmark" value="0" checked="checked" style="vertical-align: middle" />' . $strSubmit . "\n";
575 echo ' &nbsp;<input type="radio" name="action_bookmark" value="1" style="vertical-align: middle" />' . $strBookmarkView . "\n";
576 echo ' &nbsp;<input type="radio" name="action_bookmark" value="2" style="vertical-align: middle" />' . $strDelete . "\n";
577 echo ' <br />' . "\n";
578 echo ' </div>' . "\n";
582 <input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
583 </form>
584 </li>
587 <?php
589 * Query by example and dump of the db
590 * Only displayed if there is at least one table in the db
592 if ($num_tables > 0) {
594 <!-- Query by an example -->
595 <li>
596 <div style="margin-bottom: 10px"><a href="tbl_qbe.php3?<?php echo $url_query; ?>"><?php echo $strQBE; ?></a></div>
597 </li>
599 <!-- Dump of a database -->
600 <li>
601 <a name="dumpdb"></a>
602 <form method="post" action="tbl_dump.php3" name="db_dump">
603 <?php echo $strViewDumpDB; ?><br />
604 <table>
605 <tr>
606 <?php
607 $colspan = '';
608 // loic1: already defined at the top of the script!
609 // $tables = mysql_list_tables($db);
610 // $num_tables = @mysql_numrows($tables);
611 if ($num_tables > 1) {
612 $colspan = ' colspan="2"';
613 echo "\n";
615 <td>
616 <select name="table_select[]" size="5" multiple="multiple">
617 <?php
618 $i = 0;
619 echo "\n";
620 $is_selected = (!empty($selectall) ? ' selected="selected"' : '');
621 while ($i < $num_tables) {
622 $table = ((PMA_MYSQL_INT_VERSION >= 32300) ? $tables[$i]['Name'] : $tables[$i]);
623 echo ' <option value="' . $table . '"' . $is_selected . '>' . $table . '</option>' . "\n";
624 $i++;
627 </select>
628 </td>
629 <?php
630 } // end if
632 echo "\n";
634 <td valign="middle">
635 <input type="radio" name="what" value="structure" checked="checked" />
636 <?php echo $strStrucOnly; ?><br />
637 <input type="radio" name="what" value="data" />
638 <?php echo $strStrucData; ?><br />
639 <input type="radio" name="what" value="dataonly" />
640 <?php echo $strDataOnly; ?>
641 <?php
642 if ($num_tables > 1) {
643 echo "\n";
645 <br />
646 <a href="<?php echo $checkall_url; ?>&amp;selectall=1#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', true); return false;"><?php echo $strSelectAll; ?></a>
647 &nbsp;/&nbsp;
648 <a href="<?php echo $checkall_url; ?>#dumpdb" onclick="setSelectOptions('db_dump', 'table_select[]', false); return false;"><?php echo $strUnselectAll; ?></a>
649 <?php
650 } // end if
651 echo "\n";
653 </td>
654 </tr>
655 <tr>
656 <td<?php echo $colspan; ?>>
657 <input type="checkbox" name="drop" value="1" />
658 <?php echo $strStrucDrop . "\n"; ?>
659 </td>
660 </tr>
661 <tr>
662 <td<?php echo $colspan; ?>>
663 <input type="checkbox" name="showcolumns" value="yes" />
664 <?php echo $strCompleteInserts . "\n"; ?>
665 </td>
666 </tr>
667 <tr>
668 <td<?php echo $colspan; ?>>
669 <input type="checkbox" name="extended_ins" value="yes" />
670 <?php echo $strExtendedInserts . "\n"; ?>
671 </td>
672 </tr>
673 <?php
674 // Add backquotes checkbox
675 if (PMA_MYSQL_INT_VERSION >= 32306) {
677 <tr>
678 <td<?php echo $colspan; ?>>
679 <input type="checkbox" name="use_backquotes" value="1" />
680 <?php echo $strUseBackquotes . "\n"; ?>
681 </td>
682 </tr>
683 <?php
684 } // end backquotes feature
685 echo "\n";
687 <tr>
688 <td<?php echo $colspan; ?>>
689 <input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" />
690 <?php echo $strSend . "\n"; ?>
691 <?php
692 // gzip and bzip2 encode features
693 if (PMA_PHP_INT_VERSION >= 40004) {
694 $is_zip = (isset($cfgZipDump) && $cfgZipDump && @function_exists('gzcompress'));
695 $is_gzip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzencode'));
696 $is_bzip = (isset($cfgBZipDump) && $cfgBZipDump && @function_exists('bzcompress'));
697 if ($is_zip || $is_gzip || $is_bzip) {
698 echo "\n" . ' (' . "\n";
699 if ($is_zip) {
701 <input type="checkbox" name="zip" value="zip" onclick="return checkTransmitDump(this.form, 'zip')" /><?php echo $strZip . (($is_gzip || $is_bzip) ? '&nbsp;' : '') . "\n"; ?>
702 <?php
704 if ($is_gzip) {
705 echo "\n"
707 <input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip . (($is_bzip) ? '&nbsp;' : '') . "\n"; ?>
708 <?php
710 if ($is_bzip) {
711 echo "\n"
713 <input type="checkbox" name="bzip" value="bzip" onclick="return checkTransmitDump(this.form, 'bzip')" /><?php echo $strBzip . "\n"; ?>
714 <?php
716 echo "\n" . ' )';
719 echo "\n";
721 </td>
722 </tr>
723 <tr>
724 <td<?php echo $colspan; ?>>
725 <input type="submit" value="<?php echo $strGo; ?>" />
726 </td>
727 </tr>
728 </table>
729 <input type="hidden" name="server" value="<?php echo $server; ?>" />
730 <input type="hidden" name="lang" value="<?php echo $lang;?>" />
731 <input type="hidden" name="db" value="<?php echo $db;?>" />
732 </form>
733 </li>
734 <?php
735 } // end of create dump if there is at least one table in the db
738 <!-- Create a new table -->
739 <li>
740 <form method="post" action="tbl_create.php3"
741 onsubmit="return (emptyFormElements(this, 'table') && checkFormElementInRange(this, 'num_fields', 1))">
742 <input type="hidden" name="server" value="<?php echo $server; ?>" />
743 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
744 <input type="hidden" name="db" value="<?php echo $db; ?>" />
745 <?php
746 echo ' ' . $strCreateNewTable . htmlspecialchars($db) . '&nbsp;:<br />' . "\n";
747 echo ' ' . $strName . '&nbsp;:&nbsp;' . "\n";
748 echo ' ' . '<input type="text" name="table" maxlength="64" />' . "\n";
749 echo ' ' . '<br />' . "\n";
750 echo ' ' . $strFields . '&nbsp;:&nbsp;' . "\n";
751 echo ' ' . '<input type="text" name="num_fields" size="2" />' . "\n";
752 echo ' ' . '&nbsp;<input type="submit" value="' . $strGo . '" />' . "\n";
754 </form>
755 </li>
757 <?php
758 // Check if the user is a Superuser
759 // TODO: set a global variable with this information
760 // loic1: optimized query
761 $result = @mysql_query('USE mysql');
762 $is_superuser = (!mysql_error());
764 // Display the DROP DATABASE link only if allowed to do so
765 if ($cfgAllowUserDropDatabase || $is_superuser) {
767 <!-- Drop database -->
768 <li>
769 <a href="sql.php3?server=<?php echo $server; ?>&amp;lang=<?php echo $lang; ?>&amp;db=<?php echo urlencode($db); ?>&amp;sql_query=<?php echo urlencode('DROP DATABASE ' . PMA_backquote($db)); ?>&amp;zero_rows=<?php echo urlencode(sprintf($strDatabaseHasBeenDropped, htmlspecialchars(PMA_backquote($db)))); ?>&amp;goto=main.php3&amp;back=db_details.php3&amp;reload=1"
770 onclick="return confirmLink(this, 'DROP DATABASE <?php echo PMA_jsFormat($db); ?>')">
771 <?php echo $strDropDB . ' ' . htmlspecialchars($db); ?></a>
772 <?php echo PMA_showDocuShort('D/R/DROP_DATABASE.html') . "\n"; ?>
773 </li>
774 <?php
776 echo "\n";
779 </ul>
782 <?php
784 * Displays the footer
786 echo "\n";
787 require('./footer.inc.php3');