Handle hostnames with upper-case letters
[webmin.git] / dfsadmin / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3
4 require './dfs-lib.pl';
5 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
6         &help_search_link("dfstab share", "man"));
7
8 @shlist = &list_shares();
9 if (@shlist && $access{'icons'}) {
10         # Display shares as icons
11         print "<a href=\"edit_share.cgi\">$text{'index_add'}</a><br>\n";
12         foreach $s (@shlist) {
13                 next if ($s->{'type'} ne 'nfs');
14                 push(@icons, "images/share.gif");
15                 push(@titles, $s->{'dir'});
16                 push(@links, "edit_share.cgi?$s->{'index'}");
17                 }
18         &icons_table(\@links, \@titles, \@icons);
19         if (!$access{'view'}) {
20                 print "<a href=\"edit_share.cgi\">$text{'index_add'}</a><br>\n";
21                 }
22         }
23 elsif (@shlist) {
24         # Display shares as table
25         if (!$access{'view'}) {
26                 print &ui_form_start("delete_shares.cgi", "post");
27                 print &select_all_link("d"),"\n";
28                 print &select_invert_link("d"),"\n";
29                 print "<a href=\"edit_share.cgi\">$text{'index_add'}</a><br>\n";
30                 @tds = ( "width=5" );
31                 }
32         print &ui_columns_start([
33                 $access{'view'} ? ( ) : ( "" ),
34                 $text{'index_dir'},
35                 $text{'index_clients'} ], 100, 0, \@tds);
36         foreach $s (@shlist) {
37                 next if ($s->{'type'} ne 'nfs');
38                 &parse_options($s->{'opts'});
39                 local @cols;
40                 if ($access{'view'}) {
41                         push(@cols, &html_escape($s->{'dir'}));
42                         }
43                 elsif (defined($options{'public'})) {
44                         push(@cols, "<a href=\"edit_share.cgi?$s->{'index'}\">".
45                                     &html_escape($s->{'dir'})."</a>");
46                         }
47                 else {
48                         push(@cols, "<a href=\"edit_share.cgi?$s->{'index'}\">".                                    &html_escape($s->{'dir'})."</a>");
49                         }
50                 undef(%clients);
51                 foreach (split(/:/, $options{"ro"})) { $clients{$_}++; }
52                 foreach (split(/:/, $options{"rw"})) { $clients{$_}++; }
53                 foreach (split(/:/, $options{"root"})) { $clients{$_}++; }
54                 if (%clients) {
55                         $clients = join(' &nbsp;|&nbsp; ' , sort { $a cmp $b }
56                             map { &html_escape($_ =~ /^\@(.*)/ ? "$1.*" : $_) }
57                                      (keys %clients) );
58                         if (length($clients) > 80) {
59                                 $clients = substr($clients, 0, 80)."...";
60                                 }
61                         }
62                 else {
63                         $clients = $text{'index_everyone'};
64                         }
65                 push(@cols, $clients);
66                 if ($access{'view'}) {
67                         print &ui_columns_row(\@cols, \@tds);
68                         }
69                 else {
70                         print &ui_checked_columns_row(\@cols, \@tds, "d",
71                                                       $s->{'index'});
72                         }
73                 }
74         print &ui_columns_end();
75         if (!$access{'view'}) {
76                 print &select_all_link("d"),"\n";
77                 print &select_invert_link("d"),"\n";
78                 print "<a href=\"edit_share.cgi\">$text{'index_add'}</a><br>\n";
79                 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
80                 }
81         }
82 else {
83         print "<b>$text{'index_none'}</b><p>\n";
84         print "<a href=\"edit_share.cgi\">$text{'index_add'}</a><p>\n";
85         }
86
87 if (!$access{'view'}) {
88         print &ui_hr();
89         print &ui_buttons_start();
90         print &ui_buttons_row("restart_sharing.cgi",
91                               $text{'index_apply'},
92                               $text{'index_applydesc'});
93         print &ui_buttons_end();
94         }
95
96 &ui_print_footer("/", "index");
97