Handle hostnames with upper-case letters
[webmin.git] / itsecur-firewall / edit_service.cgi
1 #!/usr/bin/perl
2 # edit_service.cgi
3 # Show a form for editing or creating a user-defined
4
5 require './itsecur-lib.pl';
6 &can_use_error("services");
7 &ReadParse();
8 if ($in{'new'}) {
9         &header($text{'service_title1'}, "",
10                 undef, undef, undef, undef, &apply_button());
11         }
12 else {
13         &header($text{'service_title2'}, "",
14                 undef, undef, undef, undef, &apply_button());
15         @services = &list_services();
16         #$service = $services[$in{'idx'}];
17                 if (defined($in{'idx'})) {
18                 $service = $services[$in{'idx'}];
19                 }
20         else {
21                 ($service) = grep { $_->{'name'} eq $in{'name'} } @services;
22                 $in{'idx'} = $services->{'index'};
23                 }       
24         }
25 print "<hr>\n";
26
27 print "<form action=save_service.cgi>\n";
28 print "<input type=hidden name=new value='$in{'new'}'>\n";
29 print "<input type=hidden name=idx value='$in{'idx'}'>\n";
30 print "<table border>\n";
31 print "<tr $tb> <td><b>$text{'service_header'}</b></td> </tr>\n";
32 print "<tr $cb> <td><table>\n";
33
34 # Show service name input
35 print "<tr> <td><b>$text{'service_name'}</b></td>\n";
36 printf "<td><input name=name size=20 value='%s'></td> </tr>\n",
37         $service->{'name'};
38
39 # Show protocols and ports
40 print "<tr> <td valign=top><b>$text{'service_ports'}</b></td>\n";
41 print "<td><table border>\n";
42 print "<tr $tb> <td><b>$text{'service_proto'}</b></td> ",
43       "<td><b>$text{'service_port'}</b></td> </tr>\n";
44 for($i=0; $i<@{$service->{'protos'}}+6; $i++) {
45         print "<tr>\n";
46         print "<td>",&protocol_input(
47                 "proto_$i", $service->{'protos'}->[$i]),"</td>\n";
48         printf "<td><input name=port_%d size=20 value='%s'></td>\n",
49                 $i, $service->{'ports'}->[$i];
50         print "</tr>\n";
51         }
52 print "</table></td> </tr>\n";
53
54 # Show member services
55 print "<tr> <td valign=top><b>$text{'service_members'}</b></td>\n";
56 print "<td>",&service_input("others",
57                 join(",", @{$service->{'others'}}), 0, 1),"</td> </tr>\n";
58
59 print "</table></td></tr></table>\n";
60 if ($in{'new'}) {
61         print "<input type=submit value='$text{'create'}'>\n";
62         }
63 else {
64         print "<input type=submit value='$text{'save'}'>\n";
65         print "<input type=submit name=delete value='$text{'delete'}'>\n";
66         }
67 print "</form>\n";
68 &can_edit_disable("services");
69
70 print "<hr>\n";
71 &footer("list_services.cgi", $text{'services_return'});
72
73