Bug #739096
[phpmyadmin/crack.git] / tbl_change.php3
blob87b0c8e8982995929a77decade0f36b9c8b21755
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
6 /**
7 * Get the variables sent or posted to this script and displays the header
8 */
9 require('./libraries/grab_globals.lib.php3');
10 $js_to_run = 'tbl_change.js';
11 require('./header.inc.php3');
12 require('./libraries/relation.lib.php3'); // foreign keys
15 /**
16 * Displays the query submitted and its result
18 if (!empty($disp_message)) {
19 if (isset($goto)) {
20 $goto_cpy = $goto;
21 $goto = 'tbl_properties.php3?'
22 . PMA_generate_common_url($db, $table)
23 . '&amp;$show_query=1'
24 . '&amp;sql_query=' . urlencode($disp_query);
25 } else {
26 $show_query = '1';
28 if (isset($sql_query)) {
29 $sql_query_cpy = $sql_query;
30 unset($sql_query);
32 if (isset($disp_query)) {
33 $sql_query = $disp_query;
35 PMA_showMessage($disp_message);
36 if (isset($goto_cpy)) {
37 $goto = $goto_cpy;
38 unset($goto_cpy);
40 if (isset($sql_query_cpy)) {
41 $sql_query = $sql_query_cpy;
42 unset($sql_query_cpy);
47 /**
48 * Defines the url to return to in case of error in a sql statement
50 if (!isset($goto)) {
51 $goto = 'db_details.php3';
53 if (!ereg('^(db_details|tbl_properties|tbl_select)', $goto)) {
54 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&amp;sql_query=" . urlencode($sql_query);
55 } else {
56 $err_url = $goto . '?'
57 . PMA_generate_common_url($db)
58 . ((ereg('^(tbl_properties|tbl_select)', $goto)) ? '&amp;table=' . urlencode($table) : '');
62 /**
63 * Ensures db and table are valid, else moves to the "parent" script
65 require('./libraries/db_table_exists.lib.php3');
68 /**
69 * Sets parameters for links and displays top menu
71 $url_query = PMA_generate_common_url($db, $table)
72 . '&amp;goto=tbl_properties.php3';
74 require('./tbl_properties_table_info.php3');
75 echo '<br />';
78 /**
79 * Get the list of the fields of the current table
81 PMA_mysql_select_db($db);
82 $table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table));
83 if (isset($primary_key)) {
84 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key;
85 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
86 $row = PMA_mysql_fetch_array($result);
88 // No row returned
89 if (!$row) {
90 unset($row);
91 unset($primary_key);
92 $goto_cpy = $goto;
93 $goto = 'tbl_properties.php3?'
94 . PMA_generate_common_url($db, $table)
95 . '&amp;$show_query=1'
96 . '&amp;sql_query=' . urlencode($local_query);
97 if (isset($sql_query)) {
98 $sql_query_cpy = $sql_query;
99 unset($sql_query);
101 $sql_query = $local_query;
102 PMA_showMessage($strEmptyResultSet);
103 $goto = $goto_cpy;
104 unset($goto_cpy);
105 if (isset($sql_query_cpy)) {
106 $sql_query = $sql_query_cpy;
107 unset($sql_query_cpy);
109 } // end if (no record returned)
111 else
113 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1';
114 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
115 unset($row);
118 // <markus@noga.de>
119 // retrieve keys into foreign fields, if any
120 $cfgRelation = PMA_getRelationsParam();
121 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
125 * Displays the form
127 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
128 // must be replaced by the "onpropertychange" one in this case
129 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
130 ? 'onpropertychange'
131 : 'onchange';
132 // Had to put the URI because when hosted on an https server,
133 // some browsers send wrongly this form to the http server.
136 <?php if ($cfg['CtrlArrowsMoving']) { ?>
137 <!-- Set on key handler for moving using by Ctrl+arrows -->
138 <script type="text/javascript" language="javascript">
139 <!--
140 document.onkeydown = onKeyDownArrowsHandler;
141 // -->
142 </script>
143 <?php } ?>
145 <!-- Change table properties form -->
146 <form method="post" action="tbl_replace.php3" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>>
147 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
148 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
149 <input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
150 <input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
151 <input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
152 <input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
153 <input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
154 <input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" />
155 <input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
156 <?php
157 if (isset($primary_key)) {
159 <input type="hidden" name="primary_key" value="<?php echo urlencode($primary_key); ?>" />
160 <?php
162 echo "\n";
165 <table border="<?php echo $cfg['Border']; ?>">
166 <tr>
167 <th><?php echo $strField; ?></th>
168 <th><?php echo $strType; ?></th>
169 <?php
170 if ($cfg['ShowFunctionFields']) {
171 echo ' <th>' . $strFunction . '</th>' . "\n";
174 <th><?php echo $strNull; ?></th>
175 <th><?php echo $strValue; ?></th>
176 </tr>
178 <?php
179 // Set if we passed the first timestamp field
180 $timestamp_seen = 0;
181 $fields_cnt = mysql_num_rows($table_def);
183 // Set a flag here because the 'if' would not be valid in the loop
184 // if we set a value in some field
185 $insert_mode = (!isset($row) ? TRUE : FALSE);
187 for ($i = 0; $i < $fields_cnt; $i++) {
188 // Display the submit button after every 15 lines --swix
189 // (wanted to use an <a href="#bottom"> and <a name> instead,
190 // but it didn't worked because of the <base href>)
192 if ((($i % 15) == 0) && ($i != 0)) {
194 <tr>
195 <th colspan="5" align="right">
196 <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;
197 </th>
198 </tr>
199 <?php
200 } // end if
201 echo "\n";
203 $row_table_def = PMA_mysql_fetch_array($table_def);
204 $row_table_def['True_Type'] = ereg_replace('\\(.*', '', $row_table_def['Type']);
205 $field = $row_table_def['Field'];
207 // garvin: possible workaround. If current field is numerical, do not try to
208 // access the result-array with its 'associative' key but with its numerical
209 // represantation.
210 if ((PMA_PHP_INT_VERSION > 40000 && is_numeric($field)) || eregi('^[0-9]*$', $field)) {
211 $rowfield = $i;
212 } else {
213 $rowfield = $field;
216 // loic1: current date should not be set as default if the field is NULL
217 // for the current row
218 // lem9: but do not put here the current datetime if there is a default
219 // value (the real default value will be set in the
220 // Default value logic below)
221 if ($row_table_def['Type'] == 'datetime'
222 && (!isset($row_table_def['Default']))) {
223 // INSERT case
224 if ($insert_mode) {
225 $row[$rowfield] = date('Y-m-d H:i:s', time());
227 // UPDATE case with an empty and not NULL value under PHP4
228 else if (empty($row[$rowfield]) && function_exists('is_null')) {
229 $row[$rowfield] = (is_null($row[$rowfield]) ? $row[$rowfield] : date('Y-m-d H:i:s', time()));
231 // UPDATE case with an empty value under PHP3
232 else if (empty($row[$rowfield])) {
233 $row[$rowfield] = date('Y-m-d H:i:s', time());
234 } // end if... else if... else if...
236 $len = (eregi('float|double', $row_table_def['Type']))
237 ? 100
238 : @mysql_field_len($result, $i);
239 $first_timestamp = 0;
241 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
243 <tr>
244 <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
245 <?php
246 echo "\n";
248 // The type column
249 $is_binary = eregi(' binary', $row_table_def['Type']);
250 $is_blob = eregi('blob', $row_table_def['Type']);
251 $is_char = eregi('char', $row_table_def['Type']);
252 switch ($row_table_def['True_Type']) {
253 case 'set':
254 $type = 'set';
255 $type_nowrap = '';
256 break;
257 case 'enum':
258 $type = 'enum';
259 $type_nowrap = '';
260 break;
261 case 'timestamp':
262 if (!$timestamp_seen) { // can only occur once per table
263 $timestamp_seen = 1;
264 $first_timestamp = 1;
266 $type = $row_table_def['Type'];
267 $type_nowrap = ' nowrap="nowrap"';
268 break;
270 default:
271 $type = $row_table_def['Type'];
272 $type_nowrap = ' nowrap="nowrap"';
273 break;
276 <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
277 <?php echo $type; ?>
278 </td>
279 <?php
280 echo "\n";
282 // Prepares the field value
283 if (isset($row)) {
284 // loic1: null field value
285 if (!isset($row[$rowfield])) {
286 $row[$rowfield] = 'NULL';
287 $special_chars = '';
288 $data = $row[$rowfield];
289 } else {
290 // loic1: special binary "characters"
291 if ($is_binary || $is_blob) {
292 $row[$rowfield] = str_replace("\x00", '\0', $row[$rowfield]);
293 $row[$rowfield] = str_replace("\x08", '\b', $row[$rowfield]);
294 $row[$rowfield] = str_replace("\x0a", '\n', $row[$rowfield]);
295 $row[$rowfield] = str_replace("\x0d", '\r', $row[$rowfield]);
296 $row[$rowfield] = str_replace("\x1a", '\Z', $row[$rowfield]);
297 } // end if
298 $special_chars = htmlspecialchars($row[$rowfield]);
299 $data = $row[$rowfield];
300 } // end if... else...
301 // loic1: if a timestamp field value is not included in an update
302 // statement MySQL auto-update it to the current timestamp
303 $backup_field = ($row_table_def['True_Type'] == 'timestamp')
304 ? ''
305 : '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($row[$rowfield]) . '" />';
306 } else {
307 // loic1: display default values
308 if (!isset($row_table_def['Default'])) {
309 $row_table_def['Default'] = '';
310 $data = 'NULL';
311 } else {
312 $data = $row_table_def['Default'];
314 $special_chars = htmlspecialchars($row_table_def['Default']);
315 $backup_field = '';
318 // The function column
319 // -------------------
320 // Change by Bernard M. Piller <bernard@bmpsystems.com>
321 // We don't want binary data to be destroyed
322 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
323 // stored or retrieved" so it does not mean that the contents is
324 // binary
325 if ($cfg['ShowFunctionFields']) {
326 if (($cfg['ProtectBinary'] && $is_blob)
327 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
328 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
329 } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
330 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
331 } else {
333 <td bgcolor="<?php echo $bgcolor; ?>">
334 <select name="funcs[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($fields_cnt + $i + 1); ?>" id="field_<?php echo $i; ?>_1">
335 <option></option>
336 <?php
337 echo "\n";
338 $selected = '';
340 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
341 // or something similar. Then directly look up the entry in the RestrictFunctions array,
342 // which will then reveal the available dropdown options
343 if (isset($cfg['RestrictFunctions']) && isset($cfg['RestrictColumnTypes']) && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]) && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
344 $dropdown = $cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]];
345 } else {
346 $dropdown = array();
349 $dropdown_built = array();
350 $op_spacing_needed = FALSE;
352 // garvin: loop on the dropdown array and print all available options for that field.
353 for ($j = 0; $j < count($dropdown); $j++) {
354 // for default function = NOW() on first timestamp field
355 // -- swix/18jul01
356 $selected = ($first_timestamp && $dropdown[$j] == 'NOW')
357 ? ' selected="selected"'
358 : '';
359 echo ' ';
360 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
361 $dropdown_built[$dropdown[$j]] = 'TRUE';
362 $op_spacing_needed = TRUE;
365 // garvin: For compatibility's sake, do not let out all other functions. Instead
366 // print a seperator (blank) and then show ALL functions which weren't shown
367 // yet.
368 for ($j = 0; $j < count($cfg['Functions']); $j++) {
369 if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
370 // for default function = NOW() on first timestamp field
371 // -- swix/18jul01
372 $selected = ($first_timestamp && $cfg['Functions'][$j] == 'NOW')
373 ? ' selected="selected"'
374 : '';
375 if ($op_spacing_needed == TRUE) {
376 echo ' ';
377 echo '<option value="">--------</option>' . "\n";
378 $op_spacing_needed = FALSE;
381 echo ' ';
382 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
384 } // end for
385 unset($selected);
387 </select>
388 </td>
389 <?php
391 } // end if ($cfg['ShowFunctionFields'])
392 echo "\n";
394 // The null column
395 // ---------------
396 echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
397 if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
398 && $row_table_def['Null'] == 'YES') {
399 echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + $i + 1) . '"'
400 . ' name="fields_null[' . urlencode($field) . ']"';
401 if ($data == 'NULL' && !$first_timestamp) {
402 echo ' checked="checked"';
404 echo ' id="field_' . $i . '_2"';
405 $onclick = ' onclick="if (this.checked) {nullify(';
406 if (strstr($row_table_def['True_Type'], 'enum')) {
407 if (strlen($row_table_def['Type']) > 20) {
408 $onclick .= '1, ';
409 } else {
410 $onclick .= '2, ';
412 } else if (strstr($row_table_def['True_Type'], 'set')) {
413 $onclick .= '3, ';
414 } else if ($foreigners && isset($foreigners[$field])) {
415 $onclick .= '4, ';
416 } else {
417 $onclick .= '5, ';
419 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
420 echo $onclick;
421 } else {
422 echo ' &nbsp;' . "\n";
424 echo ' </td>' . "\n";
426 // The value column (depends on type)
427 // ----------------
429 include('./libraries/get_foreign.lib.php3');
431 if (isset($disp) && $disp) {
433 <td bgcolor="<?php echo $bgcolor; ?>">
434 <?php echo $backup_field . "\n"; ?>
435 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
436 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
437 <select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
438 <option value=""></option>
439 <?php
440 echo "\n";
441 while ($relrow = @PMA_mysql_fetch_array($disp)) {
442 $key = $relrow[$foreign_field];
443 $value = (($foreign_display != FALSE) ? '&nbsp;-&nbsp;' . htmlspecialchars($relrow[$foreign_display]) : '');
444 echo ' <option value="' . htmlspecialchars($key) . '"';
445 if ($key == $data) {
446 echo ' selected="selected"';
447 } // end if
448 echo '>' . htmlspecialchars($key) . $value . '</option>' . "\n";
449 } // end while
450 echo ' </select>' . "\n";
451 echo ' </td>' . "\n";
452 unset($disp);
454 else if ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext')) {
456 <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
457 </tr>
458 <tr>
459 <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">
460 <?php echo $backup_field . "\n"; ?>
461 <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
462 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
463 </td>
464 <?php
466 else if (strstr($row_table_def['True_Type'], 'text')) {
468 <td bgcolor="<?php echo $bgcolor; ?>">
469 <?php echo $backup_field . "\n"; ?>
470 <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
471 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
472 </td>
473 <?php
474 echo "\n";
475 if (strlen($special_chars) > 32000) {
476 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
479 else if (strstr($row_table_def['True_Type'], 'enum')) {
480 $enum = str_replace('enum(', '', $row_table_def['Type']);
481 $enum = ereg_replace('\\)$', '', $enum);
482 $enum = explode('\',\'', substr($enum, 1, -1));
483 $enum_cnt = count($enum);
485 <td bgcolor="<?php echo $bgcolor; ?>">
486 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="enum" />
487 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
488 <?php
489 echo "\n" . ' ' . $backup_field;
491 // show dropdown or radio depend on length
492 if (strlen($row_table_def['Type']) > 20) {
493 echo "\n";
495 <select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
496 <option value=""></option>
497 <?php
498 echo "\n";
500 for ($j = 0; $j < $enum_cnt; $j++) {
501 // Removes automatic MySQL escape format
502 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
503 echo ' ';
504 echo '<option value="' . htmlspecialchars($enum_atom) . '"';
505 if ($data == $enum_atom
506 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
507 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
508 echo ' selected="selected"';
510 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
511 } // end for
514 </select>
515 <?php
516 } // end if
517 else {
518 echo "\n";
519 for ($j = 0; $j < $enum_cnt; $j++) {
520 // Removes automatic MySQL escape format
521 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
522 echo ' ';
523 echo '<input type="radio" name="field_' . md5($field) . '[]" value="' . urlencode($enum_atom) . '" id="field_' . $i . '_3_' . $j . '" onclick="if (typeof(document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) .']\'].checked = false}"';
524 if ($data == $enum_atom
525 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
526 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
527 echo ' checked="checked"';
529 echo 'tabindex="' . ($i + 1) . '" />' . "\n";
530 echo ' <label for="field_' . $i . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
531 } // end for
533 } // end else
534 echo "\n";
536 </td>
537 <?php
538 echo "\n";
540 else if (strstr($row_table_def['Type'], 'set')) {
541 $set = str_replace('set(', '', $row_table_def['Type']);
542 $set = ereg_replace('\)$', '', $set);
543 $set = explode(',', $set);
545 if (isset($vset)) {
546 unset($vset);
548 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
549 $vset[$k] = 1;
551 $size = min(4, count($set));
553 <td bgcolor="<?php echo $bgcolor; ?>">
554 <?php echo $backup_field . "\n"; ?>
555 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="set" />
556 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
557 <select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
558 <?php
559 echo "\n";
560 $countset = count($set);
561 for ($j = 0; $j < $countset;$j++) {
562 $subset = substr($set[$j], 1, -1);
563 // Removes automatic MySQL escape format
564 $subset = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $subset));
565 echo ' ';
566 echo '<option value="'. htmlspecialchars($subset) . '"';
567 if (isset($vset[$subset]) && $vset[$subset]) {
568 echo ' selected="selected"';
570 echo '>' . htmlspecialchars($subset) . '</option>' . "\n";
571 } // end for
573 </select>
574 </td>
575 <?php
577 // Change by Bernard M. Piller <bernard@bmpsystems.com>
578 // We don't want binary data destroyed
579 else if ($is_binary || $is_blob) {
580 if (($cfg['ProtectBinary'] && $is_blob)
581 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
582 echo "\n";
584 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
585 <?php
586 echo $strBinaryDoNotEdit;
587 if (isset($data)) {
588 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
589 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
590 unset($data_size);
592 echo "\n";
594 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="protected" />
595 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
596 <?php
597 } else if ($is_blob) {
598 echo "\n";
600 <td bgcolor="<?php echo $bgcolor; ?>">
601 <?php echo $backup_field . "\n"; ?>
602 <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
603 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
604 <?php
606 } else {
607 if ($len < 4) {
608 $fieldsize = $maxlength = 4;
609 } else {
610 $fieldsize = (($len > 40) ? 40 : $len);
611 $maxlength = $len;
613 echo "\n";
615 <td bgcolor="<?php echo $bgcolor; ?>">
616 <?php echo $backup_field . "\n"; ?>
617 <input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
618 <?php
619 } // end if...elseif...else
621 // Upload choice (only for BLOBs because the binary
622 // attribute does not imply binary contents)
623 // (displayed whatever value the ProtectBinary has)
625 if ($is_upload && $is_blob) {
626 echo '<input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" id="field_' . $i . '_3" />';
629 if ($cfg['UploadDir'] != '') {
630 if ($handle = @opendir($cfg['UploadDir'])) {
631 $is_first = 0;
632 while ($file = @readdir($handle)) {
633 if (is_file($cfg['UploadDir'] . $file) && substr($file, -4) != '.sql') {
634 if ($is_first == 0) {
635 echo "<br />\n";
636 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . '&nbsp;:<br />' . "\n";
637 echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . '">' . "\n";
638 echo ' <option value="" selected="selected"></option>' . "\n";
639 } // end if (is_first)
640 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
641 $is_first++;
642 } // end if (is_file)
643 } // end while
644 if ($is_first > 0) {
645 echo ' </select>' . "\n";
646 } // end if (isfirst > 0)
647 @closedir($handle);
648 } else {
649 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
650 echo ' ' . $strWebServerUploadDirectoryError . "\n";
652 } // end if (web-server upload directory)
654 echo '</td>';
656 } // end else if ( binary or blob)
657 else {
658 // For char or varchar, respect the maximum length (M); for other
659 // types (int or float), the length is not a limit on the values that
660 // can be entered, so let's be generous (20) (we could also use the
661 // real limits for each numeric type)
662 if ($is_char) {
663 $fieldsize = (($len > 40) ? 40 : $len);
664 $maxlength = $len;
666 else {
667 $fieldsize = $maxlength = 20;
668 } // end if... else...
669 echo "\n";
671 <td bgcolor="<?php echo $bgcolor; ?>">
672 <?php echo $backup_field . "\n"; ?>
673 <?php
674 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
675 echo "\n";
677 <textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
678 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
679 <?php
680 } else {
681 echo "\n";
683 <input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
684 <?php
686 echo "\n";
688 </td>
689 <?php
691 echo "\n";
693 </tr>
694 <?php
695 echo "\n";
696 } // end for
698 </table>
699 <br />
701 <table cellpadding="5">
702 <tr>
703 <td valign="middle" nowrap="nowrap">
704 <?php
705 if (isset($primary_key)) {
707 <input type="radio" name="submit_type" value="<?php echo $strSave; ?>" id="radio_submit_type_save" checked="checked" tabindex="<?php echo ((3 * $fields_cnt) + 1); ?>" /><label for="radio_submit_type_save"><?php echo $strSave; ?></label><br />
708 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $strOr; ?><br />
709 <input type="radio" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" id="radio_submit_type_insert_as_new_row" tabindex="<?php echo ((3 * $fields_cnt) + 2); ?>" /><label for="radio_submit_type_insert_as_new_row"><?php echo $strInsertAsNewRow; ?></label>
710 <?php
711 } else {
712 echo "\n";
714 <input type="hidden" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" />
715 <?php
716 echo ' ' . $strInsertAsNewRow . "\n";
718 echo "\n";
720 // Defines whether "insert a new row after the current insert" should be
721 // checked or not (keep this choice sticky)
722 $checked = !empty($disp_message) ? ' checked="checked"' : '';
724 </td>
725 <td valign="middle">
726 &nbsp;&nbsp;&nbsp;<b>-- <?php echo $strAnd; ?> --</b>&nbsp;&nbsp;&nbsp;
727 </td>
728 <td valign="middle" nowrap="nowrap">
729 <input type="radio" name="after_insert" value="back" id="radio_after_insert_back" checked="checked" tabindex="<?php echo ((3 * $fields_cnt) + 3); ?>" /><label for="radio_after_insert_back"><?php echo $strAfterInsertBack; ?></label><br />
730 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $strOr; ?><br />
731 <input type="radio" name="after_insert" value="new_insert" id="radio_after_insert_new_insert"<?php echo $checked; ?> tabindex="<?php echo ((3 * $fields_cnt) + 4); ?>" /><label for="radio_after_insert_new_insert"><?php echo $strAfterInsertNewInsert; ?></label>
732 </td>
733 </tr>
735 <tr>
736 <td colspan="3" align="right" valign="middle">
737 <input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 5); ?>" />
738 <input type="reset" value="<?php echo $strReset; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 6); ?>" />
739 </td>
740 </tr>
741 </table>
743 </form>
746 <?php
748 * Displays the footer
750 echo "\n";
751 require('./footer.inc.php3');