home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 April / PCWorld_2005-04_cd.bin / akce / web / phptriad / phptriad2-2-1.exe / htdocs / phpmyadmin / db_details.php < prev    next >
PHP Script  |  2002-01-06  |  29KB  |  747 lines

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