updates
[phpmyadmin/crack.git] / tbl_properties.inc.php3
bloba22342806d6737be6b8415cdafd88e2ca57c8d58
1 <?php
2 /* $Id$ */
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="convcharset" value="<?php echo $convcharset; ?>" />
10 <input type="hidden" name="db" value="<?php echo $db; ?>" />
11 <input type="hidden" name="table" value="<?php echo $table; ?>" />
12 <?php
13 if ($action == 'tbl_create.php3') {
15 <input type="hidden" name="reload" value="1" />
16 <?php
18 else if ($action == 'tbl_addfield.php3') {
19 echo "\n";
21 <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
22 <?php
24 echo "\n";
25 $is_backup = ($action != 'tbl_create.php3' && $action != 'tbl_addfield.php3');
28 <table border="<?php echo $cfg['Border']; ?>">
29 <tr>
30 <th><?php echo $strField; ?></th>
31 <th><?php echo $strType . '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('Reference', 'Column_types'); ?></span></th>
32 <th><?php echo $strLengthSet; ?></th>
33 <th><?php echo $strAttr; ?></th>
34 <th><?php echo $strNull; ?></th>
35 <th><?php echo $strDefault; ?></th>
36 <th><?php echo $strExtra; ?></th>
37 <?php
38 // lem9: We could remove this 'if' and let the key information be shown and
39 // editable. However, for this to work, tbl_alter must be modified to use the
40 // key fields, as tbl_addfield does.
42 if (!$is_backup) {
43 echo " <th>$strPrimary</th>\n";
44 echo " <th>$strIndex</th>\n";
45 echo " <th>$strUnique</th>\n";
46 echo " <th>---</th>\n";
47 echo " <th>$strIdxFulltext</th>\n";
50 </tr>
52 <?php
53 for ($i = 0 ; $i < $num_fields; $i++) {
54 if (isset($fields_meta)) {
55 $row = $fields_meta[$i];
57 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
59 <tr>
60 <td bgcolor="<?php echo $bgcolor; ?>">
61 <?php
62 if ($is_backup) {
63 echo "\n";
65 <input type="hidden" name="field_orig[]" value="<?php if (isset($row) && isset($row['Field'])) echo urlencode($row['Field']); ?>" />
66 <?php
68 echo "\n";
70 <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" />
71 </td>
72 <td bgcolor="<?php echo $bgcolor; ?>">
73 <select name="field_type[]">
74 <?php
75 echo "\n";
76 if (empty($row['Type'])) {
77 $row['Type'] = '';
78 $type = '';
80 else if (get_magic_quotes_gpc()) {
81 $type = stripslashes($row['Type']);
83 else {
84 $type = $row['Type'];
86 $type = eregi_replace('BINARY', '', $type);
87 $type = eregi_replace('ZEROFILL', '', $type);
88 $type = eregi_replace('UNSIGNED', '', $type);
89 // set or enum types: slashes single quotes inside options
90 if (eregi('^(set|enum)\((.+)\)$', $type, $tmp)) {
91 $type = $tmp[1];
92 $length = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
93 } else {
94 $length = $type;
95 $type = chop(eregi_replace('\\(.*\\)', '', $type));
96 if (!empty($type)) {
97 $length = eregi_replace("^$type\(", '', $length);
98 $length = eregi_replace('\)$', '', trim($length));
100 if ($length == $type) {
101 $length = '';
103 } // end if else
105 for ($j = 0; $j < count($cfg['ColumnTypes']); $j++) {
106 echo ' <option value="'. $cfg['ColumnTypes'][$j] . '"';
107 if (strtoupper($type) == strtoupper($cfg['ColumnTypes'][$j])) {
108 echo ' selected="selected"';
110 echo '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
111 } // end for
113 </select>
114 </td>
115 <td bgcolor="<?php echo $bgcolor; ?>">
116 <?php
117 if ($is_backup) {
118 echo "\n";
120 <input type="hidden" name="field_length_orig[]" value="<?php echo urlencode($length); ?>" />
121 <?php
123 echo "\n";
125 <input type="text" name="field_length[]" size="8" value="<?php echo str_replace('"', '&quot;', $length); ?>" class="textfield" />
126 </td>
127 <td bgcolor="<?php echo $bgcolor; ?>">
128 <select name="field_attribute[]">
129 <?php
130 echo "\n";
131 $binary = eregi('BINARY', $row['Type'], $test_attribute1);
132 $unsigned = eregi('UNSIGNED', $row['Type'], $test_attribute2);
133 $zerofill = eregi('ZEROFILL', $row['Type'], $test_attribute3);
134 $strAttribute = '';
135 if ($binary) {
136 $strAttribute = 'BINARY';
138 if ($unsigned) {
139 $strAttribute = 'UNSIGNED';
141 if ($zerofill) {
142 $strAttribute = 'UNSIGNED ZEROFILL';
144 for ($j = 0;$j < count($cfg['AttributeTypes']); $j++) {
145 echo ' <option value="'. $cfg['AttributeTypes'][$j] . '"';
146 if (strtoupper($strAttribute) == strtoupper($cfg['AttributeTypes'][$j])) {
147 echo ' selected="selected"';
149 echo '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
152 </select>
153 </td>
154 <td bgcolor="<?php echo $bgcolor; ?>">
155 <select name="field_null[]">
156 <?php
157 if (!isset($row) || empty($row['Null'])) {
158 echo "\n";
160 <option value="NOT NULL">not null</option>
161 <option value="">null</option>
162 <?php
163 } else {
164 echo "\n";
166 <option value="">null</option>
167 <option value="NOT NULL">not null</option>
168 <?php
170 echo "\n";
172 </select>
173 </td>
174 <?php
175 if (isset($row)
176 && !isset($row['Default']) && !empty($row['Null'])) {
177 $row['Default'] = 'NULL';
179 echo "\n";
181 <td bgcolor="<?php echo $bgcolor; ?>">
182 <?php
183 if ($is_backup) {
184 echo "\n";
186 <input type="hidden" name="field_default_orig[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo urlencode($row['Default']); ?>" />
187 <?php
189 echo "\n";
191 <input type="text" name="field_default[]" size="8" value="<?php if(isset($row) && isset($row['Default'])) echo str_replace('"', '&quot;', $row['Default']); ?>" class="textfield" />
192 </td>
193 <td bgcolor="<?php echo $bgcolor; ?>">
194 <select name="field_extra[]">
195 <?php
196 if(!isset($row) || empty($row['Extra'])) {
197 echo "\n";
199 <option value=""></option>
200 <option value="AUTO_INCREMENT">auto_increment</option>
201 <?php
202 } else {
203 echo "\n";
205 <option value="AUTO_INCREMENT">auto_increment</option>
206 <option value=""></option>
207 <?php
209 echo "\n";
211 </select>
212 </td>
213 <?php
214 // lem9: See my other comment about removing this 'if'.
215 if (!$is_backup) {
216 if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
217 $checked_primary = ' checked="checked"';
218 } else {
219 $checked_primary = '';
221 if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
222 $checked_index = ' checked="checked"';
223 } else {
224 $checked_index = '';
226 if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
227 $checked_unique = ' checked="checked"';
228 } else {
229 $checked_unique = '';
231 if (empty($checked_primary)
232 && empty($checked_index)
233 && empty($checked_unique)) {
234 $checked_none = ' checked="checked"';
236 if (PMA_MYSQL_INT_VERSION >= 32323
237 &&(isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
238 $checked_fulltext = ' checked="checked"';
239 } else {
240 $checked_fulltext = '';
242 echo "\n";
244 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
245 <input type="radio" name="field_key_<?php echo $i; ?>" value="primary_<?php echo $i; ?>"<?php echo $checked_primary; ?> />
246 </td>
247 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
248 <input type="radio" name="field_key_<?php echo $i; ?>" value="index_<?php echo $i; ?>"<?php echo $checked_index; ?> />
249 </td>
250 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
251 <input type="radio" name="field_key_<?php echo $i; ?>" value="unique_<?php echo $i; ?>"<?php echo $checked_unique; ?> />
252 </td>
253 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
254 <input type="radio" name="field_key_<?php echo $i; ?>" value="none_<?php echo $i; ?>"<?php echo $checked_none; ?> />
255 </td>
256 <?php
257 if (PMA_MYSQL_INT_VERSION >= 32323) {
258 echo "\n";
260 <td bgcolor="<?php echo $bgcolor; ?>" nowrap="nowrap">
261 <input type="checkbox" name="field_fulltext[]" value="<?php echo $i; ?>"<?php echo $checked_fulltext; ?> />
262 </td>
263 <?php
264 } // end if (PMA_MYSQL_INT_VERSION >= 32323)
265 echo "\n";
266 } // end if ($action ==...)
267 echo "\n";
269 </tr>
270 <?php
271 echo "\n";
272 } // end for
274 </table>
275 <br />
277 <?php
278 if ($action == 'tbl_create.php3' && PMA_MYSQL_INT_VERSION >= 32300) {
279 echo "\n";
281 <table>
282 <tr valign="top">
283 <td><?php echo $strTableComments; ?>&nbsp;:</td>
284 <?php
285 if ($action == 'tbl_create.php3') {
286 echo "\n";
288 <td width="25">&nbsp;</td>
289 <td><?php echo $strTableType; ?>&nbsp;:</td>
290 <?php
292 echo "\n";
294 </tr>
295 <tr>
296 <td>
297 <input type="text" name="comment" size="40" maxlength="80" class="textfield" />
298 </td>
299 <?php
300 // BEGIN - Table Type - 2 May 2001 - Robbat2
301 // change by staybyte - 11 June 2001
302 if ($action == 'tbl_create.php3') {
303 // find mysql capability - staybyte - 11. June 2001
304 $query = 'SHOW VARIABLES LIKE \'have_%\'';
305 $result = PMA_mysql_query($query);
306 if ($result != FALSE && mysql_num_rows($result) > 0) {
307 while ($tmp = PMA_mysql_fetch_array($result)) {
308 if (isset($tmp['Variable_name'])) {
309 switch ($tmp['Variable_name']) {
310 case 'have_bdb':
311 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
312 $tbl_bdb = TRUE;
314 break;
315 case 'have_gemini':
316 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
317 $tbl_gemini = TRUE;
319 break;
320 case 'have_innodb':
321 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
322 $tbl_innodb = TRUE;
324 break;
325 case 'have_isam':
326 if (isset($tmp['Variable_name']) && $tmp['Value'] == 'YES') {
327 $tbl_isam = TRUE;
329 break;
330 } // end switch
331 } // end if
332 } // end while
333 } // end if
334 mysql_free_result($result);
336 echo "\n";
338 <td width="25">&nbsp;</td>
339 <td>
340 <select name="tbl_type">
341 <option value="Default"><?php echo $strDefault; ?></option>
342 <option value="MYISAM">MyISAM</option>
343 <option value="HEAP">Heap</option>
344 <option value="MERGE">Merge</option>
345 <?php if (isset($tbl_bdb)) { ?><option value="BDB">Berkeley DB</option><?php } ?>
346 <?php if (isset($tbl_gemini)) { ?><option value="GEMINI">Gemini</option><?php } ?>
347 <?php if (isset($tbl_innodb)) { ?><option value="InnoDB">INNO DB</option><?php } ?>
348 <?php if (isset($tbl_isam)) { ?><option value="ISAM">ISAM</option><?php } ?>
349 </select>
350 </td>
351 <?php
353 echo "\n";
355 </tr>
356 </table>
357 <br />
358 <?php
360 echo "\n";
361 // END - Table Type - 2 May 2001 - Robbat2
364 <input type="submit" name="submit" value="<?php echo $strSave; ?>" />
365 </form>
367 <table>
368 <tr>
369 <td valign="top">*&nbsp;</td>
370 <td>
371 <?php echo $strSetEnumVal . "\n"; ?>
372 </td>
373 </tr>
374 </table>
375 <br />
377 <center><?php echo PMA_showMySQLDocu('Reference', 'CREATE_TABLE'); ?></center>