Handle hostnames with upper-case letters
[webmin.git] / exports / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a list of directories and their client(s)
4
5 $| = 1;
6 require './exports-lib.pl';
7 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
8         &help_search_link("nfs exports", "man", "howto"));
9
10 if (!&has_nfs_commands()) {
11         print $text{'index_eprog'},"<p>\n";
12         &ui_print_footer("/", $text{'index'});
13         exit;
14         }
15
16 # Display table of exports and clients
17 @exps = &list_exports();
18 if (@exps) {
19         print &ui_form_start("delete_exports.cgi", "post");
20         @dirs = &unique(map { $_->{'dir'} } @exps);
21
22         # Directory list heading
23         @links = ( &select_all_link("d"),
24                    &select_invert_link("d"),
25                    "<a href=\"edit_export.cgi?new=1\">$text{'index_add'}</a>" );
26         print &ui_links_row(\@links);
27         @tds = ( "width=5" );
28         print &ui_columns_start([ "",
29                                   $text{'index_dir'},
30                                   $text{'index_to'} ], 100, 0, \@tds);
31
32         # Rows for directories and clients
33         foreach $d (@dirs) {
34                 local @cols;
35                 push(@cols, &html_escape($d));
36                 local $dirs;
37                 @cl = grep { $_->{'dir'} eq $d } @exps;
38                 $ccount = 0;
39                 foreach $c (@cl) {
40                         $dirs .= "&nbsp;|&nbsp; " if ($ccount++);
41                         $dirs .= "<a href='edit_export.cgi?idx=$c->{'index'}'>".
42                                  &describe_host($c->{'host'})."</a>\n";
43                          if (!$c->{'active'}) {
44                                 $dirs .= "<font color=#ff0000>(".
45                                          $text{'index_inactive'}.")</font>\n"
46                                 }
47                         }
48                 push(@cols, $dirs);
49                 print &ui_checked_columns_row(\@cols, \@tds, "d", $d);
50                 }
51         print &ui_columns_end();
52         print &ui_links_row(\@links);
53         print &ui_form_end([ [ "delete", $text{'index_delete'} ],
54                              [ "disable", $text{'index_disable'} ],
55                              [ "enable", $text{'index_enable'} ] ]);
56         }
57 else {
58         print "<b>$text{'index_none'}</b> <p>\n";
59         print "<a href=\"edit_export.cgi?new=1\">$text{'index_add'}</a> <p>\n";
60         }
61
62 print &ui_hr();
63 print &ui_buttons_start();
64 print &ui_buttons_row("restart_mountd.cgi", $text{'index_apply'},
65                       $text{'index_applymsg'});
66 print &ui_buttons_end();
67
68 &ui_print_footer("/", $text{'index'});
69