1 |
95b003ff
|
Origo
|
#!/usr/bin/perl
|
2 |
|
|
# edit_auth.cgi
|
3 |
|
|
# Display commands and allowed users
|
4 |
|
|
|
5 |
|
|
require './mon-lib.pl';
|
6 |
|
|
&ui_print_header(undef, $text{'auth_title'}, "");
|
7 |
|
|
|
8 |
|
|
$file = &mon_auth_file();
|
9 |
|
|
open(FILE, $file);
|
10 |
|
|
while(<FILE>) {
|
11 |
|
|
s/\r|\n//g;
|
12 |
|
|
s/#.*$//;
|
13 |
|
|
if (/^(\S+):\s*(.*)$/) {
|
14 |
|
|
$auth{$1} = [ split(/,/, $2) ];
|
15 |
|
|
}
|
16 |
|
|
}
|
17 |
|
|
close(FILE);
|
18 |
|
|
|
19 |
|
|
print "$text{'auth_desc'}<p>\n";
|
20 |
|
|
|
21 |
|
|
print "<form action=save_auth.cgi method=post>\n";
|
22 |
|
|
print "<table border>\n";
|
23 |
|
|
print "<tr $tb> <td><b>$text{'auth_cmd'}</b></td> ",
|
24 |
|
|
"<td><b>$text{'auth_users'}</b></td> </tr>\n";
|
25 |
|
|
printf "<input type=hidden name=types value='%s'>\n", join(" ", keys %auth);
|
26 |
|
|
foreach $a (&list_auth_types()) {
|
27 |
|
|
local @au = @{$auth{$a}};
|
28 |
|
|
print "<tr $cb> <td><b>$a</b></td> <td>\n";
|
29 |
|
|
printf "<input type=radio name=${a}_mode value=2 %s> %s\n",
|
30 |
|
|
@au ? "" : "checked", $text{'auth_none'};
|
31 |
|
|
printf "<input type=radio name=${a}_mode value=1 %s> %s\n",
|
32 |
|
|
$au[0] eq "all" ? "checked" : "", $text{'auth_all'};
|
33 |
|
|
printf "<input type=radio name=${a}_mode value=0 %s> %s\n",
|
34 |
|
|
@au && $au[0] ne "all" ? "checked" : "",
|
35 |
|
|
$text{'auth_sel'};
|
36 |
|
|
printf "<input name=$a size=40 value='%s'> %s</td> </tr>\n",
|
37 |
|
|
$au[0] eq "all" ? "" : join(" ", @{$auth{$a}}),
|
38 |
|
|
&user_chooser_button($a, 0);
|
39 |
|
|
delete($auth{$a});
|
40 |
|
|
}
|
41 |
|
|
print "</table>\n";
|
42 |
|
|
foreach $a (keys %auth) {
|
43 |
|
|
print "<input type=hidden name=$a value='",
|
44 |
|
|
join(",", @{$auth{$a}}),"'>\n";
|
45 |
|
|
}
|
46 |
|
|
print "<input type=submit value='$text{'save'}'></form>\n";
|
47 |
|
|
|
48 |
|
|
&ui_print_footer("", $text{'index_return'});
|