Handle hostnames with upper-case letters
[webmin.git] / custom / form.cgi
1 #!/usr/local/bin/perl
2 # form.cgi
3 # Display the form for one custom command on a page
4
5 require './custom-lib.pl';
6 &ReadParse();
7 $cmd = &get_command($in{'id'}, $in{'idx'});
8 &can_run_command($cmd) || &error($text{'form_ecannot'});
9
10 # Display form for command parameters
11 &ui_print_header(undef, $text{'form_title'}, "");
12 @a = @{$cmd->{'args'}};
13 @up = grep { $_->{'type'} == 10 } @a;
14 if ($cmd->{'edit'}) {
15         print &ui_form_start("view.cgi");
16         }
17 elsif (@up) {
18         # Has upload fields
19         @ufn = map { $_->{'name'} } @up;
20         $upid = time().$$;
21         print &ui_form_start("run.cgi?id=$upid",
22           "form-data", undef,
23           &read_parse_mime_javascript($upid, \@ufn));
24         }
25 elsif (@a) {
26         print &ui_form_start("run.cgi", "post");
27         }
28 else {
29         print &ui_form_start("run.cgi");
30         }
31 print &ui_hidden("id", $cmd->{'id'});
32 print &ui_table_start(&html_escape($cmd->{'desc'}), "width=100%", 4,
33                       [ "width=20%", "width=30%", "width=20%", "width=30%" ]);
34 print &ui_table_row(undef, $cmd->{'html'}, 4) if ($cmd->{'html'});
35
36 foreach $a (@{$cmd->{'args'}}) {
37         print &ui_table_row(&html_escape($a->{'desc'}),
38                 &show_parameter_input($a, 0));
39         }
40
41 $txt = $cmd->{'edit'} ? $text{'form_edit'} : $text{'form_exec'};
42 print &ui_table_end();
43 print &ui_form_end([ [ undef, $txt ] ]);
44
45 &ui_print_footer("", $text{'index_return'});
46