2 /* vim: set expandtab sw=4 ts=4 sts=4: */
9 * Gets the variables sent or posted to this script and displays the header
11 require_once './libraries/common.inc.php';
14 * Sets global variables.
15 * Here it's better to use a if, instead of the '?' operator
16 * to avoid setting a variable to '' when it's not present in $_REQUEST
19 * @todo this one is badly named, it's really a WHERE condition
20 * and exists even for tables not having a primary key or unique key
22 if (isset($_REQUEST['primary_key'])) {
23 $primary_key = $_REQUEST['primary_key'];
25 if (isset($_SESSION['edit_next'])) {
26 $primary_key = $_SESSION['edit_next'];
27 unset($_SESSION['edit_next']);
28 $after_insert = 'edit_next';
30 if (isset($_REQUEST['sql_query'])) {
31 $sql_query = $_REQUEST['sql_query'];
33 if (isset($_REQUEST['ShowFunctionFields'])) {
34 $cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
38 $js_to_run = 'tbl_change.js';
39 require_once './libraries/header.inc.php';
40 require_once './libraries/relation.lib.php'; // foreign keys
41 require_once './libraries/file_listing.php'; // file listing
45 * Displays the query submitted and its result
47 if (! empty($disp_message)) {
48 if (! isset($disp_query)) {
51 PMA_showMessage($disp_message, $disp_query);
56 * Defines the url to return to in case of error in a sql statement
57 * (at this point, $goto might be set but empty)
63 * @todo check if we could replace by "db_|tbl_"
65 if (!preg_match('@^(db|tbl)_@', $goto)) {
66 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
68 $err_url = $goto . '?'
69 . PMA_generate_common_url($db)
70 . ((preg_match('@^(tbl_)@', $goto)) ?
'&table=' . urlencode($table) : '');
75 * Ensures db and table are valid, else moves to the "parent" script
77 require_once './libraries/db_table_exists.lib.php';
81 * Sets parameters for links
83 $url_query = PMA_generate_common_url($db, $table)
84 . '&goto=tbl_sql.php';
86 require_once './libraries/tbl_info.inc.php';
90 $comments_map = array();
92 if ($GLOBALS['cfg']['ShowPropertyComments']) {
93 require_once './libraries/relation.lib.php';
94 require_once './libraries/transformations.lib.php';
96 $cfgRelation = PMA_getRelationsParam();
98 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
99 $comments_map = PMA_getComments($db, $table);
104 * Displays top menu links
106 require_once './libraries/tbl_links.inc.php';
110 * Get the analysis of SHOW CREATE TABLE for this table
112 $show_create_table = PMA_DBI_fetch_value(
113 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
115 $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
116 unset($show_create_table);
119 * Get the list of the fields of the current table
121 PMA_DBI_select_db($db);
122 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
123 if (isset($primary_key)) {
124 if (is_array($primary_key)) {
125 $primary_key_array = $primary_key;
127 $primary_key_array = array(0 => $primary_key);
132 $found_unique_key = false;
133 foreach ($primary_key_array as $rowcount => $primary_key) {
134 $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
135 $result[$rowcount] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE
);
136 $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
137 $primary_keys[$rowcount] = str_replace('\\', '\\\\', $primary_key);
140 if (!$row[$rowcount]) {
141 unset($row[$rowcount], $primary_key_array[$rowcount]);
142 PMA_showMessage($strEmptyResultSet, $local_query);
144 require_once './libraries/footer.inc.php';
145 } else { // end if (no record returned)
146 $meta = PMA_DBI_get_fields_meta($result[$rowcount]);
147 if ($tmp = PMA_getUniqueCondition($result[$rowcount], count($meta), $meta, $row[$rowcount], true)) {
148 $found_unique_key = true;
154 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE
);
159 // retrieve keys into foreign fields, if any
160 $cfgRelation = PMA_getRelationsParam();
161 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
167 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
168 // must be replaced by the "onpropertychange" one in this case
169 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
172 // Had to put the URI because when hosted on an https server,
173 // some browsers send wrongly this form to the http server.
176 <?php
if ($cfg['CtrlArrowsMoving']) { ?
>
177 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
178 <script src
="./js/keyhandler.js" type
="text/javascript"></script
>
179 <script type
="text/javascript">
181 var switch_movement
= 0;
182 document
.onkeydown
= onKeyDownArrowsHandler
;
187 <!-- Insert
/Edit form
-->
188 <form method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?
>>
189 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
190 <input type
="hidden" name
="goto" value
="<?php echo htmlspecialchars($goto); ?>" />
191 <input type
="hidden" name
="err_url" value
="<?php echo htmlspecialchars($err_url); ?>" />
192 <input type
="hidden" name
="sql_query" value
="<?php echo htmlspecialchars($sql_query); ?>" />
194 if (isset($primary_keys)) {
195 foreach ($primary_key_array as $rowcount => $primary_key) {
196 echo '<input type="hidden" name="primary_key[' . $rowcount . ']" value="' . htmlspecialchars(trim($primary_key)) . '" />'. "\n";
201 if ($cfg['PropertiesIconic'] === true ||
$cfg['PropertiesIconic'] === 'both') {
202 if ($cfg['PropertiesIconic'] === 'both') {
203 $iconic_spacer = '<div class="nowrap">';
208 $titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
210 if ($cfg['PropertiesIconic'] === 'both') {
211 $titles['Browse'] .= ' ' . $strBrowseForeignValues . '</div>';
214 $titles['Browse'] = $strBrowseForeignValues;
217 // Set if we passed the first timestamp field
219 $fields_cnt = PMA_DBI_num_rows($table_def);
221 // Set a flag here because the 'if' would not be valid in the loop
222 // if we set a value in some field
223 $insert_mode = (!isset($row) ?
TRUE : FALSE);
225 $loop_array = array();
226 for ($i = 0; $i < $cfg['InsertRows']; $i++
) {
227 $loop_array[] = FALSE;
233 while ($trow = PMA_DBI_fetch_assoc($table_def)) {
234 $trow_table_def[] = $trow;
238 $tabindex_for_function = +
1000;
239 $tabindex_for_null = +
2000;
240 $tabindex_for_value = 0;
242 $biggest_max_file_size = 0;
244 // user can toggle the display of Function column
245 // (currently does not work for multi-edits)
246 $url_params['db'] = $db;
247 $url_params['table'] = $table;
248 if (isset($primary_key)) {
249 $url_params['primary_key'] = trim($primary_key);
251 if (! empty($sql_query)) {
252 $url_params['sql_query'] = $sql_query;
255 if (! $cfg['ShowFunctionFields']) {
256 $this_url_params = array_merge($url_params,
257 array('ShowFunctionFields' => 1));
258 echo $strShow . ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . $strFunction . '</a>' . "\n";
261 foreach ($loop_array as $vrowcount => $vrow) {
262 if ($vrow === FALSE) {
266 $jsvkey = $vrowcount;
267 $browse_foreigners_uri = '&pk=' . $vrowcount;
268 $vkey = '[multi_edit][' . $jsvkey . ']';
270 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ?
$result[$vrowcount] : $result);
271 if ($insert_mode && $vrowcount > 0) {
272 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
273 echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
278 <th
><?php
echo $strField; ?
></th
>
279 <th
><?php
echo $strType; ?
></th
>
281 if ($cfg['ShowFunctionFields']) {
282 $this_url_params = array_merge($url_params,
283 array('ShowFunctionFields' => 0));
284 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . $strHide . '">' . $strFunction . '</a></th>' . "\n";
287 <th
><?php
echo $strNull; ?
></th
>
288 <th
><?php
echo $strValue; ?
></th
>
292 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
294 unset($first_timestamp);
296 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
297 $m_rows = $o_rows +
1;
300 for ($i = 0; $i < $fields_cnt; $i++
) {
301 $row_table_def = $trow_table_def[$i];
302 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
304 $field = $row_table_def['Field'];
305 $field_html = htmlspecialchars($field);
306 $field_md5 = md5($field);
308 $unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field_html) . "', '" . PMA_escapeJsString($jsvkey) . "')\"";
309 $field_name_appendix = $vkey . '[' . $field_html . ']';
310 $field_name_appendix_md5 = $field_md5 . $vkey . '[]';
313 // removed previous PHP3-workaround that caused a problem with
314 // field names like '000'
315 //$rowfield = $field;
319 // loic1: current date should not be set as default if the field is NULL
320 // for the current row
321 // lem9: but do not put here the current datetime if there is a default
322 // value (the real default value will be set in the
323 // Default value logic below)
325 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
326 // $row_table_def['Default'] is not set if it contains NULL:
327 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime)
328 // but, look what we get if we switch to iso: (Default is NULL)
329 // Array ([Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime)
330 // so I force a NULL into it (I don't think it's possible
331 // to have an empty default value for DATETIME)
332 // then, the "if" after this one will work
333 if ($row_table_def['Type'] == 'datetime'
334 && !isset($row_table_def['Default'])
335 && isset($row_table_def['Null'])
336 && $row_table_def['Null'] == 'YES') {
337 $row_table_def['Default'] = null;
340 if ($row_table_def['Type'] == 'datetime'
341 && (!isset($row_table_def['Default']))
342 && (!is_null($row_table_def['Default']))) {
346 $vrow[$field] = date('Y-m-d H:i:s', time());
348 $vrow = array($field => date('Y-m-d H:i:s', time()));
351 // UPDATE case with an empty and not NULL value under PHP4
352 elseif (empty($vrow[$field]) && is_null($vrow[$field])) {
353 $vrow[$field] = date('Y-m-d H:i:s', time());
354 } // end if... elseif...
356 $len = (preg_match('@float|double@', $row_table_def['Type']))
358 : PMA_DBI_field_len($vresult, $i);
359 $first_timestamp = 0;
361 $field_name = $field_html;
362 if (isset($comments_map[$field])) {
363 $field_name = '<span style="border-bottom: 1px dashed black;" title="'
364 . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
368 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
369 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center"><?php
echo $field_name; ?
></td
>
373 $is_binary = stristr($row_table_def['Type'], 'binary');
374 $is_blob = stristr($row_table_def['Type'], 'blob');
375 $is_char = stristr($row_table_def['Type'], 'char');
376 switch ($row_table_def['True_Type']) {
386 if (!$timestamp_seen) { // can only occur once per table
388 $first_timestamp = 1;
390 $type = $row_table_def['Type'];
391 $type_nowrap = ' nowrap="nowrap"';
395 $type = $row_table_def['Type'];
396 $type_nowrap = ' nowrap="nowrap"';
400 <td align
="center"<?php
echo $type_nowrap; ?
>>
406 // Prepares the field value
407 $real_null_value = FALSE;
409 if (!isset($vrow[$field])
410 ||
(function_exists('is_null') && is_null($vrow[$field]))) {
411 $real_null_value = TRUE;
414 $data = $vrow[$field];
415 } elseif ($row_table_def['True_Type'] == 'bit') {
417 for ($j = 0; $j < ceil($len / 8); $j++
) {
418 $special_chars .= sprintf('%08d', decbin(ord(substr($vrow[$field], $j, 1))));
420 $special_chars = substr($special_chars, -$len);
422 // loic1: special binary "characters"
423 if ($is_binary ||
$is_blob) {
424 $vrow[$field] = str_replace("\x00", '\0', $vrow[$field]);
425 $vrow[$field] = str_replace("\x08", '\b', $vrow[$field]);
426 $vrow[$field] = str_replace("\x0a", '\n', $vrow[$field]);
427 $vrow[$field] = str_replace("\x0d", '\r', $vrow[$field]);
428 $vrow[$field] = str_replace("\x1a", '\Z', $vrow[$field]);
430 $special_chars = htmlspecialchars($vrow[$field]);
431 $data = $vrow[$field];
432 } // end if... else...
433 // loic1: if a timestamp field value is not included in an update
434 // statement MySQL auto-update it to the current timestamp
435 // lem9: however, things have changed since MySQL 4.1, so
436 // it's better to set a fields_prev in this situation
437 $backup_field = (PMA_MYSQL_INT_VERSION
< 40100 && $row_table_def['True_Type'] == 'timestamp')
439 : '<input type="hidden" name="fields_prev' . $field_name_appendix . '" value="' . htmlspecialchars($vrow[$field]) . '" />';
441 // loic1: display default values
442 if (!isset($row_table_def['Default'])) {
443 $row_table_def['Default'] = '';
444 $real_null_value = TRUE;
447 $data = $row_table_def['Default'];
449 $special_chars = htmlspecialchars($row_table_def['Default']);
453 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
454 $tabindex = (($idindex - 1) * 3) +
1;
456 // The function column
457 // -------------------
458 // Change by Bernard M. Piller <bernard@bmpsystems.com>
459 // We don't want binary data to be destroyed
460 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
461 // stored or retrieved" so it does not mean that the contents is
463 if ($cfg['ShowFunctionFields']) {
464 if (($cfg['ProtectBinary'] && $is_blob && !$is_upload)
465 ||
($cfg['ProtectBinary'] == 'all' && $is_binary)) {
466 echo ' <td align="center">' . $strBinary . '</td>' . "\n";
467 } elseif (strstr($row_table_def['True_Type'], 'enum') ||
strstr($row_table_def['True_Type'], 'set')) {
468 echo ' <td align="center">--</td>' . "\n";
472 <select name
="funcs<?php echo $field_name_appendix; ?>" <?php
echo $unnullify_trigger; ?
> tabindex
="<?php echo ($tabindex + $tabindex_for_function); ?>" id
="field_<?php echo $idindex; ?>_1">
477 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
478 // or something similar. Then directly look up the entry in the RestrictFunctions array,
479 // which will then reveal the available dropdown options
480 if (isset($cfg['RestrictFunctions'])
481 && isset($cfg['RestrictColumnTypes'])
482 && isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])])
483 && isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
484 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
485 $dropdown = $cfg['RestrictFunctions'][$current_func_type];
486 $default_function = $cfg['DefaultFunctions'][$current_func_type];
489 $default_function = '';
492 $dropdown_built = array();
493 $op_spacing_needed = FALSE;
494 // garvin: loop on the dropdown array and print all available options for that field.
495 $cnt_dropdown = count($dropdown);
496 for ($j = 0; $j < $cnt_dropdown; $j++
) {
497 // Is current function defined as default?
498 // For MySQL < 4.1.2, for the first timestamp we set as
499 // default function the one defined in config (which
501 // For MySQL >= 4.1.2, we don't set the default function
502 // if there is a default value for the timestamp
503 // (not including CURRENT_TIMESTAMP)
504 // and the column does not have the
505 // ON UPDATE DEFAULT TIMESTAMP attribute.
507 if (PMA_MYSQL_INT_VERSION
< 40102
508 ||
(PMA_MYSQL_INT_VERSION
>= 40102
509 && !($row_table_def['True_Type'] == 'timestamp'
510 && !empty($row_table_def['Default'])
511 && !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp'])))) {
512 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
513 ||
(!$first_timestamp && $dropdown[$j] == $default_function)
514 ?
' selected="selected"'
518 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
519 $dropdown_built[$dropdown[$j]] = 'TRUE';
520 $op_spacing_needed = TRUE;
523 // garvin: For compatibility's sake, do not let out all other functions. Instead
524 // print a separator (blank) and then show ALL functions which weren't shown
526 $cnt_functions = count($cfg['Functions']);
527 for ($j = 0; $j < $cnt_functions; $j++
) {
528 if (!isset($dropdown_built[$cfg['Functions'][$j]]) ||
$dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
529 // Is current function defined as default?
530 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
531 ||
(!$first_timestamp && $cfg['Functions'][$j] == $default_function)
532 ?
' selected="selected"'
534 if ($op_spacing_needed == TRUE) {
536 echo '<option value="">--------</option>' . "\n";
537 $op_spacing_needed = FALSE;
541 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
550 } // end if ($cfg['ShowFunctionFields'])
556 if ($row_table_def['Null'] == 'YES') {
557 echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
558 if ($real_null_value && !$first_timestamp) {
563 if (!(($cfg['ProtectBinary'] && $is_blob) ||
($cfg['ProtectBinary'] == 'all' && $is_binary))) {
565 echo ' <input type="checkbox" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
566 . ' name="fields_null' . $field_name_appendix . '"';
567 if ($real_null_value && !$first_timestamp) {
568 echo ' checked="checked"';
570 echo ' id="field_' . ($idindex) . '_2"';
571 $onclick = ' onclick="if (this.checked) {nullify(';
572 if (strstr($row_table_def['True_Type'], 'enum')) {
573 if (strlen($row_table_def['Type']) > 20) {
578 } elseif (strstr($row_table_def['True_Type'], 'set')) {
580 } elseif ($foreigners && isset($foreigners[$field])) {
585 $onclick .= '\'' . PMA_escapeJsString($field_html) . '\', \'' . $field_md5 . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n";
588 echo ' <input type="hidden" name="fields_null' . $field_name_appendix . '"';
589 if ($real_null_value && !$first_timestamp) {
595 echo ' </td>' . "\n";
597 // The value column (depends on type)
600 require './libraries/get_foreign.lib.php';
602 if (isset($foreign_link) && $foreign_link == true) {
605 <?php
echo $backup_field . "\n"; ?
>
606 <input type
="hidden" name
="fields_type<?php echo $field_name_appendix; ?>"
608 <input type
="hidden" name
="fields<?php echo $field_name_appendix; ?>"
609 value
="" id
="field_<?php echo ($idindex); ?>_1" />
610 <input type
="text" name
="field_<?php echo $field_name_appendix_md5; ?>"
611 class="textfield" <?php
echo $unnullify_trigger; ?
>
612 tabindex
="<?php echo ($tabindex + $tabindex_for_value); ?>"
613 id
="field_<?php echo ($idindex); ?>_3"
614 value
="<?php echo htmlspecialchars($data); ?>" />
615 <script type
="text/javascript">
617 document
.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes,resizable=yes\'); return false"');
618 document
.writeln(' href="browse_foreigners.php?');
619 document
.writeln('<?php echo PMA_generate_common_url($db, $table); ?>');
620 document
.writeln('&field=<?php echo PMA_escapeJsString(urlencode($field) . $browse_foreigners_uri); ?>">');
621 document
.writeln('<?php echo str_replace("'", "\'
", $titles['Browse']); ?></a>');
626 } elseif (isset($disp_row) && is_array($disp_row)) {
629 <?php echo $backup_field . "\n
"; ?>
630 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>"
632 <input type="hidden
" name="fields
<?php
echo $field_name_appendix; ?
>"
633 value="" id="field_
<?php
echo $idindex; ?
>_1
" />
634 <select name="field_
<?php
echo $field_name_appendix_md5; ?
>"
635 <?php echo $unnullify_trigger; ?>
636 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
637 id="field_
<?php
echo ($idindex); ?
>_3
">
638 <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
643 } elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
647 <tr class="<?php
echo $odd_row ?
'odd' : 'even'; ?
>">
648 <td colspan="5" align="right
">
649 <?php echo $backup_field . "\n
"; ?>
650 <textarea name="fields
<?php
echo $field_name_appendix; ?
>"
651 rows="<?php
echo ($cfg['TextareaRows']*2); ?
>"
652 cols="<?php
echo ($cfg['TextareaCols']*2); ?
>"
653 dir="<?php
echo $text_dir; ?
>"
654 id="field_
<?php
echo ($idindex); ?
>_3
"
655 <?php echo $unnullify_trigger; ?>
656 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
657 ><?php echo $special_chars; ?></textarea>
660 } elseif (strstr($type, 'text')) {
663 <?php echo $backup_field . "\n
"; ?>
664 <textarea name="fields
<?php
echo $field_name_appendix; ?
>"
665 rows="<?php
echo $cfg['TextareaRows']; ?
>"
666 cols="<?php
echo $cfg['TextareaCols']; ?
>"
667 dir="<?php
echo $text_dir; ?
>"
668 id="field_
<?php
echo ($idindex); ?
>_3
"
669 <?php echo $unnullify_trigger; ?>
670 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
671 ><?php echo $special_chars; ?></textarea>
675 if (strlen($special_chars) > 32000) {
676 echo ' <td>' . $strTextAreaLength . '</td>' . "\n
";
678 } elseif ($type == 'enum') {
679 $enum = PMA_getEnumSetOptions($row_table_def['Type']);
680 $enum_cnt = count($enum);
683 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>" value="enum
" />
684 <input type="hidden
" name="fields
<?php
echo $field_name_appendix; ?
>" value="" />
686 echo "\n
" . ' ' . $backup_field;
688 // show dropdown or radio depend on length
689 if (strlen($row_table_def['Type']) > 20) {
692 <select name="field_
<?php
echo $field_name_appendix_md5; ?
>"
693 <?php echo $unnullify_trigger; ?>
694 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
695 id="field_
<?php
echo ($idindex); ?
>_3
">
696 <option value=""></option>
700 for ($j = 0; $j < $enum_cnt; $j++) {
701 // Removes automatic MySQL escape format
702 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
704 //echo '<option value="' . htmlspecialchars($enum_atom) . '"';
705 echo '<option value="' . htmlspecialchars($enum_atom) . '"';
706 if ($data == $enum_atom
707 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
708 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
709 echo ' selected="selected
"';
711 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n
";
719 for ($j = 0; $j < $enum_cnt; $j++) {
720 // Removes automatic MySQL escape format
721 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
723 echo '<input type="radio
" name="field_
' . $field_name_appendix_md5 . '"';
724 echo ' value="' . htmlspecialchars($enum_atom) . '"';
725 echo ' id="field_
' . ($idindex) . '_3_
' . $j . '"';
727 echo "if (typeof(document.forms['insertForm
'].elements['fields_null
"
728 . $field_name_appendix . "']) != 'undefined
') {document.forms['insertForm
'].elements['fields_null
"
729 . $field_name_appendix . "'].checked = false}";
731 if ($data == $enum_atom
732 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
733 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
734 echo ' checked="checked
"';
736 echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
737 echo '<label for="field_
' . $idindex . '_3_
' . $j . '">'
738 . htmlspecialchars($enum_atom) . '</label>' . "\n
";
747 } elseif ($type == 'set') {
748 $set = PMA_getEnumSetOptions($row_table_def['Type']);
753 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
756 $countset = count($set);
757 $size = min(4, $countset);
760 <?php echo $backup_field . "\n
"; ?>
761 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>" value="set
" />
762 <input type="hidden
" name="fields
<?php
echo $field_name_appendix; ?
>" value="" />
763 <select name="field_
<?php
echo $field_name_appendix_md5; ?
>"
764 size="<?php
echo $size; ?
>"
765 multiple="multiple
" <?php echo $unnullify_trigger; ?>
766 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
767 id="field_
<?php
echo ($idindex); ?
>_3
">
770 for ($j = 0; $j < $countset; $j++) {
772 //echo '<option value="'. htmlspecialchars($set[$j]) . '"';
773 echo '<option value="'. htmlspecialchars($set[$j]) . '"';
774 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
775 echo ' selected="selected
"';
777 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n
";
784 // Change by Bernard M. Piller <bernard@bmpsystems.com>
785 // We don't want binary data destroyed
786 elseif ($is_binary || $is_blob) {
787 if (($cfg['ProtectBinary'] && $is_blob)
788 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
793 echo $strBinaryDoNotEdit;
795 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
796 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
801 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>" value="protected" />
802 <input type="hidden
" name="fields
<?php
echo $field_name_appendix; ?
>" value="" />
804 } elseif ($is_blob) {
808 <?php echo $backup_field . "\n
"; ?>
809 <textarea name="fields
<?php
echo $field_name_appendix; ?
>"
810 rows="<?php
echo $cfg['TextareaRows']; ?
>"
811 cols="<?php
echo $cfg['TextareaCols']; ?
>"
812 dir="<?php
echo $text_dir; ?
>"
813 id="field_
<?php
echo ($idindex); ?
>_3
"
814 <?php echo $unnullify_trigger; ?>
815 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
816 ><?php echo $special_chars; ?></textarea>
820 // field size should be at least 4 and max 40
821 $fieldsize = min(max($len, 4), 40);
825 <?php echo $backup_field . "\n
"; ?>
826 <input type="text
" name="fields
<?php
echo $field_name_appendix; ?
>"
827 value="<?php
echo $special_chars; ?
>" size="<?php
echo $fieldsize; ?
>"
828 class="textfield
" <?php echo $unnullify_trigger; ?>
829 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
830 id="field_
<?php
echo ($idindex); ?
>_3
" />
832 } // end if...elseif...else
834 // Upload choice (only for BLOBs because the binary
835 // attribute does not imply binary contents)
836 // (displayed whatever value the ProtectBinary has)
838 if ($is_upload && $is_blob) {
840 echo '<input type="file
" name="fields_upload_
' . $field_html . $vkey . '" class="textfield
" id="field_
' . $idindex . '_3
" size="10" /> ';
842 // find maximum upload size, based on field type
844 * @todo with functions this is not so easy, as you can basically
845 * process any data with function like MD5
847 $max_field_sizes = array(
850 'mediumblob' => '16777216',
851 'longblob' => '4294967296'); // yeah, really
853 $this_field_max_size = $max_upload_size; // from PHP max
854 if ($this_field_max_size > $max_field_sizes[$type]) {
855 $this_field_max_size = $max_field_sizes[$type];
857 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n
";
858 // do not generate here the MAX_FILE_SIZE, because we should
859 // put only one in the form to accommodate the biggest field
860 if ($this_field_max_size > $biggest_max_file_size) {
861 $biggest_max_file_size = $this_field_max_size;
865 if (!empty($cfg['UploadDir'])) {
866 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
867 if ($files === FALSE) {
868 echo ' <font color="red
">' . $strError . '</font><br />' . "\n
";
869 echo ' ' . $strWebServerUploadDirectoryError . "\n
";
870 } elseif (!empty($files)) {
872 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n
";
873 echo ' <select size="1" name="fields_uploadlocal_
' . $field_html . $vkey . '">' . "\n
";
874 echo ' <option value="" selected="selected
"></option>' . "\n
";
876 echo ' </select>' . "\n
";
878 } // end if (web-server upload directory)
882 } // end elseif (binary or blob)
884 // field size should be at least 4 and max 40
885 $fieldsize = min(max($len, 4), 40);
889 echo $backup_field . "\n
";
890 if ($is_char && ($cfg['CharEditing'] == 'textarea' || strpos($data, "\n
") !== FALSE)) {
893 <textarea name="fields
<?php
echo $field_name_appendix; ?
>"
894 rows="<?php
echo $cfg['CharTextareaRows']; ?
>"
895 cols="<?php
echo $cfg['CharTextareaCols']; ?
>"
896 dir="<?php
echo $text_dir; ?
>"
897 id="field_
<?php
echo ($idindex); ?
>_3
"
898 <?php echo $unnullify_trigger; ?>
899 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
900 ><?php echo $special_chars; ?></textarea>
904 <input type="text
" name="fields
<?php
echo $field_name_appendix; ?
>"
905 value="<?php
echo $special_chars; ?
>" size="<?php
echo $fieldsize; ?
>"
906 class="textfield
" <?php echo $unnullify_trigger; ?>
907 tabindex="<?php
echo ($tabindex +
$tabindex_for_value); ?
>"
908 id="field_
<?php
echo ($idindex); ?
>_3
" />
910 if ($row_table_def['Extra'] == 'auto_increment') {
912 <input type="hidden
" name="auto_increment
<?php
echo $field_name_appendix; ?
>" value="1" />
915 if (substr($type, 0, 9) == 'timestamp') {
917 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>" value="timestamp
" />
920 if ($row_table_def['True_Type'] == 'bit') {
922 <input type="hidden
" name="fields_type
<?php
echo $field_name_appendix; ?
>" value="bit
" />
925 if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
927 <script type="text
/javascript
">
929 document.write('<a title="<?php
echo $strCalendar;?
>"');
930 document.write(' 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); ?
>\')">');
931 document.write('<img class="calendar
"');
932 document.write(' src="<?php
echo $pmaThemeImage; ?
>b_calendar
.png
"');
933 document.write(' alt="<?php
echo $strCalendar; ?
>"/></a>');
946 $odd_row = !$odd_row;
951 <th colspan="5" align="right
" class="tblFooters
">
952 <input type="submit
" value="<?php
echo $strGo; ?
>" />
956 echo ' </table><br />';
957 } // end foreach on multi-edit
962 <table border="0" cellpadding="5" cellspacing="0">
964 <td valign="middle
" nowrap="nowrap
">
965 <select name="submit_type
" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
1); ?
>">
967 if (isset($primary_key)) {
969 <option value="<?php
echo $strSave; ?
>"><?php echo $strSave; ?></option>
973 <option value="<?php
echo $strInsertAsNewRow; ?
>"><?php echo $strInsertAsNewRow; ?></option>
978 if (!isset($after_insert)) {
979 $after_insert = 'back';
984 <b><?php echo $strAndThen; ?></b>
986 <td valign="middle
" nowrap="nowrap
">
987 <select name="after_insert
">
988 <option value="back
" <?php echo ($after_insert == 'back' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertBack; ?></option>
989 <option value="new_insert
" <?php echo ($after_insert == 'new_insert' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertNewInsert; ?></option>
991 if (isset($primary_key)) {
993 <option value="same_insert
" <?php echo ($after_insert == 'same_insert' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertSame; ?></option>
995 // If we have just numeric primary key, we can also edit next
996 // in 2.8.2, we were looking for `field_name` = numeric_value
997 //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
998 // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
999 if ($found_unique_key && preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $primary_key)) {
1001 <option value="edit_next
" <?php echo ($after_insert == 'edit_next' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertNext; ?></option>
1012 <?php echo PMA_showHint($strUseTabKey); ?>
1014 <td colspan="3" align="right
" valign="middle
">
1015 <input type="submit
" value="<?php
echo $strGo; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
6); ?
>" id="buttonYes
" />
1016 <input type="reset
" value="<?php
echo $strReset; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
7); ?
>" />
1021 <?php if ($biggest_max_file_size > 0) {
1022 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n
";
1028 <!-- Restart insertion form -->
1029 <form method="post
" action="tbl_replace
.php
" name="restartForm
" >
1030 <?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
1031 <input type="hidden
" name="goto" value="<?php
echo htmlspecialchars($goto); ?
>" />
1032 <input type="hidden
" name="err_url
" value="<?php
echo htmlspecialchars($err_url); ?
>" />
1033 <input type="hidden
" name="sql_query
" value="<?php
echo htmlspecialchars($sql_query); ?
>" />
1035 if (isset($primary_keys)) {
1036 foreach ($primary_key_array as $rowcount => $primary_key) {
1037 echo '<input type="hidden
" name="primary_key
[' . $rowcount . ']" value="' . htmlspecialchars(trim($primary_key)) . '" />'. "\n
";
1040 $tmp = '<select name="insert_rows
" id="insert_rows
" onchange="this
.form
.submit();" />' . "\n
";
1041 $option_values = array(1,2,5,10,15,20,30,40);
1042 foreach ($option_values as $value) {
1043 $tmp .= '<option value="' . $value . '"';
1044 if ($value == $cfg['InsertRows']) {
1045 $tmp .= ' selected="selected
"';
1047 $tmp .= '>' . $value . '</option>' . "\n
";
1049 $tmp .= '</select>' . "\n
";
1050 echo "\n
" . sprintf($strRestartInsertion, $tmp);
1052 echo '<noscript><input type="submit
" value="' . $strGo . '" /></noscript>' . "\n
";
1053 echo '</form>' . "\n
";
1057 * Displays the footer
1059 require_once './libraries/footer.inc.php';