Handle hostnames with upper-case letters
[webmin.git] / tcpwrappers / index.cgi
1 #!/usr/local/bin/perl
2 # Show allowed and denied lists
3
4 require './tcpwrappers-lib.pl';
5 &ReadParse();
6 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1);
7
8 # Start of tabs
9 @types = ('allow', 'deny');
10 print &ui_tabs_start(
11         [ map { [ $_, $text{'index_'.$_.'title'},
12                   "index.cgi?type=$_" ] } @types ],
13         "type",
14         $in{'type'} || "allow",
15         1);
16
17 # Tables of rules
18 foreach my $type ('allow', 'deny') {
19         print &ui_tabs_start_tab("type", $type);
20         my $file = $type eq 'allow' ? $config{'hosts_allow'}
21                                     : $config{'hosts_deny'};
22         @rules = &list_rules($file);
23
24         # Build grid of rules
25         @table = ( );
26         foreach my $r (@rules) {
27                 push(@table, [
28                         { 'type' => 'checkbox', 'name' => 'd',
29                           'value' => $r->{'id'} },
30                         "<a href='edit_rule.cgi?$type=1&id=$r->{'id'}'>".
31                          "$r->{'service'}</a>",
32                         $r->{'host'},
33                         $r->{'cmd'} ? join("<br>", split /:/, $r->{'cmd'})
34                                     : $text{'index_none'},
35                         ]);
36                 }
37
38         # Show them
39         print &ui_form_columns_table(
40                 "delete_rules.cgi",
41                [ [ "delete", $text{'index_delete'} ] ],
42                1,
43                [ [ "edit_rule.cgi?$type=1&new=1", $text{'index_add'} ] ],
44                [ [ $type, 1 ] ],
45                [ "", $text{'index_service'},
46                  $text{'index_hosts'}, $text{'index_cmd'}, ],
47                100,
48                \@table,
49                undef,
50                0,
51                undef,
52                &text('index_norule', $file),
53                );                       
54         print &ui_tabs_end_tab("type", $type);
55         }
56
57 print &ui_tabs_end(1);
58
59 &ui_print_footer("/", $text{'index_return'});