did not work in bash
[phpmyadmin/crack.git] / tbl_properties.inc.php3
bloba8e49877d47dd19ef90d102bb81ab4984e650016
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 ?>
7 <!-- Set on key handler for moving using by Ctrl+arrows -->
8 <script type="text/javascript" language="javascript">
9 <!--
10 document.onkeydown = onKeyDownArrowsHandler;
11 // -->
12 </script>
14 <form method="post" action="<?php echo $action; ?>">
15 <?php
16 echo PMA_generate_common_hidden_inputs($db, $table);
17 if ($action == 'tbl_create.php3') {
19 <input type="hidden" name="reload" value="1" />
20 <?php
22 else if ($action == 'tbl_addfield.php3') {
23 echo "\n";
25 <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
26 <?php
28 echo "\n";
29 $is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
31 $header_cells = array();
32 $content_cells = array();
34 $header_cells[] = $strField;
35 $header_cells[] = $strType . '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('Reference', 'Column_types') . '</span>';
36 $header_cells[] = $strLengthSet;
37 $header_cells[] = $strAttr;
38 $header_cells[] = $strNull;
39 $header_cells[] = $strDefault . '**';
40 $header_cells[] = $strExtra;
42 require('./libraries/relation.lib.php3');
43 require('./libraries/transformations.lib.php3');
44 $cfgRelation = PMA_getRelationsParam();
46 $comments_map = array();
47 $mime_map = array();
48 $available_mime = array();
50 if ($cfgRelation['commwork']) {
51 $comments_map = PMA_getComments($db, $table);
52 $header_cells[] = $strComments;
54 if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
55 $mime_map = PMA_getMIME($db, $table);
56 $available_mime = PMA_getAvailableMIMEtypes();
58 $header_cells[] = $strMIME_MIMEtype;
59 $header_cells[] = $strMIME_transformation;
60 $header_cells[] = $strMIME_transformation_options . '***';
65 // lem9: We could remove this 'if' and let the key information be shown and
66 // editable. However, for this to work, tbl_alter must be modified to use the
67 // key fields, as tbl_addfield does.
69 if (!$is_backup) {
70 $header_cells[] = $strPrimary;
71 $header_cells[] = $strIndex;
72 $header_cells[] = $strUnique;
73 $header_cells[] = '---';
74 $header_cells[] = $strIdxFulltext;
77 for ($i = 0 ; $i < $num_fields; $i++) {
78 if (isset($fields_meta)) {
79 $row = $fields_meta[$i];
81 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
83 // Cell index: If certain fields get left out, the counter shouldn't chage.
84 $ci = 0;
86 if ($is_backup) {
87 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : '') . '" />' . "\n";
88 } else {
89 $content_cells[$i][$ci] = '';
92 $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_1" type="text" name="field_name[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '&quot;', $row['Field']) : '') . '" class="textfield" />';
93 $ci++;
94 $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_2">' . "\n";
96 if (empty($row['Type'])) {
97 $row['Type'] = '';
98 $type = '';
100 else {
101 $type = $row['Type'];
103 // set or enum types: slashes single quotes inside options
104 if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
105 $type = $tmp[1];
106 $length = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
107 } else {
108 $type = eregi_replace('BINARY', '', $type);
109 $type = eregi_replace('ZEROFILL', '', $type);
110 $type = eregi_replace('UNSIGNED', '', $type);
112 $length = $type;
113 $type = chop(eregi_replace('\\(.*\\)', '', $type));
114 if (!empty($type)) {
115 $length = eregi_replace("^$type\(", '', $length);
116 $length = eregi_replace('\)$', '', trim($length));
118 if ($length == $type) {
119 $length = '';
121 } // end if else
123 for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
124 $content_cells[$i][$ci] .= ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
125 if (strtoupper($type) == strtoupper($cfg['ColumnTypes'][$j])) {
126 $content_cells[$i][$ci] .= ' selected="selected"';
128 $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
129 } // end for
131 $content_cells[$i][$ci] .= ' </select>';
132 $ci++;
134 if ($is_backup) {
135 $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
136 } else {
137 $content_cells[$i][$ci] = '';
140 $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_3" type="text" name="field_length[]" size="8" value="' . str_replace('"', '&quot;', $length) . '" class="textfield" />' . "\n";
141 $ci++;
143 $content_cells[$i][$ci] = '<select name="field_attribute[]" id="field_' . $i . '_4">' . "\n";
145 if (eregi('^(set|enum)$', $type)) {
146 $binary = 0;
147 $unsigned = 0;
148 $zerofill = 0;
149 } else {
150 $binary = eregi('BINARY', $row['Type'], $test_attribute1);
151 $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2);
152 $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3);
154 $strAttribute = '';
155 if ($binary) {
156 $strAttribute = 'BINARY';
158 if ($unsigned) {
159 $strAttribute = 'UNSIGNED';
161 if ($zerofill) {
162 $strAttribute = 'UNSIGNED ZEROFILL';
164 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
165 $content_cells[$i][3] .= ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
166 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
167 $content_cells[$i][3] .= ' selected="selected"';
169 $content_cells[$i][3] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
172 $content_cells[$i][$ci] .= '</select>';
173 $ci++;
175 $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_5">';
177 if (!isset($row) || empty($row['Null'])) {
178 $content_cells[$i][$ci] .= "\n";
179 $content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
180 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
181 } else {
182 $content_cells[$i][$ci] .= "\n";
183 $content_cells[$i][$ci] .= ' <option value="">null</option>' . "\n";
184 $content_cells[$i][$ci] .= ' <option value="NOT NULL">not null</option>' . "\n";
187 $content_cells[$i][$ci] .= "\n" . '</select>';
188 $ci++;
190 if (isset($row)
191 && !isset($row['Default']) && !empty($row['Null'])) {
192 $row['Default'] = 'NULL';
195 if ($is_backup) {
196 $content_cells[$i][5] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
197 } else {
198 $content_cells[$i][5] = "\n";
201 $content_cells[$i][$ci] .= '<input id="field_' . $i . '_6" type="text" name="field_default[]" size="8" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '&quot;', $row['Default']) : '') . '" class="textfield" />';
202 $ci++;
204 $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_7">';
206 if(!isset($row) || empty($row['Extra'])) {
207 $content_cells[$i][$ci] .= "\n";
208 $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
209 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
210 } else {
211 $content_cells[$i][$ci] .= "\n";
212 $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
213 $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
216 $content_cells[$i][$ci] .= "\n" . '</select>';
217 $ci++;
219 // garvin: comments
220 if ($cfgRelation['commwork']) {
221 $content_cells[$i][$ci] = '<input id="field_' . $i . '_7" type="text" name="field_comments[]" size="8" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ? htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
222 $ci++;
225 // garvin: MIME-types
226 if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
227 $content_cells[$i][$ci] = '<select id="field_' . $i . '_8" size="1" name="field_mimetype[]">' . "\n";
228 $content_cells[$i][$ci] .= ' <option value=""></option>' . "\n";
229 $content_cells[$i][$ci] .= ' <option value="auto">auto-detect</option>' . "\n";
231 if (is_array($available_mime['mimetype'])) {
232 @reset($available_mime['mimetype']);
233 while(list($mimekey, $mimetype) = each($available_mime['mimetype'])) {
234 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
235 $content_cells[$i][$ci] .= ' <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
239 $content_cells[$i][$ci] .= '</select>';
240 $ci++;
242 $content_cells[$i][$ci] = '<select id="field_' . $i . '_9" size="1" name="field_transformation[]">' . "\n";
243 $content_cells[$i][$ci] .= ' <option value=""></option>' . "\n";
244 if (is_array($available_mime['transformation'])) {
245 @reset($available_mime['transformation']);
246 while(list($mimekey, $transform) = each($available_mime['transformation'])) {
247 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && ($mime_map[$row['Field']]['transformation'] == $available_mime['transformation_file'][$mimekey]) ? 'selected ' : '');
248 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . '>' . htmlspecialchars($transform) . '</option>' . "\n";
252 $content_cells[$i][$ci] .= '</select>';
253 $ci++;
255 $content_cells[$i][$ci] = '<input id="field_' . $i . '_10" type="text" name="field_transformation_options[]" size="8" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
256 $ci++;
259 // lem9: See my other comment about removing this 'if'.
260 if (!$is_backup) {
261 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
262 $checked_primary = ' checked="checked"';
263 } else {
264 $checked_primary = '';
266 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
267 $checked_index = ' checked="checked"';
268 } else {
269 $checked_index = '';
271 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
272 $checked_unique = ' checked="checked"';
273 } else {
274 $checked_unique = '';
276 if (empty($checked_primary)
277 && empty($checked_index)
278 && empty($checked_unique)) {
279 $checked_none = ' checked="checked"';
281 if (PMA_MYSQL_INT_VERSION >= 32323
282 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
283 $checked_fulltext = ' checked="checked"';
284 } else {
285 $checked_fulltext = '';
288 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' />';
289 $ci++;
291 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' . $checked_index . ' />';
292 $ci++;
294 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' . $checked_unique . ' />';
295 $ci++;
297 $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' . $checked_none . ' />';
298 $ci++;
300 if (PMA_MYSQL_INT_VERSION >= 32323) {
301 $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' />';
302 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
303 } // end if ($action ==...)
304 } // end for
306 if ($cfg['DefaultPropDisplay'] == 'horizontal') {
308 <table border="<?php echo $cfg['Border']; ?>">
309 <tr>
310 <?php
311 @reset($header_cells);
312 while(@list($header_nr, $header_val) = @each($header_cells)) {
314 <th><?php echo $header_val; ?></th>
315 <?php
318 </tr>
319 <?php
320 @reset($content_cells);
321 $i = 0;
322 while(@list($content_nr, $content_row) = @each($content_cells)) {
323 $i++;
324 echo "\n" . '<tr>' . "\n";
326 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
328 while(list($content_row_nr, $content_row_val) = @each($content_row)) {
330 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_row_val; ?></td>
331 <?php
333 echo "\n" . '</tr>' . "\n";
336 </table>
337 <br />
338 <?php
339 } else {
341 <table border="<?php echo $cfg['Border']; ?>">
342 <?php
343 @reset($header_cells);
344 $i = 0;
345 while(@list($header_nr, $header_val) = @each($header_cells)) {
346 echo "\n" . '<tr>' . "\n";
348 <th align="right"><?php echo $header_val; ?></th>
349 <?php
350 for ($j = 0; $j < count($content_cells); $j++) {
351 if (isset($content_cells[$j][$i]) && $content_cells[$j][$i] != '') {
352 $bgcolor = ($j % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
354 <td bgcolor="<?php echo $bgcolor; ?>"><?php echo $content_cells[$j][$i]; ?></td>
355 <?php
359 echo "\n" . '</tr>' . "\n";
360 $i++;
363 </table>
364 <br />
365 <?php
368 if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
369 echo "\n";
371 <table>
372 <tr valign="top">
373 <td><?php echo $strTableComments; ?>&nbsp;:</td>
374 <?php
375 if ($action == 'tbl_create.php3') {
376 echo "\n";
378 <td width="25">&nbsp;</td>
379 <td><?php echo $strTableType; ?>&nbsp;:</td>
380 <?php
382 echo "\n";
384 </tr>
385 <tr>
386 <td>
387 <input type="text" name="comment" size="40" maxlength="80" class="textfield" />
388 </td>
389 <?php
390 // BEGIN - Table Type - 2 May 2001 - Robbat2
391 // change by staybyte - 11 June 2001
392 if ($action == 'tbl_create.php3') {
393 // find mysql capability - staybyte - 11. June 2001
394 $query = 'SHOW VARIABLES LIKE \'have_%\'';
395 $result = PMA_mysql_query($query);
396 if ($result != FALSE && mysql_num_rows($result) > 0) {
397 while ($tmp = PMA_mysql_fetch_array($result)) {
398 if (isset($tmp['Variable_name'])) {
399 switch ($tmp['Variable_name']) {
400 case 'have_bdb':
401 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
402 $tbl_bdb = TRUE;
404 break;
405 case 'have_gemini':
406 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
407 $tbl_gemini = TRUE;
409 break;
410 case 'have_innodb':
411 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
412 $tbl_innodb = TRUE;
414 break;
415 case 'have_isam':
416 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
417 $tbl_isam = TRUE;
419 break;
420 } // end switch
421 } // end if
422 } // end while
423 } // end if
424 mysql_free_result($result);
426 echo "\n";
428 <td width="25">&nbsp;</td>
429 <td>
430 <select name="tbl_type">
431 <option value="Default"><?php echo $strDefault; ?></option>
432 <option value="MYISAM">MyISAM</option>
433 <option value="HEAP">Heap</option>
434 <option value="MERGE">Merge</option>
435 <?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php } ?>
436 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php } ?>
437 <?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php } ?>
438 <?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php } ?>
439 </select>
440 </td>
441 <?php
443 echo "\n";
445 </tr>
446 </table>
447 <br />
448 <?php
450 echo "\n";
451 // END - Table Type - 2 May 2001 - Robbat2
454 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
455 </form>
457 <table>
458 <tr>
459 <td valign="top">*&nbsp;</td>
460 <td>
461 <?php echo $strSetEnumVal . "\n"; ?>
462 </td>
463 </tr>
464 <tr>
465 <td valign="top">**&nbsp;</td>
466 <td>
467 <?php echo $strDefaultValueHelp . "\n"; ?>
468 </td>
469 </tr>
471 <?php
472 if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
474 <tr>
475 <td valign="top" rowspan="2">***&nbsp;</td>
476 <td>
477 <?php echo $strMIME_transformation_options_note . "\n"; ?>
478 </td>
479 </tr>
481 <tr>
482 <td>
483 <?php echo sprintf($strMIME_transformation_note, '<a href="libraries/transformations/overview.php3?' . PMA_generate_common_url($db, $table) . '" target="_new">', '</a>') . "\n"; ?>
484 </td>
485 </tr>
486 <?php
490 </table>
491 <br />
493 <center><?php echo PMA_showMySQLDocu('Reference', 'CREATE_TABLE'); ?></center>