home *** CD-ROM | disk | FTP | other *** search
/ Enter 2004 June / ENTER.ISO / files / xampp-win32-1.4.5-installer.exe / xampp / tbl_properties_structure.php < prev    next >
Encoding:
PHP Script  |  2003-12-29  |  31.7 KB  |  787 lines

  1. <?php
  2. /* $Id: tbl_properties_structure.php,v 2.3 2003/12/29 17:15:14 rabus Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4.  
  5. require_once('./libraries/grab_globals.lib.php');
  6. require_once('./libraries/common.lib.php');
  7. require_once('./libraries/mysql_charsets.lib.php');
  8.  
  9. /**
  10.  * Drop multiple fields if required
  11.  */
  12.  
  13. // workaround for IE problem:
  14. if (isset($submit_mult_change_x)) {
  15.     $submit_mult = $strChange;
  16. }
  17. if (isset($submit_mult_drop_x)) {
  18.     $submit_mult = $strDrop;
  19. }
  20.  
  21. if ((!empty($submit_mult) && isset($selected_fld))
  22.     || isset($mult_btn)) {
  23.     $action = 'tbl_properties_structure.php';
  24.     $err_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db, $table);
  25.     require('./mult_submits.inc.php');
  26. }
  27.  
  28. /**
  29.  * Runs common work
  30.  */
  31. require('./tbl_properties_common.php');
  32. $url_query .= '&goto=tbl_properties_structure.php&back=tbl_properties_structure.php';
  33.  
  34. /**
  35.  * Prepares the table structure display
  36.  */
  37. // 1. Get table information/display tabs
  38. require('./tbl_properties_table_info.php');
  39.  
  40. /**
  41.  * Show result of multi submit operation
  42.  */
  43. if ((!empty($submit_mult) && isset($selected_fld))
  44.     || isset($mult_btn)) {
  45.     PMA_showMessage($strSuccess);
  46. }
  47.  
  48. // 2. Gets table keys and retains them
  49. $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
  50. $result      = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  51. $primary     = '';
  52. $ret_keys    = array();
  53. $pk_array    = array(); // will be use to emphasis prim. keys in the table view
  54. while ($row = PMA_mysql_fetch_array($result)) {
  55.     $ret_keys[]  = $row;
  56.     // Backups the list of primary keys
  57.     if ($row['Key_name'] == 'PRIMARY') {
  58.         $primary .= $row['Column_name'] . ', ';
  59.         $pk_array[$row['Column_name']] = 1;
  60.     }
  61. } // end while
  62. mysql_free_result($result);
  63.  
  64. // 3. Get fields
  65. $local_query = 'SHOW FULL FIELDS FROM ' . PMA_backquote($table);
  66. $fields_rs   = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
  67. $fields_cnt  = mysql_num_rows($fields_rs);
  68.  
  69.  
  70.  
  71. /**
  72.  * Displays the table structure ('show table' works correct since 3.23.03)
  73.  */
  74. ?>
  75.  
  76. <!-- TABLE INFORMATION -->
  77.  
  78. <form method="post" action="tbl_properties_structure.php" name="fieldsForm">
  79.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  80.  
  81. <table border="<?php echo $cfg['Border']; ?>">
  82. <tr>
  83.     <td></td>
  84.     <th> <?php echo $strField; ?> </th>
  85.     <th><?php echo $strType; ?></th>
  86. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <th>' . $strCollation . '</th>' . "\n" : ''; ?>
  87.     <th><?php echo $strAttr; ?></th>
  88.     <th><?php echo $strNull; ?></th>
  89.     <th><?php echo $strDefault; ?></th>
  90.     <th><?php echo $strExtra; ?></th>
  91.     <th colspan="6"><?php echo $strAction; ?></th>
  92. </tr>
  93.  
  94. <?php
  95. $comments_map = array();
  96. $mime_map = array();
  97.  
  98. if ($GLOBALS['cfg']['ShowPropertyComments']) {
  99.     require_once('./libraries/relation.lib.php');
  100.     require_once('./libraries/transformations.lib.php');
  101.  
  102.     $cfgRelation = PMA_getRelationsParam();
  103.  
  104.  
  105.     if ($cfgRelation['commwork']) {
  106.         $comments_map = PMA_getComments($db, $table);
  107.  
  108.         if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  109.             $mime_map = PMA_getMIME($db, $table, true);
  110.         }
  111.     }
  112. }
  113.  
  114. $i         = 0;
  115. $aryFields = array();
  116. $checked   = (!empty($checkall) ? ' checked="checked"' : '');
  117.  
  118. while ($row = PMA_mysql_fetch_array($fields_rs)) {
  119.     $i++;
  120.     $bgcolor          = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
  121.     $aryFields[]      = $row['Field'];
  122.  
  123.     $type             = $row['Type'];
  124.     // reformat mysql query output - staybyte - 9. June 2001
  125.     // loic1: set or enum types: slashes single quotes inside options
  126.     if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
  127.         $tmp[2]       = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
  128.         $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
  129.         $type_nowrap  = '';
  130.  
  131.         $binary       = 0;
  132.         $unsigned     = 0;
  133.         $zerofill     = 0;
  134.     } else {
  135.         $type_nowrap  = ' nowrap="nowrap"';
  136.         $type         = preg_replace('@BINARY@i', '', $type);
  137.         $type         = preg_replace('@ZEROFILL@i', '', $type);
  138.         $type         = preg_replace('@UNSIGNED@i', '', $type);
  139.         if (empty($type)) {
  140.             $type     = ' ';
  141.         }
  142.  
  143.         $binary       = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
  144.         $unsigned     = stristr($row['Type'], 'unsigned');
  145.         $zerofill     = stristr($row['Type'], 'zerofill');
  146.     }
  147.  
  148.     // rabus: Devide charset from the rest of the type definition (MySQL >= 4.1)
  149.     unset($field_charset);
  150.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  151.         if ((substr($type, 0, 4) == 'char'
  152.             || substr($type, 0, 7) == 'varchar'
  153.             || substr($type, 0, 4) == 'text'
  154.             || substr($type, 0, 8) == 'tinytext'
  155.             || substr($type, 0, 10) == 'mediumtext'
  156.             || substr($type, 0, 8) == 'longtext'
  157.             || substr($type, 0, 3) == 'set'
  158.             || substr($type, 0, 4) == 'enum'
  159.             ) && !$binary) {
  160.             if (strpos($type, ' character set ')) {
  161.                 $type = substr($type, 0, strpos($type, ' character set '));
  162.             }
  163.             if (!empty($row['Collation'])) {
  164.                 $field_charset = $row['Collation'];
  165.             } else {
  166.                 $field_charset = '';
  167.             }
  168.         } else {
  169.             $field_charset = '';
  170.         }
  171.     }
  172.  
  173.     // garvin: Display basic mimetype [MIME]
  174.     if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
  175.         $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
  176.     } else {
  177.         $type_mime = '';
  178.     }
  179.  
  180.     $strAttribute     = ' ';
  181.     if ($binary) {
  182.         $strAttribute = 'BINARY';
  183.     }
  184.     if ($unsigned) {
  185.         $strAttribute = 'UNSIGNED';
  186.     }
  187.     if ($zerofill) {
  188.         $strAttribute = 'UNSIGNED ZEROFILL';
  189.     }
  190.     if (!isset($row['Default'])) {
  191.         if ($row['Null'] != '') {
  192.             $row['Default'] = '<i>NULL</i>';
  193.         }
  194.     } else {
  195.         $row['Default'] = htmlspecialchars($row['Default']);
  196.     }
  197.  
  198.     $field_encoded = urlencode($row['Field']);
  199.     $field_name    = htmlspecialchars($row['Field']);
  200.  
  201.     // garvin: underline commented fields and display a hover-title (CSS only)
  202.  
  203.     $comment_style = '';
  204.     if (isset($comments_map[$row['Field']])) {
  205.         $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
  206.     }
  207.  
  208.     if (isset($pk_array[$row['Field']])) {
  209.         $field_name = '<u>' . $field_name . '</u>';
  210.     }
  211.     echo "\n";
  212.  
  213.     $titles = array();
  214.     if ($cfg['PropertiesIconic'] == true) {
  215.         // We need to copy the value or else the == 'both' check will always return true
  216.         $propicon = (string)$cfg['PropertiesIconic'];
  217.  
  218.         if ($propicon == 'both') {
  219.             $iconic_spacer = '<nobr>';
  220.         } else {
  221.             $iconic_spacer = '';
  222.         }
  223.  
  224.         $titles['Change']        = $iconic_spacer . '<img hspace="7" width="12" height="13" src="images/button_edit.png" alt="' . $strChange . '" title="' . $strChange . '" border="0" />';
  225.         $titles['Drop']          = $iconic_spacer . '<img hspace="7" width="11" height="12" src="images/button_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
  226.         $titles['NoDrop']        = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" border="0" />';
  227.         $titles['Primary']       = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" border="0" />';
  228.         $titles['Index']         = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" border="0" />';
  229.         $titles['Unique']        = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" border="0" />';
  230.         $titles['IdxFulltext']   = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_fulltext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" border="0" />';
  231.         $titles['NoPrimary']     = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_noprimary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" border="0" />';
  232.         $titles['NoIndex']       = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_noindex.png" alt="' . $strIndex . '" title="' . $strIndex . '" border="0" />';
  233.         $titles['NoUnique']      = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_nounique.png" alt="' . $strUnique . '" title="' . $strUnique . '" border="0" />';
  234.         $titles['NoIdxFulltext'] = $iconic_spacer . '<img hspace="7" width="11" height="13" src="images/button_nofulltext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" border="0" />';
  235.  
  236.         if ($propicon == 'both') {
  237.             $titles['Change']        .= ' ' . $strChange . '</nobr>';
  238.             $titles['Drop']          .= ' ' . $strDrop . '</nobr>';
  239.             $titles['NoDrop']        .= ' ' . $strDrop . '</nobr>';
  240.             $titles['Primary']       .= ' ' . $strPrimary . '</nobr>';
  241.             $titles['Index']         .= ' ' . $strIndex . '</nobr>';
  242.             $titles['Unique']        .= ' ' . $strUnique . '</nobr>';
  243.             $titles['IdxFulltext'  ] .= ' ' . $strIdxFulltext . '</nobr>';
  244.             $titles['NoPrimary']     .= ' ' . $strPrimary . '</nobr>';
  245.             $titles['NoIndex']       .= ' ' . $strIndex . '</nobr>';
  246.             $titles['NoUnique']      .= ' ' . $strUnique . '</nobr>';
  247.             $titles['NoIdxFulltext'] .= ' ' . $strIdxFulltext . '</nobr>';
  248.         }
  249.     } else {
  250.         $titles['Change']        = $strChange;
  251.         $titles['Drop']          = $strDrop;
  252.         $titles['NoDrop']        = $strDrop;
  253.         $titles['Primary']       = $strPrimary;
  254.         $titles['Index']         = $strIndex;
  255.         $titles['Unique']        = $strUnique;
  256.         $titles['IdxFulltext']   = $strIdxFulltext;
  257.         $titles['NoPrimary']     = $strPrimary;
  258.         $titles['NoIndex']       = $strIndex;
  259.         $titles['NoUnique']      = $strUnique;
  260.         $titles['NoIdxFulltext'] = $strIdxFulltext;
  261.     }
  262.  
  263.     ?>
  264. <tr>
  265.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  266.         <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $i; ?>" <?php echo $checked; ?> />
  267.     </td>
  268.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"> <label for="checkbox_row_<?php echo $i; ?>"><?php echo $field_name; ?></label> </td>
  269.     <td bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>><?php echo $type; echo $type_mime; ?><bdo dir="ltr"></bdo></td>
  270. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <td bgcolor="' . $bgcolor . '">' . (empty($field_charset) ? ' ' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
  271.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $strAttribute; ?></td>
  272.     <td bgcolor="<?php echo $bgcolor; ?>"><?php echo (($row['Null'] == '') ? $strNo : $strYes); ?> </td>
  273.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php if (isset($row['Default'])) echo $row['Default']; ?> </td>
  274.     <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap"><?php echo $row['Extra']; ?> </td>
  275.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  276.         <a href="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
  277.             <?php echo $titles['Change']; ?></a>
  278.     </td>
  279.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  280.         <?php
  281.         // loic1: Drop field only if there is more than one field in the table
  282.         if ($fields_cnt > 1) {
  283.             echo "\n";
  284.             ?>
  285.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field'])); ?>&cpurge=1&purgekey=<?php echo urlencode($row['Field']); ?>&zero_rows=<?php echo urlencode(sprintf($strFieldHasBeenDropped, htmlspecialchars($row['Field']))); ?>"
  286.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
  287.             <?php echo $titles['Drop']; ?></a>
  288.             <?php
  289.         } else {
  290.             echo "\n" . '        ' . $titles['NoDrop'];
  291.         }
  292.         echo "\n";
  293.         ?>
  294.     </td>
  295.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  296.         <?php
  297.         if ($type == 'text' || $type == 'blob') {
  298.             echo $titles['NoPrimary'] . "\n";
  299.         } else {
  300.             echo "\n";
  301.             ?>
  302.         <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']))); ?>"
  303.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP PRIMARY KEY, ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
  304.             <?php echo $titles['Primary']; ?></a>
  305.             <?php
  306.         }
  307.         echo "\n";
  308.         ?>
  309.     </td>
  310.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  311.         <?php
  312.         if ($type == 'text' || $type == 'blob') {
  313.             echo $titles['NoIndex'] . "\n";
  314.         } else {
  315.             echo "\n";
  316.             ?>
  317.         <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']))); ?>">
  318.             <?php echo $titles['Index']; ?></a>
  319.             <?php
  320.         }
  321.         echo "\n";
  322.         ?>
  323.     </td>
  324.     <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  325.         <?php
  326.         if ($type == 'text' || $type == 'blob') {
  327.             echo $titles['NoUnique'] . "\n";
  328.         } else {
  329.             echo "\n";
  330.             ?>
  331.         <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']))); ?>">
  332.             <?php echo $titles['Unique']; ?></a>
  333.             <?php
  334.         }
  335.         echo "\n";
  336.         ?>
  337.     </td>
  338.     <?php
  339.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
  340.             && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'varchar'))) {
  341.             echo "\n";
  342.             ?>
  343.     <td align="center" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  344.         <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']))); ?>">
  345.             <?php echo $titles['IdxFulltext']; ?></a>
  346.     </td>
  347.             <?php
  348.         } else {
  349.             echo "\n";
  350.         ?>
  351.     <td align="center" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  352.         <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
  353.     </td>
  354.         <?php
  355.         } // end if... else...
  356.     echo "\n"
  357.     ?>
  358. </tr>
  359.     <?php
  360.     unset($field_charset);
  361. } // end while
  362.  
  363. echo "\n";
  364.  
  365. $checkall_url = 'tbl_properties_structure.php?' . PMA_generate_common_url($db,$table);
  366. ?>
  367.  
  368. <tr>
  369.     <td colspan="<?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '14' : '13'; ?>">
  370.         <table>
  371.             <tr>
  372.                 <td>
  373.                     <img src="./images/arrow_<?php echo $text_dir; ?>.gif" border="0" width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
  374.         <a href="<?php echo $checkall_url; ?>&checkall=1" onclick="setCheckboxes('fieldsForm', true); return false;">
  375.             <?php echo $strCheckAll; ?></a>
  376.          / 
  377.         <a href="<?php echo $checkall_url; ?>" onclick="setCheckboxes('fieldsForm', false); return false;">
  378.             <?php echo $strUncheckAll; ?></a>
  379.            
  380.         <i><?php echo $strWithChecked; ?></i>  
  381.                 </td>
  382.                 <td>
  383.                     <?php
  384.  
  385. if ($cfg['PropertiesIconic']) {
  386.     /* Opera has trouble with <input type="image"> */
  387.     /* IE has trouble with <button> */
  388.     if (PMA_USR_BROWSER_AGENT != 'IE') {
  389.         echo '<button class="mult_submit" type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '">' . "\n"
  390.            . '<img src="./images/button_edit.png" title="' . $strChange . '" alt="' . $strChange . '" width="12" height="13" />' . (($propicon == 'both') ? ' ' . $strChange : '') . "\n"
  391.            . '</button>' . "\n";
  392.     } else {
  393.         echo '                    <input type="image" name="submit_mult_change" value="' .$strChange . '" title="' . $strChange . '" src="./images/button_edit.png" />'  . (($propicon == 'both') ? ' ' . $strChange : '') . "\n";
  394.     }
  395.     // Drop button if there is at least two fields
  396.     if ($fields_cnt > 1) {
  397.         if (PMA_USR_BROWSER_AGENT != 'IE') {
  398.             echo '                    <button class="mult_submit" type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '">' . "\n"
  399.                . '<img src="./images/button_drop.png" title="' . $strDrop . '" alt="' . $strDrop . '" width="11" height="13" />' . (($propicon == 'both') ? ' ' . $strDrop : '') . "\n"
  400.                . '</button>' . "\n";
  401.         } else {
  402.             echo '                    <input type="image" name="submit_mult_drop" value="' .$strDrop . '" title="' . $strDrop . '" src="./images/button_drop.png" />' . (($propicon == 'both') ? ' ' . $strDrop : '') . "\n";
  403.         }
  404.     }
  405. } else {
  406.     echo '                    <input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
  407.     // Drop button if there is at least two fields
  408.     if ($fields_cnt > 1) {
  409.         echo '                     <i>' . $strOr . '</i> ' . "\n"
  410.            . '                    <input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
  411.     }
  412. }
  413.  
  414. ?>
  415.                 </td>
  416.             </tr>
  417.         </table>
  418.     </td>
  419. </tr>
  420. </table>
  421.  
  422. </form>
  423.  
  424.  
  425. <?php
  426. /**
  427.  * If there are more than 20 rows, displays browse/select/insert/empty/drop
  428.  * links again
  429.  */
  430. if ($fields_cnt > 20) {
  431.     ?>
  432. <!-- Browse links -->
  433.     <?php
  434.     echo "\n";
  435.     require('./tbl_properties_links.php');
  436. } // end if ($fields_cnt > 20)
  437. echo "\n\n";
  438.  
  439.  
  440. /**
  441.  * Displays indexes
  442.  */
  443. ?>
  444. <!-- Indexes, space usage and row statistics -->
  445. <br />
  446. <table border="0" cellspacing="0" cellpadding="0">
  447. <tr>
  448.     <td valign="top">
  449. <?php
  450. define('PMA_IDX_INCLUDED', 1);
  451. require ('./tbl_indexes.php');
  452. ?>
  453.     </td>
  454.  
  455. <?php
  456. /**
  457.  * Displays Space usage and row statistics
  458.  */
  459. // BEGIN - Calc Table Space - staybyte - 9 June 2001
  460. // loic1, 22 feb. 2002: updated with patch from
  461. //                      Joshua Nye <josh at boxcarmedia.com> to get valid
  462. //                      statistics whatever is the table type
  463. if ($cfg['ShowStats']) {
  464.     $nonisam     = FALSE;
  465.     $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
  466.     if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
  467.         $nonisam = TRUE;
  468.     }
  469.     if ($nonisam == FALSE || $is_innodb) {
  470.         // Gets some sizes
  471.         $mergetable     = FALSE;
  472.         if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
  473.             $mergetable = TRUE;
  474.         }
  475.         list($data_size, $data_unit)         = PMA_formatByteDown($showtable['Data_length']);
  476.         if ($mergetable == FALSE) {
  477.             list($index_size, $index_unit)   = PMA_formatByteDown($showtable['Index_length']);
  478.         }
  479.         if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
  480.             list($free_size, $free_unit)     = PMA_formatByteDown($showtable['Data_free']);
  481.             list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']);
  482.         } else {
  483.             list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  484.         }
  485.         list($tot_size, $tot_unit)           = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length']);
  486.         if ($table_info_num_rows > 0) {
  487.             list($avg_size, $avg_unit)       = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
  488.         }
  489.  
  490.         // Displays them
  491.         ?>
  492.  
  493.     <!-- Space usage -->
  494.     <td width="20"> </td>
  495.     <td valign="top">
  496.         <?php echo $strSpaceUsage . ' :' . "\n"; ?>
  497.         <a name="showusage"></a>
  498.         <table border="<?php echo $cfg['Border']; ?>">
  499.         <tr>
  500.             <th><?php echo $strType; ?></th>
  501.             <th colspan="2" align="center"><?php echo $strUsage; ?></th>
  502.         </tr>
  503.         <tr>
  504.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" style="padding-right: 10px"><?php echo $strData; ?></td>
  505.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right" nowrap="nowrap"><?php echo $data_size; ?></td>
  506.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"><?php echo $data_unit; ?></td>
  507.         </tr>
  508.         <?php
  509.         if (isset($index_size)) {
  510.             echo "\n";
  511.             ?>
  512.         <tr>
  513.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" style="padding-right: 10px"><?php echo $strIndex; ?></td>
  514.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right" nowrap="nowrap"><?php echo $index_size; ?></td>
  515.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"><?php echo $index_unit; ?></td>
  516.         </tr>
  517.             <?php
  518.         }
  519.         if (isset($free_size)) {
  520.             echo "\n";
  521.             ?>
  522.         <tr style="color: #bb0000">
  523.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" style="padding-right: 10px"><?php echo $strOverhead; ?></td>
  524.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>" align="right" nowrap="nowrap"><?php echo $free_size; ?></td>
  525.             <td bgcolor="<?php echo $cfg['BgcolorTwo']; ?>"><?php echo $free_unit; ?></td>
  526.         </tr>
  527.         <tr>
  528.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" style="padding-right: 10px"><?php echo $strEffective; ?></td>
  529.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right" nowrap="nowrap"><?php echo $effect_size; ?></td>
  530.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><?php echo $effect_unit; ?></td>
  531.         </tr>
  532.             <?php
  533.         }
  534.         if (isset($tot_size) && $mergetable == FALSE) {
  535.             echo "\n";
  536.         ?>
  537.         <tr>
  538.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" style="padding-right: 10px"><?php echo $strTotalUC; ?></td>
  539.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>" align="right" nowrap="nowrap"><?php echo $tot_size; ?></td>
  540.             <td bgcolor="<?php echo $cfg['BgcolorOne']; ?>"><?php echo $tot_unit; ?></td>
  541.         </tr>
  542.             <?php
  543.         }
  544.         // Optimize link if overhead
  545.         if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
  546.             echo "\n";
  547.             ?>
  548.         <tr>
  549.             <td colspan="3" align="center">
  550.                 [<a href="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php echo $strOptimizeTable; ?></a>]
  551.             </td>
  552.         </tr>
  553.             <?php
  554.         }
  555.         echo "\n";
  556.         ?>
  557.         </table>
  558.     </td>
  559.  
  560.     <!-- Rows Statistic -->
  561.     <td width="20"> </td>
  562.     <td valign="top">
  563.         <?php echo $strRowsStatistic . ' :' . "\n"; ?>
  564.         <table border="<?php echo $cfg['Border']; ?>">
  565.         <tr>
  566.             <th><?php echo $strStatement; ?></th>
  567.             <th align="center"><?php echo $strValue; ?></th>
  568.         </tr>
  569.         <?php
  570.         $i = 0;
  571.         if (isset($showtable['Row_format'])) {
  572.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  573.             echo "\n";
  574.             ?>
  575.         <tr>
  576.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strFormat; ?></td>
  577.             <td bgcolor="<?php echo $bgcolor; ?>" align="<?php echo $cell_align_left; ?>" nowrap="nowrap">
  578.             <?php
  579.             echo '                ';
  580.             if ($showtable['Row_format'] == 'Fixed') {
  581.                 echo $strFixed;
  582.             }
  583.             else if ($showtable['Row_format'] == 'Dynamic') {
  584.                 echo $strDynamic;
  585.             }
  586.             else {
  587.                 echo $showtable['Row_format'];
  588.             }
  589.             echo "\n";
  590.             ?>
  591.             </td>
  592.         </tr>
  593.             <?php
  594.         }
  595.         if (PMA_MYSQL_INT_VERSION >= 40100) {
  596.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  597.             ?>
  598.         <tr>
  599.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strCollation; ?></td>
  600.             <td bgcolor="<?php echo $bgcolor; ?>" align="<?php echo $cell_align_left; ?>" nowrap="nowrap">
  601.             <?php
  602.             echo '<dfn title="' . PMA_getCollationDescr($tbl_charset) . '">' . $tbl_charset . '</dfn>';
  603.             ?>
  604.             </td>
  605.         </tr>
  606.             <?php
  607.         }
  608.         if (!$is_innodb && isset($showtable['Rows'])) {
  609.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  610.             echo "\n";
  611.             ?>
  612.         <tr>
  613.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strRows; ?></td>
  614.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  615.                 <?php echo number_format($showtable['Rows'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  616.             </td>
  617.         </tr>
  618.             <?php
  619.         }
  620.         if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
  621.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  622.             echo "\n";
  623.             ?>
  624.         <tr>
  625.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strRowLength; ?> ø</td>
  626.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  627.                 <?php echo number_format($showtable['Avg_row_length'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  628.             </td>
  629.         </tr>
  630.             <?php
  631.         }
  632.         if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == FALSE) {
  633.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  634.             echo "\n";
  635.             ?>
  636.         <tr>
  637.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strRowSize; ?> ø</td>
  638.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  639.                 <?php echo $avg_size . ' ' . $avg_unit . "\n"; ?>
  640.             </td>
  641.         </tr>
  642.             <?php
  643.         }
  644.         if (isset($showtable['Auto_increment'])) {
  645.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  646.             echo "\n";
  647.             ?>
  648.         <tr>
  649.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strNext; ?> Autoindex</td>
  650.             <td bgcolor="<?php echo $bgcolor; ?>" align="right" nowrap="nowrap">
  651.                 <?php echo number_format($showtable['Auto_increment'], 0, $number_decimal_separator, $number_thousands_separator) . "\n"; ?>
  652.             </td>
  653.         </tr>
  654.             <?php
  655.         }
  656.         echo "\n";
  657.  
  658.         if (isset($showtable['Create_time'])) {
  659.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  660.             echo "\n";
  661.             ?>
  662.         <tr>
  663.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strStatCreateTime; ?></td>
  664.             <td style="font-size: <?php echo $font_smaller; ?>" align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  665.                 <?php echo PMA_localisedDate(strtotime($showtable['Create_time'])) . "\n"; ?>
  666.             </td>
  667.         </tr>
  668.                 <?php
  669.         }
  670.         echo "\n";
  671.  
  672.         if (isset($showtable['Update_time'])) {
  673.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  674.             echo "\n";
  675.             ?>
  676.         <tr>
  677.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strStatUpdateTime; ?></td>
  678.             <td style="font-size: <?php echo $font_smaller; ?>" align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  679.                 <?php echo PMA_localisedDate(strtotime($showtable['Update_time'])) . "\n"; ?>
  680.             </td>
  681.         </tr>
  682.                 <?php
  683.         }
  684.         echo "\n";
  685.  
  686.         if (isset($showtable['Check_time'])) {
  687.             $bgcolor = ((++$i%2) ? $cfg['BgcolorTwo'] : $cfg['BgcolorOne']);
  688.             echo "\n";
  689.             ?>
  690.         <tr>
  691.             <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $strStatCheckTime; ?></td>
  692.             <td style="font-size: <?php echo $font_smaller; ?>" align="right" bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  693.                 <?php echo PMA_localisedDate(strtotime($showtable['Check_time'])) . "\n"; ?>
  694.             </td>
  695.         </tr>
  696.             <?php
  697.         }
  698.         echo "\n";
  699.         ?>
  700.         </table>
  701.     </td>
  702.         <?php
  703.     }
  704. }
  705. // END - Calc Table Space
  706. echo "\n";
  707. ?>
  708. </tr>
  709. </table>
  710. <hr />
  711.  
  712.  
  713. <?php
  714. /**
  715.  * Work on the table
  716.  */
  717. ?>
  718. <!-- TABLE WORK -->
  719. <ul>
  720.  
  721.     <!-- Printable view of the table -->
  722.     <li>
  723.         <div style="margin-bottom: 10px"><a href="tbl_printview.php?<?php echo $url_query; ?>"><?php echo $strPrintView; ?></a></div>
  724.     </li>
  725.  
  726.     <!-- Add some new fields -->
  727.     <li>
  728.         <form method="post" action="tbl_addfield.php"
  729.             onsubmit="return checkFormElementInRange(this, 'num_fields', 1)">
  730.             <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  731.             <?php echo $strAddNewField; ?> :
  732.             <input type="text" name="num_fields" size="2" maxlength="2" value="1" class="textfield" style="vertical-align: middle" onfocus="this.select()" />
  733.             <select name="after_field" style="vertical-align: middle">
  734.                 <option value="--end--"><?php echo $strAtEndOfTable; ?></option>
  735.                 <option value="--first--"><?php echo $strAtBeginningOfTable; ?></option>
  736. <?php
  737. foreach($aryFields AS $junk => $fieldname) {
  738.     echo '                <option value="' . htmlspecialchars($fieldname) . '">' . sprintf($strAfter, htmlspecialchars($fieldname)) . '</option>' . "\n";
  739. }
  740. unset($aryFields);
  741. ?>
  742.             </select>
  743.             <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  744.         </form>
  745.     </li>
  746.  
  747. <?php
  748. if ($cfg['Server']['relation']) {
  749.     ?>
  750.     <!-- Work on Relations -->
  751.     <li>
  752.         <div style="margin-bottom: 10px">
  753.             <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php echo $strRelationView; ?></a>
  754.         </div>
  755.     </li>
  756.     <?php
  757. }
  758. echo "\n";
  759. ?>
  760.  
  761.     <!-- Let MySQL propose the optimal structure -->
  762.     <li>
  763.         <div style="margin-bottom: 10px">
  764.         <a href="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>">
  765.             <?php echo $strStructPropose; ?></a>
  766.         <?php echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n"; ?>
  767.         </div>
  768.     </li>
  769.  
  770. <?php
  771. /**
  772.  * Query box, bookmark, insert data from textfile
  773.  */
  774. $goto = 'tbl_properties_structure.php';
  775. require('./tbl_query_box.php');
  776. ?>
  777.  
  778. </ul>
  779.  
  780.  
  781. <?php
  782. /**
  783.  * Displays the footer
  784.  */
  785. require_once('./footer.inc.php');
  786. ?>
  787.