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

  1. <?php
  2. /* $Id: tbl_properties.inc.php,v 1.25 2002/01/03 14:15:13 loic1 Exp $ */
  3.  
  4.  
  5. ?>
  6. <form method="post" action="<?php echo $action; ?>">
  7.     <input type="hidden" name="server" value="<?php echo $server; ?>" />
  8.     <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
  9.     <input type="hidden" name="db" value="<?php echo $db; ?>" />
  10.     <input type="hidden" name="table" value="<?php echo $table; ?>" />
  11. <?php
  12. if ($action == 'tbl_create.php') {
  13.     ?>
  14.     <input type="hidden" name="reload" value="1" />
  15.     <?php
  16. }
  17. else if ($action == 'tbl_addfield.php') {
  18.     echo "\n";
  19.     ?>
  20.     <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
  21.     <?php
  22. }
  23. echo "\n";
  24. $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
  25. ?>
  26.  
  27.     <table border="<?php echo $cfgBorder; ?>">
  28.     <tr>
  29.         <th><?php echo $strField; ?></th>
  30.         <th><?php echo $strType; ?></th>
  31.         <th><?php echo $strLengthSet; ?></th>
  32.         <th><?php echo $strAttr; ?></th>
  33.         <th><?php echo $strNull; ?></th>
  34.         <th><?php echo $strDefault; ?></th>
  35.         <th><?php echo $strExtra; ?></th>
  36. <?php
  37. if (!$is_backup) {
  38.     if (empty($num_indexes)) {
  39.         echo "        <th>$strPrimary</th>\n";
  40.         echo "        <th>$strIndex</th>\n";
  41.         echo "        <th>$strUnique</th>\n";
  42.         echo "        <th>$strIdxFulltext</th>\n";
  43.     } else {
  44.         for ($i = 0; $i < $num_indexes; $i++) {
  45.             echo "        <th>$strSequence</th>\n";
  46.             echo "        <th>$strLength</th>\n";
  47.         } // end for
  48.     } // end if
  49. }
  50. ?>
  51.     </tr>
  52.  
  53. <?php
  54. for ($i = 0 ; $i < $num_fields; $i++) {
  55.     if (isset($fields_meta)) {
  56.         $row = $fields_meta[$i];
  57.     }
  58.     $bgcolor = ($i % 2) ? $cfgBgcolorOne : $cfgBgcolorTwo;
  59.     ?>
  60.     <tr>
  61.         <td bgcolor="<?php echo $bgcolor; ?>">
  62.     <?php
  63.     if ($is_backup) {
  64.         echo "\n";
  65.         ?>
  66.             <input type="hidden" name="field_orig[]" value="<?php if (isset($row) && isset($row['Field'])) echo urlencode($row['Field']); ?>" />
  67.         <?php
  68.     }
  69.     echo "\n";
  70.     ?>
  71.             <input type="text" name="field_name[]" size="10" maxlength="64" value="<?php if (isset($row) && isset($row['Field'])) echo str_replace('"', '"', $row['Field']); ?>" />
  72.         </td>
  73.         <td bgcolor="<?php echo $bgcolor; ?>">
  74.             <select name="field_type[]">
  75.     <?php
  76.     echo "\n";
  77.     if (empty($row['Type'])) {
  78.         $row['Type'] = '';
  79.         $type        = '';
  80.     }
  81.     else if (get_magic_quotes_gpc()) {
  82.         $type        = stripslashes($row['Type']);
  83.     }
  84.     else {
  85.         $type        = $row['Type'];
  86.     }
  87.     $type   = eregi_replace('BINARY', '', $type);
  88.     $type   = eregi_replace('ZEROFILL', '', $type);
  89.     $type   = eregi_replace('UNSIGNED', '', $type);
  90.     // set or enum types: slashes single quotes inside options
  91.     if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
  92.         $type   = $tmp[1];
  93.         $length = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
  94.     } else {
  95.         $length = $type;
  96.         $type   = chop(eregi_replace('\\(.*\\)', '', $type));
  97.         if (!empty($type)) {
  98.             $length = eregi_replace("^$type\(", '', $length);
  99.             $length = eregi_replace('\)$', '', trim($length));
  100.         }
  101.         if ($length == $type) {
  102.             $length = '';
  103.         }
  104.     } // end if else
  105.  
  106.     for ($j = 0; $j < count($cfgColumnTypes); $j++) {
  107.         echo '                <option value="'. $cfgColumnTypes[$j] . '"';
  108.         if (strtoupper($type) == strtoupper($cfgColumnTypes[$j])) {
  109.             echo ' selected="selected"';
  110.         }
  111.         echo ">$cfgColumnTypes[$j]</option>\n";
  112.     } // end for
  113.     ?>
  114.             </select>
  115.         </td>
  116.         <td bgcolor="<?php echo $bgcolor; ?>">
  117.     <?php
  118.     if ($is_backup) {
  119.         echo "\n";
  120.         ?>
  121.             <input type="hidden" name="field_length_orig[]" value="<?php echo urlencode($length); ?>" />
  122.         <?php
  123.     }
  124.     echo "\n";
  125.     ?>
  126.             <input type="text" name="field_length[]" size="8" value="<?php echo str_replace('"', '"', $length); ?>" />
  127.         </td>
  128.         <td bgcolor="<?php echo $bgcolor; ?>">
  129.             <select name="field_attribute[]">
  130.     <?php
  131.     echo "\n";
  132.     $binary           = eregi('BINARY', $row['Type'], $test_attribute1);
  133.     $unsigned         = eregi('UNSIGNED', $row['Type'], $test_attribute2);
  134.     $zerofill         = eregi('ZEROFILL', $row['Type'], $test_attribute3);
  135.     $strAttribute     = '';
  136.     if ($binary) {
  137.         $strAttribute = 'BINARY';
  138.     }
  139.     if ($unsigned) {
  140.         $strAttribute = 'UNSIGNED';
  141.     }
  142.     if ($zerofill) {
  143.         $strAttribute = 'UNSIGNED ZEROFILL';
  144.     }
  145.     for ($j = 0;$j < count($cfgAttributeTypes); $j++) {
  146.         echo '                <option value="'. $cfgAttributeTypes[$j] . '"';
  147.         if (strtoupper($strAttribute) == strtoupper($cfgAttributeTypes[$j])) {
  148.             echo ' selected="selected"';
  149.         }
  150.         echo ">$cfgAttributeTypes[$j]</option>\n";
  151.     }
  152.     ?>
  153.             </select>
  154.         </td>
  155.         <td bgcolor="<?php echo $bgcolor; ?>">
  156.             <select name="field_null[]">
  157.     <?php
  158.     if (!isset($row) || empty($row['Null'])) {
  159.         echo "\n";
  160.         ?>
  161.                 <option value="NOT NULL">not null</option>
  162.                 <option value="">null</option>
  163.         <?php
  164.     } else {
  165.         echo "\n";
  166.         ?>
  167.                 <option value="">null</option>
  168.                 <option value="NOT NULL">not null</option>
  169.         <?php
  170.     }
  171.     echo "\n";
  172.     ?>
  173.             </select>
  174.         </td>
  175.     <?php
  176.     if (isset($row)
  177.         && !isset($row['Default']) && !empty($row['Null'])) {
  178.         $row['Default'] = 'NULL';
  179.     }
  180.     echo "\n";
  181.     ?>
  182.         <td bgcolor="<?php echo $bgcolor; ?>">
  183.     <?php
  184.     if ($is_backup) {
  185.         echo "\n";
  186.         ?>
  187.             <input type="hidden" name="field_default_orig[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo urlencode($row['Default']); ?>" />
  188.         <?php
  189.     }
  190.     echo "\n";
  191.     ?>
  192.             <input type="text" name="field_default[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo str_replace('"', '"', $row['Default']); ?>" />
  193.         </td>
  194.         <td bgcolor="<?php echo $bgcolor; ?>">
  195.             <select name="field_extra[]">
  196.     <?php
  197.     if(!isset($row) || empty($row['Extra'])) {
  198.         echo "\n";
  199.         ?>
  200.                 <option value=""></option>
  201.                 <option value="AUTO_INCREMENT">auto_increment</option>
  202.         <?php
  203.     } else {
  204.         echo "\n";
  205.         ?>
  206.                 <option value="AUTO_INCREMENT">auto_increment</option>
  207.                 <option value=""></option>
  208.         <?php
  209.     }
  210.     echo "\n";
  211.     ?>
  212.             </select>
  213.         </td>
  214.     <?php
  215.     if (!$is_backup) {
  216.         if (empty($num_indexes)) {
  217.             if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
  218.                 $checked_primary = ' checked="checked"';
  219.             } else {
  220.                 $checked_primary = '';
  221.             }
  222.             if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
  223.                 $checked_index   = ' checked="checked"';
  224.             } else {
  225.                 $checked_index   = '';
  226.             }
  227.             if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
  228.                 $checked_unique   = ' checked="checked"';
  229.             } else {
  230.                 $checked_unique   = '';
  231.             }
  232.             if (PMA_MYSQL_INT_VERSION >= 32323
  233.                 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
  234.                 $checked_fulltext = ' checked="checked"';
  235.             } else {
  236.                 $checked_fulltext = '';
  237.             }
  238.             echo "\n";
  239.             ?>
  240.         <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  241.             <input type="checkbox" name="field_primary[]" value="<?php echo $i; ?>"<?php echo $checked_primary; ?> />
  242.         </td>
  243.         <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  244.             <input type="checkbox" name="field_index[]" value="<?php echo $i; ?>"<?php echo $checked_index; ?> />
  245.         </td>
  246.         <td align="center" bgcolor="<?php echo $bgcolor; ?>">
  247.             <input type="checkbox" name="field_unique[]" value="<?php echo $i; ?>"<?php echo $checked_unique; ?> />
  248.         </td>
  249.             <?php
  250.             if (PMA_MYSQL_INT_VERSION >= 32323) {
  251.                 echo "\n";
  252.                 ?>
  253.         <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
  254.             <input type="checkbox" name="field_fulltext[]" value="<?php echo $i; ?>"<?php echo $checked_fulltext; ?> />
  255.         </td>
  256.                 <?php
  257.             } // end if (PMA_MYSQL_INT_VERSION >= 32323)
  258.             echo "\n";
  259.         } // end if (empty($num_indexes))
  260.     } // end if ($action ==...)
  261.     echo "\n";
  262.     ?>
  263.     </tr>
  264.     <?php
  265.     echo "\n";
  266. } // end for
  267. ?>
  268.     </table>
  269.     <br />
  270.  
  271. <?php
  272. if ($action == 'tbl_create.php' && PMA_MYSQL_INT_VERSION >= 32300) {
  273.     echo "\n";
  274.     ?>
  275.     <table>
  276.     <tr valign="top">
  277.         <td><?php echo $strTableComments; ?> :</td>
  278.     <?php
  279.     if ($action == 'tbl_create.php') {
  280.         echo "\n";
  281.         ?>
  282.         <td width="25"> </td>
  283.         <td><?php echo $strTableType; ?> :</td>
  284.         <?php
  285.     }
  286.     echo "\n";
  287.     ?>
  288.     </tr>
  289.     <tr>
  290.         <td>
  291.             <input type="text" name="comment" size="40" maxlength="80" />
  292.         </td>
  293.     <?php
  294.     // BEGIN - Table Type - 2 May 2001 - Robbat2
  295.     // change by staybyte - 11 June 2001
  296.     if ($action == 'tbl_create.php') {
  297.         // find mysql capability - staybyte - 11. June 2001
  298.         $query = 'SHOW VARIABLES LIKE \'have_%\'';
  299.         $result = mysql_query($query);
  300.         if ($result != FALSE && mysql_num_rows($result) > 0) {
  301.             while ($tmp = mysql_fetch_array($result)) {
  302.                 if (isset($tmp['Variable_name'])) {
  303.                     switch ($tmp['Variable_name']) {
  304.                         case 'have_bdb':
  305.                             if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
  306.                                 $tbl_bdb    = TRUE;
  307.                             }
  308.                             break;
  309.                         case 'have_gemini':
  310.                             if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
  311.                                 $tbl_gemini = TRUE;
  312.                             }
  313.                             break;
  314.                         case 'have_innodb':
  315.                             if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
  316.                                 $tbl_innodb = TRUE;
  317.                             }
  318.                             break;
  319.                         case 'have_isam':
  320.                             if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
  321.                                 $tbl_isam   = TRUE;
  322.                             }
  323.                             break;
  324.                     } // end switch
  325.                 } // end if
  326.             } // end while
  327.         } // end if
  328.         mysql_free_result($result);
  329.  
  330.         echo "\n";
  331.         ?>
  332.         <td width="25"> </td>
  333.         <td>
  334.             <select name="tbl_type">
  335.                 <option value="Default"><?php echo $strDefault; ?></option>
  336.                 <option value="MYISAM">MyISAM</option>
  337.                 <option value="HEAP">Heap</option>
  338.                 <option value="MERGE">Merge</option>
  339.                 <?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php }?> 
  340.                 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php }?> 
  341.                 <?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php }?> 
  342.                 <?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php }?> 
  343.             </select>
  344.         </td>
  345.         <?php
  346.     }
  347.     echo "\n";
  348.     ?>
  349.         </tr>
  350.     </table>
  351.     <br />
  352.     <?php
  353. }
  354. echo "\n";
  355. // END - Table Type - 2 May 2001 - Robbat2
  356. ?>
  357.  
  358. <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
  359. </form>
  360.  
  361. <table>
  362. <tr>
  363.     <td valign="top">* </td>
  364.     <td>
  365.         <?php echo $strSetEnumVal . "\n"; ?>
  366.     </td>
  367. </tr>
  368. </table>
  369. <br />
  370.  
  371. <center><?php echo PMA_showDocuShort('C/R/CREATE_TABLE.html'); ?></center>
  372.