3 // vim: expandtab sw=4 ts=4 sts=4:
6 * Gets the variables sent or posted to this script and displays the header
8 require_once './libraries/common.lib.php';
11 * Sets global variables.
12 * Here it's better to use a if, instead of the '?' operator
13 * to avoid setting a variable to '' when it's not present in $_REQUEST
15 if (isset($_REQUEST['pos'])) {
16 $pos = $_REQUEST['pos'];
18 if (isset($_REQUEST['session_max_rows'])) {
19 $session_max_rows = $_REQUEST['session_max_rows'];
21 if (isset($_REQUEST['disp_direction'])) {
22 $disp_direction = $_REQUEST['disp_direction'];
24 if (isset($_REQUEST['repeat_cells'])) {
25 $repeat_cells = $_REQUEST['repeat_cells'];
27 if (isset($_REQUEST['dontlimitchars'])) {
28 $dontlimitchars = $_REQUEST['dontlimitchars'];
30 if (isset($_REQUEST['primary_key'])) {
31 $primary_key = $_REQUEST['primary_key'];
33 if (isset($_REQUEST['sql_query'])) {
34 $sql_query = $_REQUEST['sql_query'];
36 if (isset($_REQUEST['ShowFunctionFields'])) {
37 $cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
41 $js_to_run = 'tbl_change.js';
42 require_once './libraries/header.inc.php';
43 require_once './libraries/relation.lib.php'; // foreign keys
44 require_once './libraries/file_listing.php'; // file listing
48 * Displays the query submitted and its result
50 if (!empty($disp_message)) {
53 $goto = 'tbl_sql.php?'
54 . PMA_generate_common_url($db, $table)
55 . '&$show_query=1'
56 . '&sql_query=' . (isset($disp_query) ?
urlencode($disp_query) : '');
60 if (isset($sql_query)) {
61 $sql_query_cpy = $sql_query;
64 if (isset($disp_query)) {
65 $sql_query = $disp_query;
67 PMA_showMessage($disp_message);
68 if (isset($goto_cpy)) {
72 if (isset($sql_query_cpy)) {
73 $sql_query = $sql_query_cpy;
74 unset($sql_query_cpy);
80 * Defines the url to return to in case of error in a sql statement
81 * (at this point, $goto might be set but empty)
87 * @todo check if we could replace by "db_|tbl_"
89 if (!preg_match('@^(db|tbl)_@', $goto)) {
90 $err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
92 $err_url = $goto . '?'
93 . PMA_generate_common_url($db)
94 . ((preg_match('@^(tbl_)@', $goto)) ?
'&table=' . urlencode($table) : '');
99 * Ensures db and table are valid, else moves to the "parent" script
101 require_once './libraries/db_table_exists.lib.php';
105 * Sets parameters for links
107 $url_query = PMA_generate_common_url($db, $table)
108 . '&goto=tbl_sql.php';
110 require_once './libraries/tbl_info.inc.php';
114 $comments_map = array();
116 if ($GLOBALS['cfg']['ShowPropertyComments']) {
117 require_once './libraries/relation.lib.php';
118 require_once './libraries/transformations.lib.php';
120 $cfgRelation = PMA_getRelationsParam();
122 if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION
>= 40100) {
123 $comments_map = PMA_getComments($db, $table);
128 * Displays top menu links
130 require_once './libraries/tbl_links.inc.php';
134 * Get the analysis of SHOW CREATE TABLE for this table
136 $show_create_table = PMA_DBI_fetch_value(
137 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
139 $analyzed_sql = PMA_SQP_analyze( PMA_SQP_parse( $show_create_table ) );
140 unset($show_create_table);
143 * Get the list of the fields of the current table
145 PMA_DBI_select_db($db);
146 $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE
);
147 if (isset($primary_key)) {
148 if (is_array($primary_key)) {
149 $primary_key_array = $primary_key;
151 $primary_key_array = array(0 => $primary_key);
156 foreach ($primary_key_array AS $rowcount => $primary_key) {
157 $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
158 $result[$rowcount] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE
);
159 $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
160 $primary_keys[$rowcount] = $primary_key;
163 if (!$row[$rowcount]) {
164 unset($row[$rowcount]);
165 unset($primary_key_array[$rowcount]);
167 $goto = 'tbl_sql.php?'
168 . PMA_generate_common_url($db, $table)
169 . '&$show_query=1'
170 . '&sql_query=' . urlencode($local_query);
171 if (isset($sql_query)) {
172 $sql_query_cpy = $sql_query;
175 $sql_query = $local_query;
176 PMA_showMessage($strEmptyResultSet);
179 if (isset($sql_query_cpy)) {
180 $sql_query = $sql_query_cpy;
181 unset($sql_query_cpy);
184 require_once './libraries/footer.inc.php';
185 } // end if (no record returned)
188 $result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE
);
193 // retrieve keys into foreign fields, if any
194 $cfgRelation = PMA_getRelationsParam();
195 $foreigners = ($cfgRelation['relwork'] ?
PMA_getForeigners($db, $table) : FALSE);
201 // loic1: autocomplete feature of IE kills the "onchange" event handler and it
202 // must be replaced by the "onpropertychange" one in this case
203 $chg_evt_handler = (PMA_USR_BROWSER_AGENT
== 'IE' && PMA_USR_BROWSER_VER
>= 5)
206 // Had to put the URI because when hosted on an https server,
207 // some browsers send wrongly this form to the http server.
210 <?php
if ($cfg['CtrlArrowsMoving']) { ?
>
211 <!-- Set on key handler
for moving using by Ctrl+arrows
-->
212 <script src
="./js/keyhandler.js" type
="text/javascript" language
="javascript"></script
>
213 <script type
="text/javascript" language
="javascript">
215 var switch_movement
= 0;
216 document
.onkeydown
= onKeyDownArrowsHandler
;
221 <!-- Change table properties form
-->
222 <form method
="post" action
="tbl_replace.php" name
="insertForm" <?php
if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?
>>
223 <?php
echo PMA_generate_common_hidden_inputs($db, $table); ?
>
224 <input type
="hidden" name
="goto" value
="<?php echo urlencode($goto); ?>" />
225 <input type
="hidden" name
="pos" value
="<?php echo isset($pos) ? $pos : 0; ?>" />
226 <input type
="hidden" name
="session_max_rows" value
="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
227 <input type
="hidden" name
="disp_direction" value
="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
228 <input type
="hidden" name
="repeat_cells" value
="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
229 <input type
="hidden" name
="dontlimitchars" value
="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
230 <input type
="hidden" name
="err_url" value
="<?php echo urlencode($err_url); ?>" />
231 <input type
="hidden" name
="sql_query" value
="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
233 if (isset($primary_key_array)) {
234 foreach ($primary_key_array AS $primary_key) {
236 <input type
="hidden" name
="primary_key[]" value
="<?php echo urlencode($primary_key); ?>" />
242 if ($cfg['PropertiesIconic'] == true) {
243 // We need to copy the value or else the == 'both' check will always return true
244 $propicon = (string)$cfg['PropertiesIconic'];
246 if ($propicon == 'both') {
247 $iconic_spacer = '<div class="nowrap">';
252 $titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
254 if ($propicon == 'both') {
255 $titles['Browse'] .= ' ' . $strBrowseForeignValues . '</div>';
258 $titles['Browse'] = $strBrowseForeignValues;
261 // Set if we passed the first timestamp field
263 $fields_cnt = PMA_DBI_num_rows($table_def);
265 // Set a flag here because the 'if' would not be valid in the loop
266 // if we set a value in some field
267 $insert_mode = (!isset($row) ?
TRUE : FALSE);
269 $loop_array = array();
270 for ($i = 0; $i < $cfg['InsertRows']; $i++
) {
271 $loop_array[] = FALSE;
277 while ($trow = PMA_DBI_fetch_assoc($table_def)) {
278 $trow_table_def[] = $trow;
282 $tabindex_for_function = +
1000;
283 $tabindex_for_null = +
2000;
284 $tabindex_for_value = 0;
286 $biggest_max_file_size = 0;
288 // user can toggle the display of Function column
289 // (currently does not work for multi-edits)
290 $url_params['db'] = $db;
291 $url_params['table'] = $table;
292 if (isset($primary_key)) {
293 $url_params['primary_key'] = $primary_key;
295 if (isset($sql_query)) {
296 $url_params['sql_query'] = $sql_query;
299 if (! $cfg['ShowFunctionFields']) {
300 $this_url_params = array_merge($url_params,
301 array('ShowFunctionFields' => 1));
302 echo $strShow . ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . $strFunction . '</a>' . "\n";
305 foreach ($loop_array AS $vrowcount => $vrow) {
306 if ($vrow === FALSE) {
311 $jsvkey = $vrowcount;
312 $browse_foreigners_uri = '&pk=' . $vrowcount;
314 $jsvkey = urlencode($primary_keys[$vrowcount]);
315 $browse_foreigners_uri = '&pk=' . urlencode($primary_keys[$vrowcount]);
317 $vkey = '[multi_edit][' . $jsvkey . ']';
319 $vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ?
$result[$vrowcount] : $result);
320 if ($insert_mode && $vrowcount > 0) {
321 echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
322 echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
327 <th
><?php
echo $strField; ?
></th
>
328 <th
><?php
echo $strType; ?
></th
>
330 if ($cfg['ShowFunctionFields']) {
331 $this_url_params = array_merge($url_params,
332 array('ShowFunctionFields' => 0));
333 echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . $strHide . '">' . $strFunction . '</a></th>' . "\n";
336 <th
><?php
echo $strNull; ?
></th
>
337 <th
><?php
echo $strValue; ?
></th
>
341 // garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
343 unset($first_timestamp);
345 // Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
346 $m_rows = $o_rows +
1;
349 for ($i = 0; $i < $fields_cnt; $i++
) {
350 // Display the submit button after every 15 lines --swix
351 // (wanted to use an <a href="#bottom"> and <a name> instead,
352 // but it didn't worked because of the <base href>)
354 if ((($o_rows * $fields_cnt +
$i) %
15 == 0) && ($i +
$o_rows != 0)) {
357 <th colspan
="5" align
="right" class="tblFooters">
358 <input type
="submit" value
="<?php echo $strGo; ?>" /> 
;
365 $row_table_def = $trow_table_def[$i];
366 $row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
368 $field = $row_table_def['Field'];
370 // removed previous PHP3-workaround that caused a problem with
371 // field names like '000'
376 // loic1: current date should not be set as default if the field is NULL
377 // for the current row
378 // lem9: but do not put here the current datetime if there is a default
379 // value (the real default value will be set in the
380 // Default value logic below)
382 // Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
383 // $row_table_def['Default'] is not set if it contains NULL:
384 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime )
385 // but, look what we get if we switch to iso: (Default is NULL)
386 // Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime )
387 // so I force a NULL into it (I don't think it's possible
388 // to have an empty default value for DATETIME)
389 // then, the "if" after this one will work
390 if ($row_table_def['Type'] == 'datetime'
391 && !isset($row_table_def['Default'])
392 && isset($row_table_def['Null'])
393 && $row_table_def['Null'] == 'YES') {
394 $row_table_def['Default'] = null;
397 if ($row_table_def['Type'] == 'datetime'
398 && (!isset($row_table_def['Default']))
399 && (!is_null($row_table_def['Default']))) {
403 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
405 $vrow = array($rowfield => date('Y-m-d H:i:s', time()));
408 // UPDATE case with an empty and not NULL value under PHP4
409 elseif (empty($vrow[$rowfield]) && is_null($vrow[$rowfield])) {
410 $vrow[$rowfield] = date('Y-m-d H:i:s', time());
411 } // end if... elseif...
413 $len = (preg_match('@float|double@', $row_table_def['Type']))
415 : PMA_DBI_field_len($vresult, $i);
416 $first_timestamp = 0;
418 $field_name = htmlspecialchars($field);
419 if (isset($comments_map[$field])) {
420 $field_name = '<span style="border-bottom: 1px dashed black;" title="' . htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
424 <tr
class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
425 <td
<?php
echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ?
'rowspan="2"' : ''); ?
> align
="center"><?php
echo $field_name; ?
></td
>
429 $is_binary = stristr($row_table_def['Type'], ' binary');
430 $is_blob = stristr($row_table_def['Type'], 'blob');
431 $is_char = stristr($row_table_def['Type'], 'char');
432 switch ($row_table_def['True_Type']) {
442 if (!$timestamp_seen) { // can only occur once per table
444 $first_timestamp = 1;
446 $type = $row_table_def['Type'];
447 $type_nowrap = ' nowrap="nowrap"';
451 $type = $row_table_def['Type'];
452 $type_nowrap = ' nowrap="nowrap"';
456 <td align
="center"<?php
echo $type_nowrap; ?
>>
462 // Prepares the field value
463 $real_null_value = FALSE;
465 if (!isset($vrow[$rowfield])
466 ||
(function_exists('is_null') && is_null($vrow[$rowfield]))) {
467 $real_null_value = TRUE;
468 $vrow[$rowfield] = '';
470 $data = $vrow[$rowfield];
472 // loic1: special binary "characters"
473 if ($is_binary ||
$is_blob) {
474 $vrow[$rowfield] = str_replace("\x00", '\0', $vrow[$rowfield]);
475 $vrow[$rowfield] = str_replace("\x08", '\b', $vrow[$rowfield]);
476 $vrow[$rowfield] = str_replace("\x0a", '\n', $vrow[$rowfield]);
477 $vrow[$rowfield] = str_replace("\x0d", '\r', $vrow[$rowfield]);
478 $vrow[$rowfield] = str_replace("\x1a", '\Z', $vrow[$rowfield]);
480 $special_chars = htmlspecialchars($vrow[$rowfield]);
481 $data = $vrow[$rowfield];
482 } // end if... else...
483 // loic1: if a timestamp field value is not included in an update
484 // statement MySQL auto-update it to the current timestamp
485 // lem9: however, things have changed since MySQL 4.1, so
486 // it's better to set a fields_prev in this situation
487 $backup_field = (PMA_MYSQL_INT_VERSION
< 40100 && $row_table_def['True_Type'] == 'timestamp')
489 : '<input type="hidden" name="fields_prev' . $vkey . '[' . urlencode($field) . ']" value="' . urlencode($vrow[$rowfield]) . '" />';
491 // loic1: display default values
492 if (!isset($row_table_def['Default'])) {
493 $row_table_def['Default'] = '';
494 $real_null_value = TRUE;
497 $data = $row_table_def['Default'];
499 $special_chars = htmlspecialchars($row_table_def['Default']);
503 $idindex = ($o_rows * $fields_cnt) +
$i +
1;
504 $tabindex = (($idindex - 1) * 3) +
1;
506 // The function column
507 // -------------------
508 // Change by Bernard M. Piller <bernard@bmpsystems.com>
509 // We don't want binary data to be destroyed
510 // Note: from the MySQL manual: "BINARY doesn't affect how the column is
511 // stored or retrieved" so it does not mean that the contents is
513 if ($cfg['ShowFunctionFields']) {
514 if (($cfg['ProtectBinary'] && $is_blob && !$is_upload)
515 ||
($cfg['ProtectBinary'] == 'all' && $is_binary)) {
516 echo ' <td align="center">' . $strBinary . '</td>' . "\n";
517 } elseif (strstr($row_table_def['True_Type'], 'enum') ||
strstr($row_table_def['True_Type'], 'set')) {
518 echo ' <td align="center">--</td>' . "\n";
522 <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">
527 // garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
528 // or something similar. Then directly look up the entry in the RestrictFunctions array,
529 // which will then reveal the available dropdown options
530 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'])]])) {
531 $current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
532 $dropdown = $cfg['RestrictFunctions'][$current_func_type];
533 $default_function = $cfg['DefaultFunctions'][$current_func_type];
536 $default_function = '';
539 $dropdown_built = array();
540 $op_spacing_needed = FALSE;
541 // garvin: loop on the dropdown array and print all available options for that field.
542 $cnt_dropdown = count($dropdown);
543 for ($j = 0; $j < $cnt_dropdown; $j++
) {
544 // Is current function defined as default?
545 // For MySQL < 4.1.2, for the first timestamp we set as
546 // default function the one defined in config (which
547 // should be NOW() ).
548 // For MySQL >= 4.1.2, we don't set the default function
549 // if there is a default value for the timestamp
550 // (not including CURRENT_TIMESTAMP)
551 // and the column does not have the
552 // ON UPDATE DEFAULT TIMESTAMP attribute.
554 if (PMA_MYSQL_INT_VERSION
< 40102
555 ||
(PMA_MYSQL_INT_VERSION
>= 40102
556 && !($row_table_def['True_Type'] == 'timestamp' && !empty($row_table_def['Default']) && !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp'])))) {
557 $selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
558 ||
(!$first_timestamp && $dropdown[$j] == $default_function)
559 ?
' selected="selected"'
563 echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
564 $dropdown_built[$dropdown[$j]] = 'TRUE';
565 $op_spacing_needed = TRUE;
568 // garvin: For compatibility's sake, do not let out all other functions. Instead
569 // print a separator (blank) and then show ALL functions which weren't shown
571 $cnt_functions = count($cfg['Functions']);
572 for ($j = 0; $j < $cnt_functions; $j++
) {
573 if (!isset($dropdown_built[$cfg['Functions'][$j]]) ||
$dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
574 // Is current function defined as default?
575 $selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
576 ||
(!$first_timestamp && $cfg['Functions'][$j] == $default_function)
577 ?
' selected="selected"'
579 if ($op_spacing_needed == TRUE) {
581 echo '<option value="">--------</option>' . "\n";
582 $op_spacing_needed = FALSE;
586 echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
595 } // end if ($cfg['ShowFunctionFields'])
601 if ($row_table_def['Null'] == 'YES') {
602 echo ' <input type="hidden" name="fields_null_prev' . $vkey . '[' . urlencode($field) . ']"';
603 if ($real_null_value && !$first_timestamp) {
608 if (!(($cfg['ProtectBinary'] && $is_blob) ||
($cfg['ProtectBinary'] == 'all' && $is_binary)) ) {
610 echo ' <input type="checkbox" tabindex="' . ($tabindex +
$tabindex_for_null) . '"'
611 . ' name="fields_null' . $vkey . '[' . urlencode($field) . ']"';
612 if ($real_null_value && !$first_timestamp) {
613 echo ' checked="checked"';
615 echo ' id="field_' . ($idindex) . '_2"';
616 $onclick = ' onclick="if (this.checked) {nullify(';
617 if (strstr($row_table_def['True_Type'], 'enum')) {
618 if (strlen($row_table_def['Type']) > 20) {
623 } elseif (strstr($row_table_def['True_Type'], 'set')) {
625 } elseif ($foreigners && isset($foreigners[$field])) {
630 $onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\', \'' . $vkey . '\'); this.checked = true}; return true" />' . "\n";
633 echo ' <input type="hidden" name="fields_null' . $vkey . '[' . urlencode($field) . ']"';
634 if ($real_null_value && !$first_timestamp) {
640 echo ' </td>' . "\n";
642 // The value column (depends on type)
645 require './libraries/get_foreign.lib.php';
647 if (isset($foreign_link) && $foreign_link == true) {
650 <?php
echo $backup_field . "\n"; ?
>
651 <input type
="hidden" name
="fields_type<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="foreign" />
652 <input type
="hidden" name
="fields<?php echo $vkey; ?>[<?php echo urlencode($field); ?>]" value
="" id
="field_<?php echo ($idindex); ?>_1" />
653 <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); ?>" />
654 <script type
="text/javascript" language
="javascript">
656 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); ?>&field=<?php echo urlencode($field) . $browse_foreigners_uri; ?>"><?php echo str_replace("'", "\'
", $titles['Browse']); ?></a>');
661 } elseif (isset($disp_row) && is_array($disp_row)) {
664 <?php echo $backup_field . "\n
"; ?>
665 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="foreign
" />
666 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" id="field_
<?php
echo $idindex; ?
>_1
" />
667 <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
">
668 <?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
673 } elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
677 <tr class="<?php
echo $odd_row ?
'odd' : 'even'; ?
>">
678 <td colspan="5" align="right
">
679 <?php echo $backup_field . "\n
"; ?>
680 <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
"
681 <?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>
684 } elseif (strstr($type, 'text')) {
687 <?php echo $backup_field . "\n
"; ?>
688 <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
"
689 <?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>
693 if (strlen($special_chars) > 32000) {
694 echo ' <td>' . $strTextAreaLength . '</td>' . "\n
";
696 } elseif ($type == 'enum') {
697 $enum = PMA_getEnumSetOptions($row_table_def['Type']);
698 $enum_cnt = count($enum);
701 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="enum
" />
702 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
704 echo "\n
" . ' ' . $backup_field;
706 // show dropdown or radio depend on length
707 if (strlen($row_table_def['Type']) > 20) {
710 <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
">
711 <option value=""></option>
715 for ($j = 0; $j < $enum_cnt; $j++) {
716 // Removes automatic MySQL escape format
717 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
719 //echo '<option value="' . htmlspecialchars($enum_atom) . '"';
720 echo '<option value="' . urlencode($enum_atom) . '"';
721 if ($data == $enum_atom
722 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
723 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
724 echo ' selected="selected
"';
726 echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n
";
734 for ($j = 0; $j < $enum_cnt; $j++) {
735 // Removes automatic MySQL escape format
736 $enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
738 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}"';
739 if ($data == $enum_atom
740 || ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
741 && isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
742 echo ' checked="checked
"';
744 echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
745 echo '<label for="field_
' . $idindex . '_3_
' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n
";
754 } elseif ($type == 'set') {
755 $set = PMA_getEnumSetOptions($row_table_def['Type']);
760 for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
763 $countset = count($set);
764 $size = min(4, $countset);
767 <?php echo $backup_field . "\n
"; ?>
768 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="set
" />
769 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
770 <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
">
773 for ($j = 0; $j < $countset; $j++) {
775 //echo '<option value="'. htmlspecialchars($set[$j]) . '"';
776 echo '<option value="'. urlencode($set[$j]) . '"';
777 if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
778 echo ' selected="selected
"';
780 echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n
";
787 // Change by Bernard M. Piller <bernard@bmpsystems.com>
788 // We don't want binary data destroyed
789 elseif ($is_binary || $is_blob) {
790 if (($cfg['ProtectBinary'] && $is_blob)
791 || ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
796 echo $strBinaryDoNotEdit;
798 $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
799 echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
804 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="protected" />
805 <input type="hidden
" name="fields
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="" />
807 } elseif ($is_blob) {
811 <?php echo $backup_field . "\n
"; ?>
812 <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
"
813 <?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>
818 $fieldsize = $maxlength = 4;
820 $fieldsize = (($len > 40) ? 40 : $len);
826 <?php echo $backup_field . "\n
"; ?>
827 <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
" />
829 } // end if...elseif...else
831 // Upload choice (only for BLOBs because the binary
832 // attribute does not imply binary contents)
833 // (displayed whatever value the ProtectBinary has)
835 if ($is_upload && $is_blob) {
837 echo '<input type="file
" name="fields_upload_
' . urlencode($field) . $vkey . '" class="textfield
" id="field_
' . ($idindex) . '_3
" size="10" /> ';
839 // find maximum upload size, based on field type
841 * @todo with functions this is not so easy, as you can basically
842 * process any data with function like MD5
844 $max_field_sizes = array(
847 'mediumblob' => '16777216',
848 'longblob' => '4294967296'); // yeah, really
850 $this_field_max_size = $max_upload_size; // from PHP max
851 if ($this_field_max_size > $max_field_sizes[$type]) {
852 $this_field_max_size = $max_field_sizes[$type];
854 echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n
";
855 // do not generate here the MAX_FILE_SIZE, because we should
856 // put only one in the form to accommodate the biggest field
857 if ($this_field_max_size > $biggest_max_file_size) {
858 $biggest_max_file_size = $this_field_max_size;
862 if (!empty($cfg['UploadDir'])) {
863 $files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
864 if ($files === FALSE) {
865 echo ' <font color="red
">' . $strError . '</font><br />' . "\n
";
866 echo ' ' . $strWebServerUploadDirectoryError . "\n
";
867 } elseif (!empty($files)) {
869 echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n
";
870 echo ' <select size="1" name="fields_uploadlocal_
' . urlencode($field) . $vkey . '">' . "\n
";
871 echo ' <option value="" selected="selected
"></option>' . "\n
";
873 echo ' </select>' . "\n
";
875 } // end if (web-server upload directory)
879 } // end elseif ( binary or blob)
881 // For char or varchar, respect the maximum length (M); for other
882 // types (int or float), the length is not a limit on the values that
883 // can be entered, so let's be generous (20) (we could also use the
884 // real limits for each numeric type)
885 // 2004-04-07, it turned out that 20 was not generous enough
888 $fieldsize = (($len > 40) ? 40 : $len);
893 } // end if... else...
897 echo $backup_field . "\n
";
898 if ($is_char && ($cfg['CharEditing'] == 'textarea' || strpos($data, "\n
") !== FALSE)) {
901 <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
"
902 <?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>
906 <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
" />
908 if ($row_table_def['Extra'] == 'auto_increment') {
910 <input type="hidden
" name="auto_increment
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="1" />
913 if (substr($type, 0, 9) == 'timestamp') {
915 <input type="hidden
" name="fields_type
<?php
echo $vkey; ?
>[<?php
echo urlencode($field); ?
>]" value="timestamp
" />
918 if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
920 <script type="text
/javascript
" language="javascript
">
922 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>');
935 $odd_row = !$odd_row;
938 echo ' </table><br />';
939 } // end foreach on multi-edit
943 <table border="0" cellpadding="5" cellspacing="0">
945 <td valign="middle
" nowrap="nowrap
">
946 <select name="submit_type
" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
1); ?
>">
948 if (isset($primary_key)) {
950 <option value="<?php
echo $strSave; ?
>"><?php echo $strSave; ?></option>
954 <option value="<?php
echo $strInsertAsNewRow; ?
>"><?php echo $strInsertAsNewRow; ?></option>
959 if (!isset($after_insert)) {
960 $after_insert = 'back';
965 <b><?php echo $strAndThen; ?></b>
967 <td valign="middle
" nowrap="nowrap
">
968 <select name="after_insert
">
969 <option value="back
" <?php echo ($after_insert == 'back' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertBack; ?></option>
970 <option value="new_insert
" <?php echo ($after_insert == 'new_insert' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertNewInsert; ?></option>
972 if (isset($primary_key)) {
974 <option value="same_insert
" <?php echo ($after_insert == 'same_insert' ? 'selected="selected
"' : ''); ?>><?php echo $strAfterInsertSame; ?></option>
976 // If we have just numeric primary key, we can also edit next
977 // in 2.8.2, we were looking for `field_name` = numeric_value
978 //if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
979 // in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
980 if (preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $primary_key)) {
982 <option value="edit_next
"><?php echo $strAfterInsertNext; ?></option>
993 <?php echo PMA_showHint($strUseTabKey); ?>
995 <td colspan="3" align="right
" valign="middle
">
996 <input type="submit
" value="<?php
echo $strGo; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
6); ?
>" id="buttonYes
" />
997 <input type="reset
" value="<?php
echo $strReset; ?
>" tabindex="<?php
echo ($tabindex +
$tabindex_for_value +
7); ?
>" />
1001 <?php if ($biggest_max_file_size > 0) {
1002 echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n
";
1009 * Displays the footer
1011 require_once './libraries/footer.inc.php';