Handle hostnames with upper-case letters
[webmin.git] / pap / edit_secret.cgi
1 #!/usr/local/bin/perl
2 # edit_secret.cgi
3 # Displays a form for editing or creating a pap secret
4
5 require './pap-lib.pl';
6 $access{'secrets'} || &error($text{'secrets_ecannot'});
7 if (@ARGV) {
8         $idx = $ARGV[0];
9         &ui_print_header(undef, $text{'edit_secret_etitle'}, "");
10         @seclist = &list_secrets();
11         %sec = %{$seclist[$idx]};
12         }
13 else {
14         &ui_print_header(undef, $text{'edit_secret_ctitle'}, "");
15         }
16
17 print "<form action=save_secret.cgi>\n";
18 if (%sec) { print "<input type=hidden name=idx value=$idx>\n"; }
19 print "<table border width=100%>\n";
20 print "<tr $tb> <td><b>",$text{'edit_secret_acc'},"</b></td> </tr>\n";
21 print "<tr $cb> <td><table widht=100%>\n";
22
23 print "<tr $cb> <td><b>", $text{'edit_secret_user'}, "</b></td>\n";
24 printf "<td><input type=radio name=client_def value=1 %s> ",
25         %sec && !$sec{'client'} ? "checked" : "";
26 print $text{'edit_secret_uany'}, "\n";
27 printf "<input type=radio name=client_def value=0 %s> ",
28         %sec && !$sec{'client'} ? "" : "checked";
29 print "<input name=client size=20 value=\"$sec{'client'}\"></td>\n";
30
31 print "<td><b>",$text{'edit_secret_serv'},"</b></td>\n";
32 printf "<td><input type=radio name=server_def value=1 %s> ",
33         $sec{'server'} eq "*" ? "checked" : "";
34 print $text{'edit_secret_sany'},"\n";
35 printf "<input type=radio name=server_def value=0 %s> ",
36         $sec{'server'} eq "*" ? "" : "checked";
37 printf "<input name=server size=20 value=\"%s\"></td> </tr>\n",
38         $sec{'server'} eq "*" ? "" : $sec{'server'};
39
40 print "<tr $cb> <td valign=top><b>", $text{'edit_secret_pass'}, "</b></td>\n";
41 printf "<td valign=top><input type=radio name=pass_mode value=0 %s> ",
42         %sec && $sec{'secret'} eq "" ? "checked" : "";
43 print $text{'edit_secret_none'}, "<br>\n";
44 printf "<input type=radio name=pass_mode value=1 %s> ",
45         $sec{'secret'} =~ /^@(.*)$/ ? "checked" : "";
46 print $text{'edit_secret_ffile'};
47 printf "<input name=pass_file size=20 value=\"%s\">\n",
48         $sec{'secret'} =~ /^@(.*)$/ ? $1 : "";
49 print &file_chooser_button("pass_file", 0);
50 print "<br>\n";
51 if (%sec) {
52         printf "<input type=radio name=pass_mode value=2 %s> ",
53                 $sec{'secret'} !~ /^(@.*|)$/ ? "checked" : "";
54         print $text{'edit_secret_leave'}, "<br>\n";
55         }
56 printf "<input type=radio name=pass_mode value=3 %s> ",
57         %sec ? "" : "checked";
58 print $text{'edit_secret_setto'}, "\n";
59 print "<input type=password name=pass_text size=15></td>\n";
60
61 @ips = @{$sec{'ips'}};
62 print "<td valign=top><b>", $text{'edit_secret_vaddr'}, "</b></td>\n";
63 printf "<td><input type=radio name=ips_mode value=0 %s> ",
64         $ips[0] eq "*" || !@ips ? "checked" : "";
65 print $text{'edit_secret_aany'}, "<br>\n";
66 printf "<input type=radio name=ips_mode value=1 %s> ",
67         $ips[0] eq "-" ? "checked" : "";
68 print $text{'edit_secret_anone'}, "<br>\n";
69 printf "<input type=radio name=ips_mode value=2 %s> ",
70         @ips && $ips[0] ne "-" && $ips[0] ne "*" ? "checked" : "";
71 print $text{'edit_secret_alist'}, "<br>\n";
72 printf "<textarea name=ips rows=5 cols=20>%s</textarea></td> </tr>\n",
73         @ips && $ips[0] ne "-" && $ips[0] ne "*" ? join("\n", @ips) : "";
74
75 print "</table></td></tr></table>\n";
76
77 print "<table width=100%><tr><td align=left>\n";
78 print "<input type=submit value=", $text{'edit_secret_save'}, "></td>\n";
79 if (%sec) {
80         print "<td align=right>\n";
81         print "<input type=submit name=delete value=", $text{'edit_secret_del'},
82               "></td>\n";
83         }
84 print "</tr></table></form>\n";
85
86 &ui_print_footer("list_secrets.cgi", $text{'edit_secret_return'});
87