some updates
[phpmyadmin/crack.git] / tbl_properties.inc.php3
blob0403f2dd7f132bdb0015e844a45c68e5ef60a3b2
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 ?>
7 <form method="post" action="<?php echo $action; ?>">
8 <input type="hidden" name="server" value="<?php echo $server; ?>" />
9 <input type="hidden" name="lang" value="<?php echo $lang; ?>" />
10 <input type="hidden" name="convcharset" value="<?php echo $convcharset; ?>" />
11 <input type="hidden" name="db" value="<?php echo htmlspecialchars($db); ?>" />
12 <input type="hidden" name="table" value="<?php echo htmlspecialchars($table); ?>" />
13 <?php
14 if ($action == 'tbl_create.php3') {
16 <input type="hidden" name="reload" value="1" />
17 <?php
19 else if ($action == 'tbl_addfield.php3') {
20 echo "\n";
22 <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
23 <?php
25 echo "\n";
26 $is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
29 <table border="<?php echo $cfg['Border']; ?>">
30 <tr>
31 <th><?php echo $strField; ?></th>
32 <th><?php echo $strType . '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('Reference', 'Column_types'); ?></span></th>
33 <th><?php echo $strLengthSet; ?></th>
34 <th><?php echo $strAttr; ?></th>
35 <th><?php echo $strNull; ?></th>
36 <th><?php echo $strDefault; ?></th>
37 <th><?php echo $strExtra; ?></th>
38 <?php
39 // lem9: We could remove this 'if' and let the key information be shown and
40 // editable. However, for this to work, tbl_alter must be modified to use the
41 // key fields, as tbl_addfield does.
43 if (!$is_backup) {
44 echo " <th>$strPrimary</th>\n";
45 echo " <th>$strIndex</th>\n";
46 echo " <th>$strUnique</th>\n";
47 echo " <th>---</th>\n";
48 echo " <th>$strIdxFulltext</th>\n";
51 </tr>
53 <?php
54 for ($i = 0 ; $i < $num_fields; $i++) {
55 if (isset($fields_meta)) {
56 $row = $fields_meta[$i];
58 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
60 <tr>
61 <td bgcolor="<?php echo $bgcolor; ?>">
62 <?php
63 if ($is_backup) {
64 echo "\n";
66 <input type="hidden" name="field_orig[]" value="<?php if (isset($row) && isset($row['Field'])) echo urlencode($row['Field']); ?>" />
67 <?php
69 echo "\n";
71 <input 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" />
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 = '';
81 else if (get_magic_quotes_gpc()) {
82 $type = stripslashes($row['Type']);
84 else {
85 $type = $row['Type'];
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));
101 if ($length == $type) {
102 $length = '';
104 } // end if else
106 for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
107 echo ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
108 if (strtoupper($type) == strtoupper($cfg['ColumnTypes'][$j])) {
109 echo ' selected="selected"';
111 echo '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
112 } // end for
114 </select>
115 </td>
116 <td bgcolor="<?php echo $bgcolor; ?>">
117 <?php
118 if ($is_backup) {
119 echo "\n";
121 <input type="hidden" name="field_length_orig[]" value="<?php echo urlencode($length); ?>" />
122 <?php
124 echo "\n";
126 <input type="text" name="field_length[]" size="8" value="<?php echo str_replace('"', '&quot;', $length); ?>" class="textfield" />
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';
139 if ($unsigned) {
140 $strAttribute = 'UNSIGNED';
142 if ($zerofill) {
143 $strAttribute = 'UNSIGNED ZEROFILL';
145 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
146 echo ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
147 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
148 echo ' selected="selected"';
150 echo '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
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";
161 <option value="NOT NULL">not null</option>
162 <option value="">null</option>
163 <?php
164 } else {
165 echo "\n";
167 <option value="">null</option>
168 <option value="NOT NULL">not null</option>
169 <?php
171 echo "\n";
173 </select>
174 </td>
175 <?php
176 if (isset($row)
177 && !isset($row['Default']) && !empty($row['Null'])) {
178 $row['Default'] = 'NULL';
180 echo "\n";
182 <td bgcolor="<?php echo $bgcolor; ?>">
183 <?php
184 if ($is_backup) {
185 echo "\n";
187 <input type="hidden" name="field_default_orig[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo urlencode($row['Default']); ?>" />
188 <?php
190 echo "\n";
192 <input type="text" name="field_default[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo str_replace('"', '&quot;', $row['Default']); ?>" class="textfield" />
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";
200 <option value=""></option>
201 <option value="AUTO_INCREMENT">auto_increment</option>
202 <?php
203 } else {
204 echo "\n";
206 <option value="AUTO_INCREMENT">auto_increment</option>
207 <option value=""></option>
208 <?php
210 echo "\n";
212 </select>
213 </td>
214 <?php
215 // lem9: See my other comment about removing this 'if'.
216 if (!$is_backup) {
217 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
218 $checked_primary = ' checked="checked"';
219 } else {
220 $checked_primary = '';
222 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
223 $checked_index = ' checked="checked"';
224 } else {
225 $checked_index = '';
227 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
228 $checked_unique = ' checked="checked"';
229 } else {
230 $checked_unique = '';
232 if (empty($checked_primary)
233 && empty($checked_index)
234 && empty($checked_unique)) {
235 $checked_none = ' checked="checked"';
237 if (PMA_MYSQL_INT_VERSION >= 32323
238 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
239 $checked_fulltext = ' checked="checked"';
240 } else {
241 $checked_fulltext = '';
243 echo "\n";
245 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
246 <input type="radio" name="field_key_<?php echo $i; ?>" value="primary_<?php echo $i; ?>"<?php echo $checked_primary; ?> />
247 </td>
248 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
249 <input type="radio" name="field_key_<?php echo $i; ?>" value="index_<?php echo $i; ?>"<?php echo $checked_index; ?> />
250 </td>
251 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
252 <input type="radio" name="field_key_<?php echo $i; ?>" value="unique_<?php echo $i; ?>"<?php echo $checked_unique; ?> />
253 </td>
254 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
255 <input type="radio" name="field_key_<?php echo $i; ?>" value="none_<?php echo $i; ?>"<?php echo $checked_none; ?> />
256 </td>
257 <?php
258 if (PMA_MYSQL_INT_VERSION >= 32323) {
259 echo "\n";
261 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
262 <input type="checkbox" name="field_fulltext[]" value="<?php echo $i; ?>"<?php echo $checked_fulltext; ?> />
263 </td>
264 <?php
265 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
266 echo "\n";
267 } // end if ($action ==...)
268 echo "\n";
270 </tr>
271 <?php
272 echo "\n";
273 } // end for
275 </table>
276 <br />
278 <?php
279 if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
280 echo "\n";
282 <table>
283 <tr valign="top">
284 <td><?php echo $strTableComments; ?>&nbsp;:</td>
285 <?php
286 if ($action == 'tbl_create.php3') {
287 echo "\n";
289 <td width="25">&nbsp;</td>
290 <td><?php echo $strTableType; ?>&nbsp;:</td>
291 <?php
293 echo "\n";
295 </tr>
296 <tr>
297 <td>
298 <input type="text" name="comment" size="40" maxlength="80" class="textfield" />
299 </td>
300 <?php
301 // BEGIN - Table Type - 2 May 2001 - Robbat2
302 // change by staybyte - 11 June 2001
303 if ($action == 'tbl_create.php3') {
304 // find mysql capability - staybyte - 11. June 2001
305 $query = 'SHOW VARIABLES LIKE \'have_%\'';
306 $result = PMA_mysql_query($query);
307 if ($result != FALSE && mysql_num_rows($result) > 0) {
308 while ($tmp = PMA_mysql_fetch_array($result)) {
309 if (isset($tmp['Variable_name'])) {
310 switch ($tmp['Variable_name']) {
311 case 'have_bdb':
312 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
313 $tbl_bdb = TRUE;
315 break;
316 case 'have_gemini':
317 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
318 $tbl_gemini = TRUE;
320 break;
321 case 'have_innodb':
322 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
323 $tbl_innodb = TRUE;
325 break;
326 case 'have_isam':
327 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
328 $tbl_isam = TRUE;
330 break;
331 } // end switch
332 } // end if
333 } // end while
334 } // end if
335 mysql_free_result($result);
337 echo "\n";
339 <td width="25">&nbsp;</td>
340 <td>
341 <select name="tbl_type">
342 <option value="Default"><?php echo $strDefault; ?></option>
343 <option value="MYISAM">MyISAM</option>
344 <option value="HEAP">Heap</option>
345 <option value="MERGE">Merge</option>
346 <?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php } ?>
347 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php } ?>
348 <?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php } ?>
349 <?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php } ?>
350 </select>
351 </td>
352 <?php
354 echo "\n";
356 </tr>
357 </table>
358 <br />
359 <?php
361 echo "\n";
362 // END - Table Type - 2 May 2001 - Robbat2
365 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
366 </form>
368 <table>
369 <tr>
370 <td valign="top">*&nbsp;</td>
371 <td>
372 <?php echo $strSetEnumVal . "\n"; ?>
373 </td>
374 </tr>
375 </table>
376 <br />
378 <center><?php echo PMA_showMySQLDocu('Reference', 'CREATE_TABLE'); ?></center>