forked from phpmyadmin/phpmyadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtbl_change.php
784 lines (721 loc) · 33.7 KB
/
tbl_change.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
<?php
/* $Id$ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Get the variables sent or posted to this script and displays the header
*/
require_once('./libraries/grab_globals.lib.php');
$js_to_run = 'tbl_change.js';
require_once('./header.inc.php');
require_once('./libraries/relation.lib.php'); // foreign keys
/**
* Displays the query submitted and its result
*/
if (!empty($disp_message)) {
if (isset($goto)) {
$goto_cpy = $goto;
$goto = 'tbl_properties.php?'
. PMA_generate_common_url($db, $table)
. '&$show_query=1'
. '&sql_query=' . (isset($disp_query) ? urlencode($disp_query) : '');
} else {
$show_query = '1';
}
if (isset($sql_query)) {
$sql_query_cpy = $sql_query;
unset($sql_query);
}
if (isset($disp_query)) {
$sql_query = $disp_query;
}
PMA_showMessage($disp_message);
if (isset($goto_cpy)) {
$goto = $goto_cpy;
unset($goto_cpy);
}
if (isset($sql_query_cpy)) {
$sql_query = $sql_query_cpy;
unset($sql_query_cpy);
}
}
/**
* Defines the url to return to in case of error in a sql statement
*/
if (!isset($goto)) {
$goto = 'db_details.php';
}
if (!preg_match('@^(db_details|tbl_properties|tbl_select)@', $goto)) {
$err_url = $goto . "?" . PMA_generate_common_url($db) . "&sql_query=" . urlencode($sql_query);
} else {
$err_url = $goto . '?'
. PMA_generate_common_url($db)
. ((preg_match('@^(tbl_properties|tbl_select)@', $goto)) ? '&table=' . urlencode($table) : '');
}
/**
* Ensures db and table are valid, else moves to the "parent" script
*/
require('./libraries/db_table_exists.lib.php');
/**
* Sets parameters for links and displays top menu
*/
$url_query = PMA_generate_common_url($db, $table)
. '&goto=tbl_properties.php';
require('./tbl_properties_table_info.php');
echo '<br />';
/**
* Get the list of the fields of the current table
*/
PMA_mysql_select_db($db);
$table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($table));
if (isset($primary_key)) {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key;
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
$row = PMA_mysql_fetch_array($result);
// No row returned
if (!$row) {
unset($row);
unset($primary_key);
$goto_cpy = $goto;
$goto = 'tbl_properties.php?'
. PMA_generate_common_url($db, $table)
. '&$show_query=1'
. '&sql_query=' . urlencode($local_query);
if (isset($sql_query)) {
$sql_query_cpy = $sql_query;
unset($sql_query);
}
$sql_query = $local_query;
PMA_showMessage($strEmptyResultSet);
$goto = $goto_cpy;
unset($goto_cpy);
if (isset($sql_query_cpy)) {
$sql_query = $sql_query_cpy;
unset($sql_query_cpy);
}
} // end if (no record returned)
}
else
{
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1';
$result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
unset($row);
}
// <markus@noga.de>
// retrieve keys into foreign fields, if any
$cfgRelation = PMA_getRelationsParam();
$foreigners = ($cfgRelation['relwork'] ? PMA_getForeigners($db, $table) : FALSE);
/**
* Displays the form
*/
// loic1: autocomplete feature of IE kills the "onchange" event handler and it
// must be replaced by the "onpropertychange" one in this case
$chg_evt_handler = (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5)
? 'onpropertychange'
: 'onchange';
// Had to put the URI because when hosted on an https server,
// some browsers send wrongly this form to the http server.
?>
<?php if ($cfg['CtrlArrowsMoving']) { ?>
<!-- Set on key handler for moving using by Ctrl+arrows -->
<script type="text/javascript" language="javascript">
<!--
document.onkeydown = onKeyDownArrowsHandler;
// -->
</script>
<?php } ?>
<!-- Change table properties form -->
<form method="post" action="tbl_replace.php" name="insertForm" <?php if ($is_upload) echo ' enctype="multipart/form-data"'; ?>>
<?php echo PMA_generate_common_hidden_inputs($db, $table); ?>
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
<input type="hidden" name="pos" value="<?php echo isset($pos) ? $pos : 0; ?>" />
<input type="hidden" name="session_max_rows" value="<?php echo isset($session_max_rows) ? $session_max_rows : ''; ?>" />
<input type="hidden" name="disp_direction" value="<?php echo isset($disp_direction) ? $disp_direction : ''; ?>" />
<input type="hidden" name="repeat_cells" value="<?php echo isset($repeat_cells) ? $repeat_cells : ''; ?>" />
<input type="hidden" name="dontlimitchars" value="<?php echo (isset($dontlimitchars) ? $dontlimitchars : 0); ?>" />
<input type="hidden" name="err_url" value="<?php echo urlencode($err_url); ?>" />
<input type="hidden" name="sql_query" value="<?php echo isset($sql_query) ? urlencode($sql_query) : ''; ?>" />
<?php
if (isset($primary_key)) {
?>
<input type="hidden" name="primary_key" value="<?php echo urlencode($primary_key); ?>" />
<?php
}
echo "\n";
?>
<table border="<?php echo $cfg['Border']; ?>">
<tr>
<th><?php echo $strField; ?></th>
<th><?php echo $strType; ?></th>
<?php
if ($cfg['ShowFunctionFields']) {
echo ' <th>' . $strFunction . '</th>' . "\n";
}
?>
<th><?php echo $strNull; ?></th>
<th><?php echo $strValue; ?></th>
</tr>
<?php
if ($cfg['PropertiesIconic'] == true) {
// We need to copy the value or else the == 'both' check will always return true
$propicon = (string)$cfg['PropertiesIconic'];
if ($propicon == 'both') {
$iconic_spacer = '<nobr>';
} else {
$iconic_spacer = '';
}
$titles['Browse'] = $iconic_spacer . '<img width="12" height="13" src="images/button_browse.png" alt="' . $strBrowseForeignValues . '" title="' . $strBrowseForeignValues . '" border="0" />';
if ($propicon == 'both') {
$titles['Browse'] .= ' ' . $strBrowseForeignValues . '</nobr>';
}
} else {
$titles['Browse'] = $strBrowseForeignValues;
}
// Set if we passed the first timestamp field
$timestamp_seen = 0;
$fields_cnt = mysql_num_rows($table_def);
// Set a flag here because the 'if' would not be valid in the loop
// if we set a value in some field
$insert_mode = (!isset($row) ? TRUE : FALSE);
for ($i = 0; $i < $fields_cnt; $i++) {
// Display the submit button after every 15 lines --swix
// (wanted to use an <a href="#bottom"> and <a name> instead,
// but it didn't worked because of the <base href>)
if ((($i % 15) == 0) && ($i != 0)) {
?>
<tr>
<th colspan="5" align="right">
<input type="submit" value="<?php echo $strGo; ?>" />
</th>
</tr>
<?php
} // end if
echo "\n";
$row_table_def = PMA_mysql_fetch_array($table_def);
$row_table_def['True_Type'] = preg_replace('@\(.*@s', '', $row_table_def['Type']);
$field = $row_table_def['Field'];
// garvin: possible workaround. If current field is numerical, do not try to
// access the result-array with its 'associative' key but with its numerical
// represantation.
if (is_numeric($field)) {
$rowfield = $i;
} else {
$rowfield = $field;
}
// d a t e t i m e
//
// loic1: current date should not be set as default if the field is NULL
// for the current row
// lem9: but do not put here the current datetime if there is a default
// value (the real default value will be set in the
// Default value logic below)
if ($row_table_def['Type'] == 'datetime'
&& (!isset($row_table_def['Default']))) {
// INSERT case
if ($insert_mode) {
$row[$rowfield] = date('Y-m-d H:i:s', time());
}
// UPDATE case with an empty and not NULL value under PHP4
else if (empty($row[$rowfield]) && is_null($row[$rowfield])) {
$row[$rowfield] = date('Y-m-d H:i:s', time());
} // end if... else if...
}
$len = (preg_match('@float|double@', $row_table_def['Type']))
? 100
: @mysql_field_len($result, $i);
$first_timestamp = 0;
$bgcolor = ($i % 2) ? $cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
?>
<tr>
<td <?php echo ($cfg['LongtextDoubleTextarea'] && strstr($row_table_def['True_Type'], 'longtext') ? 'rowspan="2"' : ''); ?> align="center" bgcolor="<?php echo $bgcolor; ?>"><?php echo htmlspecialchars($field); ?></td>
<?php
echo "\n";
// The type column
$is_binary = stristr($row_table_def['Type'], ' binary');
$is_blob = stristr($row_table_def['Type'], 'blob');
$is_char = stristr($row_table_def['Type'], 'char');
switch ($row_table_def['True_Type']) {
case 'set':
$type = 'set';
$type_nowrap = '';
break;
case 'enum':
$type = 'enum';
$type_nowrap = '';
break;
case 'timestamp':
if (!$timestamp_seen) { // can only occur once per table
$timestamp_seen = 1;
$first_timestamp = 1;
}
$type = $row_table_def['Type'];
$type_nowrap = ' nowrap="nowrap"';
break;
default:
$type = $row_table_def['Type'];
$type_nowrap = ' nowrap="nowrap"';
break;
}
?>
<td align="center" bgcolor="<?php echo $bgcolor; ?>"<?php echo $type_nowrap; ?>>
<?php echo $type; ?>
</td>
<?php
echo "\n";
// Prepares the field value
$real_null_value = FALSE;
if (isset($row)) {
if (!isset($row[$rowfield])
|| (function_exists('is_null') && is_null($row[$rowfield]))) {
$real_null_value = TRUE;
$row[$rowfield] = '';
$special_chars = '';
$data = $row[$rowfield];
} else {
// loic1: special binary "characters"
if ($is_binary || $is_blob) {
$row[$rowfield] = str_replace("\x00", '\0', $row[$rowfield]);
$row[$rowfield] = str_replace("\x08", '\b', $row[$rowfield]);
$row[$rowfield] = str_replace("\x0a", '\n', $row[$rowfield]);
$row[$rowfield] = str_replace("\x0d", '\r', $row[$rowfield]);
$row[$rowfield] = str_replace("\x1a", '\Z', $row[$rowfield]);
} // end if
$special_chars = htmlspecialchars($row[$rowfield]);
$data = $row[$rowfield];
} // end if... else...
// loic1: if a timestamp field value is not included in an update
// statement MySQL auto-update it to the current timestamp
$backup_field = ($row_table_def['True_Type'] == 'timestamp')
? ''
: '<input type="hidden" name="fields_prev[' . urlencode($field) . ']" value="' . urlencode($row[$rowfield]) . '" />';
} else {
// loic1: display default values
if (!isset($row_table_def['Default'])) {
$row_table_def['Default'] = '';
$real_null_value = TRUE;
$data = '';
//$data = 'NULL';
} else {
$data = $row_table_def['Default'];
}
$special_chars = htmlspecialchars($row_table_def['Default']);
$backup_field = '';
}
// The function column
// -------------------
// Change by Bernard M. Piller <bernard@bmpsystems.com>
// We don't want binary data to be destroyed
// Note: from the MySQL manual: "BINARY doesn't affect how the column is
// stored or retrieved" so it does not mean that the contents is
// binary
if ($cfg['ShowFunctionFields']) {
if (($cfg['ProtectBinary'] && $is_blob)
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
echo ' <td align="center" bgcolor="'. $bgcolor . '">' . $strBinary . '</td>' . "\n";
} else if (strstr($row_table_def['True_Type'], 'enum') || strstr($row_table_def['True_Type'], 'set')) {
echo ' <td align="center" bgcolor="'. $bgcolor . '">--</td>' . "\n";
} else {
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<select name="funcs[<?php echo urlencode($field); ?>]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($fields_cnt + $i + 1); ?>" id="field_<?php echo $i; ?>_1">
<option></option>
<?php
echo "\n";
$selected = '';
// garvin: Find the current type in the RestrictColumnTypes. Will result in 'FUNC_CHAR'
// or something similar. Then directly look up the entry in the RestrictFunctions array,
// which will then reveal the available dropdown options
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'])]])) {
$current_func_type = $cfg['RestrictColumnTypes'][strtoupper($row_table_def['True_Type'])];
$dropdown = $cfg['RestrictFunctions'][$current_func_type];
$default_function = $cfg['DefaultFunctions'][$current_func_type];
} else {
$dropdown = array();
}
$dropdown_built = array();
$op_spacing_needed = FALSE;
// garvin: loop on the dropdown array and print all available options for that field.
$cnt_dropdown = count($dropdown);
for ($j = 0; $j < $cnt_dropdown; $j++) {
// Is current function defined as default?
$selected = ($first_timestamp && $dropdown[$j] == $cfg['DefaultFunctions']['first_timestamp'])
|| (!$first_timestamp && $dropdown[$j] == $default_function)
? ' selected="selected"'
: '';
echo ' ';
echo '<option' . $selected . '>' . $dropdown[$j] . '</option>' . "\n";
$dropdown_built[$dropdown[$j]] = 'TRUE';
$op_spacing_needed = TRUE;
}
// garvin: For compatibility's sake, do not let out all other functions. Instead
// print a seperator (blank) and then show ALL functions which weren't shown
// yet.
$cnt_functions = count($cfg['Functions']);
for ($j = 0; $j < $cnt_functions; $j++) {
if (!isset($dropdown_built[$cfg['Functions'][$j]]) || $dropdown_built[$cfg['Functions'][$j]] != 'TRUE') {
// Is current function defined as default?
$selected = ($first_timestamp && $cfg['Functions'][$j] == $cfg['DefaultFunctions']['first_timestamp'])
|| (!$first_timestamp && $cfg['Functions'][$j] == $default_function)
? ' selected="selected"'
: '';
if ($op_spacing_needed == TRUE) {
echo ' ';
echo '<option value="">--------</option>' . "\n";
$op_spacing_needed = FALSE;
}
echo ' ';
echo '<option' . $selected . '>' . $cfg['Functions'][$j] . '</option>' . "\n";
}
} // end for
unset($selected);
?>
</select>
</td>
<?php
}
} // end if ($cfg['ShowFunctionFields'])
echo "\n";
// The null column
// ---------------
echo ' <td bgcolor="' . $bgcolor . '">' . "\n";
if (!(($cfg['ProtectBinary'] && $is_blob) || ($cfg['ProtectBinary'] == 'all' && $is_binary))
&& $row_table_def['Null'] == 'YES') {
echo ' <input type="checkbox" tabindex="' . ((2 * $fields_cnt) + $i + 1) . '"'
. ' name="fields_null[' . urlencode($field) . ']"';
//if ($data == 'NULL' && !$first_timestamp) {
if ($real_null_value && !$first_timestamp) {
echo ' checked="checked"';
}
echo ' id="field_' . $i . '_2"';
$onclick = ' onclick="if (this.checked) {nullify(';
if (strstr($row_table_def['True_Type'], 'enum')) {
if (strlen($row_table_def['Type']) > 20) {
$onclick .= '1, ';
} else {
$onclick .= '2, ';
}
} else if (strstr($row_table_def['True_Type'], 'set')) {
$onclick .= '3, ';
} else if ($foreigners && isset($foreigners[$field])) {
$onclick .= '4, ';
} else {
$onclick .= '5, ';
}
$onclick .= '\'' . urlencode($field) . '\', \'' . md5($field) . '\'); this.checked = true}; return true" />' . "\n";
echo $onclick;
} else {
echo ' ' . "\n";
}
echo ' </td>' . "\n";
// The value column (depends on type)
// ----------------
require('./libraries/get_foreign.lib.php');
if (isset($foreign_link) && $foreign_link == true) {
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
<input type="text" name="field_<?php echo md5($field); ?>[]" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" value="<?php echo htmlspecialchars($data); ?>" />
<script type="text/javascript" language="javascript">
document.writeln('<a target="_blank" onclick="window.open(this.href, \'foreigners\', \'width=640,height=240,scrollbars=yes\'); return false" href="browse_foreigners.php?<?php echo PMA_generate_common_url($db, $table); ?>&field=<?php echo urlencode($field); ?>"><?php echo str_replace("'", "\'", $titles['Browse']); ?></a>');
</script>
</td>
<?php
} else if (isset($disp) && $disp) {
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="foreign" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" id="field_<?php echo $i; ?>_1" />
<select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<?php echo PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, 100); ?>
</select>
</td>
<?php
unset($disp);
}
else if ($cfg['LongtextDoubleTextarea'] && strstr($type, 'longtext')) {
?>
<td bgcolor="<?php echo $bgcolor; ?>"> </td>
</tr>
<tr>
<td colspan="4" align="right" bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo ($cfg['TextareaRows']*2); ?>" cols="<?php echo ($cfg['TextareaCols']*2); ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
</td>
<?php
}
else if (strstr($type, 'text')) {
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>"><?php echo $special_chars; ?></textarea>
</td>
<?php
echo "\n";
if (strlen($special_chars) > 32000) {
echo ' <td bgcolor="' . $bgcolor . '">' . $strTextAreaLength . '</td>' . "\n";
}
}
else if ($type == 'enum') {
$enum = PMA_getEnumSetOptions($row_table_def['Type']);
$enum_cnt = count($enum);
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="enum" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<?php
echo "\n" . ' ' . $backup_field;
// show dropdown or radio depend on length
if (strlen($row_table_def['Type']) > 20) {
echo "\n";
?>
<select name="field_<?php echo md5($field); ?>[]" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<option value=""></option>
<?php
echo "\n";
for ($j = 0; $j < $enum_cnt; $j++) {
// Removes automatic MySQL escape format
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
echo ' ';
echo '<option value="' . htmlspecialchars($enum_atom) . '"';
if ($data == $enum_atom
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
echo ' selected="selected"';
}
echo '>' . htmlspecialchars($enum_atom) . '</option>' . "\n";
} // end for
?>
</select>
<?php
} // end if
else {
echo "\n";
for ($j = 0; $j < $enum_cnt; $j++) {
// Removes automatic MySQL escape format
$enum_atom = str_replace('\'\'', '\'', str_replace('\\\\', '\\', $enum[$j]));
echo ' ';
echo '<input type="radio" name="field_' . md5($field) . '[]" value="' . urlencode($enum_atom) . '" id="field_' . $i . '_3_' . $j . '" onclick="if (typeof(document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) . ']\']) != \'undefined\') {document.forms[\'insertForm\'].elements[\'fields_null[' . urlencode($field) .']\'].checked = false}"';
if ($data == $enum_atom
|| ($data == '' && (!isset($primary_key) || $row_table_def['Null'] != 'YES')
&& isset($row_table_def['Default']) && $enum_atom == $row_table_def['Default'])) {
echo ' checked="checked"';
}
echo 'tabindex="' . ($i + 1) . '" />' . "\n";
echo ' <label for="field_' . $i . '_3_' . $j . '">' . htmlspecialchars($enum_atom) . '</label>' . "\n";
} // end for
} // end else
echo "\n";
?>
</td>
<?php
echo "\n";
}
else if ($type == 'set') {
$set = PMA_getEnumSetOptions($row_table_def['Type']);
if (isset($vset)) {
unset($vset);
}
for ($vals = explode(',', $data); list($t, $k) = each($vals);) {
$vset[$k] = 1;
}
$countset = count($set);
$size = min(4, $countset);
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="set" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<select name="field_<?php echo md5($field); ?>[]" size="<?php echo $size; ?>" multiple="multiple" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3">
<?php
echo "\n";
for ($j = 0; $j < $countset; $j++) {
echo ' ';
echo '<option value="'. htmlspecialchars($set[$j]) . '"';
if (isset($vset[$set[$j]]) && $vset[$set[$j]]) {
echo ' selected="selected"';
}
echo '>' . htmlspecialchars($set[$j]) . '</option>' . "\n";
} // end for
?>
</select>
</td>
<?php
}
// Change by Bernard M. Piller <bernard@bmpsystems.com>
// We don't want binary data destroyed
else if ($is_binary || $is_blob) {
if (($cfg['ProtectBinary'] && $is_blob)
|| ($cfg['ProtectBinary'] == 'all' && $is_binary)) {
echo "\n";
?>
<td align="center" bgcolor="<?php echo $bgcolor; ?>">
<?php
echo $strBinaryDoNotEdit;
if (isset($data)) {
$data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
echo ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
unset($data_size);
}
echo "\n";
?>
<input type="hidden" name="fields_type[<?php echo urlencode($field); ?>]" value="protected" />
<input type="hidden" name="fields[<?php echo urlencode($field); ?>]" value="" />
<?php
} else if ($is_blob) {
echo "\n";
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['TextareaRows']; ?>" cols="<?php echo $cfg['TextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
<?php
} else {
if ($len < 4) {
$fieldsize = $maxlength = 4;
} else {
$fieldsize = (($len > 40) ? 40 : $len);
$maxlength = $len;
}
echo "\n";
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
<?php
} // end if...elseif...else
// Upload choice (only for BLOBs because the binary
// attribute does not imply binary contents)
// (displayed whatever value the ProtectBinary has)
if ($is_upload && $is_blob) {
echo '<input type="file" name="fields_upload_' . urlencode($field) . '" class="textfield" id="field_' . $i . '_3" />';
}
if (!empty($cfg['UploadDir'])) {
if (substr($cfg['UploadDir'], -1) != '/') {
$cfg['UploadDir'] .= '/';
}
if ($handle = @opendir($cfg['UploadDir'])) {
$is_first = 0;
while ($file = @readdir($handle)) {
if (is_file($cfg['UploadDir'] . $file) && !PMA_checkFileExtensions($file, '.sql')) {
if ($is_first == 0) {
echo "<br />\n";
echo ' <i>' . $strOr . '</i>' . ' ' . $strWebServerUploadDirectory . ' :<br />' . "\n";
echo ' <select size="1" name="fields_uploadlocal_' . urlencode($field) . '">' . "\n";
echo ' <option value="" selected="selected"></option>' . "\n";
} // end if (is_first)
echo ' <option value="' . htmlspecialchars($file) . '">' . htmlspecialchars($file) . '</option>' . "\n";
$is_first++;
} // end if (is_file)
} // end while
if ($is_first > 0) {
echo ' </select>' . "\n";
} // end if (isfirst > 0)
@closedir($handle);
} else {
echo ' <font color="red">' . $strError . '</font><br />' . "\n";
echo ' ' . $strWebServerUploadDirectoryError . "\n";
}
} // end if (web-server upload directory)
echo '</td>';
} // end else if ( binary or blob)
else {
// For char or varchar, respect the maximum length (M); for other
// types (int or float), the length is not a limit on the values that
// can be entered, so let's be generous (20) (we could also use the
// real limits for each numeric type)
if ($is_char) {
$fieldsize = (($len > 40) ? 40 : $len);
$maxlength = $len;
}
else {
$fieldsize = $maxlength = 20;
} // end if... else...
echo "\n";
?>
<td bgcolor="<?php echo $bgcolor; ?>">
<?php echo $backup_field . "\n"; ?>
<?php
if ($is_char && isset($cfg['CharEditing']) && ($cfg['CharEditing'] == 'textarea')) {
echo "\n";
?>
<textarea name="fields[<?php echo urlencode($field); ?>]" rows="<?php echo $cfg['CharTextareaRows']; ?>" cols="<?php echo $cfg['CharTextareaCols']; ?>" wrap="virtual" dir="<?php echo $text_dir; ?>" id="field_<?php echo $i; ?>_3"
<?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" ><?php echo $special_chars; ?></textarea>
<?php
} else {
echo "\n";
?>
<input type="text" name="fields[<?php echo urlencode($field); ?>]" value="<?php echo $special_chars; ?>" size="<?php echo $fieldsize; ?>" maxlength="<?php echo $maxlength; ?>" class="textfield" <?php echo $chg_evt_handler; ?>="return unNullify('<?php echo urlencode($field); ?>')" tabindex="<?php echo ($i + 1); ?>" id="field_<?php echo $i; ?>_3" />
<?php
}
echo "\n";
?>
</td>
<?php
}
echo "\n";
?>
</tr>
<?php
echo "\n";
} // end for
?>
</table>
<br />
<table cellpadding="5">
<tr>
<td valign="middle" nowrap="nowrap">
<?php
if (isset($primary_key)) {
?>
<input type="radio" name="submit_type" value="<?php echo $strSave; ?>" id="radio_submit_type_save" checked="checked" tabindex="<?php echo ((3 * $fields_cnt) + 1); ?>" /><label for="radio_submit_type_save"><?php echo $strSave; ?></label><br />
<?php echo $strOr; ?><br />
<input type="radio" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" id="radio_submit_type_insert_as_new_row" tabindex="<?php echo ((3 * $fields_cnt) + 2); ?>" /><label for="radio_submit_type_insert_as_new_row"><?php echo $strInsertAsNewRow; ?></label>
<?php
} else {
echo "\n";
?>
<input type="hidden" name="submit_type" value="<?php echo $strInsertAsNewRow; ?>" />
<?php
echo ' ' . $strInsertAsNewRow . "\n";
}
echo "\n";
// Defines whether "insert a new row after the current insert" should be
// checked or not (keep this choice sticky)
// but do not check both radios, because Netscape 4.8 would display both checked
if (!empty($disp_message)) {
$checked_after_insert_new_insert = ' checked="checked"';
$checked_after_insert_back = '';
} else {
$checked_after_insert_back = ' checked="checked"';
$checked_after_insert_new_insert = '';
}
?>
</td>
<td valign="middle">
<b>-- <?php echo $strAnd; ?> --</b>
</td>
<td valign="middle" nowrap="nowrap">
<input type="radio" name="after_insert" value="back" id="radio_after_insert_back" <?php echo $checked_after_insert_back; ?> tabindex="<?php echo ((3 * $fields_cnt) + 3); ?>" /><label for="radio_after_insert_back"><?php echo $strAfterInsertBack; ?></label><br />
<?php echo $strOr; ?><br />
<input type="radio" name="after_insert" value="new_insert" id="radio_after_insert_new_insert"<?php echo $checked_after_insert_new_insert; ?> tabindex="<?php echo ((3 * $fields_cnt) + 4); ?>" /><label for="radio_after_insert_new_insert"><?php echo $strAfterInsertNewInsert; ?></label>
</td>
</tr>
<tr>
<td colspan="3" align="right" valign="middle">
<input type="submit" value="<?php echo $strGo; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 5); ?>" />
<input type="reset" value="<?php echo $strReset; ?>" tabindex="<?php echo ((3 * $fields_cnt) + 6); ?>" />
</td>
</tr>
</table>
</form>
<?php
/**
* Displays the footer
*/
echo "\n";
require_once('./footer.inc.php');
?>