Bugfixing, better defaults for query window.
[phpmyadmin/crack.git] / tbl_change.php3
blob7d440b10a3bdd1a2d5876b3bba76873c5ff619b3
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($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 = (get_magic_quotes_gpc() ? stripslashes($disp_query) : $disp_query);
35 PMA_showMessage($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);
45 if (get_magic_quotes_gpc()) {
46 if (!empty($sql_query)) {
47 $sql_query = stripslashes($sql_query);
49 if (!empty($primary_key)) {
50 $primary_key = stripslashes($primary_key);
52 } // end if
55 /**
56 * Defines the url to return to in case of error in a sql statement
58 if (!isset($goto)) {
59 $goto = 'db_details.php3';
61 if (!ereg('^(db_details|tbl_properties|tbl_select)', $goto)) {
62 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&amp;sql_query=" . urlencode($sql_query);
63 } else {
64 $err_url = $goto . '?'
65 . PMA_generate_common_url($db)
66 . ((ereg('^(tbl_properties|tbl_select)', $goto)) ? '&amp;table=' . urlencode($table) : '');
70 /**
71 * Ensures db and table are valid, else moves to the "parent" script
73 require('./libraries/db_table_exists.lib.php3');
76 /**
77 * Sets parameters for links and displays top menu
79 $url_query = PMA_generate_common_url($db, $table)
80 . '&amp;goto=tbl_properties.php3';
82 require('./tbl_properties_table_info.php3');
83 echo '<br />';
86 /**
87 * Get the list of the fields of the current table
89 PMA_mysql_select_db($db);
90 $table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table));
91 if (isset($primary_key)) {
92 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key;
93 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
94 $row = PMA_mysql_fetch_array($result);
95 // No row returned
96 if (!$row) {
97 unset($row);
98 unset($primary_key);
99 $goto_cpy = $goto;
100 $goto = 'tbl_properties.php3?'
101 . PMA_generate_common_url($db, $table)
102 . '&amp;$show_query=1'
103 . '&amp;sql_query=' . urlencode($local_query);
104 if (isset($sql_query)) {
105 $sql_query_cpy = $sql_query;
106 unset($sql_query);
108 $sql_query = $local_query;
109 PMA_showMessage($strEmptyResultSet);
110 $goto = $goto_cpy;
111 unset($goto_cpy);
112 if (isset($sql_query_cpy)) {
113 $sql_query = $sql_query_cpy;
114 unset($sql_query_cpy);
116 } // end if (no record returned)
118 else
120 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1';
121 $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
122 unset($row);
125 // <markus@noga.de>
126 // retrieve keys into foreign fields, if any
127 $cfgRelation = PMA_getRelationsParam();
128 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
132 * Displays the form
134 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
135 // must be replaced by the "onpropertychange" one in this case
136 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
137 ? 'onpropertychange'
138 : 'onchange';
139 // Had to put the URI because when hosted on an https server,
140 // some browsers send wrongly this form to the http server.
143 <!-- Set on key handler for moving using by Ctrl+arrows -->
144 <script type="text/javascript" language="javascript">
145 <!--
146 document.onkeydown = onKeyDownArrowsHandler;
147 // -->
148 </script>
150 <!-- Change table properties form -->
151 <form method="post" action="tbl_replace.php3" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>>
152 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
153 <input type="hidden" name="goto" value="<?php echo $goto; ?>" />
154 <input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
155 <input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
156 <input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
157 <input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
158 <input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
159 <input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" />
160 <input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
161 <?php
162 if (isset($primary_key)) {
164 <input type="hidden" name="primary_key" value="<?php echo urlencode($primary_key); ?>" />
165 <?php
167 echo "\n";
170 <table border="<?php echo $cfg['Border']; ?>">
171 <tr>
172 <th><?php echo $strField; ?></th>
173 <th><?php echo $strType; ?></th>
174 <?php
175 if ($cfg['ShowFunctionFields']) {
176 echo ' <th>' . $strFunction . '</th>' . "\n";
179 <th><?php echo $strNull; ?></th>
180 <th><?php echo $strValue; ?></th>
181 </tr>
183 <?php
184 // Set if we passed the first timestamp field
185 $timestamp_seen = 0;
186 $fields_cnt = mysql_num_rows($table_def);
188 // Set a flag here because the 'if' would not be valid in the loop
189 // if we set a value in some field
190 $insert_mode = (!isset($row) ? TRUE : FALSE);
192 for ($i = 0; $i < $fields_cnt; $i++) {
193 // Display the submit button after every 15 lines --swix
194 // (wanted to use an <a href="#bottom"> and <a name> instead,
195 // but it didn't worked because of the <base href>)
197 if ((($i % 15) == 0) && ($i != 0)) {
199 <tr>
200 <th colspan="5" align="right">
201 <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;
202 </th>
203 </tr>
204 <?php
205 } // end if
206 echo "\n";
208 $row_table_def = PMA_mysql_fetch_array($table_def);
209 $field = $row_table_def['Field'];
210 // loic1: current date should not be set as default if the field is NULL
211 // for the current row
212 // lem9: but do not put here the current datetime if there is a default
213 // value (the real default value will be set in the
214 // Default value logic below)
215 if ($row_table_def['Type'] == 'datetime'
216 && (!isset($row_table_def['Default']))) {
217 // INSERT case
218 if ($insert_mode) {
219 $row[$field] = date('Y-m-d H:i:s', time());
221 // UPDATE case with an empty and not NULL value under PHP4
222 else if (empty($row[$field]) && function_exists('is_null')) {
223 $row[$field] = (is_null($row[$field]) ? $row[$field] : date('Y-m-d H:i:s', time()));
225 // UPDATE case with an empty value under PHP3
226 else if (empty($row[$field])) {
227 $row[$field] = date('Y-m-d H:i:s', time());
228 } // end if... else if... else if...
230 $len = (eregi('float|double', $row_table_def['Type']))
231 ? 100
232 : @mysql_field_len($result, $i);
233 $first_timestamp = 0;
235 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
237 <tr>
238 <td align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
239 <?php
240 echo "\n";
242 // The type column
243 $is_binary = eregi(' binary', $row_table_def['Type']);
244 $is_blob = eregi('blob', $row_table_def['Type']);
245 $is_char = eregi('char', $row_table_def['Type']);
246 $row_table_def['True_Type'] = ereg_replace('\\(.*', '', $row_table_def['Type']);
247 switch ($row_table_def['True_Type']) {
248 case 'set':
249 $type = 'set';
250 $type_nowrap = '';
251 break;
252 case 'enum':
253 $type = 'enum';
254 $type_nowrap = '';
255 break;
256 case 'timestamp':
257 if (!$timestamp_seen) { // can only occur once per table
258 $timestamp_seen = 1;
259 $first_timestamp = 1;
261 $type = $row_table_def['Type'];
262 $type_nowrap = ' nowrap="nowrap"';
263 break;
265 default:
266 $type = $row_table_def['Type'];
267 $type_nowrap = ' nowrap="nowrap"';
268 break;
271 <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
272 <?php echo $type; ?>
273 </td>
274 <?php
275 echo "\n";
277 // Prepares the field value
278 if (isset($row)) {
279 // loic1: null field value
280 if (!isset($row[$field])) {
281 $row[$field] = 'NULL';
282 $special_chars = '';
283 $data = $row[$field];
284 } else {
285 // loic1: special binary "characters"
286 if ($is_binary || $is_blob) {
287 $row[$field] = str_replace("\x00", '\0', $row[$field]);
288 $row[$field] = str_replace("\x08", '\b', $row[$field]);
289 $row[$field] = str_replace("\x0a", '\n', $row[$field]);
290 $row[$field] = str_replace("\x0d", '\r', $row[$field]);
291 $row[$field] = str_replace("\x1a", '\Z', $row[$field]);
292 } // end if
293 $special_chars = htmlspecialchars($row[$field]);
294 $data = $row[$field];
295 } // end if... else...
296 // loic1: if a timestamp field value is not included in an update
297 // statement MySQL auto-update it to the current timestamp
298 $backup_field = ($row_table_def['True_Type'] == 'timestamp')
299 ? ''
300 : '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($row[$field]) . '" />';
301 } else {
302 // loic1: display default values
303 if (!isset($row_table_def['Default'])) {
304 $row_table_def['Default'] = '';
305 $data = 'NULL';
306 } else {
307 $data = $row_table_def['Default'];
309 $special_chars = htmlspecialchars($row_table_def['Default']);
310 $backup_field = '';
313 // The function column
314 // -------------------
315 // Change by Bernard M. Piller <bernard@bmpsystems.com>
316 // We don't want binary data to be destroyed
317 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
318 // stored or retrieved" so it does not mean that the contents is
319 // binary
320 if ($cfg['ShowFunctionFields']) {
321 if (($cfg['ProtectBinary'] && $is_blob)
322 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
323 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
324 } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
325 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
326 } else {
328 <td bgcolor="<?php echo $bgcolor; ?>">
329 <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">
330 <option></option>
331 <?php
332 echo "\n";
333 $selected = '';
334 for ($j = 0; $j < count($cfg['Functions']); $j++) {
335 // for default function = NOW() on first timestamp field
336 // -- swix/18jul01
337 $selected = ($first_timestamp && $cfg['Functions'][$j] == 'NOW')
338 ? ' selected="selected"'
339 : '';
340 echo ' ';
341 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
342 } // end for
343 unset($selected);
345 </select>
346 </td>
347 <?php
349 } // end if ($cfg['ShowFunctionFields'])
350 echo "\n";
352 // The null column
353 // ---------------
354 echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
355 if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
356 && $row_table_def['Null'] == 'YES') {
357 echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + $i + 1) . '"'
358 . ' name="fields_null[' . urlencode($field) . ']"';
359 if ($data == 'NULL' && !$first_timestamp) {
360 echo ' checked="checked"';
362 echo ' id="field_' . $i . '_2"';
363 $onclick = ' onclick="if (this.checked) {nullify(';
364 if (strstr($row_table_def['True_Type'], 'enum')) {
365 if (strlen($row_table_def['Type']) > 20) {
366 $onclick .= '1, ';
367 } else {
368 $onclick .= '2, ';
370 } else if (strstr($row_table_def['True_Type'], 'set')) {
371 $onclick .= '3, ';
372 } else if ($foreigners && isset($foreigners[$field])) {
373 $onclick .= '4, ';
374 } else {
375 $onclick .= '5, ';
377 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
378 echo $onclick;
379 } else {
380 echo ' &nbsp;' . "\n";
382 echo ' </td>' . "\n";
384 // The value column (depends on type)
385 // ----------------
387 include('./libraries/get_foreign.lib.php3');
389 if (isset($disp) && $disp) {
391 <td bgcolor="<?php echo $bgcolor; ?>">
392 <?php echo $backup_field . "\n"; ?>
393 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
394 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
395 <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">
396 <option value=""></option>
397 <?php
398 echo "\n";
399 while ($relrow = @PMA_mysql_fetch_array($disp)) {
400 $key = $relrow[$foreign_field];
401 $value = (($foreign_display != FALSE) ? '&nbsp;-&nbsp;' . htmlspecialchars($relrow[$foreign_display]) : '');
402 echo ' <option value="' . htmlspecialchars($key) . '"';
403 if ($key == $data) {
404 echo ' selected="selected"';
405 } // end if
406 echo '>' . htmlspecialchars($key) . $value . '</option>' . "\n";
407 } // end while
408 echo ' </select>' . "\n";
409 echo ' </td>' . "\n";
410 unset($disp);
412 else if (strstr($row_table_def['True_Type'], 'text')) {
414 <td bgcolor="<?php echo $bgcolor; ?>">
415 <?php echo $backup_field . "\n"; ?>
416 <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"
417 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
418 </td>
419 <?php
420 echo "\n";
421 if (strlen($special_chars) > 32000) {
422 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
425 else if (strstr($row_table_def['True_Type'], 'enum')) {
426 $enum = str_replace('enum(', '', $row_table_def['Type']);
427 $enum = ereg_replace('\\)$', '', $enum);
428 $enum = explode('\',\'', substr($enum, 1, -1));
429 $enum_cnt = count($enum);
431 <td bgcolor="<?php echo $bgcolor; ?>">
432 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="enum" />
433 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
434 <?php
435 echo "\n" . ' ' . $backup_field;
437 // show dropdown or radio depend on length
438 if (strlen($row_table_def['Type']) > 20) {
439 echo "\n";
441 <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">
442 <option value=""></option>
443 <?php
444 echo "\n";
446 for ($j = 0; $j < $enum_cnt; $j++) {
447 // Removes automatic MySQL escape format
448 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
449 echo ' ';
450 echo '<option value="' . urlencode($enum_atom) . '"';
451 if ($data == $enum_atom
452 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
453 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
454 echo ' selected="selected"';
456 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
457 } // end for
460 </select>
461 <?php
462 } // end if
463 else {
464 echo "\n";
465 for ($j = 0; $j < $enum_cnt; $j++) {
466 // Removes automatic MySQL escape format
467 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
468 echo ' ';
469 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}"';
470 if ($data == $enum_atom
471 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
472 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
473 echo ' checked="checked"';
475 echo 'tabindex="' . ($i + 1) . '" />' . "\n";
476 echo ' <label for="field_' . $i . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
477 } // end for
479 } // end else
480 echo "\n";
482 </td>
483 <?php
484 echo "\n";
486 else if (strstr($row_table_def['Type'], 'set')) {
487 $set = str_replace('set(', '', $row_table_def['Type']);
488 $set = ereg_replace('\)$', '', $set);
489 $set = explode(',', $set);
491 if (isset($vset)) {
492 unset($vset);
494 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
495 $vset[$k] = 1;
497 $size = min(4, count($set));
499 <td bgcolor="<?php echo $bgcolor; ?>">
500 <?php echo $backup_field . "\n"; ?>
501 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="set" />
502 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
503 <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">
504 <?php
505 echo "\n";
506 $countset = count($set);
507 for ($j = 0; $j < $countset;$j++) {
508 $subset = substr($set[$j], 1, -1);
509 // Removes automatic MySQL escape format
510 $subset = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $subset));
511 echo ' ';
512 echo '<option value="'. urlencode($subset) . '"';
513 if (isset($vset[$subset]) && $vset[$subset]) {
514 echo ' selected="selected"';
516 echo '>' . htmlspecialchars($subset) . '</option>' . "\n";
517 } // end for
519 </select>
520 </td>
521 <?php
523 // Change by Bernard M. Piller <bernard@bmpsystems.com>
524 // We don't want binary data destroyed
525 else if ($is_binary || $is_blob) {
526 if (($cfg['ProtectBinary'] && $is_blob)
527 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
528 echo "\n";
530 <td align="center" bgcolor="<?php echo $bgcolor; ?>">
531 <?php
532 echo $strBinaryDoNotEdit;
533 if (isset($data)) {
534 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
535 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
536 unset($data_size);
538 echo "\n";
540 <input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="protected" />
541 <input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
542 <?php
543 } else if ($is_blob) {
544 echo "\n";
546 <td bgcolor="<?php echo $bgcolor; ?>">
547 <?php echo $backup_field . "\n"; ?>
548 <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"
549 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
550 <?php
552 } else {
553 if ($len < 4) {
554 $fieldsize = $maxlength = 4;
555 } else {
556 $fieldsize = (($len > 40) ? 40 : $len);
557 $maxlength = $len;
559 echo "\n";
561 <td bgcolor="<?php echo $bgcolor; ?>">
562 <?php echo $backup_field . "\n"; ?>
563 <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" />
564 <?php
565 } // end if...elseif...else
567 // Upload choice (only for BLOBs because the binary
568 // attribute does not imply binary contents)
569 // (displayed whatever value the ProtectBinary has)
571 if ($is_upload && $is_blob) {
572 echo '<input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" id="field_' . $i . '_3" />';
574 echo '</td>';
576 } // end else if ( binary or blob)
577 else {
578 // For char or varchar, respect the maximum length (M); for other
579 // types (int or float), the length is not a limit on the values that
580 // can be entered, so let's be generous (20) (we could also use the
581 // real limits for each numeric type)
582 if ($is_char) {
583 $fieldsize = (($len > 40) ? 40 : $len);
584 $maxlength = $len;
586 else {
587 $fieldsize = $maxlength = 20;
588 } // end if... else...
589 echo "\n";
591 <td bgcolor="<?php echo $bgcolor; ?>">
592 <?php echo $backup_field . "\n"; ?>
593 <?php
594 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
595 echo "\n";
597 <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"
598 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
599 <?php
600 } else {
601 echo "\n";
603 <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" />
604 <?php
606 echo "\n";
608 </td>
609 <?php
611 echo "\n";
613 </tr>
614 <?php
615 echo "\n";
616 } // end for
618 </table>
619 <br />
621 <table cellpadding="5">
622 <tr>
623 <td valign="middle" nowrap="nowrap">
624 <?php
625 if (isset($primary_key)) {
627 <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 />
628 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $strOr; ?><br />
629 <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>
630 <?php
631 } else {
632 echo "\n";
634 <input type="hidden" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" />
635 <?php
636 echo ' ' . $strInsertAsNewRow . "\n";
638 echo "\n";
640 // Defines whether "insert a new row after the current insert" should be
641 // checked or not (keep this choice sticky)
642 $checked = (!empty($message)) ? ' checked="checked"' : '';
644 </td>
645 <td valign="middle">
646 &nbsp;&nbsp;&nbsp;<b>-- <?php echo $strAnd; ?> --</b>&nbsp;&nbsp;&nbsp;
647 </td>
648 <td valign="middle" nowrap="nowrap">
649 <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 />
650 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $strOr; ?><br />
651 <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>
652 </td>
653 </tr>
655 <tr>
656 <td colspan="3" align="center" valign="middle">
657 <input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 5); ?>" />
658 </td>
659 </tr>
660 </table>
662 </form>
665 <?php
667 * Displays the footer
669 echo "\n";
670 require('./footer.inc.php3');