bug #1258956, typo
[phpmyadmin/crack.git] / tbl_change.php
blobbdc962c2ca8c953a72f0dfc293c4cfde36dad8cb
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Get the variables sent or posted to this script and displays the header
7 */
8 require_once('./libraries/grab_globals.lib.php');
9 $js_to_run = 'tbl_change.js';
10 require_once('./header.inc.php');
11 require_once('./libraries/relation.lib.php'); // foreign keys
14 /**
15 * Displays the query submitted and its result
17 if (!empty($disp_message)) {
18 if (isset($goto)) {
19 $goto_cpy = $goto;
20 $goto = 'tbl_properties.php?'
21 . PMA_generate_common_url($db, $table)
22 . '&amp;$show_query=1'
23 . '&amp;sql_query=' . (isset($disp_query) ? urlencode($disp_query) : '');
24 } else {
25 $show_query = '1';
27 if (isset($sql_query)) {
28 $sql_query_cpy = $sql_query;
29 unset($sql_query);
31 if (isset($disp_query)) {
32 $sql_query = $disp_query;
34 PMA_showMessage($disp_message);
35 if (isset($goto_cpy)) {
36 $goto = $goto_cpy;
37 unset($goto_cpy);
39 if (isset($sql_query_cpy)) {
40 $sql_query = $sql_query_cpy;
41 unset($sql_query_cpy);
46 /**
47 * Defines the url to return to in case of error in a sql statement
49 if (!isset($goto)) {
50 $goto = 'db_details.php';
52 if (!preg_match('@^(db_details|tbl_properties|tbl_select|ldi_table)@', $goto)) {
53 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&amp;sql_query=" . urlencode($sql_query);
54 } else {
55 $err_url = $goto . '?'
56 . PMA_generate_common_url($db)
57 . ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ? '&amp;table=' . urlencode($table) : '');
61 /**
62 * Ensures db and table are valid, else moves to the "parent" script
64 require('./libraries/db_table_exists.lib.php');
67 /**
68 * Sets parameters for links
70 $url_query = PMA_generate_common_url($db, $table)
71 . '&amp;goto=tbl_properties.php';
73 require('./tbl_properties_table_info.php');
75 /* Get comments */
77 $comments_map = array();
79 if ($GLOBALS['cfg']['ShowPropertyComments']) {
80 require_once('./libraries/relation.lib.php');
81 require_once('./libraries/transformations.lib.php');
83 $cfgRelation = PMA_getRelationsParam();
85 if ($cfgRelation['commwork']) {
86 $comments_map = PMA_getComments($db, $table);
90 /**
91 * Displays top menu links
93 require('./tbl_properties_links.php');
95 /**
96 * Get the list of the fields of the current table
98 PMA_DBI_select_db($db);
99 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE);
100 if (isset($primary_key)) {
101 if (is_array($primary_key)) {
102 $primary_key_array = $primary_key;
103 } else {
104 $primary_key_array = array(0 => $primary_key);
107 $row = array();
108 $result = array();
109 foreach ($primary_key_array AS $rowcount => $primary_key) {
110 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
111 $result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE);
112 $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
113 $primary_keys[$rowcount] = $primary_key;
115 // No row returned
116 if (!$row[$rowcount]) {
117 unset($row[$rowcount]);
118 unset($primary_key_array[$rowcount]);
119 $goto_cpy = $goto;
120 $goto = 'tbl_properties.php?'
121 . PMA_generate_common_url($db, $table)
122 . '&amp;$show_query=1'
123 . '&amp;sql_query=' . urlencode($local_query);
124 if (isset($sql_query)) {
125 $sql_query_cpy = $sql_query;
126 unset($sql_query);
128 $sql_query = $local_query;
129 PMA_showMessage($strEmptyResultSet);
130 $goto = $goto_cpy;
131 unset($goto_cpy);
132 if (isset($sql_query_cpy)) {
133 $sql_query = $sql_query_cpy;
134 unset($sql_query_cpy);
136 echo "\n";
137 require_once('./footer.inc.php');
138 } // end if (no record returned)
140 } else {
141 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', NULL, PMA_DBI_QUERY_STORE);
142 unset($row);
145 // <markus@noga.de>
146 // retrieve keys into foreign fields, if any
147 $cfgRelation = PMA_getRelationsParam();
148 $foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
152 * Displays the form
154 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
155 // must be replaced by the "onpropertychange" one in this case
156 $chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
157 ? 'onpropertychange'
158 : 'onchange';
159 // Had to put the URI because when hosted on an https server,
160 // some browsers send wrongly this form to the http server.
163 <?php if ($cfg['CtrlArrowsMoving']) { ?>
164 <!-- Set on key handler for moving using by Ctrl+arrows -->
165 <script src="libraries/keyhandler.js" type="text/javascript" language="javascript"></script>
166 <script type="text/javascript" language="javascript">
167 <!--
168 var switch_movement = 0;
169 document.onkeydown = onKeyDownArrowsHandler;
170 // -->
171 </script>
172 <?php } ?>
174 <!-- Change table properties form -->
175 <form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>>
176 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
177 <input type="hidden" name="goto" value="<?php echo urlencode($goto); ?>" />
178 <input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
179 <input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
180 <input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
181 <input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
182 <input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
183 <input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" />
184 <input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
185 <input type="hidden" name="reload" value="1" />
186 <?php
187 if (isset($primary_key_array)) {
188 foreach ($primary_key_array AS $primary_key) {
190 <input type="hidden" name="primary_key[]" value="<?php echo urlencode($primary_key); ?>" />
191 <?php
194 echo "\n";
196 if ($cfg['PropertiesIconic'] == true) {
197 // We need to copy the value or else the == 'both' check will always return true
198 $propicon = (string)$cfg['PropertiesIconic'];
200 if ($propicon == 'both') {
201 $iconic_spacer = '<div class="nowrap">';
202 } else {
203 $iconic_spacer = '';
206 $titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
208 if ($propicon == 'both') {
209 $titles['Browse'] .= '&nbsp;' . $strBrowseForeignValues . '</div>';
211 } else {
212 $titles['Browse'] = $strBrowseForeignValues;
215 // Set if we passed the first timestamp field
216 $timestamp_seen = 0;
217 $fields_cnt = PMA_DBI_num_rows($table_def);
219 // Set a flag here because the 'if' would not be valid in the loop
220 // if we set a value in some field
221 $insert_mode = (!isset($row) ? TRUE : FALSE);
222 if ($insert_mode) {
223 $loop_array = array();
224 for ($i = 0; $i < $cfg['InsertRows']; $i++) $loop_array[] = FALSE;
225 } else {
226 $loop_array = $row;
229 while ($trow = PMA_DBI_fetch_assoc($table_def)) {
230 $trow_table_def[] = $trow;
233 $tabindex = 0;
234 $tabindex_for_function = +1000;
235 $tabindex_for_null = +2000;
236 $tabindex_for_value = 0;
237 $o_rows = 0;
238 foreach ($loop_array AS $vrowcount => $vrow) {
239 if ($vrow === FALSE) {
240 unset($vrow);
243 if ($insert_mode) {
244 $jsvkey = $vrowcount;
245 $browse_foreigners_uri = '&amp;pk=' . $vrowcount;
246 } else {
247 $jsvkey = urlencode($primary_keys[$vrowcount]);
248 $browse_foreigners_uri = '&amp;pk=' . urlencode($primary_keys[$vrowcount]);
250 $vkey = '[multi_edit][' . $jsvkey . ']';
252 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ? $result[$vrowcount] : $result);
253 if ($insert_mode && $vrowcount > 0) {
254 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
255 echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
258 <table border="<?php echo $cfg['Border']; ?>" cellpadding="2" cellspacing="1">
259 <tr>
260 <th><?php echo $strField; ?></th>
261 <th><?php echo $strType; ?></th>
262 <?php
263 if ($cfg['ShowFunctionFields']) {
264 echo ' <th>' . $strFunction . '</th>' . "\n";
267 <th><?php echo $strNull; ?></th>
268 <th><?php echo $strValue; ?></th>
269 </tr>
270 <?php
272 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
273 $timestamp_seen = 0;
274 unset($first_timestamp);
276 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
277 $m_rows = $o_rows + 1;
279 for ($i = 0; $i < $fields_cnt; $i++) {
280 // Display the submit button after every 15 lines --swix
281 // (wanted to use an <a href="#bottom"> and <a name> instead,
282 // but it didn't worked because of the <base href>)
284 if ((($o_rows * $fields_cnt + $i) % 15 == 0) && ($i + $o_rows != 0)) {
286 <tr>
287 <th colspan="5" align="right" class="tblFooters">
288 <input type="submit" value="<?php echo $strGo; ?>" />&nbsp;
289 </th>
290 </tr>
291 <?php
292 } // end if
293 echo "\n";
295 $row_table_def = $trow_table_def[$i];
296 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
298 $field = $row_table_def['Field'];
300 // removed previous PHP3-workaround that caused a problem with
301 // field names like '000'
302 $rowfield = $field;
304 // d a t e t i m e
306 // loic1: current date should not be set as default if the field is NULL
307 // for the current row
308 // lem9: but do not put here the current datetime if there is a default
309 // value (the real default value will be set in the
310 // Default value logic below)
312 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
313 // $row_table_def['Default'] is not set if it contains NULL:
314 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime )
315 // but, look what we get if we switch to iso: (Default is NULL)
316 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime )
317 // so I force a NULL into it (I don't think it's possible
318 // to have an empty default value for DATETIME)
319 // then, the "if" after this one will work
320 if ($row_table_def['Type'] == 'datetime'
321 && !isset($row_table_def['Default'])
322 && isset($row_table_def['Null'])
323 && $row_table_def['Null'] == 'YES') {
324 $row_table_def['Default'] = NULL;
327 if ($row_table_def['Type'] == 'datetime'
328 && (!isset($row_table_def['Default']))
329 && (!is_null($row_table_def['Default']))) {
330 // INSERT case
331 if ($insert_mode) {
332 if (isset($vrow)) {
333 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
334 } else {
335 $vrow = array($rowfield => date('Y-m-d H:i:s', time()));
338 // UPDATE case with an empty and not NULL value under PHP4
339 else if (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
340 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
341 } // end if... else if...
343 $len = (preg_match('@float|double@', $row_table_def['Type']))
344 ? 100
345 : PMA_DBI_field_len($vresult, $i);
346 $first_timestamp = 0;
348 $field_name = htmlspecialchars($field);
349 if (isset($comments_map[$field])) {
350 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
353 $bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
355 <tr>
356 <td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo $field_name; ?></td>
357 <?php
358 echo "\n";
360 // The type column
361 $is_binary = stristr($row_table_def['Type'], ' binary');
362 $is_blob = stristr($row_table_def['Type'], 'blob');
363 $is_char = stristr($row_table_def['Type'], 'char');
364 switch ($row_table_def['True_Type']) {
365 case 'set':
366 $type = 'set';
367 $type_nowrap = '';
368 break;
369 case 'enum':
370 $type = 'enum';
371 $type_nowrap = '';
372 break;
373 case 'timestamp':
374 if (!$timestamp_seen) { // can only occur once per table
375 $timestamp_seen = 1;
376 $first_timestamp = 1;
378 $type = $row_table_def['Type'];
379 $type_nowrap = ' nowrap="nowrap"';
380 break;
382 default:
383 $type = $row_table_def['Type'];
384 $type_nowrap = ' nowrap="nowrap"';
385 break;
388 <td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
389 <?php echo $type; ?>
390 </td>
391 <?php
392 echo "\n";
394 // Prepares the field value
395 $real_null_value = FALSE;
396 if (isset($vrow)) {
397 if (!isset($vrow[$rowfield])
398 || (function_exists('is_null') && is_null($vrow[$rowfield]))) {
399 $real_null_value = TRUE;
400 $vrow[$rowfield] = '';
401 $special_chars = '';
402 $data = $vrow[$rowfield];
403 } else {
404 // loic1: special binary "characters"
405 if ($is_binary || $is_blob) {
406 $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);
407 $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);
408 $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);
409 $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);
410 $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);
411 } // end if
412 $special_chars = htmlspecialchars($vrow[$rowfield]);
413 $data = $vrow[$rowfield];
414 } // end if... else...
415 // loic1: if a timestamp field value is not included in an update
416 // statement MySQL auto-update it to the current timestamp
417 $backup_field = ($row_table_def['True_Type'] == 'timestamp')
418 ? ''
419 : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';
420 } else {
421 // loic1: display default values
422 if (!isset($row_table_def['Default'])) {
423 $row_table_def['Default'] = '';
424 $real_null_value = TRUE;
425 $data = '';
426 } else {
427 $data = $row_table_def['Default'];
429 $special_chars = htmlspecialchars($row_table_def['Default']);
430 $backup_field = '';
433 $idindex = ($o_rows * $fields_cnt) + $i + 1;
434 $tabindex = (($idindex - 1) * 3) + 1;
436 // The function column
437 // -------------------
438 // Change by Bernard M. Piller <bernard@bmpsystems.com>
439 // We don't want binary data to be destroyed
440 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
441 // stored or retrieved" so it does not mean that the contents is
442 // binary
443 if ($cfg['ShowFunctionFields']) {
444 if (($cfg['ProtectBinary'] && $is_blob)
445 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
446 echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
447 } else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
448 echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
449 } else {
451 <td bgcolor="<?php echo $bgcolor; ?>">
452 <select name="funcs<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_function); ?>" id="field_<?php echo $idindex; ?>_1">
453 <option></option>
454 <?php
455 echo "\n";
456 $selected = '';
458 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
459 // or something similar. Then directly look up the entry in the RestrictFunctions array,
460 // which will then reveal the available dropdown options
461 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'])]])) {
462 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
463 $dropdown = $cfg['RestrictFunctions'][$current_func_type];
464 $default_function = $cfg['DefaultFunctions'][$current_func_type];
465 } else {
466 $dropdown = array();
467 $default_function = '';
470 $dropdown_built = array();
471 $op_spacing_needed = FALSE;
473 // garvin: loop on the dropdown array and print all available options for that field.
474 $cnt_dropdown = count($dropdown);
475 for ($j = 0; $j < $cnt_dropdown; $j++) {
476 // Is current function defined as default?
477 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
478 || (!$first_timestamp && $dropdown[$j] == $default_function)
479 ? ' selected="selected"'
480 : '';
481 echo ' ';
482 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
483 $dropdown_built[$dropdown[$j]] = 'TRUE';
484 $op_spacing_needed = TRUE;
487 // garvin: For compatibility's sake, do not let out all other functions. Instead
488 // print a seperator (blank) and then show ALL functions which weren't shown
489 // yet.
490 $cnt_functions = count($cfg['Functions']);
491 for ($j = 0; $j < $cnt_functions; $j++) {
492 if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
493 // Is current function defined as default?
494 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
495 || (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
496 ? ' selected="selected"'
497 : '';
498 if ($op_spacing_needed == TRUE) {
499 echo ' ';
500 echo '<option value="">--------</option>' . "\n";
501 $op_spacing_needed = FALSE;
504 echo ' ';
505 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
507 } // end for
508 unset($selected);
510 </select>
511 </td>
512 <?php
514 } // end if ($cfg['ShowFunctionFields'])
515 echo "\n";
517 // The null column
518 // ---------------
519 echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
520 if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
521 && $row_table_def['Null'] == 'YES') {
522 echo ' <input type="checkbox" tabindex="' . ($tabindex + $tabindex_for_null) . '"'
523 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"';
524 if ($real_null_value && !$first_timestamp) {
525 echo ' checked="checked"';
527 echo ' id="field_' . ($idindex) . '_2"';
528 $onclick = ' onclick="if (this.checked) {nullify(';
529 if (strstr($row_table_def['True_Type'], 'enum')) {
530 if (strlen($row_table_def['Type']) > 20) {
531 $onclick .= '1, ';
532 } else {
533 $onclick .= '2, ';
535 } else if (strstr($row_table_def['True_Type'], 'set')) {
536 $onclick .= '3, ';
537 } else if ($foreigners && isset($foreigners[$field])) {
538 $onclick .= '4, ';
539 } else {
540 $onclick .= '5, ';
542 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n";
543 echo $onclick;
544 } else {
545 echo ' &nbsp;' . "\n";
547 echo ' </td>' . "\n";
549 // The value column (depends on type)
550 // ----------------
552 require('./libraries/get_foreign.lib.php');
554 if (isset($foreign_link) && $foreign_link == true) {
556 <td bgcolor="<?php echo $bgcolor; ?>">
557 <?php echo $backup_field . "\n"; ?>
558 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
559 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo ($idindex); ?>_1" />
560 <input type="text" name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" value="<?php echo htmlspecialchars($data); ?>" />
561 <script type="text/javascript" language="javascript">
562 document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes,resizable=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&amp;field=<?php echo urlencode($field) . $browse_foreigners_uri; ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
563 </script>
564 </td>
565 <?php
566 } else if (isset($disp_row) && is_array($disp_row)) {
568 <td bgcolor="<?php echo $bgcolor; ?>">
569 <?php echo $backup_field . "\n"; ?>
570 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="foreign" />
571 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $idindex; ?>_1" />
572 <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3">
573 <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
574 </select>
575 </td>
576 <?php
577 unset($disp_row);
579 else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
581 <td bgcolor="<?php echo $bgcolor; ?>">&nbsp;</td>
582 </tr>
583 <tr>
584 <td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">
585 <?php echo $backup_field . "\n"; ?>
586 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($idindex); ?>_3"
587 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"><?php echo $special_chars; ?></textarea>
588 </td>
589 <?php
591 else if (strstr($type, 'text')) {
593 <td bgcolor="<?php echo $bgcolor; ?>">
594 <?php echo $backup_field . "\n"; ?>
595 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($idindex); ?>_3"
596 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"><?php echo $special_chars; ?></textarea>
597 </td>
598 <?php
599 echo "\n";
600 if (strlen($special_chars) > 32000) {
601 echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
604 else if ($type == 'enum') {
605 $enum = PMA_getEnumSetOptions($row_table_def['Type']);
606 $enum_cnt = count($enum);
608 <td bgcolor="<?php echo $bgcolor; ?>">
609 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="enum" />
610 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
611 <?php
612 echo "\n" . ' ' . $backup_field;
614 // show dropdown or radio depend on length
615 if (strlen($row_table_def['Type']) > 20) {
616 echo "\n";
618 <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3">
619 <option value=""></option>
620 <?php
621 echo "\n";
623 for ($j = 0; $j < $enum_cnt; $j++) {
624 // Removes automatic MySQL escape format
625 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
626 echo ' ';
627 //echo '<option value="' . htmlspecialchars($enum_atom) . '"';
628 echo '<option value="' . urlencode($enum_atom) . '"';
629 if ($data == $enum_atom
630 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
631 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
632 echo ' selected="selected"';
634 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
635 } // end for
638 </select>
639 <?php
640 } // end if
641 else {
642 echo "\n";
643 for ($j = 0; $j < $enum_cnt; $j++) {
644 // Removes automatic MySQL escape format
645 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
646 echo ' ';
647 echo '<input type="radio" name="field_' . md5($field) . $vkey . '[]" value="' . urlencode($enum_atom) . '" id="field_' . ($idindex) . '_3_' . $j . '" onclick="if (typeof(document.forms[\'insertForm\'].elements[\'fields_null' . str_replace('"', '\"', $vkey) . '[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null' . str_replace('"', '\"', $vkey) . '[' . urlencode($field) .']\'].checked = false}"';
648 if ($data == $enum_atom
649 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
650 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
651 echo ' checked="checked"';
653 echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
654 echo '<label for="field_' . $idindex . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
655 } // end for
657 } // end else
658 echo "\n";
660 </td>
661 <?php
662 echo "\n";
664 else if ($type == 'set') {
665 $set = PMA_getEnumSetOptions($row_table_def['Type']);
667 if (isset($vset)) {
668 unset($vset);
670 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
671 $vset[$k] = 1;
673 $countset = count($set);
674 $size = min(4, $countset);
676 <td bgcolor="<?php echo $bgcolor; ?>">
677 <?php echo $backup_field . "\n"; ?>
678 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="set" />
679 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
680 <select name="field_<?php echo md5($field); ?><?php echo $vkey; ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3">
681 <?php
682 echo "\n";
683 for ($j = 0; $j < $countset; $j++) {
684 echo ' ';
685 //echo '<option value="'. htmlspecialchars($set[$j]) . '"';
686 echo '<option value="'. urlencode($set[$j]) . '"';
687 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
688 echo ' selected="selected"';
690 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
691 } // end for
693 </select>
694 </td>
695 <?php
697 // Change by Bernard M. Piller <bernard@bmpsystems.com>
698 // We don't want binary data destroyed
699 else if ($is_binary || $is_blob) {
700 if (($cfg['ProtectBinary'] && $is_blob)
701 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
702 echo "\n";
704 <td bgcolor="<?php echo $bgcolor; ?>">
705 <?php
706 echo $strBinaryDoNotEdit;
707 if (isset($data)) {
708 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
709 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
710 unset($data_size);
712 echo "\n";
714 <input type="hidden" name="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="protected" />
715 <input type="hidden" name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value="" />
716 <?php
717 } else if ($is_blob) {
718 echo "\n";
720 <td bgcolor="<?php echo $bgcolor; ?>">
721 <?php echo $backup_field . "\n"; ?>
722 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($idindex); ?>_3"
723 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" ><?php echo $special_chars; ?></textarea>
724 <?php
726 } else {
727 if ($len < 4) {
728 $fieldsize = $maxlength = 4;
729 } else {
730 $fieldsize = (($len > 40) ? 40 : $len);
731 $maxlength = $len;
733 echo "\n";
735 <td bgcolor="<?php echo $bgcolor; ?>">
736 <?php echo $backup_field . "\n"; ?>
737 <input type="text" name="fields<?php echo $vkey; ?>[<?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); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" />
738 <?php
739 } // end if...elseif...else
741 // Upload choice (only for BLOBs because the binary
742 // attribute does not imply binary contents)
743 // (displayed whatever value the ProtectBinary has)
745 if ($is_upload && $is_blob) {
746 echo '<input type="file" name="fields_upload_' . urlencode($field) . $vkey . '" class="textfield" id="field_' . ($idindex) . '_3" size="10" />&nbsp;';
748 // find maximum upload size, based on field type
749 $max_field_sizes = array(
750 'tinyblob' => '256',
751 'blob' => '65536',
752 'mediumblob' => '16777216',
753 'longblob' => '4294967296'); // yeah, really
755 $this_field_max_size = $max_upload_size; // from PHP max
756 if ($this_field_max_size > $max_field_sizes[$type]) {
757 $this_field_max_size = $max_field_sizes[$type];
759 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
760 echo ' ' . PMA_generateHiddenMaxFileSize($this_field_max_size) . "\n";
763 if (!empty($cfg['UploadDir'])) {
764 if (substr($cfg['UploadDir'], -1) != '/') {
765 $cfg['UploadDir'] .= '/';
767 if ($handle = @opendir($cfg['UploadDir'])) {
768 $is_first = 0;
769 while ($file = @readdir($handle)) {
770 if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) {
771 if ($is_first == 0) {
772 echo "<br />\n";
773 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n";
774 echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . $vkey . '">' . "\n";
775 echo ' <option value="" selected="selected"></option>' . "\n";
776 } // end if (is_first)
777 echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
778 $is_first++;
779 } // end if (is_file)
780 } // end while
781 if ($is_first > 0) {
782 echo ' </select>' . "\n";
783 } // end if (isfirst > 0)
784 @closedir($handle);
785 } else {
786 echo ' <font color="red">' . $strError . '</font><br />' . "\n";
787 echo ' ' . $strWebServerUploadDirectoryError . "\n";
789 } // end if (web-server upload directory)
791 echo '</td>';
793 } // end else if ( binary or blob)
794 else {
795 // For char or varchar, respect the maximum length (M); for other
796 // types (int or float), the length is not a limit on the values that
797 // can be entered, so let's be generous (20) (we could also use the
798 // real limits for each numeric type)
799 // 2004-04-07, it turned out that 20 was not generous enough
800 // for the maxlength
801 if ($is_char) {
802 $fieldsize = (($len > 40) ? 40 : $len);
803 $maxlength = $len;
805 else {
806 $fieldsize = 20;
807 $maxlength = 99;
808 } // end if... else...
809 echo "\n";
811 <td bgcolor="<?php echo $bgcolor; ?>">
812 <?php echo $backup_field . "\n"; ?>
813 <?php
814 if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
815 echo "\n";
817 <textarea name="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" dir="<?php echo $text_dir; ?>" id="field_<?php echo ($idindex); ?>_3"
818 <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" ><?php echo $special_chars; ?></textarea>
819 <?php
820 } else {
821 echo "\n";
823 <input type="text" name="fields<?php echo $vkey; ?>[<?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); ?>', '<?php echo $jsvkey; ?>')" tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>" id="field_<?php echo ($idindex); ?>_3" />
824 <?php
825 if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
827 <script type="text/javascript">
828 <!--
829 document.write('<a title="<?php echo $strCalendar;?>" href="javascript:openCalendar(\'<?php echo PMA_generate_common_url();?>\', \'insertForm\', \'field_<?php echo ($idindex); ?>_3\', \'<?php echo (PMA_MYSQL_INT_VERSION >= 40100 && substr($type, 0, 9) == 'timestamp') ? 'datetime' : substr($type, 0, 9); ?>\')"><img class="calendar" src="<?php echo $pmaThemeImage; ?>b_calendar.png" alt="<?php echo $strCalendar; ?>"/></a>');
830 //-->
831 </script>
832 <?php
835 echo "\n";
837 </td>
838 <?php
840 echo "\n";
842 </tr>
843 <?php
844 echo "\n";
845 } // end for
846 $o_rows++;
847 echo ' </table><br />';
848 } // end foreach on multi-edit
850 <br />
852 <table border="0" cellpadding="5" cellspacing="0">
853 <tr>
854 <td valign="middle" nowrap="nowrap">
855 <select name="submit_type">
856 <?php
857 if (isset($primary_key)) {
859 <option value="<?php echo $strSave; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 1); ?>"><?php echo $strSave; ?></option>
860 <?php
863 <option value="<?php echo $strInsertAsNewRow; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 2); ?>"><?php echo $strInsertAsNewRow; ?></option>
864 </select>
865 <?php
866 echo "\n";
868 // Defines whether "insert another new row" should be
869 // selected or not (keep this choice sticky)
870 if (!empty($disp_message)) {
871 $selected_after_insert_new_insert = ' selected="selected"';
872 $selected_after_insert_back = '';
873 } else {
874 $selected_after_insert_back = ' selected="selected"';
875 $selected_after_insert_new_insert = '';
878 </td>
879 <td valign="middle">
880 &nbsp;&nbsp;&nbsp;<b><?php echo $strAndThen; ?></b>&nbsp;&nbsp;&nbsp;
881 </td>
882 <td valign="middle" nowrap="nowrap">
883 <select name="after_insert">
884 <option value="back" <?php echo $selected_after_insert_back; ?>><?php echo $strAfterInsertBack; ?></option>
885 <option value="new_insert" <?php echo $selected_after_insert_new_insert; ?>><?php echo $strAfterInsertNewInsert; ?></option>
886 <?php
887 if (isset($primary_key))
889 <option value="same_insert"><?php echo $strAfterInsertSame; ?></option>
890 <?php
891 // If we have just numeric primary key, we can also edit next
892 if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
894 <option value="edit_next"><?php echo $strAfterInsertNext; ?></option>
895 <?php
899 </select>
900 </td>
901 </tr>
903 <tr>
904 <td>
905 <?php echo PMA_showHint($strUseTabKey); ?>
906 </td>
907 <td colspan="3" align="right" valign="middle">
908 <input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id="buttonYes" />
909 <input type="reset" value="<?php echo $strReset; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
910 </td>
911 </tr>
912 </table>
914 </form>
917 <?php
919 * Displays the footer
921 echo "\n";
922 require_once('./footer.inc.php');