Handle hostnames with upper-case letters
[webmin.git] / postgresql / list_hosts.cgi
1 #!/usr/local/bin/perl
2 # list_hosts.cgi
3 # Display host access records
4
5 require './postgresql-lib.pl';
6 $access{'users'} || &error($text{'host_ecannot'});
7 &ui_print_header(undef, $text{'host_title'}, "", "list_hosts");
8
9 print "$text{'host_desc'}<p>\n";
10
11 $v = &get_postgresql_version();
12 @hosts = &get_hba_config($v);
13 print &ui_form_start("delete_hosts.cgi", "post");
14 @rowlinks = ( &select_all_link("d", 0),
15               &select_invert_link("d", 0),
16               "<a href='edit_host.cgi?new=1'>$text{'host_add'}</a>" );
17 print &ui_links_row(\@rowlinks);
18 if ($v >= 7.3) {
19         @tds = ( "width=5", "width=25%", "width=25%", "width=25%",
20                  "width=25%", "width=16" );
21         }
22 else {
23         @tds = ( "width=5", "width=33%", "width=33%", "width=33%", "width=16" );
24         }
25 print &ui_columns_start([ "",
26                           $text{'host_address'},
27                           $text{'host_db'},
28                           $v >= 7.3 ? ( $text{'host_user'} ) : ( ),
29                           $text{'host_auth'},
30                           $text{'host_move'} ], 100, 0, \@tds);
31 foreach $h (@hosts) {
32         local @cols;
33         local $ssl = $h->{'type'} eq 'hostssl' ? " ($text{'host_viassl'})" : "";
34         push(@cols, "<a href='edit_host.cgi?idx=$h->{'index'}'>".
35            &html_escape(
36               $h->{'type'} eq 'local' ? $text{'host_local'} :
37               $h->{'netmask'} eq '255.255.255.255' ? $h->{'address'}.$ssl :
38               $h->{'netmask'} eq '0.0.0.0' ? $text{'host_any'}.$ssl :
39               $h->{'cidr'} ne "" ? $h->{'address'}.'/'.$h->{'cidr'}.$ssl :
40               $h->{'address'}.'/'.$h->{'netmask'}.$ssl)."</a>");
41         push(@cols, $h->{'db'} eq 'all' ? $text{'host_all'} :
42                     $h->{'db'} eq 'sameuser' ? $text{'host_same'} :
43                                                $h->{'db'});
44         if ($v >= 7.3) {
45                 push(@cols, $h->{'user'} eq 'all' ? $text{'host_uall'}
46                                                    : $h->{'user'});
47                 }
48         push(@cols, $text{"host_$h->{'auth'}"} || $h->{'auth'});
49         local $mover;
50         if ($h eq $hosts[@hosts-1]) {
51                 $mover .= "<img src=images/gap.gif>";
52                 }
53         else {
54                 $mover .= "<a href='down.cgi?idx=$h->{'index'}'>".
55                           "<img src=images/down.gif border=0></a>";
56                 }
57         if ($h eq $hosts[0]) {
58                 $mover .= "<img src=images/gap.gif>";
59                 }
60         else {
61                 $mover .= "<a href='up.cgi?idx=$h->{'index'}'>".
62                           "<img src=images/up.gif border=0></a>";
63                 }
64         push(@cols, $mover);
65         print &ui_checked_columns_row(\@cols, \@tds, "d", $h->{'index'});
66         }
67 print &ui_columns_end();
68 print &ui_links_row(\@rowlinks);
69 print &ui_form_end([ [ "delete", $text{'user_delete'} ] ]);
70
71 &ui_print_footer("", $text{'index_return'});
72