Handle hostnames with upper-case letters
[webmin.git] / ipsec / edit_policy.cgi
1 #!/usr/local/bin/perl
2 # edit_policy.cgi
3 # Display entries from a policy file for editing
4
5 require './ipsec-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'policy_desc_'.$in{'policy'}} ||
8         &text('policy_desc', $in{'policy'}), "");
9
10 # Show explanation of this policy
11 print $text{'policy_longdesc_'.$in{'policy'}} ||
12       &text('policy_longdesc', $in{'policy'}),"<p>\n";
13 print "<form action=save_policy.cgi method=post>\n";
14 print "<input type=hidden name=policy value='$in{'policy'}'>\n";
15
16 @policies = &read_policy($in{'policy'});
17 $mode = !@policies ? 0 :
18         @policies == 1 && $policies[0] eq "0.0.0.0/0" ? 1 : 2;
19 foreach $m (0 .. 2) {
20         printf "<input type=radio name=mode value=%s %s> %s\n",
21                 $m, $mode == $m ? "checked" : "", $text{'policy_mode'.$m};
22         }
23 print "<br>\n";
24
25 # Show a table of networks
26 print "<table border>\n";
27 print "<tr $tb> <td><b>$text{'policy_net'}</b></td> ",
28       "<td><b>$text{'policy_mask'}</b></td> </tr>\n";
29 $i = 0;
30 foreach $p ($mode == 2 ? @policies : ( ), "", "") {
31         local ($n, $m) = split(/\//, $p);
32         print "<tr $cb>\n";
33         print "<td><input name=net_$i size=20 value='$n'></td>\n";
34         print "<td><input name=mask_$i size=5 value='$m'></td>\n";
35         print "</tr>\n";
36         $i++;
37         }
38 print "</table>\n";
39 print "<input type=submit value='$text{'save'}'></form>\n";
40
41 &ui_print_footer("", $text{'index_return'});
42