home *** CD-ROM | disk | FTP | other *** search
/ Freelog 70 / Freelog070.iso / Internet / EasyPHP / easyphp1-8_setup.exe / {app} / phpmyadmin / tbl_properties_structure.php < prev    next >
Encoding:
PHP Script  |  2004-10-25  |  35.6 KB  |  831 lines

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