home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / xampp-win32-1.6.7-installer.exe / phpMyAdmin / tbl_structure.php < prev    next >
PHP Script  |  2008-06-23  |  34KB  |  847 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: tbl_structure.php 11183 2008-04-02 17:19:59Z lem9 $
  6.  */
  7.  
  8. /**
  9.  *
  10.  */
  11. require_once './libraries/common.inc.php';
  12. require_once './libraries/mysql_charsets.lib.php';
  13. require_once './libraries/relation.lib.php';
  14.  
  15. /**
  16.  * Gets the relation settings
  17.  */
  18. $cfgRelation = PMA_getRelationsParam();
  19.  
  20.  
  21. /**
  22.  * Drop multiple fields if required
  23.  */
  24.  
  25. // workaround for IE problem:
  26. if (isset($submit_mult_change_x)) {
  27.     $submit_mult = $strChange;
  28. } elseif (isset($submit_mult_drop_x)) {
  29.     $submit_mult = $strDrop;
  30. } elseif (isset($submit_mult_primary_x)) {
  31.     $submit_mult = $strPrimary;
  32. } elseif (isset($submit_mult_index_x)) {
  33.     $submit_mult = $strIndex;
  34. } elseif (isset($submit_mult_unique_x)) {
  35.     $submit_mult = $strUnique;
  36. } elseif (isset($submit_mult_fulltext_x)) {
  37.     $submit_mult = $strIdxFulltext;
  38. }
  39.  
  40. if ((!empty($submit_mult) && isset($selected_fld))
  41.     || isset($mult_btn)) {
  42.     $action = 'tbl_structure.php';
  43.     $err_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
  44.     require_once('./libraries/header.inc.php');
  45.     require_once './libraries/tbl_links.inc.php';
  46.     require './libraries/mult_submits.inc.php';
  47. }
  48.  
  49. /**
  50.  * Runs common work
  51.  */
  52. require_once './libraries/tbl_common.php';
  53. $url_query .= '&goto=tbl_structure.php&back=tbl_structure.php';
  54.  
  55. /**
  56.  * Prepares the table structure display
  57.  */
  58.  
  59. /**
  60.  * Gets tables informations
  61.  */
  62. require_once './libraries/tbl_info.inc.php';
  63.  
  64. /**
  65.  * Show result of multi submit operation
  66.  */
  67. if ((!empty($submit_mult) && isset($selected_fld))
  68.     || isset($mult_btn)) {
  69.     $message = $strSuccess;
  70. }
  71.  
  72. /**
  73.  * Displays top menu links
  74.  */
  75. require_once './libraries/tbl_links.inc.php';
  76.  
  77. // 2. Gets table keys and retains them
  78. $result      = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($table) . ';');
  79. $primary     = '';
  80. $ret_keys    = array();
  81. $pk_array    = array(); // will be use to emphasis prim. keys in the table view
  82. while ($row = PMA_DBI_fetch_assoc($result)) {
  83.     $ret_keys[]  = $row;
  84.     // Backups the list of primary keys
  85.     if ($row['Key_name'] == 'PRIMARY') {
  86.         $primary .= $row['Column_name'] . ', ';
  87.         $pk_array[$row['Column_name']] = 1;
  88.     }
  89. } // end while
  90. PMA_DBI_free_result($result);
  91.  
  92. // 3. Get fields
  93. $fields_rs   = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
  94. $fields_cnt  = PMA_DBI_num_rows($fields_rs);
  95.  
  96. // Get more complete field information
  97. // For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
  98. // but later, if the analyser returns more information, it
  99. // could be executed for any MySQL version and replace
  100. // the info given by SHOW FULL FIELDS FROM.
  101. //
  102. // We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
  103. // SHOW FULL FIELDS or INFORMATION_SCHEMA incorrectly says NULL
  104. // and SHOW CREATE TABLE says NOT NULL (tested
  105. // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
  106.  
  107. $show_create_table = PMA_DBI_fetch_value(
  108.         'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
  109.         0, 1);
  110. $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
  111.  
  112. /**
  113.  * prepare table infos
  114.  */
  115. // action titles (image or string)
  116. $titles = array();
  117. if ($cfg['PropertiesIconic'] == true) {
  118.     if ($cfg['PropertiesIconic'] === 'both') {
  119.         $iconic_spacer = '<div class="nowrap">';
  120.     } else {
  121.         $iconic_spacer = '';
  122.     }
  123.  
  124.     // images replaced 2004-05-08 by mkkeck
  125.     $titles['Change']        = $iconic_spacer
  126.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  127.         . 'b_edit.png" alt="' . $strChange . '" title="' . $strChange . '" />';
  128.     $titles['Drop']          = $iconic_spacer
  129.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  130.         . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
  131.     $titles['NoDrop']        = $iconic_spacer
  132.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  133.         . 'b_drop.png" alt="' . $strDrop . '" title="' . $strDrop . '" />';
  134.     $titles['Primary']       = $iconic_spacer
  135.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  136.         . 'b_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
  137.     $titles['Index']         = $iconic_spacer
  138.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  139.         . 'b_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
  140.     $titles['Unique']        = $iconic_spacer
  141.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  142.         . 'b_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
  143.     $titles['IdxFulltext']   = $iconic_spacer
  144.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  145.         . 'b_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
  146.     $titles['NoPrimary']     = $iconic_spacer
  147.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  148.         . 'bd_primary.png" alt="' . $strPrimary . '" title="' . $strPrimary . '" />';
  149.     $titles['NoIndex']       = $iconic_spacer
  150.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  151.         . 'bd_index.png" alt="' . $strIndex . '" title="' . $strIndex . '" />';
  152.     $titles['NoUnique']      = $iconic_spacer
  153.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  154.         . 'bd_unique.png" alt="' . $strUnique . '" title="' . $strUnique . '" />';
  155.     $titles['NoIdxFulltext'] = $iconic_spacer
  156.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  157.         . 'bd_ftext.png" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />';
  158.     $titles['BrowseDistinctValues']        = $iconic_spacer
  159.         . '<img class="icon" width="16" height="16" src="' . $pmaThemeImage
  160.         . 'b_browse.png" alt="' . $strBrowseDistinctValues . '" title="' . $strBrowseDistinctValues . '" />';
  161.  
  162.     if ($cfg['PropertiesIconic'] === 'both') {
  163.         $titles['Change']               .= $strChange . '</div>';
  164.         $titles['Drop']                 .= $strDrop . '</div>';
  165.         $titles['NoDrop']               .= $strDrop . '</div>';
  166.         $titles['Primary']              .= $strPrimary . '</div>';
  167.         $titles['Index']                .= $strIndex . '</div>';
  168.         $titles['Unique']               .= $strUnique . '</div>';
  169.         $titles['IdxFulltext'  ]        .= $strIdxFulltext . '</div>';
  170.         $titles['NoPrimary']            .= $strPrimary . '</div>';
  171.         $titles['NoIndex']              .= $strIndex . '</div>';
  172.         $titles['NoUnique']             .= $strUnique . '</div>';
  173.         $titles['NoIdxFulltext']        .= $strIdxFulltext . '</div>';
  174.         $titles['BrowseDistinctValues'] .= $strBrowseDistinctValues . '</div>';
  175.     }
  176. } else {
  177.     $titles['Change']               = $strChange;
  178.     $titles['Drop']                 = $strDrop;
  179.     $titles['NoDrop']               = $strDrop;
  180.     $titles['Primary']              = $strPrimary;
  181.     $titles['Index']                = $strIndex;
  182.     $titles['Unique']               = $strUnique;
  183.     $titles['IdxFulltext']          = $strIdxFulltext;
  184.     $titles['NoPrimary']            = $strPrimary;
  185.     $titles['NoIndex']              = $strIndex;
  186.     $titles['NoUnique']             = $strUnique;
  187.     $titles['NoIdxFulltext']        = $strIdxFulltext;
  188.     $titles['BrowseDistinctValues'] = $strBrowseDistinctValues;
  189. }
  190.  
  191. /**
  192.  * Displays the table structure ('show table' works correct since 3.23.03)
  193.  */
  194. /* TABLE INFORMATION */
  195. // table header
  196. $i = 0;
  197. ?>
  198. <form method="post" action="tbl_structure.php" name="fieldsForm" id="fieldsForm">
  199.     <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
  200. <table id="tablestructure" class="data">
  201. <thead>
  202. <tr>
  203.     <th id="th<?php echo ++$i; ?>"></th>
  204.     <th id="th<?php echo ++$i; ?>"><?php echo $strField; ?></th>
  205.     <th id="th<?php echo ++$i; ?>"><?php echo $strType; ?></th>
  206. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <th id="th' . ++$i . '">' . $strCollation . '</th>' . "\n" : ''; ?>
  207.     <th id="th<?php echo ++$i; ?>"><?php echo $strAttr; ?></th>
  208.     <th id="th<?php echo ++$i; ?>"><?php echo $strNull; ?></th>
  209.     <th id="th<?php echo ++$i; ?>"><?php echo $strDefault; ?></th>
  210.     <th id="th<?php echo ++$i; ?>"><?php echo $strExtra; ?></th>
  211. <?php if ($db_is_information_schema || $tbl_is_view) { ?>
  212.     <th id="th<?php echo ++$i; ?>"><?php echo $strView; ?></th>
  213. <?php } else { ?>
  214.     <th colspan="7" id="th<?php echo ++$i; ?>"><?php echo $strAction; ?></th>
  215. <?php } ?>
  216. </tr>
  217. </thead>
  218. <tbody>
  219. <?php
  220. unset($i);
  221.  
  222.  
  223. // table body
  224.  
  225. // prepare comments
  226. $comments_map = array();
  227. $mime_map = array();
  228.  
  229. if ($GLOBALS['cfg']['ShowPropertyComments']) {
  230.     require_once './libraries/relation.lib.php';
  231.     require_once './libraries/transformations.lib.php';
  232.  
  233.     $cfgRelation = PMA_getRelationsParam();
  234.  
  235.     if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  236.         $comments_map = PMA_getComments($db, $table);
  237.  
  238.         if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  239.             $mime_map = PMA_getMIME($db, $table, true);
  240.         }
  241.     }
  242. }
  243.  
  244. $rownum    = 0;
  245. $aryFields = array();
  246. $checked   = (!empty($checkall) ? ' checked="checked"' : '');
  247. $save_row  = array();
  248. $odd_row   = true;
  249. while ($row = PMA_DBI_fetch_assoc($fields_rs)) {
  250.     $save_row[] = $row;
  251.     $rownum++;
  252.     $aryFields[]      = $row['Field'];
  253.  
  254.     $type             = $row['Type'];
  255.     $type_and_length = PMA_extract_type_length($row['Type']);
  256.  
  257.     // reformat mysql query output - staybyte - 9. June 2001
  258.     // loic1: set or enum types: slashes single quotes inside options
  259.     if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
  260.         $tmp[2]       = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
  261.         $type         = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
  262.  
  263.         // for the case ENUM('–','“')
  264.         $type         = htmlspecialchars($type);
  265.  
  266.         $type_nowrap  = '';
  267.  
  268.         $binary       = 0;
  269.         $unsigned     = 0;
  270.         $zerofill     = 0;
  271.     } else {
  272.         $type_nowrap  = ' nowrap="nowrap"';
  273.         // strip the "BINARY" attribute, except if we find "BINARY(" because
  274.         // this would be a BINARY or VARBINARY field type
  275.         if (!preg_match('@BINARY[\(]@i', $type)) {
  276.             $type         = preg_replace('@BINARY@i', '', $type);
  277.         }
  278.         $type         = preg_replace('@ZEROFILL@i', '', $type);
  279.         $type         = preg_replace('@UNSIGNED@i', '', $type);
  280.         if (empty($type)) {
  281.             $type     = ' ';
  282.         }
  283.  
  284.         if (!preg_match('@BINARY[\(]@i', $row['Type'])) {
  285.             $binary           = stristr($row['Type'], 'blob') || stristr($row['Type'], 'binary');
  286.         } else {
  287.             $binary           = false;
  288.         }
  289.  
  290.         $unsigned     = stristr($row['Type'], 'unsigned');
  291.         $zerofill     = stristr($row['Type'], 'zerofill');
  292.     }
  293.  
  294.     // rabus: Divide charset from the rest of the type definition (MySQL >= 4.1)
  295.     unset($field_charset);
  296.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  297.         if ((substr($type, 0, 4) == 'char'
  298.             || substr($type, 0, 7) == 'varchar'
  299.             || substr($type, 0, 4) == 'text'
  300.             || substr($type, 0, 8) == 'tinytext'
  301.             || substr($type, 0, 10) == 'mediumtext'
  302.             || substr($type, 0, 8) == 'longtext'
  303.             || substr($type, 0, 3) == 'set'
  304.             || substr($type, 0, 4) == 'enum'
  305.             ) && !$binary) {
  306.             if (strpos($type, ' character set ')) {
  307.                 $type = substr($type, 0, strpos($type, ' character set '));
  308.             }
  309.             if (!empty($row['Collation'])) {
  310.                 $field_charset = $row['Collation'];
  311.             } else {
  312.                 $field_charset = '';
  313.             }
  314.         } else {
  315.             $field_charset = '';
  316.         }
  317.     }
  318.  
  319.     // garvin: Display basic mimetype [MIME]
  320.     if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME'] && isset($mime_map[$row['Field']]['mimetype'])) {
  321.         $type_mime = '<br />MIME: ' . str_replace('_', '/', $mime_map[$row['Field']]['mimetype']);
  322.     } else {
  323.         $type_mime = '';
  324.     }
  325.  
  326.     $attribute     = ' ';
  327.     if ($binary) {
  328.         $attribute = 'BINARY';
  329.     }
  330.     if ($unsigned) {
  331.         $attribute = 'UNSIGNED';
  332.     }
  333.     if ($zerofill) {
  334.         $attribute = 'UNSIGNED ZEROFILL';
  335.     }
  336.  
  337.     // MySQL 4.1.2+ TIMESTAMP options
  338.     // (if on_update_current_timestamp is set, then it's TRUE)
  339.     if (isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
  340.         $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
  341.     }
  342.  
  343.     // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
  344.     // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
  345.     // the latter.
  346.     if (!empty($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null']) {
  347.         $row['Null'] = '';
  348.     }
  349.  
  350.  
  351.     if (!isset($row['Default'])) {
  352.         if ($row['Null'] == 'YES') {
  353.             $row['Default'] = '<i>NULL</i>';
  354.         }
  355.     } else {
  356.         $row['Default'] = htmlspecialchars($row['Default']);
  357.     }
  358.  
  359.     $field_encoded = urlencode($row['Field']);
  360.     $field_name    = htmlspecialchars($row['Field']);
  361.  
  362.     // garvin: underline commented fields and display a hover-title (CSS only)
  363.  
  364.     $comment_style = '';
  365.     if (isset($comments_map[$row['Field']])) {
  366.         $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$row['Field']]) . '">' . $field_name . '</span>';
  367.     }
  368.  
  369.     if (isset($pk_array[$row['Field']])) {
  370.         $field_name = '<u>' . $field_name . '</u>';
  371.     }
  372.     echo "\n";
  373.     ?>
  374. <tr class="<?php echo $odd_row ? 'odd': 'even'; $odd_row = !$odd_row; ?>">
  375.     <td align="center">
  376.         <input type="checkbox" name="selected_fld[]" value="<?php echo $field_encoded; ?>" id="checkbox_row_<?php echo $rownum; ?>" <?php echo $checked; ?> />
  377.     </td>
  378.     <th nowrap="nowrap"><label for="checkbox_row_<?php echo $rownum; ?>"><?php echo $field_name; ?></label></th>
  379.     <td<?php echo $type_nowrap; ?>><bdo dir="ltr" xml:lang="en"><?php echo $type; echo $type_mime; ?></bdo></td>
  380. <?php echo PMA_MYSQL_INT_VERSION >= 40100 ? '    <td>' . (empty($field_charset) ? '' : '<dfn title="' . PMA_getCollationDescr($field_charset) . '">' . $field_charset . '</dfn>') . '</td>' . "\n" : '' ?>
  381.     <td nowrap="nowrap" style="font-size: 70%"><?php echo $attribute; ?></td>
  382.     <td><?php echo (($row['Null'] == 'YES') ? $strYes : $strNo); ?></td>
  383.     <td nowrap="nowrap"><?php
  384.     if (isset($row['Default'])) { 
  385.         if ($type_and_length['type'] == 'bit') {
  386.             echo PMA_printable_bit_value($row['Default'], $type_and_length['length']);
  387.         } else {
  388.             echo $row['Default']; 
  389.         }
  390.     } ?></td>
  391.     <td nowrap="nowrap"><?php echo $row['Extra']; ?></td>
  392.     <td align="center">
  393.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote($strRows) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>">
  394.             <?php echo $titles['BrowseDistinctValues']; ?></a>
  395.     </td>
  396.     <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
  397.     <td align="center">
  398.         <a href="tbl_alter.php?<?php echo $url_query; ?>&field=<?php echo $field_encoded; ?>">
  399.             <?php echo $titles['Change']; ?></a>
  400.     </td>
  401.     <td align="center">
  402.         <?php
  403.         // loic1: Drop field only if there is more than one field in the table
  404.         if ($fields_cnt > 1) {
  405.             echo "\n";
  406.             ?>
  407.         <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']))); ?>"
  408.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table); ?> DROP <?php echo PMA_jsFormat($row['Field']); ?>')">
  409.             <?php echo $titles['Drop']; ?></a>
  410.             <?php
  411.         } else {
  412.             echo "\n" . '        ' . $titles['NoDrop'];
  413.         }
  414.         echo "\n";
  415.         ?>
  416.     </td>
  417.     <td align="center">
  418.         <?php
  419.         if ($type == 'text' || $type == 'blob') {
  420.             echo $titles['NoPrimary'] . "\n";
  421.         } else {
  422.             echo "\n";
  423.             ?>
  424.         <a href="sql.php?<?php echo $url_query; ?>&sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ')'); ?>&zero_rows=<?php echo urlencode(sprintf($strAPrimaryKey, htmlspecialchars($row['Field']))); ?>"
  425.             onclick="return confirmLink(this, 'ALTER TABLE <?php echo PMA_jsFormat($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,'); ?> ADD PRIMARY KEY(<?php echo PMA_jsFormat($row['Field']); ?>)')">
  426.             <?php echo $titles['Primary']; ?></a>
  427.             <?php
  428.         }
  429.         echo "\n";
  430.         ?>
  431.     </td>
  432.     <td align="center">
  433.         <?php
  434.         if ($type == 'text' || $type == 'blob') {
  435.             echo $titles['NoUnique'] . "\n";
  436.         } else {
  437.             echo "\n";
  438.             ?>
  439.         <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']))); ?>">
  440.             <?php echo $titles['Unique']; ?></a>
  441.             <?php
  442.         }
  443.         echo "\n";
  444.         ?>
  445.     </td>
  446.     <td align="center">
  447.         <?php
  448.         if ($type == 'text' || $type == 'blob') {
  449.             echo $titles['NoIndex'] . "\n";
  450.         } else {
  451.             echo "\n";
  452.             ?>
  453.         <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']))); ?>">
  454.             <?php echo $titles['Index']; ?></a>
  455.             <?php
  456.         }
  457.         echo "\n";
  458.         ?>
  459.     </td>
  460.     <?php
  461.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')
  462.             // FULLTEXT is possible on TEXT, CHAR and VARCHAR
  463.             && (strpos(' ' . $type, 'text') || strpos(' ' . $type, 'char'))) {
  464.             echo "\n";
  465.             ?>
  466.     <td align="center" nowrap="nowrap">
  467.         <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']))); ?>">
  468.             <?php echo $titles['IdxFulltext']; ?></a>
  469.     </td>
  470.             <?php
  471.         } else {
  472.             echo "\n";
  473.         ?>
  474.     <td align="center" nowrap="nowrap">
  475.         <?php echo $titles['NoIdxFulltext'] . "\n"; ?>
  476.     </td>
  477.         <?php
  478.         } // end if... else...
  479.         echo "\n";
  480.     } // end if (! $tbl_is_view && ! $db_is_information_schema)
  481.     ?>
  482. </tr>
  483.     <?php
  484.     unset($field_charset);
  485. } // end while
  486.  
  487. echo '</tbody>' . "\n"
  488.     .'</table>' . "\n";
  489.  
  490. $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
  491. ?>
  492.  
  493. <img class="selectallarrow" src="<?php echo $pmaThemeImage . 'arrow_' . $text_dir . '.png'; ?>"
  494.     width="38" height="22" alt="<?php echo $strWithChecked; ?>" />
  495. <a href="<?php echo $checkall_url; ?>&checkall=1"
  496.     onclick="if (markAllRows('fieldsForm')) return false;">
  497.     <?php echo $strCheckAll; ?></a>
  498. /
  499. <a href="<?php echo $checkall_url; ?>"
  500.     onclick="if (unMarkAllRows('fieldsForm')) return false;">
  501.     <?php echo $strUncheckAll; ?></a>
  502.  
  503. <i><?php echo $strWithChecked; ?></i>
  504.  
  505. <?php
  506. if ($cfg['PropertiesIconic']) {
  507.     PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_browse', $strBrowse, 'b_browse.png');
  508. } else {
  509.     echo '<input type="submit" name="submit_mult" value="' . $strChange . '" title="' . $strChange . '" />' . "\n";
  510. }
  511. if (! $tbl_is_view && ! $db_is_information_schema) {
  512.     if ($cfg['PropertiesIconic']) {
  513.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_change', $strChange, 'b_edit.png');
  514.         // Drop button if there is at least two fields
  515.         if ($fields_cnt > 1) {
  516.             PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', $strDrop, 'b_drop.png');
  517.         }
  518.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_primary', $strPrimary, 'b_primary.png');
  519.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_unique', $strUnique, 'b_unique.png');
  520.         PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_index', $strIndex, 'b_index.png');
  521.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
  522.             PMA_buttonOrImage('submit_mult', 'mult_submit', 'submit_mult_fulltext', $strIdxFulltext, 'b_ftext.png');
  523.         }
  524.     } else {
  525.         // Drop button if there is at least two fields
  526.         if ($fields_cnt > 1) {
  527.             echo '<i>' . $strOr . '</i>' . "\n"
  528.                . '<input type="submit" name="submit_mult" value="' . $strDrop . '" title="' . $strDrop . '" />' . "\n";
  529.         }
  530.         echo '<i>' . $strOr . '</i>' . "\n"
  531.            . '<input type="submit" name="submit_mult" value="' . $strPrimary . '" title="' . $strPrimary . '" />' . "\n";
  532.         echo '<i>' . $strOr . '</i>' . "\n"
  533.            . '<input type="submit" name="submit_mult" value="' . $strIndex . '" title="' . $strIndex . '" />' . "\n";
  534.         echo '<i>' . $strOr . '</i>' . "\n"
  535.            . '<input type="submit" name="submit_mult" value="' . $strUnique . '" title="' . $strUnique . '" />' . "\n";
  536.         if ((!empty($tbl_type) && $tbl_type == 'MYISAM')) {
  537.             echo '<i>' . $strOr . '</i>' . "\n"
  538.                . '<input type="submit" name="submit_mult" value="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' . "\n";
  539.         }
  540.     }
  541. }
  542. ?>
  543. </form>
  544. <hr />
  545.  
  546. <?php
  547. /**
  548.  * Work on the table
  549.  */
  550. ?>
  551. <a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
  552. if ($cfg['PropertiesIconic']) {
  553.     echo '<img class="icon" src="' . $pmaThemeImage . 'b_print.png" width="16" height="16" alt="' . $strPrintView . '"/>';
  554. }
  555. echo $strPrintView;
  556. ?></a>
  557.  
  558. <?php
  559. if (! $tbl_is_view && ! $db_is_information_schema) {
  560.  
  561.     // if internal relations are available, or the table type is INNODB
  562.     // ($tbl_type comes from libraries/tbl_info.inc.php)
  563.     if ($cfgRelation['relwork'] || $tbl_type=="INNODB") {
  564.         ?>
  565. <a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
  566.         if ($cfg['PropertiesIconic']) {
  567.             echo '<img class="icon" src="' . $pmaThemeImage . 'b_relations.png" width="16" height="16" alt="' . $strRelationView . '"/>';
  568.         }
  569.         echo $strRelationView;
  570.         ?></a>
  571.         <?php
  572.     }
  573.     ?>
  574. <a href="sql.php?<?php echo $url_query; ?>&session_max_rows=all&sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
  575.     if ($cfg['PropertiesIconic']) {
  576.         echo '<img class="icon" src="' . $pmaThemeImage . 'b_tblanalyse.png" width="16" height="16" alt="' . $strStructPropose . '" />';
  577.     }
  578.     echo $strStructPropose;
  579.     ?></a><?php
  580.     echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
  581.     ?><br />
  582. <form method="post" action="tbl_addfield.php"
  583.     onsubmit="return checkFormElementInRange(this, 'num_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)">
  584.     <?php
  585.     echo PMA_generate_common_hidden_inputs($db, $table);
  586.     if ($cfg['PropertiesIconic']) {
  587.         echo '<img class="icon" src="' . $pmaThemeImage . 'b_insrow.png" width="16" height="16" alt="' . $strAddNewField . '"/>';
  588.     }
  589.     echo sprintf($strAddFields, '<input type="text" name="num_fields" size="2" maxlength="2" value="1" style="vertical-align: middle" onfocus="this.select()" />');
  590.     ?>
  591. <input type="radio" name="field_where" id="radio_field_where_last" value="last" checked="checked" /><label for="radio_field_where_last"><?php echo $strAtEndOfTable; ?></label>
  592. <input type="radio" name="field_where" id="radio_field_where_first" value="first" /><label for="radio_field_where_first"><?php echo $strAtBeginningOfTable; ?></label>
  593. <input type="radio" name="field_where" id="radio_field_where_after" value="after" /><?php
  594.     $fieldOptions = '</label><select name="after_field" style="vertical-align: middle" onclick="this.form.field_where[2].checked=true" onchange="this.form.field_where[2].checked=true">';
  595.     foreach ($aryFields as $fieldname) {
  596.         $fieldOptions .= '<option value="' . htmlspecialchars($fieldname) . '">' . htmlspecialchars($fieldname) . '</option>' . "\n";
  597.     }
  598.     unset($aryFields);
  599.     $fieldOptions .= '</select><label for="radio_field_where_after">';
  600.     echo str_replace('<label for="radio_field_where_after"></label>', '', '<label for="radio_field_where_after">' . sprintf($strAfter, $fieldOptions) . '</label>') . "\n";
  601.     ?>
  602. <input type="submit" value="<?php echo $strGo; ?>" style="vertical-align: middle" />
  603. </form>
  604. <hr />
  605.     <?php
  606. }
  607.  
  608. /**
  609.  * If there are more than 20 rows, displays browse/select/insert/empty/drop
  610.  * links again
  611.  */
  612. if ($fields_cnt > 20) {
  613.     require './libraries/tbl_links.inc.php';
  614. } // end if ($fields_cnt > 20)
  615. echo "\n\n";
  616.  
  617. /**
  618.  * Displays indexes
  619.  */
  620. echo '<div id="tablestatistics">' . "\n";
  621. if (! $tbl_is_view && ! $db_is_information_schema) {
  622.     define('PMA_IDX_INCLUDED', 1);
  623.     require './tbl_indexes.php';
  624. }
  625.  
  626. /**
  627.  * Displays Space usage and row statistics
  628.  */
  629. // BEGIN - Calc Table Space - staybyte - 9 June 2001
  630. // loic1, 22 feb. 2002: updated with patch from
  631. //                      Joshua Nye <josh at boxcarmedia.com> to get valid
  632. //                      statistics whatever is the table type
  633. if ($cfg['ShowStats']) {
  634.     $nonisam     = false;
  635.     $is_innodb = (isset($showtable['Type']) && $showtable['Type'] == 'InnoDB');
  636.     if (isset($showtable['Type']) && !preg_match('@ISAM|HEAP@i', $showtable['Type'])) {
  637.         $nonisam = true;
  638.     }
  639.  
  640.     // Gets some sizes
  641.     $mergetable     = false;
  642.     if (isset($showtable['Type']) && $showtable['Type'] == 'MRG_MyISAM') {
  643.         $mergetable = true;
  644.     }
  645.     // this is to display for example 261.2 MiB instead of 268k KiB
  646.     $max_digits = 5;
  647.     $decimals = 1;
  648.     list($data_size, $data_unit)         = PMA_formatByteDown($showtable['Data_length'], $max_digits, $decimals);
  649.     if ($mergetable == false) {
  650.         list($index_size, $index_unit)   = PMA_formatByteDown($showtable['Index_length'], $max_digits, $decimals);
  651.     }
  652.     if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) {
  653.         list($free_size, $free_unit)     = PMA_formatByteDown($showtable['Data_free'], $max_digits, $decimals);
  654.         list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals);
  655.     } else {
  656.         list($effect_size, $effect_unit) = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
  657.     }
  658.     list($tot_size, $tot_unit)           = PMA_formatByteDown($showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals);
  659.     if ($table_info_num_rows > 0) {
  660.         list($avg_size, $avg_unit)       = PMA_formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1);
  661.     }
  662.  
  663.     // Displays them
  664.     $odd_row = false;
  665.     ?>
  666.  
  667.     <a name="showusage"></a>
  668.     <?php if (! $tbl_is_view && ! $db_is_information_schema) { ?>
  669.     <table id="tablespaceusage" class="data">
  670.     <caption class="tblHeaders"><?php echo $strSpaceUsage; ?></caption>
  671.     <thead>
  672.     <tr>
  673.         <th><?php echo $strType; ?></th>
  674.         <th colspan="2"><?php echo $strUsage; ?></th>
  675.     </tr>
  676.     </thead>
  677.     <tbody>
  678.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  679.         <th class="name"><?php echo $strData; ?></th>
  680.         <td class="value"><?php echo $data_size; ?></td>
  681.         <td class="unit"><?php echo $data_unit; ?></td>
  682.     </tr>
  683.         <?php
  684.         if (isset($index_size)) {
  685.             ?>
  686.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  687.         <th class="name"><?php echo $strIndex; ?></th>
  688.         <td class="value"><?php echo $index_size; ?></td>
  689.         <td class="unit"><?php echo $index_unit; ?></td>
  690.     </tr>
  691.             <?php
  692.         }
  693.         if (isset($free_size)) {
  694.             ?>
  695.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?> warning">
  696.         <th class="name"><?php echo $strOverhead; ?></th>
  697.         <td class="value"><?php echo $free_size; ?></td>
  698.         <td class="unit"><?php echo $free_unit; ?></td>
  699.     </tr>
  700.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  701.         <th class="name"><?php echo $strEffective; ?></th>
  702.         <td class="value"><?php echo $effect_size; ?></td>
  703.         <td class="unit"><?php echo $effect_unit; ?></td>
  704.     </tr>
  705.             <?php
  706.         }
  707.         if (isset($tot_size) && $mergetable == false) {
  708.             ?>
  709.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  710.         <th class="name"><?php echo $strTotalUC; ?></th>
  711.         <td class="value"><?php echo $tot_size; ?></td>
  712.         <td class="unit"><?php echo $tot_unit; ?></td>
  713.     </tr>
  714.             <?php
  715.         }
  716.         // Optimize link if overhead
  717.         if (isset($free_size) && ($tbl_type == 'MYISAM' || $tbl_type == 'BDB')) {
  718.             ?>
  719.     <tr class="tblFooters">
  720.         <td colspan="3" align="center">
  721.             <a href="sql.php?<?php echo $url_query; ?>&pos=0&sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
  722.             if ($cfg['PropertiesIconic']) {
  723.                echo '<img class="icon" src="' . $pmaThemeImage . 'b_tbloptimize.png" width="16" height="16" alt="' . $strOptimizeTable. '" />';
  724.             }
  725.             echo $strOptimizeTable;
  726.             ?></a>
  727.         </td>
  728.     </tr>
  729.             <?php
  730.         }
  731.         ?>
  732.     </tbody>
  733.     </table>
  734.         <?php
  735.     }
  736.     $odd_row = false;
  737.     ?>
  738.     <table id="tablerowstats" class="data">
  739.     <caption class="tblHeaders"><?php echo $strRowsStatistic; ?></caption>
  740.     <thead>
  741.     <tr>
  742.         <th><?php echo $strStatement; ?></th>
  743.         <th><?php echo $strValue; ?></th>
  744.     </tr>
  745.     </thead>
  746.     <tbody>
  747.     <?php
  748.     if (isset($showtable['Row_format'])) {
  749.         ?>
  750.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  751.         <th class="name"><?php echo $strFormat; ?></th>
  752.         <td class="value"><?php
  753.         if ($showtable['Row_format'] == 'Fixed') {
  754.             echo $strFixed;
  755.         } elseif ($showtable['Row_format'] == 'Dynamic') {
  756.             echo $strDynamic;
  757.         } else {
  758.             echo $showtable['Row_format'];
  759.         }
  760.         ?></td>
  761.     </tr>
  762.         <?php
  763.     }
  764.     if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
  765.         ?>
  766.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  767.         <th class="name"><?php echo $strCollation; ?></th>
  768.         <td class="value"><?php
  769.             echo '<dfn title="' . PMA_getCollationDescr($tbl_collation) . '">' . $tbl_collation . '</dfn>';
  770.             ?></td>
  771.     </tr>
  772.         <?php
  773.     }
  774.     if (!$is_innodb && isset($showtable['Rows'])) {
  775.         ?>
  776.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  777.         <th class="name"><?php echo $strRows; ?></th>
  778.         <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
  779.     </tr>
  780.         <?php
  781.     }
  782.     if (!$is_innodb && isset($showtable['Avg_row_length']) && $showtable['Avg_row_length'] > 0) {
  783.         ?>
  784.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  785.         <th class="name"><?php echo $strRowLength; ?> ø</th>
  786.         <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
  787.     </tr>
  788.         <?php
  789.     }
  790.     if (!$is_innodb && isset($showtable['Data_length']) && $showtable['Rows'] > 0 && $mergetable == false) {
  791.         ?>
  792.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  793.         <th class="name"><?php echo $strRowSize; ?> ø</th>
  794.         <td class="value"><?php echo $avg_size . ' ' . $avg_unit; ?></td>
  795.     </tr>
  796.         <?php
  797.     }
  798.     if (isset($showtable['Auto_increment'])) {
  799.         ?>
  800.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  801.         <th class="name"><?php echo $strNext; ?> Autoindex</th>
  802.         <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
  803.     </tr>
  804.         <?php
  805.     }
  806.     if (isset($showtable['Create_time'])) {
  807.         ?>
  808.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  809.         <th class="name"><?php echo $strStatCreateTime; ?></th>
  810.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
  811.     </tr>
  812.         <?php
  813.     }
  814.     if (isset($showtable['Update_time'])) {
  815.         ?>
  816.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  817.         <th class="name"><?php echo $strStatUpdateTime; ?></th>
  818.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
  819.     </tr>
  820.         <?php
  821.     }
  822.     if (isset($showtable['Check_time'])) {
  823.         ?>
  824.     <tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
  825.         <th class="name"><?php echo $strStatCheckTime; ?></th>
  826.         <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
  827.     </tr>
  828.         <?php
  829.     }
  830.     ?>
  831.     </tbody>
  832.     </table>
  833.     <?php
  834. }
  835. // END - Calc Table Space
  836.  
  837. require './libraries/tbl_triggers.lib.php';
  838.  
  839. echo '<div class="clearfloat"></div>' . "\n";
  840. echo '</div>' . "\n";
  841.  
  842. /**
  843.  * Displays the footer
  844.  */
  845. require_once './libraries/footer.inc.php';
  846. ?>
  847.