analyzer: clauses
[phpmyadmin/crack.git] / tbl_properties.inc.php3
blob5a89fe0d4db0102174a8cac36048fc88e37fbc39
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');
32 <table border="<?php echo $cfg['Border']; ?>">
33 <tr>
34 <th><?php echo $strField; ?></th>
35 <th><?php echo $strType . '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('Reference', 'Column_types'); ?></span></th>
36 <th><?php echo $strLengthSet; ?></th>
37 <th><?php echo $strAttr; ?></th>
38 <th><?php echo $strNull; ?></th>
39 <th><?php echo $strDefault; ?>**</th>
40 <th><?php echo $strExtra; ?></th>
41 <?php
42 // lem9: We could remove this 'if' and let the key information be shown and
43 // editable. However, for this to work, tbl_alter must be modified to use the
44 // key fields, as tbl_addfield does.
46 if (!$is_backup) {
47 echo " <th>$strPrimary</th>\n";
48 echo " <th>$strIndex</th>\n";
49 echo " <th>$strUnique</th>\n";
50 echo " <th>---</th>\n";
51 echo " <th>$strIdxFulltext</th>\n";
54 </tr>
56 <?php
57 for ($i = 0 ; $i < $num_fields; $i++) {
58 if (isset($fields_meta)) {
59 $row = $fields_meta[$i];
61 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
63 <tr>
64 <td bgcolor="<?php echo $bgcolor; ?>">
65 <?php
66 if ($is_backup) {
67 echo "\n";
69 <input type="hidden" name="field_orig[]" value="<?php if (isset($row) && isset($row['Field'])) echo urlencode($row['Field']); ?>" />
70 <?php
72 echo "\n";
74 <input id="field_<?php echo $i; ?>_1" type="text" name="field_name[]" size="10" maxlength="64" value="<?php if (isset($row) && isset($row['Field'])) echo str_replace('"', '&quot;', $row['Field']); ?>" class="textfield" />
75 </td>
76 <td bgcolor="<?php echo $bgcolor; ?>">
77 <select name="field_type[]" id="field_<?php echo $i; ?>_2">
78 <?php
79 echo "\n";
80 if (empty($row['Type'])) {
81 $row['Type'] = '';
82 $type = '';
84 else if (get_magic_quotes_gpc()) {
85 $type = stripslashes($row['Type']);
87 else {
88 $type = $row['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 $type = eregi_replace('BINARY', '', $type);
96 $type = eregi_replace('ZEROFILL', '', $type);
97 $type = eregi_replace('UNSIGNED', '', $type);
99 $length = $type;
100 $type = chop(eregi_replace('\\(.*\\)', '', $type));
101 if (!empty($type)) {
102 $length = eregi_replace("^$type\(", '', $length);
103 $length = eregi_replace('\)$', '', trim($length));
105 if ($length == $type) {
106 $length = '';
108 } // end if else
110 for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
111 echo ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
112 if (strtoupper($type) == strtoupper($cfg['ColumnTypes'][$j])) {
113 echo ' selected="selected"';
115 echo '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
116 } // end for
118 </select>
119 </td>
120 <td bgcolor="<?php echo $bgcolor; ?>">
121 <?php
122 if ($is_backup) {
123 echo "\n";
125 <input type="hidden" name="field_length_orig[]" value="<?php echo urlencode($length); ?>" />
126 <?php
128 echo "\n";
130 <input id="field_<?php echo $i; ?>_3" type="text" name="field_length[]" size="8" value="<?php echo str_replace('"', '&quot;', $length); ?>" class="textfield" />
131 </td>
132 <td bgcolor="<?php echo $bgcolor; ?>">
133 <select name="field_attribute[]" id="field_<?php echo $i; ?>_4">
134 <?php
135 echo "\n";
136 if (eregi('^(set|enum)$', $type)) {
137 $binary = 0;
138 $unsigned = 0;
139 $zerofill = 0;
140 } else {
141 $binary = eregi('BINARY', $row['Type'], $test_attribute1);
142 $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2);
143 $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3);
145 $strAttribute = '';
146 if ($binary) {
147 $strAttribute = 'BINARY';
149 if ($unsigned) {
150 $strAttribute = 'UNSIGNED';
152 if ($zerofill) {
153 $strAttribute = 'UNSIGNED ZEROFILL';
155 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
156 echo ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
157 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
158 echo ' selected="selected"';
160 echo '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
163 </select>
164 </td>
165 <td bgcolor="<?php echo $bgcolor; ?>">
166 <select name="field_null[]" id="field_<?php echo $i; ?>_5">
167 <?php
168 if (!isset($row) || empty($row['Null'])) {
169 echo "\n";
171 <option value="NOT NULL">not null</option>
172 <option value="">null</option>
173 <?php
174 } else {
175 echo "\n";
177 <option value="">null</option>
178 <option value="NOT NULL">not null</option>
179 <?php
181 echo "\n";
183 </select>
184 </td>
185 <?php
186 if (isset($row)
187 && !isset($row['Default']) && !empty($row['Null'])) {
188 $row['Default'] = 'NULL';
190 echo "\n";
192 <td bgcolor="<?php echo $bgcolor; ?>">
193 <?php
194 if ($is_backup) {
195 echo "\n";
197 <input type="hidden" name="field_default_orig[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo urlencode($row['Default']); ?>" />
198 <?php
200 echo "\n";
202 <input id="field_<?php echo $i; ?>_6" type="text" name="field_default[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo str_replace('"', '&quot;', $row['Default']); ?>" class="textfield" />
203 </td>
204 <td bgcolor="<?php echo $bgcolor; ?>">
205 <select name="field_extra[]" id="field_<?php echo $i; ?>_7">
206 <?php
207 if(!isset($row) || empty($row['Extra'])) {
208 echo "\n";
210 <option value=""></option>
211 <option value="AUTO_INCREMENT">auto_increment</option>
212 <?php
213 } else {
214 echo "\n";
216 <option value="AUTO_INCREMENT">auto_increment</option>
217 <option value=""></option>
218 <?php
220 echo "\n";
222 </select>
223 </td>
224 <?php
225 // lem9: See my other comment about removing this 'if'.
226 if (!$is_backup) {
227 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
228 $checked_primary = ' checked="checked"';
229 } else {
230 $checked_primary = '';
232 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
233 $checked_index = ' checked="checked"';
234 } else {
235 $checked_index = '';
237 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
238 $checked_unique = ' checked="checked"';
239 } else {
240 $checked_unique = '';
242 if (empty($checked_primary)
243 && empty($checked_index)
244 && empty($checked_unique)) {
245 $checked_none = ' checked="checked"';
247 if (PMA_MYSQL_INT_VERSION >= 32323
248 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
249 $checked_fulltext = ' checked="checked"';
250 } else {
251 $checked_fulltext = '';
253 echo "\n";
255 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
256 <input type="radio" name="field_key_<?php echo $i; ?>" value="primary_<?php echo $i; ?>"<?php echo $checked_primary; ?> />
257 </td>
258 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
259 <input type="radio" name="field_key_<?php echo $i; ?>" value="index_<?php echo $i; ?>"<?php echo $checked_index; ?> />
260 </td>
261 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
262 <input type="radio" name="field_key_<?php echo $i; ?>" value="unique_<?php echo $i; ?>"<?php echo $checked_unique; ?> />
263 </td>
264 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
265 <input type="radio" name="field_key_<?php echo $i; ?>" value="none_<?php echo $i; ?>"<?php echo $checked_none; ?> />
266 </td>
267 <?php
268 if (PMA_MYSQL_INT_VERSION >= 32323) {
269 echo "\n";
271 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
272 <input type="checkbox" name="field_fulltext[]" value="<?php echo $i; ?>"<?php echo $checked_fulltext; ?> />
273 </td>
274 <?php
275 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
276 echo "\n";
277 } // end if ($action ==...)
278 echo "\n";
280 </tr>
281 <?php
282 echo "\n";
283 } // end for
285 </table>
286 <br />
288 <?php
289 if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
290 echo "\n";
292 <table>
293 <tr valign="top">
294 <td><?php echo $strTableComments; ?>&nbsp;:</td>
295 <?php
296 if ($action == 'tbl_create.php3') {
297 echo "\n";
299 <td width="25">&nbsp;</td>
300 <td><?php echo $strTableType; ?>&nbsp;:</td>
301 <?php
303 echo "\n";
305 </tr>
306 <tr>
307 <td>
308 <input type="text" name="comment" size="40" maxlength="80" class="textfield" />
309 </td>
310 <?php
311 // BEGIN - Table Type - 2 May 2001 - Robbat2
312 // change by staybyte - 11 June 2001
313 if ($action == 'tbl_create.php3') {
314 // find mysql capability - staybyte - 11. June 2001
315 $query = 'SHOW VARIABLES LIKE \'have_%\'';
316 $result = PMA_mysql_query($query);
317 if ($result != FALSE && mysql_num_rows($result) > 0) {
318 while ($tmp = PMA_mysql_fetch_array($result)) {
319 if (isset($tmp['Variable_name'])) {
320 switch ($tmp['Variable_name']) {
321 case 'have_bdb':
322 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
323 $tbl_bdb = TRUE;
325 break;
326 case 'have_gemini':
327 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
328 $tbl_gemini = TRUE;
330 break;
331 case 'have_innodb':
332 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
333 $tbl_innodb = TRUE;
335 break;
336 case 'have_isam':
337 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
338 $tbl_isam = TRUE;
340 break;
341 } // end switch
342 } // end if
343 } // end while
344 } // end if
345 mysql_free_result($result);
347 echo "\n";
349 <td width="25">&nbsp;</td>
350 <td>
351 <select name="tbl_type">
352 <option value="Default"><?php echo $strDefault; ?></option>
353 <option value="MYISAM">MyISAM</option>
354 <option value="HEAP">Heap</option>
355 <option value="MERGE">Merge</option>
356 <?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php } ?>
357 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php } ?>
358 <?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php } ?>
359 <?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php } ?>
360 </select>
361 </td>
362 <?php
364 echo "\n";
366 </tr>
367 </table>
368 <br />
369 <?php
371 echo "\n";
372 // END - Table Type - 2 May 2001 - Robbat2
375 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
376 </form>
378 <table>
379 <tr>
380 <td valign="top">*&nbsp;</td>
381 <td>
382 <?php echo $strSetEnumVal . "\n"; ?>
383 </td>
384 </tr>
385 <tr>
386 <td valign="top">**&nbsp;</td>
387 <td>
388 <?php echo $strDefaultValueHelp . "\n"; ?>
389 </td>
390 </tr>
391 </table>
392 <br />
394 <center><?php echo PMA_showMySQLDocu('Reference', 'CREATE_TABLE'); ?></center>