Handle hostnames with upper-case letters
[webmin.git] / quota / index.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a list of all local filesystems, and allow editing of quotas
4 # on those which have quotas turned on. The actual turning on of quotas must
5 # be done in the mount module first.
6
7 require './quota-lib.pl';
8 &ui_print_header(undef, $text{'index_title'}, "", "intro", 1, 1, 0,
9         &help_search_link("quota", "man", "howto"));
10
11 $err = &quotas_init();
12 if ($err) {
13         print "<p><b>$err</b><p>\n";
14         &ui_print_footer("/", $text{'index_return'});
15         exit;
16         }
17
18 @list = &list_filesystems();
19 if (@list) {
20         print &ui_columns_start([
21                 $text{'index_fs'},
22                 $text{'index_type'},
23                 $text{'index_mount'},
24                 $text{'index_status'},
25                 $access{'enable'} ? ( $text{'index_action'} ) : (),
26                 ], 100);
27         @tds = ( "", "valign=top", "valign=top", "valign=top", "valign=top" );
28         foreach $f (@list) {
29                 $qc = $f->[4];
30                 $qc = $qc&1 if ($access{'gmode'} == 3);
31                 next if (!$qc);
32                 next if (!&can_edit_filesys($f->[0]));
33                 $qn = $f->[5];
34                 if ($qc == 1) { $msg = $text{'index_quser'}; }
35                 elsif ($qc == 2) { $msg = $text{'index_qgroup'}; }
36                 elsif ($qc == 3) { $msg = $text{'index_qboth'}; }
37                 $canactivate = 1;
38                 if ($qn >= 4) {
39                         $chg = $text{'index_mountonly'};
40                         $qn -= 4;
41                         $canactivate = 0;
42                         if ($qn) {
43                                 $msg .= " $text{'index_active'}";
44                                 }
45                         else {
46                                 $msg .= " $text{'index_inactive'}";
47                                 }
48                         }
49                 elsif ($qn) {
50                         $msg .= " $text{'index_active'}";
51                         $chg = $text{'index_disable'};
52                         }
53                 else {
54                         $msg .= " $text{'index_inactive'}";
55                         $chg = $text{'index_enable'};
56                         }
57                 if ($qn%2 == 1) { $useractive++; }
58                 if ($qn > 1) { $groupactive++; }
59
60                 local @cols;
61                 $dir = $f->[0];
62                 if (!$qn) {
63                         push(@cols, $dir);
64                         }
65                 elsif ($qc == 1) {
66                         push(@cols, "<a href=\"list_users.cgi?dir=".
67                            &urlize($dir)."&can=",&urlize($qc),"\">$dir</a>");
68                         }
69                 elsif ($qc == 2) {
70                         push(@cols, "<a href=\"list_groups.cgi?dir=".
71                             &urlize($dir)."&can=",&urlize($qc),"\">$dir</a>");
72                         }
73                 elsif ($qc == 3) {
74                         push(@cols, "<a href=\"list_users.cgi?dir=".
75                             &urlize($dir)."&can=".&urlize($qc).
76                             "\">$dir (users)</a><br>".
77                             "<a href=\"list_groups.cgi?dir=".&urlize($dir).
78                             "&can=".&urlize($qc)."\">$dir (groups)</a>");
79                         }
80
81                 push(@cols, &foreign_call("mount", "fstype_name", $f->[2]));
82                 push(@cols, &foreign_call("mount", "device_name", $f->[1]));
83                 push(@cols, $msg);
84                 if ($access{'enable'}) {
85                         if ($canactivate) {
86                                 push(@cols, "<a href=\"activate.cgi?dir=$dir&active=$qn&mode=$qc\">$chg</a>");
87                                 }
88                         else {
89                                 push(@cols, $chg);
90                                 }
91                         }
92                 print &ui_columns_row(\@cols, \@tds);
93                 }
94         print &ui_columns_end();
95         }
96 else {
97         print "<b>$text{'index_nosupport'}</b><p>\n";
98         if (&foreign_available("mount")) {
99                 print &text('index_mountmod', "../mount/"),"<p>\n";
100                 }
101         }
102
103 # Buttons to edit and specific user or group
104 if ($useractive || $groupactive) {
105         print &ui_hr();
106         print &ui_buttons_start();
107         }
108 if ($useractive) {
109         print &ui_buttons_row("user_filesys.cgi", $text{'index_euser'},
110                               $text{'index_euserdesc'}, undef,
111                               &ui_user_textbox("user"));
112         }
113 if ($groupactive) {
114         print &ui_buttons_row("group_filesys.cgi", $text{'index_egroup'},
115                               $text{'index_egroupdesc'}, undef,
116                               &ui_group_textbox("group"));
117         }
118 if ($useractive || $groupactive) {
119         print &ui_buttons_end();
120         }
121
122 &ui_print_footer("/", $text{'index_return'});
123