Handle hostnames with upper-case letters
[webmin.git] / exports-nfs4 / index.cgi
1 #!/usr/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         print &select_all_link("d"),"\n";
24         print &select_invert_link("d"),"\n";
25         print "<a href=\"edit_export.cgi?new=1\">$text{'index_add'}</a> <br>\n";
26         @tds = ( "width=5" );
27         print &ui_columns_start([ "",
28                                   $text{'index_dir'},
29                                   $text{'index_to'} ], 100, 0, \@tds);
30
31         # Rows for directories and clients
32         foreach $d (@dirs) {
33                 local @cols;
34                 if ($d ne $nfsv4_root) {
35                         push(@cols, &html_escape($d));
36                         }
37                 else {
38                         push(@cols, "<font color=#00ff00>".
39                                     &html_escape($d)." (".$text{'index_vr'}.")".
40                                     "</font>");
41                         }
42                 local $dirs;
43                 @cl = grep { $_->{'dir'} eq $d } @exps;
44                 $ccount = 0;
45                 foreach $c (@cl) {
46                         $dirs .= "&nbsp;|&nbsp; " if ($ccount++);
47                         $dirs .= "<a href='edit_export.cgi?idx=$c->{'index'}'>".
48                                  &describe_host($c->{'host'})."</a>\n";
49                          if (!$c->{'active'}) {
50                                 $dirs .= "<font color=#ff0000>(".
51                                          $text{'index_inactive'}.")</font>\n"
52                                 }
53                         }
54                 push(@cols, $dirs);
55                 print &ui_checked_columns_row(\@cols, \@tds, "d", $d);
56                 }
57         print &ui_columns_end();
58         print &select_all_link("d"),"\n";
59         print &select_invert_link("d"),"\n";
60         print "<a href=\"edit_export.cgi?new=1\">$text{'index_add'}</a> <br>\n";
61         print &ui_form_end([ [ "delete", $text{'index_delete'} ],
62                              [ "disable", $text{'index_disable'} ],
63                              [ "enable", $text{'index_enable'} ] ]);
64         }
65 else {
66         print "<b>$text{'index_none'}</b> <p>\n";
67         print "<a href=\"edit_export.cgi?new=1\">$text{'index_add'}</a> <p>\n";
68         }
69
70 print "<hr>\n";
71 print "<table width=100%> <tr>\n";
72 print "<td><form action=restart_mountd.cgi>\n";
73 print "<input type=submit value=\"$text{'index_apply'}\">\n";
74 print "</form></td>\n";
75 print "<td valign=top>$text{'index_applymsg'}</td>\n";
76 print "</tr> <tr> </table>\n";
77
78 &ui_print_footer("/", $text{'index'});
79