Handle hostnames with upper-case letters
[webmin.git] / mysql / csv_form.cgi
1 #!/usr/local/bin/perl
2 # Show a form for exporting CSV data
3
4 require './mysql-lib.pl';
5 &ReadParse();
6 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
7 $access{'edonly'} && &error($text{'dbase_ecannot'});
8
9 $desc = &text('table_header', "<tt>$in{'table'}</tt>", "<tt>$in{'db'}</tt>");
10 &ui_print_header($desc, $text{'csv_title'}, "", "csv");
11
12 print &ui_form_start("csv.cgi/$in{'table'}.csv", "post");
13 print &ui_hidden("db", $in{'db'}),"\n";
14 print &ui_hidden("table", $in{'table'}),"\n";
15 print &ui_table_start($text{'csv_header'}, undef, 2);
16
17 print &ui_table_row($text{'csv_format'},
18                     &ui_radio("format", 0, [ [ 0, $text{'csv_format0'} ],
19                                              [ 1, $text{'csv_format1'} ],
20                                              [ 2, $text{'csv_format2'} ] ]));
21
22 print &ui_table_row($text{'csv_headers'},
23                     &ui_yesno_radio("headers", 0));
24
25 if ($access{'buser'}) {
26         # Only allow saving to file if a backup user is configured
27         print &ui_table_row($text{'csv_dest'},
28                     &ui_radio("dest", 0, [ [ 0, $text{'csv_browser'}."<br>" ],
29                                            [ 1, $text{'csv_file'} ] ])."\n".
30                     &ui_textbox("file", undef, 40)." ".
31                     &file_chooser_button("file"));
32         }
33
34 # Rows to select
35 print &ui_table_row($text{'csv_where'},
36                     &ui_opt_textbox("where", undef, 30, $text{'csv_all'}));
37
38 # Columns to select
39 @str = &table_structure($in{'db'}, $in{'table'});
40 @cols = map { $_->{'field'} } @str;
41 print &ui_table_row($text{'csv_cols'},
42             &ui_select("cols", \@cols,
43                        [ map { [ $_->{'field'}, "$_->{'field'} - $_->{'type'}" ] } @str ], 5, 1));
44
45 print &ui_table_end();
46 print &ui_form_end([ [ "ok", $text{'csv_ok'} ] ]);
47
48 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
49         "", $text{'index_return'});