Handle hostnames with upper-case letters
[webmin.git] / mysql / edit_host.cgi
1 #!/usr/local/bin/perl
2 # edit_host.cgi
3 # Edit or create a host table record
4
5 require './mysql-lib.pl';
6 &ReadParse();
7 $access{'perms'} || &error($text{'perms_ecannot'});
8
9 if ($in{'new'}) {
10         &ui_print_header(undef, $text{'host_title1'}, "");
11         }
12 else {
13         $d = &execute_sql_safe($master_db, "select * from host order by host");
14         $u = $d->{'data'}->[$in{'idx'}];
15         $access{'perms'} == 1 || &can_edit_db($u->[1]) ||
16                 &error($text{'perms_edb'});
17         &ui_print_header(undef, $text{'host_title2'}, "");
18         }
19
20 print &ui_form_start("save_host.cgi");
21 if ($in{'new'}) {
22         print &ui_hidden("new", 1);
23         }
24 else {
25         print &ui_hidden("oldhost", $u->[0]);
26         print &ui_hidden("olddb", $u->[1]);
27         }
28 print &ui_table_start($text{'host_header'}, undef, 2);
29
30 # Database name
31 print &ui_table_row($text{'host_db'}, &select_db($u->[1]));
32
33 # Hostname pattern
34 print &ui_table_row($text{'host_host'},
35         &ui_opt_textbox("host", $u->[0] eq '%' ? '' : $u->[0], 40,
36                         $text{'host_any'}));
37
38 # Host's permissions
39 for($i=2; $i<=&host_priv_cols()+2-1; $i++) {
40         push(@opts, [ $i, $text{"host_priv$i"} ]);
41         push(@sel, $i) if ($u->[$i] eq 'Y');
42         }
43 print &ui_table_row($text{'host_perms'},
44         &ui_select("perms", \@sel, \@opts, 10, 1, 1));
45
46 print &ui_table_end();
47 print &ui_form_end([ $in{'new'} ? ( [ undef, $text{'create'} ] )
48                                 : ( [ undef, $text{'save'} ],
49                                     [ 'delete', $text{'delete'} ] ) ]);
50
51 &ui_print_footer('list_hosts.cgi', $text{'hosts_return'},
52         "", $text{'index_return'});
53