Handle hostnames with upper-case letters
[webmin.git] / net / list_hosts.cgi
1 #!/usr/local/bin/perl
2 # list_hosts.cgi
3 # List hosts from /etc/hosts
4
5 require './net-lib.pl';
6 $access{'hosts'} || &error($text{'hosts_ecannot'});
7 &ui_print_header(undef, $text{'hosts_title'}, "");
8
9 if ($access{'hosts'} == 2) {
10         print &ui_form_start("delete_hosts.cgi", "post");
11         @links = ( &select_all_link("d"),
12                    &select_invert_link("d"),
13                    "<a href=\"edit_host.cgi?new=1\">$text{'hosts_add'}</a>" );
14         print &ui_links_row(\@links);
15         @tds = ( "width=5" );
16         }
17 print &ui_columns_start([ $access{'hosts'} == 2 ? ( "" ) : ( ),
18                           $text{'hosts_ip'},
19                           $text{'hosts_host'} ], undef, 0, \@tds);
20 foreach $h (&list_hosts()) {
21         local @cols;
22         if ($access{'hosts'} == 2) {
23                 push(@cols, "<a href=\"edit_host.cgi?idx=$h->{'index'}\">".
24                             &html_escape($h->{'address'})."</a>");
25                 }
26         else {
27                 push(@cols, &html_escape($h->{'address'}));
28                 }
29         push(@cols, join(" , ", map { &html_escape($_) }
30                                     @{$h->{'hosts'}}));
31         if ($access{'hosts'} == 2) {
32                 print &ui_checked_columns_row(\@cols, \@tds, "d",$h->{'index'});
33                 }
34         else {
35                 print &ui_columns_row(\@cols);
36                 }
37         }
38 print &ui_columns_end();
39 if ($access{'hosts'} == 2) {
40         print &ui_links_row(\@links);
41         print &ui_form_end([ [ "delete", $text{'hosts_delete'} ] ]);
42         }
43
44 &ui_print_footer("", $text{'index_return'});
45