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 / tbl_properties.php < prev    next >
PHP Script  |  2002-01-06  |  52KB  |  1,213 lines

  1. <?php
  2. /* $Id: tbl_properties.php,v 1.125 2001/12/23 22:55:49 lem9 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 = 'db_details.php'
  17.            . '?lang=' . $lang
  18.            . '&server=' . $server
  19.            . '&db=' . urlencode($db);
  20. $err_url   = 'tbl_properties.php'
  21.            . '?lang=' . $lang
  22.            . '&server=' . $server
  23.            . '&db=' . urlencode($db)
  24.            . '&table=' . urlencode($table);
  25.  
  26.  
  27. /**
  28.  * Ensures the database and the table exist (else move to the "parent" script)
  29.  * and diplays headers
  30.  */
  31. if (!isset($is_db) || !$is_db) {
  32.     // Not a valid db name -> back to the welcome page
  33.     if (!empty($db)) {
  34.         $is_db = @mysql_select_db($db);
  35.     }
  36.     if (empty($db) || !$is_db) {
  37.         header('Location: ' . $cfgPmaAbsoluteUri . 'main.php?lang=' . $lang . '&server=' . $server . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
  38.         exit();
  39.     }
  40. } // end if (ensures db exists)
  41. if (!isset($is_table) || !$is_table) {
  42.     // Not a valid table name -> back to the db_details.php
  43.     if (!empty($table)) {
  44.         $is_table = @mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
  45.     }
  46.     if (empty($table) || !@mysql_numrows($is_table)) {
  47.         header('Location: ' . $cfgPmaAbsoluteUri . 'db_details.php?lang=' . $lang . '&server=' . $server . '&db=' . urlencode($db) . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
  48.         exit();
  49.     } else if (isset($is_table)) {
  50.         mysql_free_result($is_table);
  51.     }
  52. } // end if (ensures table exists)
  53.  
  54. // Displays headers
  55. if (!isset($message)) {
  56.     $js_to_run = 'functions.js';
  57.     include('./header.inc.php');
  58. } else {
  59.     PMA_showMessage($message);
  60. }
  61.  
  62.  
  63. /**
  64.  * Drop/delete mutliple tables if required
  65.  */
  66. if ((!empty($submit_mult) && isset($selected_fld))
  67.     || isset($mult_btnDrop)) {
  68.     $action = 'tbl_properties.php';
  69.     include('./mult_submits.inc.php');
  70. }
  71.  
  72.  
  73. /**
  74.  * Defines the query to be displayed in the query textarea
  75.  */
  76. if (isset($show_query) && $show_query == 'y') {
  77.     // This script has been called by read_dump.php
  78.     if (isset($sql_query_cpy)) {
  79.         $query_to_display = $sql_query_cpy;
  80.     }
  81.     // Other cases
  82.     else if (get_magic_quotes_gpc()) {
  83.         $query_to_display = stripslashes($sql_query);
  84.     }
  85.     else {
  86.         $query_to_display = $sql_query;
  87.     }
  88. } else {
  89.     $query_to_display     = '';
  90. }
  91. unset($sql_query);
  92.  
  93.  
  94. /**
  95.  * Set parameters for links
  96.  */
  97. $url_query = 'lang=' . $lang
  98.            . '&server=' . $server
  99.            . '&db=' . urlencode($db)
  100.            . '&table=' . urlencode($table)
  101.            . '&goto=tbl_properties.php';
  102.  
  103.  
  104. /**
  105.  * Updates table type, comment and order if required
  106.  */
  107. if (isset($submitcomment)) {
  108.     if (get_magic_quotes_gpc()) {
  109.         $comment = stripslashes($comment);
  110.     }
  111.     if (empty($prev_comment) || urldecode($prev_comment) != $comment) {
  112.         $local_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
  113.         $result      = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
  114.     }
  115. }
  116. if (isset($submittype)) {
  117.     $local_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type;
  118.     $result      = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
  119. }
  120. if (isset($submitorderby) && !empty($order_field)) {
  121.     $order_field = PMA_backquote(urldecode($order_field));
  122.     $local_query = 'ALTER TABLE ' . PMA_backquote($table) . 'ORDER BY ' . $order_field;
  123.     $result      = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
  124. }
  125.  
  126.  
  127. /**
  128.  * Gets table informations and displays these informations and also top
  129.  * browse/select/insert/empty links
  130.  */
  131. // The 'show table' statement works correct since 3.23.03
  132. if (PMA_MYSQL_INT_VERSION >= 32303) {
  133.     $local_query  = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'';
  134.     $result       = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  135.     $showtable    = mysql_fetch_array($result);
  136.     $tbl_type     = strtoupper($showtable['Type']);
  137.     $num_rows     = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
  138.     $show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
  139. } else {
  140.     $local_query  = 'SELECT COUNT(*) AS count FROM ' . PMA_backquote($table);
  141.     $result       = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  142.     $showtable    = array();
  143.     $num_rows     = mysql_result($result, 0, 'count');
  144.     $show_comment = '';
  145. }
  146. mysql_free_result($result);
  147. ?>
  148.  
  149. <?php
  150. if ($num_rows > 0) {
  151.     echo "\n";
  152.     ?>
  153. <!-- first browse links --> 
  154. <p>
  155.     [ <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0">
  156.         <b><?php echo $strBrowse; ?></b></a> ]   
  157.     [ <a href="tbl_select.php?<?php echo $url_query; ?>">
  158.         <b><?php echo $strSelect; ?></b></a> ]   
  159.     [ <a href="tbl_change.php?<?php echo $url_query; ?>">
  160.         <b><?php echo $strInsert; ?></b></a> ]   
  161.     [ <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))); ?>"
  162.          onclick="return confirmLink(this, 'DELETE FROM <?php echo PMA_jsFormat($table); ?>')">
  163.          <b><?php echo $strEmpty; ?></b></a> ]      
  164.     [ <a href="sql.php?<?php echo ereg_replace('tbl_properties.php$', 'db_details.php', $url_query); ?>&back=tbl_properties.php&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
  165.          onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
  166.          <b><?php echo $strDrop; ?></b></a> ]
  167. </p>
  168.     <?php
  169. } else {
  170.     echo "\n";
  171.     ?>
  172. <!-- first browse links -->
  173. <p>
  174.     [ <b><?php echo $strBrowse; ?></b> ]   
  175.     [ <b><?php echo $strSelect; ?></b> ]   
  176.     [ <a href="tbl_change.php?<?php echo $url_query; ?>">
  177.         <b><?php echo $strInsert; ?></b></a> ]   
  178.     [ <b><?php echo $strEmpty; ?></b> ]      
  179.     [ <a href="sql.php?<?php echo ereg_replace('tbl_properties.php$', 'db_details.php', $url_query); ?>&back=tbl_properties.php&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
  180.          onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
  181.          <b><?php echo $strDrop; ?></b></a> ]
  182. </p>
  183.     <?php
  184. }
  185. echo "\n";
  186.  
  187. if (!empty($show_comment)) {
  188.     ?>
  189. <!-- Table comment -->
  190. <p><i>
  191.     <?php echo $show_comment . "\n"; ?>
  192. </i></p>
  193.     <?php
  194. } // end (1.)
  195.  
  196. // 2. Gets table keys and retains them
  197. $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
  198. $result      = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  199. $primary     = '';
  200. $ret_keys    = array();
  201. $pk_array    = array(); // will be use to emphasis prim. keys in the table view
  202. while ($row = mysql_fetch_array($result)) {
  203.     $ret_keys[]  = $row;
  204.     // Backups the list of primary keys
  205.     if ($row['Key_name'] == 'PRIMARY') {
  206.         $primary .= $row['Column_name'] . ', ';
  207.         $pk_array[$row['Column_name']] = 1;
  208.     }
  209. } // end while
  210. mysql_free_result($result);
  211.  
  212.  
  213. // 3. Get fields
  214. $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
  215. $fields_rs   = mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  216. $fields_cnt  = mysql_num_rows($fields_rs);
  217.  
  218.  
  219.  
  220. /**
  221.  * Displays the table structure ('show table' works correct since 3.23.03)
  222.  */
  223. ?>
  224.  
  225. <!-- TABLE INFORMATIONS -->
  226.  
  227. <form action="tbl_properties.php">
  228.     <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  229.     <input type="hidden" name="server" value="<?php echo $server; ?>" />
  230.     <input type="hidden" name="db" value="<?php echo $db; ?>" />
  231.     <input type="hidden" name="table" value="<?php echo $table; ?>" />
  232.  
  233. <table border="<?php echo $cfgBorder; ?>">
  234. <tr>
  235.     <td></td>
  236.     <th> <?php echo ucfirst($strField); ?> </th>
  237.     <th><?php echo ucfirst($strType); ?></th>
  238.     <th><?php echo ucfirst($strAttr); ?></th>
  239.     <th><?php echo ucfirst($strNull); ?></th>
  240.     <th><?php echo ucfirst($strDefault); ?></th>
  241.     <th><?php echo ucfirst($strExtra); ?></th>
  242.     <th colspan="<?php echo((PMA_MYSQL_INT_VERSION >= 32323) ? '6' : '5'); ?>"><?php echo ucfirst($strAction); ?></th>
  243. </tr>
  244.  
  245. <?php
  246. $i         = 0;
  247. $aryFields = array();
  248.  
  249. while ($row = mysql_fetch_array($fields_rs)) {
  250.     $i++;
  251.     $bgcolor          = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
  252.     $aryFields[]      = $row['Field'];
  253.  
  254.     $type             = $row['Type'];
  255.     // reformat mysql query output - staybyte - 9. June 2001
  256.     // loic1: set or enum types: slashes single quotes inside options
  257.     if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
  258.         $tmp[2]       = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
  259.         $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
  260.         $type_nowrap  = '';
  261.     } else {
  262.         $type_nowrap  = ' nowrap="nowrap"';
  263.     }
  264.     $type             = eregi_replace('BINARY', '', $type);
  265.     $type             = eregi_replace('ZEROFILL', '', $type);
  266.     $type             = eregi_replace('UNSIGNED', '', $type);
  267.     if (empty($type)) {
  268.         $type         = ' ';
  269.     }
  270.  
  271.     $binary           = eregi('BINARY', $row['Type'], $test);
  272.     $unsigned         = eregi('UNSIGNED', $row['Type'], $test);
  273.     $zerofill         = eregi('ZEROFILL', $row['Type'], $test);
  274.     $strAttribute     = ' ';
  275.     if ($binary) {
  276.         $strAttribute = 'BINARY';
  277.     }
  278.     if ($unsigned) {
  279.         $strAttribute = 'UNSIGNED';
  280.     }
  281.     if ($zerofill) {
  282.         $strAttribute = 'UNSIGNED ZEROFILL';
  283.     }
  284.     if (!isset($row['Default'])) {
  285.         if ($row['Null'] != '') {
  286.             $row['Default'] = '<i>NULL</i>';
  287.         }
  288.     } else {
  289.         $row['Default'] = htmlspecialchars($row['Default']);
  290.     }
  291.     $field_name = htmlspecialchars($row['Field']);
  292.     if (isset($pk_array[$row['Field']])) {
  293.         $field_name = '<u>' . $field_name . '</u>';
  294.     }
  295.     echo "\n";
  296.     ?>
  297. <tr>
  298.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  299.         <input type="checkbox" name="selected_fld[]" value="<?php echo urlencode($row['Field']); ?>" />
  300.     </td>
  301.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"> <?php echo $field_name; ?> </td>
  302.     <td bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>><?php echo $type; ?><bdo dir="ltr"></bdo></td>
  303.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>
  304.     <td bgcolor="<?php echo $bgcolor; ?>"><?php echo (($row['Null'] == '') ? $strNo : $strYes); ?> </td>
  305.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?> </td>
  306.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?> </td>
  307.     <td bgcolor="<?php echo $bgcolor; ?>">
  308.         <a href="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo urlencode($row['Field']); ?>">
  309.             <?php echo $strChange; ?></a>
  310.     </td>
  311.     <td bgcolor="<?php echo $bgcolor; ?>">
  312.         <?php
  313.         // loic1: Drop field only if there is more than one field in the table
  314.         if ($fields_cnt > 1) {
  315.             echo "\n";
  316.             ?>
  317.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
  318.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
  319.             <?php echo $strDrop; ?></a>
  320.             <?php
  321.         } else {
  322.             echo "\n" . '        ' . $strDrop;
  323.         }
  324.         echo "\n";
  325.         ?>
  326.     </td>
  327.     <td bgcolor="<?php echo $bgcolor; ?>">
  328.         <?php
  329.         if ($type == 'text' || $type == 'blob') {
  330.             echo $strPrimary . "\n";
  331.         } else {
  332.             echo "\n";
  333.             ?>
  334.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY, ADD PRIMARY KEY(' . $primary . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
  335.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP PRIMARY KEY, ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
  336.             <?php echo $strPrimary; ?></a>
  337.             <?php
  338.         }
  339.         echo "\n";
  340.         ?>
  341.     </td>
  342.     <td bgcolor="<?php echo $bgcolor; ?>">
  343.         <?php
  344.         if ($type == 'text' || $type == 'blob') {
  345.             echo $strIndex . "\n";
  346.         } else {
  347.             echo "\n";
  348.             ?>
  349.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex ,htmlspecialchars($row['Field']))); ?>">
  350.             <?php echo $strIndex; ?></a>
  351.             <?php
  352.         }
  353.         echo "\n";
  354.         ?>
  355.     </td>
  356.     <td bgcolor="<?php echo $bgcolor; ?>">
  357.         <?php
  358.         if ($type == 'text' || $type == 'blob') {
  359.             echo $strUnique . "\n";
  360.         } else {
  361.             echo "\n";
  362.             ?>
  363.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex , htmlspecialchars($row['Field']))); ?>">
  364.             <?php echo $strUnique; ?></a>
  365.             <?php
  366.         }
  367.         echo "\n";
  368.         ?>
  369.     </td>
  370.     <?php
  371.     if (PMA_MYSQL_INT_VERSION >= 32323) {
  372.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
  373.             && ($type == 'text' || strpos(' ' . $type, 'varchar'))) {
  374.             echo "\n";
  375.             ?>
  376.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  377.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAnIndex , htmlspecialchars($row['Field']))); ?>">
  378.             <?php echo $strIdxFulltext; ?></a>
  379.     </td>
  380.             <?php
  381.         } else {
  382.             echo "\n";
  383.             ?>
  384.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  385.         <?php echo $strIdxFulltext . "\n"; ?>
  386.     </td>
  387.             <?php
  388.         } // end if... else...
  389.     } // end if
  390.     echo "\n"
  391.     ?>
  392. </tr>
  393.     <?php
  394. } // end while
  395.  
  396. echo "\n";
  397. ?>
  398.  
  399. <tr>
  400.     <td colspan="<?php echo((PMA_MYSQL_INT_VERSION >= 32323) ? '13' : '12'); ?>">
  401.         <img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
  402.         <i><?php echo $strWithChecked; ?></i>  
  403.         <input type="submit" name="submit_mult" value="<?php echo $strChange; ?>" />
  404. <?php
  405. // Drop button if there is at least two fields
  406. if ($fields_cnt > 1) {
  407.     ?>
  408.          <i><?php echo $strOr; ?></i> 
  409.         <input type="submit" name="submit_mult" value="<?php echo $strDrop; ?>" />
  410.     <?php
  411. }
  412. echo "\n";
  413. ?>
  414.     </td>
  415. </tr>
  416. </table>
  417.  
  418. </form>
  419.  
  420.  
  421. <?php
  422. /**
  423.  * If there are more than 20 rows, displays browse/select/insert/empty/drop
  424.  * links again
  425.  */
  426. if ($fields_cnt > 20) {
  427.     if ($num_rows > 0) {
  428.         ?>
  429. <!-- Browse links --> 
  430. <p>
  431.     [ <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table)); ?>&pos=0">
  432.         <b><?php echo $strBrowse; ?></b></a> ]   
  433.     [ <a href="tbl_select.php?<?php echo $url_query; ?>">
  434.         <b><?php echo $strSelect; ?></b></a> ]   
  435.     [ <a href="tbl_change.php?<?php echo $url_query; ?>">
  436.         <b><?php echo $strInsert; ?></b></a> ]   
  437.     [ <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))); ?>"
  438.          onclick="return confirmLink(this, 'DELETE FROM <?php echo PMA_jsFormat($table); ?>')">
  439.          <b><?php echo $strEmpty; ?></b></a> ]      
  440.     [ <a href="sql.php?<?php echo ereg_replace('tbl_properties.php$', 'db_details.php', $url_query); ?>&back=tbl_properties.php&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
  441.          onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
  442.          <b><?php echo $strDrop; ?></b></a> ]
  443. </p>
  444.         <?php
  445.     } else {
  446.         echo "\n";
  447.         ?>
  448. <!-- first browse links -->
  449. <p>
  450.     [ <b><?php echo $strBrowse; ?></b> ]   
  451.     [ <b><?php echo $strSelect; ?></b> ]   
  452.     [ <a href="tbl_change.php?<?php echo $url_query; ?>">
  453.         <b><?php echo $strInsert; ?></b></a> ]   
  454.     [ <b><?php echo $strEmpty; ?></b> ]      
  455.     [ <a href="sql.php?<?php echo ereg_replace('tbl_properties.php$', 'db_details.php', $url_query); ?>&back=tbl_properties.php&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
  456.          onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
  457.          <b><?php echo $strDrop; ?></b></a> ]
  458. </p>
  459.         <?php
  460.     } // end if...else
  461. } // end if ($fields_cnt > 20)
  462. echo "\n\n";
  463.  
  464.  
  465. /**
  466.  * Displays indexes
  467.  */
  468. ?>
  469. <!-- Indexes, space usage and row statistics -->
  470. <br />
  471. <table border="0" cellspacing="0" cellpadding="0">
  472. <tr>
  473.     <td>
  474. <?php
  475. define('PMA_IDX_INCLUDED', 1);
  476. require ('./tbl_indexes.php');
  477. ?>
  478.     </td>
  479.  
  480. <?php
  481. /**
  482.  * Displays Space usage and row statistics
  483.  */
  484. // BEGIN - Calc Table Space - staybyte - 9 June 2001
  485. if ($cfgShowStats) {
  486.     $nonisam     = FALSE;
  487.     if (isset($showtable['Type']) && !eregi('ISAM|HEAP', $showtable['Type'])) {
  488.         $nonisam = TRUE;
  489.     }
  490.     if (PMA_MYSQL_INT_VERSION >= 32303 && $nonisam == FALSE) {
  491.         // Gets some sizes
  492.         $mergetable     = FALSE;
  493.         if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
  494.             $mergetable = TRUE;
  495.         }
  496.         list($data_size, $data_unit)         = PMA_formatByteDown($showtable['Data_length']);
  497.         if ($mergetable == FALSE) {
  498.             list($index_size, $index_unit)   = PMA_formatByteDown($showtable['Index_length']);
  499.         }
  500.         if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
  501.             list($free_size, $free_unit)     = PMA_formatByteDown($showtable['Data_free']);
  502.             list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
  503.         } else {
  504.             list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  505.         }
  506.         list($tot_size, $tot_unit)           = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  507.         if ($num_rows > 0) {
  508.             list($avg_size, $avg_unit)       = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
  509.         }
  510.  
  511.         // Displays them
  512.         ?>
  513.  
  514.     <!-- Space usage -->
  515.     <td width="20"> </td>
  516.     <td valign="top">
  517.         <?php echo $strSpaceUsage . ' :' . "\n"; ?>
  518.         <a name="showusage"></a>
  519.         <table border="<?php echo $cfgBorder; ?>">
  520.         <tr>
  521.             <th><?php echo $strType; ?></th>
  522.             <th colspan="2" align="center"><?php echo $strUsage; ?></th>
  523.         </tr>
  524.         <tr>
  525.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" style="padding-right: 10px"><?php echo ucfirst($strData); ?></td>
  526.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" align="right" nowrap="nowrap"><?php echo $data_size; ?></td>
  527.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>"><?php echo $data_unit; ?></td>
  528.         </tr>
  529.         <?php
  530.         if (isset($index_size)) {
  531.             echo "\n";
  532.             ?>
  533.         <tr>
  534.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" style="padding-right: 10px"><?php echo ucfirst($strIndex); ?></td>
  535.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" align="right" nowrap="nowrap"><?php echo $index_size; ?></td>
  536.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>"><?php echo $index_unit; ?></td>
  537.         </tr>
  538.             <?php
  539.         }
  540.         if (isset($free_size)) {
  541.             echo "\n";
  542.             ?>
  543.         <tr style="color: #bb0000">
  544.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" style="padding-right: 10px"><?php echo ucfirst($strOverhead); ?></td>
  545.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>" align="right" nowrap="nowrap"><?php echo $free_size; ?></td>
  546.             <td bgcolor="<?php echo $cfgBgcolorTwo; ?>"><?php echo $free_unit; ?></td>
  547.         </tr>
  548.         <tr>
  549.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>" style="padding-right: 10px"><?php echo ucfirst($strEffective); ?></td>
  550.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>" align="right" nowrap="nowrap"><?php echo $effect_size; ?></td>
  551.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>"><?php echo $effect_unit; ?></td>
  552.         </tr>
  553.             <?php
  554.         }
  555.         if (isset($tot_size) && $mergetable == FALSE) {
  556.             echo "\n";
  557.         ?>
  558.         <tr>
  559.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>" style="padding-right: 10px"><?php echo ucfirst($strTotal); ?></td>
  560.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>" align="right" nowrap="nowrap"><?php echo $tot_size; ?></td>
  561.             <td bgcolor="<?php echo $cfgBgcolorOne; ?>"><?php echo $tot_unit; ?></td>
  562.         </tr>
  563.             <?php
  564.         }
  565.         // Optimize link if overhead
  566.         if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
  567.             echo "\n";
  568.             ?>
  569.         <tr>
  570.             <td colspan="3" align="center">
  571.                 [<a href="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php echo $strOptimizeTable; ?></a>]
  572.             </td>
  573.         <tr>
  574.             <?php
  575.         }
  576.         echo "\n";
  577.         ?>
  578.         </table>
  579.     </td>
  580.  
  581.     <!-- Rows Statistic -->
  582.     <td width="20"> </td>
  583.     <td valign="top">
  584.         <?php echo $strRowsStatistic . ' :' . "\n"; ?>
  585.         <table border="<?php echo $cfgBorder; ?>">
  586.         <tr>
  587.             <th><?php echo $strStatement; ?></th>
  588.             <th align="center"><?php echo $strValue; ?></th>
  589.         </tr>
  590.         <?php
  591.         $i = 0;
  592.         if (isset($showtable['Row_format'])) {
  593.             $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
  594.             echo "\n";
  595.             ?>
  596.         <tr>
  597.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ucfirst($strFormat); ?></td>
  598.             <td bgcolor="<?php echo $bgcolor; ?>" align="<?php echo $cell_align_left; ?>" nowrap="nowrap">
  599.             <?php
  600.             echo '                ';
  601.             if ($showtable['Row_format'] == 'Fixed') {
  602.                 echo $strFixed;
  603.             }
  604.             else if ($showtable['Row_format'] == 'Dynamic') {
  605.                 echo $strDynamic;
  606.             }
  607.             else {
  608.                 echo $showtable['Row_format'];
  609.             }
  610.             echo "\n";
  611.             ?>
  612.             </td>
  613.         </tr>
  614.             <?php
  615.         }
  616.         if (isset($showtable['Rows'])) {
  617.             $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
  618.             echo "\n";
  619.             ?>
  620.         <tr>
  621.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ucfirst($strRows); ?></td>
  622.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  623.                 <?php echo number_format($showtable['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  624.             </td>
  625.         </tr>
  626.             <?php
  627.         }
  628.         if (isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
  629.             $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
  630.             echo "\n";
  631.             ?>
  632.         <tr>
  633.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ucfirst($strRowLength); ?> ø</td>
  634.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  635.                 <?php echo number_format($showtable['Avg_row_length'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  636.             </td>
  637.         </tr>
  638.             <?php
  639.         }
  640.         if (isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
  641.             $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
  642.             echo "\n";
  643.             ?>
  644.         <tr>
  645.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ucfirst($strRowSize); ?> ø</td>
  646.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  647.                 <?php echo $avg_size . ' ' . $avg_unit . "\n"; ?>
  648.             </td>
  649.         </tr>
  650.             <?php
  651.         }
  652.         if (isset($showtable['Auto_increment'])) {
  653.             $bgcolor = ((++$i%2) ? $cfgBgcolorTwo : $cfgBgcolorOne);
  654.             echo "\n";
  655.             ?>
  656.         <tr>
  657.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo ucfirst($strNext); ?> Autoindex</td>
  658.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  659.                 <?php echo number_format($showtable['Auto_increment'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  660.             </td>
  661.         </tr>
  662.             <?php
  663.         }
  664.         echo "\n";
  665.         ?>
  666.         </table>
  667.     </td>
  668.         <?php
  669.     }
  670. }
  671. // END - Calc Table Space
  672. echo "\n";
  673. ?>
  674. </tr>
  675. </table>
  676. <hr />
  677.  
  678.  
  679.  
  680. <?php
  681. /**
  682.  * Work on the table
  683.  */
  684. ?>
  685. <!-- TABLE WORK -->
  686. <ul>
  687.  
  688.     <!-- Printable view of the table -->
  689.     <li>
  690.         <div style="margin-bottom: 10px"><a href="tbl_printview.php?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
  691.     </li>
  692.  
  693.     <!-- Query box and bookmark support -->
  694.     <a name="querybox"></a>
  695.     <li>
  696.         <form method="post" action="read_dump.php" enctype="multipart/form-data"
  697.             onsubmit="return checkSqlQuery(this)">
  698.             <input type="hidden" name="is_js_confirmed" value="0" />
  699.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  700.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  701.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  702.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  703.             <input type="hidden" name="pos" value="0" />
  704.             <input type="hidden" name="goto" value="tbl_properties.php" />
  705.             <input type="hidden" name="zero_rows" value="<?php echo $strSuccess; ?>" />
  706.             <input type="hidden" name="prev_sql_query" value="<?php echo ((!empty($query_to_display)) ? urlencode($query_to_display) : ''); ?>" />
  707.             <?php echo sprintf($strRunSQLQuery,  htmlspecialchars($db)) . ' ' . PMA_showDocuShort('S/E/SELECT.html'); ?> :<br />
  708.             <div style="margin-bottom: 5px">
  709. <textarea name="sql_query" rows="<?php echo $cfgTextareaRows; ?>" cols="<?php echo $cfgTextareaCols; ?>" wrap="virtual" onfocus="this.select()">
  710. <?php echo ((!empty($query_to_display)) ? htmlspecialchars($query_to_display) : 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE 1'); ?>
  711. </textarea><br />
  712.             <input type="checkbox" name="show_query" value="y" checked="checked" /> 
  713.                 <?php echo $strShowThisQuery; ?><br />
  714.             </div>
  715. <?php
  716. // loic1: displays import dump feature only if file upload available
  717. $is_upload = (PMA_PHP_INT_VERSION >= 40000 && function_exists('ini_get'))
  718.            ? ((strtolower(ini_get('file_uploads')) == 'on' || ini_get('file_uploads') == 1) && intval(ini_get('upload_max_filesize')))
  719.            : (intval(@get_cfg_var('upload_max_filesize')));
  720. if ($is_upload) {
  721.     echo '            <i>' . $strOr . '</i> ' . $strLocationTextfile . ' :<br />' . "\n";
  722.     ?>
  723.             <div style="margin-bottom: 5px">
  724.             <input type="file" name="sql_file" /><br />
  725.             </div>
  726.     <?php
  727. } // end if
  728. echo "\n";
  729.  
  730. // Bookmark Support
  731. if ($cfgBookmark['db'] && $cfgBookmark['table']) {
  732.     if (($bookmark_list = PMA_listBookmarks($db, $cfgBookmark)) && count($bookmark_list) > 0) {
  733.         echo "            <i>$strOr</i> $strBookmarkQuery :<br />\n";
  734.         echo '            <div style="margin-bottom: 5px">' . "\n";
  735.         echo '            <select name="id_bookmark" style="vertical-align: middle">' . "\n";
  736.         echo '                <option value=""></option>' . "\n";
  737.         while (list($key, $value) = each($bookmark_list)) {
  738.             echo '                <option value="' . $value . '">' . htmlentities($key) . '</option>' . "\n";
  739.         }
  740.         echo '            </select>' . "\n";
  741.         echo '            <input type="radio" name="action_bookmark" value="0" checked="checked" style="vertical-align: middle" />' . $strSubmit . "\n";
  742.         echo '             <input type="radio" name="action_bookmark" value="1" style="vertical-align: middle" />' . $strBookmarkView . "\n";
  743.         echo '             <input type="radio" name="action_bookmark" value="2" style="vertical-align: middle" />' . $strDelete . "\n";
  744.         echo '            <br />' . "\n";
  745.         echo '            </div>' . "\n";
  746.     }
  747. }
  748. ?>
  749.             <input type="submit" name="SQL" value="<?php echo $strGo; ?>" />
  750.         </form>
  751.     </li>
  752.  
  753.     <!-- Add some new fields -->
  754.     <li>
  755.         <form method="post" action="tbl_addfield.php"
  756.             onsubmit="return checkFormElementInRange(this, 'num_fields', 1)">
  757.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  758.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  759.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  760.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  761.             <?php echo $strAddNewField; ?> :
  762.             <input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />
  763.             <select name="after_field" style="vertical-align: middle">
  764.                 <option value="--end--"><?php echo $strAtEndOfTable; ?></option>
  765.                 <option value="--first--"><?php echo $strAtBeginningOfTable; ?></option>
  766. <?php
  767. reset($aryFields);
  768. while (list($junk, $fieldname) = each($aryFields)) {
  769.     echo '                <option value="' . urlencode($fieldname) . '">' . $strAfter . ' ' . htmlspecialchars($fieldname) . '</option>' . "\n";
  770. }
  771. ?>
  772.             </select>
  773.             <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  774.         </form>
  775.     </li>
  776.  
  777. <?php
  778. if (PMA_MYSQL_INT_VERSION >= 32334) {
  779.     ?>
  780.     <!-- Order the table -->
  781.     <li>
  782.         <form method="post" action="tbl_properties.php">
  783.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  784.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  785.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  786.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  787.             <?php echo $strAlterOrderBy; ?> :
  788.             <select name="order_field" style="vertical-align: middle">
  789.     <?php
  790.     echo "\n";
  791.     reset($aryFields);
  792.     while (list($junk, $fieldname) = each($aryFields)) {
  793.         echo '                <option value="' . urlencode($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
  794.     }
  795.     ?>
  796.             </select>
  797.             <input type="submit" name="submitorderby" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  798.              <?php echo $strSingly . "\n"; ?>
  799.         </form>
  800.     </li>
  801.     <?php
  802. }
  803. echo "\n";
  804. ?>
  805.  
  806.     <!-- Insert a text file -->
  807.     <li>
  808.         <div style="margin-bottom: 10px"><a href="ldi_table.php?<?php echo $url_query; ?>"><?php echo $strInsertTextfiles; ?></a></div>
  809.     </li>
  810.  
  811.     <!-- Dump of a database -->
  812.     <li>
  813.         <form method="post" action="tbl_dump.php" name="tbl_dump">
  814.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  815.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  816.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  817.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  818.             <?php echo $strViewDump; ?><br />
  819.             <table cellpadding="5" border="2">
  820.             <tr>
  821.                 <td nowrap="nowrap">
  822.                     <input type="radio" name="what" value="structure" checked="checked" />
  823.                     <?php echo $strStrucOnly; ?>  <br />
  824.                     <input type="radio" name="what" value="data" />
  825.                     <?php echo $strStrucData; ?>  <br />
  826.                     <input type="radio" name="what" value="dataonly" />
  827.                     <?php echo $strDataOnly; ?>  <br />
  828.                     <input type="radio" name="what" value="excel" />
  829.                     <?php echo $strStrucExcelCSV; ?>  <br />
  830.                     <input type="radio" name="what" value="csv" />
  831.                     <?php echo $strStrucCSV;?> :<br />
  832.                           <?php echo $strFieldsTerminatedBy; ?> 
  833.                     <input type="text" name="separator" size="2" value=";" />  <br />
  834.                           <?php echo $strFieldsEnclosedBy; ?> 
  835.                     <input type="text" name="enclosed" size="1" value=""" />  <br />
  836.                           <?php echo $strFieldsEscapedBy; ?> 
  837.                     <input type="text" name="escaped" size="2" value="\" />  <br />
  838.                           <?php echo $strLinesTerminatedBy; ?> 
  839.                     <input type="text" name="add_character" size="2" value="<?php echo ((PMA_whichCrlf() == "\n") ? '\n' : '\r\n'); ?>" />  
  840.                 </td>
  841.                 <td valign="middle">
  842.                     <input type="checkbox" name="drop" value="1" />
  843.                     <?php echo $strStrucDrop; ?><br />
  844.                     <input type="checkbox" name="showcolumns" value="yes" />
  845.                     <?php echo $strCompleteInserts; ?><br />
  846.                     <input type="checkbox" name="extended_ins" value="yes" />
  847.                     <?php echo $strExtendedInserts; ?><br />
  848. <?php
  849. // Add backquotes checkbox
  850. if (PMA_MYSQL_INT_VERSION >= 32306) {
  851.     ?>
  852.                     <input type="checkbox" name="use_backquotes" value="1" />
  853.                     <?php echo $strUseBackquotes; ?><br />
  854.     <?php
  855. } // end backquotes feature
  856. echo "\n";
  857. ?>
  858.                     <br />
  859.                     <input type="checkbox" name="asfile" value="sendit" onclick="return checkTransmitDump(this.form, 'transmit')" />
  860.                     <?php echo $strSend . "\n"; ?>
  861. <?php
  862. // zip, gzip and bzip2 encode features
  863. if (PMA_PHP_INT_VERSION >= 40004) {
  864.     $is_zip  = (isset($cfgZipDump) && $cfgZipDump && @function_exists('gzcompress'));
  865.     $is_gzip = (isset($cfgGZipDump) && $cfgGZipDump && @function_exists('gzencode'));
  866.     $is_bzip = (isset($cfgBZipDump) && $cfgBZipDump && @function_exists('bzcompress'));
  867.     if ($is_zip || $is_gzip || $is_bzip) {
  868.         echo "\n" . '                    (' . "\n";
  869.         if ($is_zip) {
  870.             ?>
  871.                     <input type="checkbox" name="zip" value="zip" onclick="return checkTransmitDump(this.form, 'zip')" /><?php echo $strZip . (($is_gzip || $is_bzip) ? ' ' : '') . "\n"; ?>
  872.             <?php
  873.         }
  874.         if ($is_gzip) {
  875.             echo "\n"
  876.             ?>
  877.                     <input type="checkbox" name="gzip" value="gzip" onclick="return checkTransmitDump(this.form, 'gzip')" /><?php echo $strGzip . (($is_bzip) ? ' ' : '') . "\n"; ?>
  878.             <?php
  879.         }
  880.         if ($is_bzip) {
  881.             echo "\n"
  882.             ?>
  883.                     <input type="checkbox" name="bzip" value="bzip" onclick="return checkTransmitDump(this.form, 'bzip')" /><?php echo $strBzip . "\n"; ?>
  884.             <?php
  885.         }
  886.         echo "\n" . '                    )';
  887.     }
  888. }
  889. echo "\n";
  890. ?>
  891.                 </td>
  892.             </tr>
  893.             <tr>
  894.                 <td colspan="2">
  895.                      <?php echo $strStartingRecord; ?> 
  896.                     <input type="text" name="limit_from" value="0" size="5" style="vertical-align: middle" onfocus="this.select()" />
  897.                      -- <?php echo $strNbRecords; ?> 
  898.                     <input type="text" name="limit_to" size="5" value="<?php echo PMA_countRecords($db, $table, TRUE); ?>" style="vertical-align: middle" onfocus="this.select()" />
  899.                 </td>
  900.             </tr>
  901.             <tr>
  902.                 <td colspan="2" align="center">
  903.                     <input type="submit" value="<?php echo $strGo; ?>" />
  904.                 </td>
  905.             </tr>
  906.             </table>
  907.         </form>
  908.     </li>
  909.  
  910.     <!-- Change table name -->
  911.     <li>
  912.         <div style="margin-bottom: 10px">
  913.             <form method="post" action="tbl_rename.php"
  914.                 onsubmit="return emptyFormElements(this, 'new_name')">
  915.                 <input type="hidden" name="server" value="<?php echo $server; ?>" />
  916.                 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  917.                 <input type="hidden" name="db" value="<?php echo $db; ?>" />
  918.                 <input type="hidden" name="table" value="<?php echo $table; ?>" />
  919.                 <input type="hidden" name="reload" value="1" />
  920.                 <?php echo $strRenameTable; ?> :
  921.                 <input type="text" size="20" name="new_name" value="<?php echo htmlspecialchars($table); ?>" onfocus="this.select()" /> 
  922.                 <input type="submit" value="<?php echo $strGo; ?>" />
  923.             </form>
  924.         </div>
  925.     </li>
  926.  
  927.     <!-- Move and copy table -->
  928.     <li style="vertical-align: top">
  929.         <div style="margin-bottom: 10px">
  930.         <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
  931.         <tr>
  932.             <td valign="top">
  933.             <form method="post" action="tbl_move_copy.php"
  934.                 onsubmit="return emptyFormElements(this, 'new_name')">
  935.                 <input type="hidden" name="server" value="<?php echo $server; ?>" />
  936.                 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  937.                 <input type="hidden" name="db" value="<?php echo $db; ?>" />
  938.                 <input type="hidden" name="table" value="<?php echo $table; ?>" />
  939.                 <input type="hidden" name="reload" value="1" />
  940.                 <input type="hidden" name="what" value="data" />
  941.                 <table border="0" cellspacing="0" cellpadding="0">
  942.                 <tr>
  943.                     <td nowrap="nowrap">
  944.                         <?php echo $strMoveTable . "\n"; ?>
  945.                     </td>
  946.                 </tr>
  947.                 <tr>
  948.                     <td>
  949.                         <select name="target_db">
  950.                             <option value=""></option>
  951. <?php
  952. // The function used below is defined in "common.lib.php"
  953. PMA_availableDatabases('main.php?lang=' . $lang . '&server=' . $server);
  954. for ($i = 0; $i < $num_dbs; $i++) {
  955.     echo '                            ';
  956.     echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '">' . htmlspecialchars($dblist[$i]) . '</option>';
  957.     echo "\n";
  958. } // end for
  959. ?>
  960.                         </select>
  961.                          <b>.</b> 
  962.                         <input type="text" size="20" name="new_name" value="<?php echo $table; ?>" onfocus="this.select()" />
  963.                     </td>
  964.                 </tr>
  965.                 <tr>
  966.                     <td align="<?php echo $cell_align_right; ?>" valign="top">
  967.                         <input type="submit" name="submit_move" value="<?php echo $strGo; ?>" />
  968.                     </td>
  969.                 </tr>
  970.                 </table>
  971.             </form>
  972.             </td>
  973.             <td width="25"> </td>
  974.             <td valign="top">
  975.             <form method="post" action="tbl_move_copy.php"
  976.                 onsubmit="return emptyFormElements(this, 'new_name')">
  977.                 <input type="hidden" name="server" value="<?php echo $server; ?>" />
  978.                 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  979.                 <input type="hidden" name="db" value="<?php echo $db; ?>" />
  980.                 <input type="hidden" name="table" value="<?php echo $table; ?>" />
  981.                 <input type="hidden" name="reload" value="1" />
  982.                 <table border="0" cellspacing="0" cellpadding="0">
  983.                 <tr>
  984.                     <td colspan="2" nowrap="nowrap">
  985.                         <?php echo $strCopyTable . "\n"; ?>
  986.                     </td>
  987.                 </tr>
  988.                 <tr>
  989.                     <td colspan="2">
  990.                         <select name="target_db">
  991. <?php
  992. for ($i = 0; $i < $num_dbs; $i++) {
  993.     echo '                            ';
  994.     echo '<option value="' . str_replace('"', '"', $dblist[$i]) . '"';
  995.     if ($dblist[$i] == $db) {
  996.         echo ' selected="selected"';
  997.     }
  998.     echo '>' . htmlspecialchars($dblist[$i]) . '</option>';
  999.     echo "\n";
  1000. } // end for
  1001. ?>
  1002.                         </select>
  1003.                          <b>.</b> 
  1004.                         <input type="text" size="20" name="new_name" onfocus="this.select()" />
  1005.                     </td>
  1006.                 </tr>
  1007.                 <tr>
  1008.                     <td nowrap="nowrap">
  1009.                         <input type="radio" name="what" value="structure" checked="checked" />
  1010.                         <?php echo $strStrucOnly; ?>  <br />
  1011.                         <input type="radio" name="what" value="data" />
  1012.                         <?php echo $strStrucData; ?>  
  1013.                     </td>
  1014.                     <td align="<?php echo $cell_align_right; ?>" valign="top">
  1015.                         <input type="submit" name="submit_copy" value="<?php echo $strGo; ?>" />
  1016.                     </td>
  1017.                 </tr>
  1018.                 </table>
  1019.             </form>
  1020.         </td>
  1021.     </tr>
  1022.     </table>
  1023.     </div>
  1024.     </li>
  1025.  
  1026. <?php
  1027. if (PMA_MYSQL_INT_VERSION >= 32322) {
  1028.     if ($tbl_type == 'MYISAM' or $tbl_type == 'BDB') {
  1029.         ?>
  1030.     <!-- Table maintenance -->
  1031.     <li style="vertical-align: top">
  1032.         <div style="margin-bottom: 10px">
  1033.         <table border="0" cellspacing="0" cellpadding="0" style="vertical-align: top">
  1034.         <tr>
  1035.             <td><?php echo $strTableMaintenance; ?> : </td>
  1036.         <?php
  1037.         echo "\n";
  1038.         if ($tbl_type == 'MYISAM') {
  1039.             ?>
  1040.             <td>
  1041.                 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('CHECK TABLE ' . PMA_backquote($table)); ?>">
  1042.                     <?php echo $strCheckTable; ?></a> 
  1043.                 <?php echo PMA_showDocuShort('C/H/CHECK_TABLE.html') . "\n"; ?>
  1044.             </td>
  1045.             <td> - </td>
  1046.             <?php
  1047.         }
  1048.         echo "\n";
  1049.         if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
  1050.             ?>
  1051.             <td>
  1052.                 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ANALYZE TABLE ' . PMA_backquote($table)); ?>">
  1053.                     <?php echo $strAnalyzeTable; ?></a> 
  1054.                 <?php echo PMA_showDocuShort('A/N/ANALYZE_TABLE.html') . "\n";?>
  1055.             </td>
  1056.             <?php
  1057.         }
  1058.         echo "\n";
  1059.         ?>
  1060.         </tr>
  1061.         <tr>
  1062.             <td> </td>
  1063.         <?php
  1064.         echo "\n";
  1065.         if ($tbl_type == 'MYISAM') {
  1066.             ?>
  1067.             <td>
  1068.                 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('REPAIR TABLE ' . PMA_backquote($table)); ?>">
  1069.                     <?php echo $strRepairTable; ?></a> 
  1070.                 <?php echo PMA_showDocuShort('R/E/REPAIR_TABLE.html') . "\n"; ?>
  1071.             </td>
  1072.             <td> - </td>
  1073.             <?php
  1074.         }
  1075.         echo "\n";
  1076.         if ($tbl_type == 'MYISAM' || $tbl_type == 'BDB') {
  1077.             ?>
  1078.             <td>
  1079.                 <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
  1080.                     <?php echo $strOptimizeTable; ?></a> 
  1081.                 <?php echo PMA_showDocuShort('O/P/OPTIMIZE_TABLE.html') . "\n"; ?>
  1082.             </td>
  1083.             <?php
  1084.         }
  1085.         echo "\n";
  1086.         ?>
  1087.         </tr>
  1088.         </table><br />
  1089.         </div>
  1090.     </li>
  1091.         <?php
  1092.     } // end MYISAM or BDB case
  1093.     echo "\n";
  1094.     ?>
  1095.  
  1096.     <!-- Table comments -->
  1097.     <li>
  1098.         <form method="post" action="tbl_properties.php">
  1099.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  1100.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  1101.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  1102.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  1103.             <?php echo $strTableComments; ?> : 
  1104.             <input type="hidden" name="prev_comment" value="<?php echo urlencode($show_comment); ?>" /> 
  1105.             <input type="text" name="comment" maxlength="60" size="30" value="<?php echo str_replace('"', '"', $show_comment); ?>" style="vertical-align: middle" onfocus="this.select()" /> 
  1106.             <input type="submit" name="submitcomment" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  1107.         </form>
  1108.     </li>
  1109.  
  1110.     <!-- Table type -->
  1111.     <?php
  1112.     // modify robbat2 code - staybyte - 11. June 2001
  1113.     $query  = 'SHOW VARIABLES LIKE \'have_%\'';
  1114.     $result = mysql_query($query);
  1115.     if ($result != FALSE && mysql_num_rows($result) > 0) {
  1116.         while ($tmp = mysql_fetch_array($result)) {
  1117.             if (isset($tmp['Variable_name'])) {
  1118.                 switch ($tmp['Variable_name']) {
  1119.                     case 'have_bdb':
  1120.                         if ($tmp['Value'] == 'YES') {
  1121.                             $tbl_bdb    = TRUE;
  1122.                         }
  1123.                         break;
  1124.                     case 'have_gemini':
  1125.                         if ($tmp['Value'] == 'YES') {
  1126.                             $tbl_gemini = TRUE;
  1127.                         }
  1128.                         break;
  1129.                     case 'have_innodb':
  1130.                         if ($tmp['Value'] == 'YES') {
  1131.                             $tbl_innodb = TRUE;
  1132.                         }
  1133.                         break;
  1134.                     case 'have_isam':
  1135.                         if ($tmp['Value'] == 'YES') {
  1136.                             $tbl_isam   = TRUE;
  1137.                         }
  1138.                         break;
  1139.                 } // end switch
  1140.             } // end if isset($tmp['Variable_name'])
  1141.         } // end while
  1142.     } // end if $result
  1143.  
  1144.     mysql_free_result($result);
  1145.     echo "\n";
  1146.     ?>
  1147.     <li>
  1148.         <form method="post" action="tbl_properties.php">
  1149.             <input type="hidden" name="server" value="<?php echo $server; ?>" />
  1150.             <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  1151.             <input type="hidden" name="db" value="<?php echo $db; ?>" />
  1152.             <input type="hidden" name="table" value="<?php echo $table; ?>" />
  1153.             <?php echo $strTableType; ?> : 
  1154.             <select name="tbl_type" style="vertical-align: middle">
  1155.                 <option value="MYISAM"<?php if ($tbl_type == 'MYISAM') echo ' selected="selected"'; ?>>MyISAM</option>
  1156.                 <option value="HEAP"<?php if ($tbl_type == 'HEAP') echo ' selected="selected"'; ?>>Heap</option>
  1157.                 <?php if (isset($tbl_bdb)) { ?><option value="BDB"<?php if ($tbl_type == 'BERKELEYDB') echo ' selected="selected"'; ?>>Berkeley DB</option><?php } ?> 
  1158.                 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI"<?php if ($tbl_type == 'GEMINI') echo ' selected="selected"'; ?>>Gemini</option><?php } ?> 
  1159.                 <?php if (isset($tbl_innodb)) { ?><option value="INNODB"<?php if ($tbl_type == 'INNODB') echo ' selected="selected"'; ?>>INNO DB</option><?php } ?> 
  1160.                 <?php if (isset($tbl_isam)) { ?><option value="ISAM"<?php if ($tbl_type == 'ISAM') echo ' selected="selected"'; ?>>ISAM</option><?php } ?> 
  1161.                 <option value="MERGE"<?php if ($tbl_type == 'MRG_MYISAM') echo ' selected="selected"'; ?>>Merge</option>
  1162.             </select> 
  1163.             <input type="submit" name="submittype" value="<?php echo $strGo; ?>" style="vertical-align: middle" /> 
  1164.             <?php echo PMA_showDocuShort('T/a/Table_types.html') . "\n"; ?>
  1165.         </form>
  1166.     </li>
  1167.     <?php
  1168.     echo "\n";
  1169. } // end MySQL >= 3.23.22
  1170.  
  1171. // loic1: "OPTIMIZE" statement is available for MyISAM and BDB tables only and
  1172. //        MyISAM/BDB tables exists since MySQL 3.23.06/3.23.34
  1173. else if (PMA_MYSQL_INT_VERSION >= 32306
  1174.          && ($tbl_type == 'MYISAM' or $tbl_type == 'BDB')) {
  1175.     ?>
  1176.     <!-- Table maintenance -->
  1177.     <li style="vertical-align: top">
  1178.         <div style="margin-bottom: 10px">
  1179.         <?php echo $strTableMaintenance; ?> : 
  1180.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>">
  1181.             <?php echo $strOptimizeTable; ?></a> 
  1182.         <?php echo PMA_showDocuShort('O/P/OPTIMIZE_TABLE.html') . "\n"; ?>
  1183.         </div>
  1184.     </li>
  1185.     <?php
  1186.     echo "\n";
  1187. } // end 3.23.06 < MySQL < 3.23.22
  1188. ?>
  1189.  
  1190.     <!-- Flushes the table -->
  1191.     <li>
  1192.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('FLUSH TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenFlushed, htmlspecialchars($table))); if ($cfgShowTooltip) echo '&reload=1'; ?>">
  1193.             <?php echo $strFlushTable; ?></a>
  1194.         <br /><br />
  1195.     </li>
  1196.  
  1197.     <!-- Deletes the table -->
  1198.     <li>
  1199.         <a href="sql.php?<?php echo ereg_replace('tbl_properties.php$', 'db_details.php', $url_query); ?>&back=tbl_properties.php&reload=1&sql_query=<?php echo urlencode('DROP TABLE ' . PMA_backquote($table)); ?>&zero_rows=<?php echo urlencode(sprintf($strTableHasBeenDropped, htmlspecialchars($table))); ?>"
  1200.             onclick="return confirmLink(this, 'DROP TABLE <?php echo PMA_jsFormat($table); ?>')">
  1201.             <?php echo $strDropTable; ?></a>
  1202.     </li>
  1203.  
  1204. </ul>
  1205.  
  1206. <?php
  1207. /**
  1208.  * Displays the footer
  1209.  */
  1210. echo "\n";
  1211. require('./footer.inc.php');
  1212. ?>
  1213.