3
* vim: expandtab sw=4 ts=4 sts=4:
4
* @version $Id: tbl_change.php 10144 2007-03-20 11:22:31Z cybot_tm $
8
* Gets the variables sent or posted to this script and displays the header
10
require_once './libraries/common.lib.php';
13
* Sets global variables.
14
* Here it's better to use a if, instead of the '?' operator
15
* to avoid setting a variable to '' when it's not present in $_REQUEST
17
if (isset($_REQUEST['pos'])) {
18
$pos = $_REQUEST['pos'];
20
if (isset($_REQUEST['session_max_rows'])) {
21
$session_max_rows = $_REQUEST['session_max_rows'];
23
if (isset($_REQUEST['disp_direction'])) {
24
$disp_direction = $_REQUEST['disp_direction'];
26
if (isset($_REQUEST['repeat_cells'])) {
27
$repeat_cells = $_REQUEST['repeat_cells'];
29
if (isset($_REQUEST['dontlimitchars'])) {
30
$dontlimitchars = $_REQUEST['dontlimitchars'];
32
if (isset($_REQUEST['primary_key'])) {
33
$primary_key = $_REQUEST['primary_key'];
35
if (isset($_REQUEST['sql_query'])) {
36
$sql_query = $_REQUEST['sql_query'];
38
if (isset($_REQUEST['ShowFunctionFields'])) {
39
$cfg['ShowFunctionFields'] = $_REQUEST['ShowFunctionFields'];
43
$js_to_run = 'tbl_change.js';
44
require_once './libraries/header.inc.php';
45
require_once './libraries/relation.lib.php'; // foreign keys
46
require_once './libraries/file_listing.php'; // file listing
50
* Displays the query submitted and its result
52
if (! empty($disp_message)) {
53
if (! isset($disp_query)) {
56
PMA_showMessage($disp_message, $disp_query);
61
* Defines the url to return to in case of error in a sql statement
62
* (at this point, $goto might be set but empty)
68
* @todo check if we could replace by "db_|tbl_"
70
if (!preg_match('@^(db|tbl)_@', $goto)) {
71
$err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
73
$err_url = $goto . '?'
74
. PMA_generate_common_url($db)
75
. ((preg_match('@^(tbl_)@', $goto)) ? '&table=' . urlencode($table) : '');
80
* Ensures db and table are valid, else moves to the "parent" script
82
require_once './libraries/db_table_exists.lib.php';
86
* Sets parameters for links
88
$url_query = PMA_generate_common_url($db, $table)
89
. '&goto=tbl_sql.php';
91
require_once './libraries/tbl_info.inc.php';
95
$comments_map = array();
97
if ($GLOBALS['cfg']['ShowPropertyComments']) {
98
require_once './libraries/relation.lib.php';
99
require_once './libraries/transformations.lib.php';
101
$cfgRelation = PMA_getRelationsParam();
103
if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
104
$comments_map = PMA_getComments($db, $table);
109
* Displays top menu links
111
require_once './libraries/tbl_links.inc.php';
115
* Get the analysis of SHOW CREATE TABLE for this table
117
$show_create_table = PMA_DBI_fetch_value(
118
'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table),
120
$analyzed_sql = PMA_SQP_analyze( PMA_SQP_parse( $show_create_table ) );
121
unset($show_create_table);
124
* Get the list of the fields of the current table
126
PMA_DBI_select_db($db);
127
$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', null, PMA_DBI_QUERY_STORE);
128
if (isset($primary_key)) {
129
if (is_array($primary_key)) {
130
$primary_key_array = $primary_key;
132
$primary_key_array = array(0 => $primary_key);
137
foreach ($primary_key_array as $rowcount => $primary_key) {
138
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
139
$result[$rowcount] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
140
$row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
141
$primary_keys[$rowcount] = str_replace('\\', '\\\\', $primary_key);
144
if (!$row[$rowcount]) {
145
unset($row[$rowcount], $primary_key_array[$rowcount]);
146
PMA_showMessage($strEmptyResultSet, $local_query);
148
require_once './libraries/footer.inc.php';
149
} // end if (no record returned)
152
$result = PMA_DBI_query('SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;', null, PMA_DBI_QUERY_STORE);
157
// retrieve keys into foreign fields, if any
158
$cfgRelation = PMA_getRelationsParam();
159
$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
165
// loic1: autocomplete feature of IE kills the "onchange" event handler and it
166
// must be replaced by the "onpropertychange" one in this case
167
$chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
170
// Had to put the URI because when hosted on an https server,
171
// some browsers send wrongly this form to the http server.
174
<?php if ($cfg['CtrlArrowsMoving']) { ?>
175
<!-- Set on key handler for moving using by Ctrl+arrows -->
176
<script src="./js/keyhandler.js" type="text/javascript" language="javascript"></script>
177
<script type="text/javascript" language="javascript">
179
var switch_movement = 0;
180
document.onkeydown = onKeyDownArrowsHandler;
185
<!-- Change table properties form -->
186
<form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) { echo ' enctype="multipart/form-data"'; } ?>>
187
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
188
<input type="hidden" name="goto" value="<?php echo htmlspecialchars($goto); ?>" />
189
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
190
<input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
191
<input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
192
<input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
193
<input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
194
<input type="hidden" name="err_url" value="<?php echo htmlspecialchars($err_url); ?>" />
195
<input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? htmlspecialchars($sql_query) : ''; ?>" />
197
if (isset($primary_key_array)) {
198
foreach ($primary_key_array as $primary_key) {
200
<input type="hidden" name="primary_key[]" value="<?php echo htmlspecialchars(trim($primary_key)); ?>" />
206
if ($cfg['PropertiesIconic'] == true) {
207
// We need to copy the value or else the == 'both' check will always return true
208
$propicon = (string)$cfg['PropertiesIconic'];
210
if ($propicon == 'both') {
211
$iconic_spacer = '<div class="nowrap">';
216
$titles['Browse'] = $iconic_spacer . '<img width="16" height="16" src="' . $pmaThemeImage . 'b_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
218
if ($propicon == 'both') {
219
$titles['Browse'] .= ' ' . $strBrowseForeignValues . '</div>';
222
$titles['Browse'] = $strBrowseForeignValues;
225
// Set if we passed the first timestamp field
227
$fields_cnt = PMA_DBI_num_rows($table_def);
229
// Set a flag here because the 'if' would not be valid in the loop
230
// if we set a value in some field
231
$insert_mode = (!isset($row) ? TRUE : FALSE);
233
$loop_array = array();
234
for ($i = 0; $i < $cfg['InsertRows']; $i++) {
235
$loop_array[] = FALSE;
241
while ($trow = PMA_DBI_fetch_assoc($table_def)) {
242
$trow_table_def[] = $trow;
246
$tabindex_for_function = +1000;
247
$tabindex_for_null = +2000;
248
$tabindex_for_value = 0;
250
$biggest_max_file_size = 0;
252
// user can toggle the display of Function column
253
// (currently does not work for multi-edits)
254
$url_params['db'] = $db;
255
$url_params['table'] = $table;
256
if (isset($primary_key)) {
257
$url_params['primary_key'] = trim($primary_key);
259
if (isset($sql_query)) {
260
$url_params['sql_query'] = $sql_query;
263
if (! $cfg['ShowFunctionFields']) {
264
$this_url_params = array_merge($url_params,
265
array('ShowFunctionFields' => 1));
266
echo $strShow . ' : <a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '">' . $strFunction . '</a>' . "\n";
269
foreach ($loop_array as $vrowcount => $vrow) {
270
if ($vrow === FALSE) {
275
$jsvkey = $vrowcount;
276
$browse_foreigners_uri = '&pk=' . $vrowcount;
278
$jsvkey = htmlspecialchars(trim($primary_keys[$vrowcount]));
279
$browse_foreigners_uri = '&pk=' . urlencode(trim($primary_keys[$vrowcount]));
281
$vkey = '[multi_edit][' . $jsvkey . ']';
283
$vresult = (isset($result) && is_array($result) && isset($result[$vrowcount]) ? $result[$vrowcount] : $result);
284
if ($insert_mode && $vrowcount > 0) {
285
echo '<input type="checkbox" checked="checked" name="insert_ignore_' . $vrowcount . '" id="insert_ignore_check_' . $vrowcount . '" />';
286
echo '<label for="insert_ignore_check_' . $vrowcount . '">' . $strIgnore . '</label><br />' . "\n";
291
<th><?php echo $strField; ?></th>
292
<th><?php echo $strType; ?></th>
294
if ($cfg['ShowFunctionFields']) {
295
$this_url_params = array_merge($url_params,
296
array('ShowFunctionFields' => 0));
297
echo ' <th><a href="tbl_change.php' . PMA_generate_common_url($this_url_params) . '" title="' . $strHide . '">' . $strFunction . '</a></th>' . "\n";
300
<th><?php echo $strNull; ?></th>
301
<th><?php echo $strValue; ?></th>
305
// garvin: For looping on multiple rows, we need to reset any variable used inside the loop to indicate sth.
307
unset($first_timestamp);
309
// Sets a multiplier used for input-field counts (as zero cannot be used, advance the counter plus one)
310
$m_rows = $o_rows + 1;
313
for ($i = 0; $i < $fields_cnt; $i++) {
314
// Display the submit button after every 15 lines --swix
315
// (wanted to use an <a href="#bottom"> and <a name> instead,
316
// but it didn't worked because of the <base href>)
318
if ((($o_rows * $fields_cnt + $i) % 15 == 0) && ($i + $o_rows != 0)) {
321
<th colspan="5" align="right" class="tblFooters">
322
<input type="submit" value="<?php echo $strGo; ?>" />
329
$row_table_def = $trow_table_def[$i];
330
$row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
332
$field = $row_table_def['Field'];
333
$field_html = htmlspecialchars($field);
334
$field_md5 = md5($field);
336
$unnillify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field_html) . "', '" . PMA_escapeJsString($jsvkey) . "')\"";
337
$field_name_appendix = $vkey . '[' . $field_html . ']';
338
$field_name_appendix_md5 = $field_md5 . $vkey . '[]';
341
// removed previous PHP3-workaround that caused a problem with
342
// field names like '000'
343
//$rowfield = $field;
347
// loic1: current date should not be set as default if the field is NULL
348
// for the current row
349
// lem9: but do not put here the current datetime if there is a default
350
// value (the real default value will be set in the
351
// Default value logic below)
353
// Note: (tested in MySQL 4.0.16): when lang is some UTF-8,
354
// $row_table_def['Default'] is not set if it contains NULL:
355
// Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Extra] => [True_Type] => datetime )
356
// but, look what we get if we switch to iso: (Default is NULL)
357
// Array ( [Field] => d [Type] => datetime [Null] => YES [Key] => [Default] => [Extra] => [True_Type] => datetime )
358
// so I force a NULL into it (I don't think it's possible
359
// to have an empty default value for DATETIME)
360
// then, the "if" after this one will work
361
if ($row_table_def['Type'] == 'datetime'
362
&& !isset($row_table_def['Default'])
363
&& isset($row_table_def['Null'])
364
&& $row_table_def['Null'] == 'YES') {
365
$row_table_def['Default'] = null;
368
if ($row_table_def['Type'] == 'datetime'
369
&& (!isset($row_table_def['Default']))
370
&& (!is_null($row_table_def['Default']))) {
374
$vrow[$field] = date('Y-m-d H:i:s', time());
376
$vrow = array($field => date('Y-m-d H:i:s', time()));
379
// UPDATE case with an empty and not NULL value under PHP4
380
elseif (empty($vrow[$field]) && is_null($vrow[$field])) {
381
$vrow[$field] = date('Y-m-d H:i:s', time());
382
} // end if... elseif...
384
$len = (preg_match('@float|double@', $row_table_def['Type']))
386
: PMA_DBI_field_len($vresult, $i);
387
$first_timestamp = 0;
389
$field_name = $field_html;
390
if (isset($comments_map[$field])) {
391
$field_name = '<span style="border-bottom: 1px dashed black;" title="'
392
. htmlspecialchars($comments_map[$field]) . '">' . $field_name . '</span>';
396
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
397
<td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center"><?php echo $field_name; ?></td>
401
$is_binary = stristr($row_table_def['Type'], 'binary');
402
$is_blob = stristr($row_table_def['Type'], 'blob');
403
$is_char = stristr($row_table_def['Type'], 'char');
404
switch ($row_table_def['True_Type']) {
414
if (!$timestamp_seen) { // can only occur once per table
416
$first_timestamp = 1;
418
$type = $row_table_def['Type'];
419
$type_nowrap = ' nowrap="nowrap"';
423
$type = $row_table_def['Type'];
424
$type_nowrap = ' nowrap="nowrap"';
428
<td align="center"<?php echo $type_nowrap; ?>>
434
// Prepares the field value
435
$real_null_value = FALSE;
437
if (!isset($vrow[$field])
438
|| (function_exists('is_null') && is_null($vrow[$field]))) {
439
$real_null_value = TRUE;
442
$data = $vrow[$field];
444
// loic1: special binary "characters"
445
if ($is_binary || $is_blob) {
446
$vrow[$field] = str_replace("\x00", '\0', $vrow[$field]);
447
$vrow[$field] = str_replace("\x08", '\b', $vrow[$field]);
448
$vrow[$field] = str_replace("\x0a", '\n', $vrow[$field]);
449
$vrow[$field] = str_replace("\x0d", '\r', $vrow[$field]);
450
$vrow[$field] = str_replace("\x1a", '\Z', $vrow[$field]);
452
$special_chars = htmlspecialchars($vrow[$field]);
453
$data = $vrow[$field];
454
} // end if... else...
455
// loic1: if a timestamp field value is not included in an update
456
// statement MySQL auto-update it to the current timestamp
457
// lem9: however, things have changed since MySQL 4.1, so
458
// it's better to set a fields_prev in this situation
459
$backup_field = (PMA_MYSQL_INT_VERSION < 40100 && $row_table_def['True_Type'] == 'timestamp')
461
: '<input type="hidden" name="fields_prev' . $field_name_appendix . '" value="' . htmlspecialchars($vrow[$field]) . '" />';
463
// loic1: display default values
464
if (!isset($row_table_def['Default'])) {
465
$row_table_def['Default'] = '';
466
$real_null_value = TRUE;
469
$data = $row_table_def['Default'];
471
$special_chars = htmlspecialchars($row_table_def['Default']);
475
$idindex = ($o_rows * $fields_cnt) + $i + 1;
476
$tabindex = (($idindex - 1) * 3) + 1;
478
// The function column
479
// -------------------
480
// Change by Bernard M. Piller <bernard@bmpsystems.com>
481
// We don't want binary data to be destroyed
482
// Note: from the MySQL manual: "BINARY doesn't affect how the column is
483
// stored or retrieved" so it does not mean that the contents is
485
if ($cfg['ShowFunctionFields']) {
486
if (($cfg['ProtectBinary'] && $is_blob && !$is_upload)
487
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
488
echo ' <td align="center">' . $strBinary . '</td>' . "\n";
489
} elseif (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
490
echo ' <td align="center">--</td>' . "\n";
494
<select name="funcs<?php echo $field_name_appendix; ?>" <?php echo $unnillify_trigger; ?> tabindex="<?php echo ($tabindex + $tabindex_for_function); ?>" id="field_<?php echo $idindex; ?>_1">
499
// garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
500
// or something similar. Then directly look up the entry in the RestrictFunctions array,
501
// which will then reveal the available dropdown options
502
if (isset($cfg['RestrictFunctions'])
503
&& isset($cfg['RestrictColumnTypes'])
504
&& isset($cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])])
505
&& isset($cfg['RestrictFunctions'][$cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])]])) {
506
$current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
507
$dropdown = $cfg['RestrictFunctions'][$current_func_type];
508
$default_function = $cfg['DefaultFunctions'][$current_func_type];
511
$default_function = '';
514
$dropdown_built = array();
515
$op_spacing_needed = FALSE;
516
// garvin: loop on the dropdown array and print all available options for that field.
517
$cnt_dropdown = count($dropdown);
518
for ($j = 0; $j < $cnt_dropdown; $j++) {
519
// Is current function defined as default?
520
// For MySQL < 4.1.2, for the first timestamp we set as
521
// default function the one defined in config (which
522
// should be NOW() ).
523
// For MySQL >= 4.1.2, we don't set the default function
524
// if there is a default value for the timestamp
525
// (not including CURRENT_TIMESTAMP)
526
// and the column does not have the
527
// ON UPDATE DEFAULT TIMESTAMP attribute.
529
if (PMA_MYSQL_INT_VERSION < 40102
530
|| (PMA_MYSQL_INT_VERSION >= 40102
531
&& !($row_table_def['True_Type'] == 'timestamp'
532
&& !empty($row_table_def['Default'])
533
&& !isset($analyzed_sql[0]['create_table_fields'][$field]['on_update_current_timestamp'])))) {
534
$selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
535
|| (!$first_timestamp && $dropdown[$j] == $default_function)
536
? ' selected="selected"'
540
echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
541
$dropdown_built[$dropdown[$j]] = 'TRUE';
542
$op_spacing_needed = TRUE;
545
// garvin: For compatibility's sake, do not let out all other functions. Instead
546
// print a separator (blank) and then show ALL functions which weren't shown
548
$cnt_functions = count($cfg['Functions']);
549
for ($j = 0; $j < $cnt_functions; $j++) {
550
if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
551
// Is current function defined as default?
552
$selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
553
|| (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
554
? ' selected="selected"'
556
if ($op_spacing_needed == TRUE) {
558
echo '<option value="">--------</option>' . "\n";
559
$op_spacing_needed = FALSE;
563
echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
572
} // end if ($cfg['ShowFunctionFields'])
578
if ($row_table_def['Null'] == 'YES') {
579
echo ' <input type="hidden" name="fields_null_prev' . $field_name_appendix . '"';
580
if ($real_null_value && !$first_timestamp) {
585
if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary)) ) {
587
echo ' <input type="checkbox" tabindex="' . ($tabindex + $tabindex_for_null) . '"'
588
. ' name="fields_null' . $field_name_appendix . '"';
589
if ($real_null_value && !$first_timestamp) {
590
echo ' checked="checked"';
592
echo ' id="field_' . ($idindex) . '_2"';
593
$onclick = ' onclick="if (this.checked) {nullify(';
594
if (strstr($row_table_def['True_Type'], 'enum')) {
595
if (strlen($row_table_def['Type']) > 20) {
600
} elseif (strstr($row_table_def['True_Type'], 'set')) {
602
} elseif ($foreigners && isset($foreigners[$field])) {
607
$onclick .= '\'' . PMA_escapeJsString($field_html) . '\', \'' . $field_md5 . '\', \'' . PMA_escapeJsString($vkey) . '\'); this.checked = true}; return true" />' . "\n";
610
echo ' <input type="hidden" name="fields_null' . $field_name_appendix . '"';
611
if ($real_null_value && !$first_timestamp) {
617
echo ' </td>' . "\n";
619
// The value column (depends on type)
622
require './libraries/get_foreign.lib.php';
624
if (isset($foreign_link) && $foreign_link == true) {
627
<?php echo $backup_field . "\n"; ?>
628
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"
630
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>"
631
value="" id="field_<?php echo ($idindex); ?>_1" />
632
<input type="text" name="field_<?php echo $field_name_appendix_md5; ?>"
633
class="textfield" <?php echo $unnillify_trigger; ?>
634
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
635
id="field_<?php echo ($idindex); ?>_3"
636
value="<?php echo htmlspecialchars($data); ?>" />
637
<script type="text/javascript" language="javascript">
639
document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes,resizable=yes\'); return false"');
640
document.writeln(' href="browse_foreigners.php?');
641
document.writeln('<?php echo PMA_generate_common_url($db, $table); ?>');
642
document.writeln('&field=<?php echo PMA_escapeJsString(urlencode($field) . $browse_foreigners_uri); ?>">');
643
document.writeln('<?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
648
} elseif (isset($disp_row) && is_array($disp_row)) {
651
<?php echo $backup_field . "\n"; ?>
652
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>"
654
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>"
655
value="" id="field_<?php echo $idindex; ?>_1" />
656
<select name="field_<?php echo $field_name_appendix_md5; ?>"
657
<?php echo $unnillify_trigger; ?>
658
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
659
id="field_<?php echo ($idindex); ?>_3">
660
<?php echo PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data, $cfg['ForeignKeyMaxLimit']); ?>
665
} elseif ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
669
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
670
<td colspan="5" align="right">
671
<?php echo $backup_field . "\n"; ?>
672
<textarea name="fields<?php echo $field_name_appendix; ?>"
673
rows="<?php echo ($cfg['TextareaRows']*2); ?>"
674
cols="<?php echo ($cfg['TextareaCols']*2); ?>"
675
dir="<?php echo $text_dir; ?>"
676
id="field_<?php echo ($idindex); ?>_3"
677
<?php echo $unnillify_trigger; ?>
678
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
679
><?php echo $special_chars; ?></textarea>
682
} elseif (strstr($type, 'text')) {
685
<?php echo $backup_field . "\n"; ?>
686
<textarea name="fields<?php echo $field_name_appendix; ?>"
687
rows="<?php echo $cfg['TextareaRows']; ?>"
688
cols="<?php echo $cfg['TextareaCols']; ?>"
689
dir="<?php echo $text_dir; ?>"
690
id="field_<?php echo ($idindex); ?>_3"
691
<?php echo $unnillify_trigger; ?>
692
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
693
><?php echo $special_chars; ?></textarea>
697
if (strlen($special_chars) > 32000) {
698
echo ' <td>' . $strTextAreaLength . '</td>' . "\n";
700
} elseif ($type == 'enum') {
701
$enum = PMA_getEnumSetOptions($row_table_def['Type']);
702
$enum_cnt = count($enum);
705
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="enum" />
706
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
708
echo "\n" . ' ' . $backup_field;
710
// show dropdown or radio depend on length
711
if (strlen($row_table_def['Type']) > 20) {
714
<select name="field_<?php echo $field_name_appendix_md5; ?>"
715
<?php echo $unnillify_trigger; ?>
716
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
717
id="field_<?php echo ($idindex); ?>_3">
718
<option value=""></option>
722
for ($j = 0; $j < $enum_cnt; $j++) {
723
// Removes automatic MySQL escape format
724
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
726
//echo '<option value="' . htmlspecialchars($enum_atom) . '"';
727
echo '<option value="' . htmlspecialchars($enum_atom) . '"';
728
if ($data == $enum_atom
729
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
730
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
731
echo ' selected="selected"';
733
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
741
for ($j = 0; $j < $enum_cnt; $j++) {
742
// Removes automatic MySQL escape format
743
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
745
echo '<input type="radio" name="field_' . $field_name_appendix_md5 . '"';
746
echo ' value="' . htmlspecialchars($enum_atom) . '"';
747
echo ' id="field_' . ($idindex) . '_3_' . $j . '"';
749
echo "if (typeof(document.forms['insertForm'].elements['fields_null"
750
. $field_name_appendix . "']) != 'undefined') {document.forms['insertForm'].elements['fields_null"
751
. $field_name_appendix . "'].checked = false}";
753
if ($data == $enum_atom
754
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
755
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
756
echo ' checked="checked"';
758
echo 'tabindex="' . ($tabindex + $tabindex_for_value) . '" />';
759
echo '<label for="field_' . $idindex . '_3_' . $j . '">'
760
. htmlspecialchars($enum_atom) . '</label>' . "\n";
769
} elseif ($type == 'set') {
770
$set = PMA_getEnumSetOptions($row_table_def['Type']);
775
for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
778
$countset = count($set);
779
$size = min(4, $countset);
782
<?php echo $backup_field . "\n"; ?>
783
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="set" />
784
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
785
<select name="field_<?php echo $field_name_appendix_md5; ?>"
786
size="<?php echo $size; ?>"
787
multiple="multiple" <?php echo $unnillify_trigger; ?>
788
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
789
id="field_<?php echo ($idindex); ?>_3">
792
for ($j = 0; $j < $countset; $j++) {
794
//echo '<option value="'. htmlspecialchars($set[$j]) . '"';
795
echo '<option value="'. htmlspecialchars($set[$j]) . '"';
796
if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
797
echo ' selected="selected"';
799
echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
806
// Change by Bernard M. Piller <bernard@bmpsystems.com>
807
// We don't want binary data destroyed
808
elseif ($is_binary || $is_blob) {
809
if (($cfg['ProtectBinary'] && $is_blob)
810
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
815
echo $strBinaryDoNotEdit;
817
$data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
818
echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
823
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="protected" />
824
<input type="hidden" name="fields<?php echo $field_name_appendix; ?>" value="" />
826
} elseif ($is_blob) {
830
<?php echo $backup_field . "\n"; ?>
831
<textarea name="fields<?php echo $field_name_appendix; ?>"
832
rows="<?php echo $cfg['TextareaRows']; ?>"
833
cols="<?php echo $cfg['TextareaCols']; ?>"
834
dir="<?php echo $text_dir; ?>"
835
id="field_<?php echo ($idindex); ?>_3"
836
<?php echo $unnillify_trigger; ?>
837
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
838
><?php echo $special_chars; ?></textarea>
842
// field size should be at least 4 and max 40
843
$fieldsize = min(max($len, 4), 40);
847
<?php echo $backup_field . "\n"; ?>
848
<input type="text" name="fields<?php echo $field_name_appendix; ?>"
849
value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>"
850
class="textfield" <?php echo $unnillify_trigger; ?>
851
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
852
id="field_<?php echo ($idindex); ?>_3" />
854
} // end if...elseif...else
856
// Upload choice (only for BLOBs because the binary
857
// attribute does not imply binary contents)
858
// (displayed whatever value the ProtectBinary has)
860
if ($is_upload && $is_blob) {
862
echo '<input type="file" name="fields_upload_' . $field_html . $vkey . '" class="textfield" id="field_' . $idindex . '_3" size="10" /> ';
864
// find maximum upload size, based on field type
866
* @todo with functions this is not so easy, as you can basically
867
* process any data with function like MD5
869
$max_field_sizes = array(
872
'mediumblob' => '16777216',
873
'longblob' => '4294967296'); // yeah, really
875
$this_field_max_size = $max_upload_size; // from PHP max
876
if ($this_field_max_size > $max_field_sizes[$type]) {
877
$this_field_max_size = $max_field_sizes[$type];
879
echo PMA_displayMaximumUploadSize($this_field_max_size) . "\n";
880
// do not generate here the MAX_FILE_SIZE, because we should
881
// put only one in the form to accommodate the biggest field
882
if ($this_field_max_size > $biggest_max_file_size) {
883
$biggest_max_file_size = $this_field_max_size;
887
if (!empty($cfg['UploadDir'])) {
888
$files = PMA_getFileSelectOptions(PMA_userDir($cfg['UploadDir']));
889
if ($files === FALSE) {
890
echo ' <font color="red">' . $strError . '</font><br />' . "\n";
891
echo ' ' . $strWebServerUploadDirectoryError . "\n";
892
} elseif (!empty($files)) {
894
echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ':<br />' . "\n";
895
echo ' <select size="1" name="fields_uploadlocal_' . $field_html . $vkey . '">' . "\n";
896
echo ' <option value="" selected="selected"></option>' . "\n";
898
echo ' </select>' . "\n";
900
} // end if (web-server upload directory)
904
} // end elseif ( binary or blob)
906
// field size should be at least 4 and max 40
907
$fieldsize = min(max($len, 4), 40);
911
echo $backup_field . "\n";
912
if ($is_char && ($cfg['CharEditing'] == 'textarea' || strpos($data, "\n") !== FALSE)) {
915
<textarea name="fields<?php echo $field_name_appendix; ?>"
916
rows="<?php echo $cfg['CharTextareaRows']; ?>"
917
cols="<?php echo $cfg['CharTextareaCols']; ?>"
918
dir="<?php echo $text_dir; ?>"
919
id="field_<?php echo ($idindex); ?>_3"
920
<?php echo $unnillify_trigger; ?>
921
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
922
><?php echo $special_chars; ?></textarea>
926
<input type="text" name="fields<?php echo $field_name_appendix; ?>"
927
value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>"
928
class="textfield" <?php echo $unnillify_trigger; ?>
929
tabindex="<?php echo ($tabindex + $tabindex_for_value); ?>"
930
id="field_<?php echo ($idindex); ?>_3" />
932
if ($row_table_def['Extra'] == 'auto_increment') {
934
<input type="hidden" name="auto_increment<?php echo $field_name_appendix; ?>" value="1" />
937
if (substr($type, 0, 9) == 'timestamp') {
939
<input type="hidden" name="fields_type<?php echo $field_name_appendix; ?>" value="timestamp" />
942
if ($type == 'date' || $type == 'datetime' || substr($type, 0, 9) == 'timestamp') {
944
<script type="text/javascript" language="javascript">
946
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>');
959
$odd_row = !$odd_row;
962
echo ' </table><br />';
963
} // end foreach on multi-edit
967
<table border="0" cellpadding="5" cellspacing="0">
969
<td valign="middle" nowrap="nowrap">
970
<select name="submit_type" tabindex="<?php echo ($tabindex + $tabindex_for_value + 1); ?>">
972
if (isset($primary_key)) {
974
<option value="<?php echo $strSave; ?>"><?php echo $strSave; ?></option>
978
<option value="<?php echo $strInsertAsNewRow; ?>"><?php echo $strInsertAsNewRow; ?></option>
983
if (!isset($after_insert)) {
984
$after_insert = 'back';
989
<b><?php echo $strAndThen; ?></b>
991
<td valign="middle" nowrap="nowrap">
992
<select name="after_insert">
993
<option value="back" <?php echo ($after_insert == 'back' ? 'selected="selected"' : ''); ?>><?php echo $strAfterInsertBack; ?></option>
994
<option value="new_insert" <?php echo ($after_insert == 'new_insert' ? 'selected="selected"' : ''); ?>><?php echo $strAfterInsertNewInsert; ?></option>
996
if (isset($primary_key)) {
998
<option value="same_insert" <?php echo ($after_insert == 'same_insert' ? 'selected="selected"' : ''); ?>><?php echo $strAfterInsertSame; ?></option>
1000
// If we have just numeric primary key, we can also edit next
1001
// in 2.8.2, we were looking for `field_name` = numeric_value
1002
//if (preg_match('@^[\s]*`[^`]*` = [0-9]+@', $primary_key)) {
1003
// in 2.9.0, we are looking for `table_name`.`field_name` = numeric_value
1004
if (preg_match('@^[\s]*`[^`]*`[\.]`[^`]*` = [0-9]+@', $primary_key)) {
1006
<option value="edit_next"><?php echo $strAfterInsertNext; ?></option>
1017
<?php echo PMA_showHint($strUseTabKey); ?>
1019
<td colspan="3" align="right" valign="middle">
1020
<input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 6); ?>" id="buttonYes" />
1021
<input type="reset" value="<?php echo $strReset; ?>" tabindex="<?php echo ($tabindex + $tabindex_for_value + 7); ?>" />
1025
<?php if ($biggest_max_file_size > 0) {
1026
echo ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n";
1033
* Displays the footer
1035
require_once './libraries/footer.inc.php';