Forward Firewall: fixed 12 Bugs from forum.
[people/teissler/ipfire-2.x.git] / html / cgi-bin / optionsfw.cgi
1 #!/usr/bin/perl
2 #
3 # SmoothWall CGIs
4 #
5 # This code is distributed under the terms of the GPL
6 #
7 # (c) The SmoothWall Team
8 #
9 # Copyright (C) 01-02-2002 Graham Smith <grhm@grhm.co.uk>
10 #
11 # $Id: optionsfw.cgi,v 1.1.2.10 2005/10/03 00:34:10 gespinasse Exp $
12 #
13 #
14
15 # enable only the following on debugging purpose
16 #use warnings;
17 #use CGI::Carp 'fatalsToBrowser';
18
19 require '/var/ipfire/general-functions.pl';
20 require "${General::swroot}/lang.pl";
21 require "${General::swroot}/header.pl";
22
23
24 my %checked =(); # Checkbox manipulations
25
26 # File used
27 my $filename = "${General::swroot}/optionsfw/settings";
28
29 our %settings=();
30 $settings{'DISABLEPING'} = 'NO';
31 $settings{'DROPNEWNOTSYN'} = 'on';
32 $settings{'DROPINPUT'} = 'on';
33 $settings{'DROPFORWARD'} = 'on';
34 $settings{'DROPPORTSCAN'} = 'on';
35 $settings{'DROPWIRELESSINPUT'} = 'on';
36 $settings{'DROPWIRELESSFORWARD'} = 'on';
37
38 my $errormessage = '';
39 my $warnmessage = '';
40
41 &Header::showhttpheaders();
42
43 #Get GUI values
44 &Header::getcgihash(\%settings);
45
46 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
47
48 $errormessage = $Lang::tr{'new optionsfw later'};
49 delete $settings{'__CGI__'};
50 delete $settings{'x'};
51 delete $settings{'y'};
52 &General::writehash($filename, \%settings); # Save good settings
53 }else {
54 &General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
55 }
56 system("/usr/local/bin/forwardfwctrl");
57 &Header::openpage($Lang::tr{'options fw'}, 1, '');
58 &Header::openbigbox('100%', 'left', '', $errormessage);
59
60 if ($errormessage) {
61 &Header::openbox('100%', 'left', $Lang::tr{'warning messages'});
62 print "<font color='red'>$errormessage&nbsp;</font>";
63 &Header::closebox();
64 }
65
66 $checked{'DROPNEWNOTSYN'}{'off'} = '';
67 $checked{'DROPNEWNOTSYN'}{'on'} = '';
68 $checked{'DROPNEWNOTSYN'}{$settings{'DROPNEWNOTSYN'}} = "checked='checked'";
69 $checked{'DROPINPUT'}{'off'} = '';
70 $checked{'DROPINPUT'}{'on'} = '';
71 $checked{'DROPINPUT'}{$settings{'DROPINPUT'}} = "checked='checked'";
72 $checked{'DROPFORWARD'}{'off'} = '';
73 $checked{'DROPFORWARD'}{'on'} = '';
74 $checked{'DROPFORWARD'}{$settings{'DROPFORWARD'}} = "checked='checked'";
75 $checked{'DROPPORTSCAN'}{'off'} = '';
76 $checked{'DROPPORTSCAN'}{'on'} = '';
77 $checked{'DROPPORTSCAN'}{$settings{'DROPPORTSCAN'}} = "checked='checked'";
78 $checked{'DROPWIRELESSINPUT'}{'off'} = '';
79 $checked{'DROPWIRELESSINPUT'}{'on'} = '';
80 $checked{'DROPWIRELESSINPUT'}{$settings{'DROPWIRELESSINPUT'}} = "checked='checked'";
81 $checked{'DROPWIRELESSFORWARD'}{'off'} = '';
82 $checked{'DROPWIRELESSFORWARD'}{'on'} = '';
83 $checked{'DROPWIRELESSFORWARD'}{$settings{'DROPWIRELESSFORWARD'}} = "checked='checked'";
84 $checked{'DROPPROXY'}{'off'} = '';
85 $checked{'DROPPROXY'}{'on'} = '';
86 $checked{'DROPPROXY'}{$settings{'DROPPROXY'}} = "checked='checked'";
87 $checked{'DROPSAMBA'}{'off'} = '';
88 $checked{'DROPSAMBA'}{'on'} = '';
89 $checked{'DROPSAMBA'}{$settings{'DROPSAMBA'}} = "checked='checked'";
90 $selected{'FWPOLICY'}{$settings{'FWPOLICY'}}= 'selected';
91
92 &Header::openbox('100%', 'center', $Lang::tr{'options fw'});
93 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
94
95 print <<END
96 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
97 <table width='95%' cellspacing='0'>
98 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw logging'}</b></td></tr>
99 <tr><td align='left' width='60%'>$Lang::tr{'drop newnotsyn'}</td><td align='left'>on <input type='radio' name='DROPNEWNOTSYN' value='on' $checked{'DROPNEWNOTSYN'}{'on'} />/
100 <input type='radio' name='DROPNEWNOTSYN' value='off' $checked{'DROPNEWNOTSYN'}{'off'} /> off</td></tr>
101 <tr><td align='left' width='60%'>$Lang::tr{'drop input'}</td><td align='left'>on <input type='radio' name='DROPINPUT' value='on' $checked{'DROPINPUT'}{'on'} />/
102 <input type='radio' name='DROPINPUT' value='off' $checked{'DROPINPUT'}{'off'} /> off</td></tr>
103 <tr><td align='left' width='60%'>$Lang::tr{'drop forward'}</td><td align='left'>on <input type='radio' name='DROPFORWARD' value='on' $checked{'DROPFORWARD'}{'on'} />/
104 <input type='radio' name='DROPFORWARD' value='off' $checked{'DROPFORWARD'}{'off'} /> off</td></tr>
105 <tr><td align='left' width='60%'>$Lang::tr{'drop portscan'}</td><td align='left'>on <input type='radio' name='DROPPORTSCAN' value='on' $checked{'DROPPORTSCAN'}{'on'} />/
106 <input type='radio' name='DROPPORTSCAN' value='off' $checked{'DROPPORTSCAN'}{'off'} /> off</td></tr>
107 <tr><td align='left' width='60%'>$Lang::tr{'drop wirelessinput'}</td><td align='left'>on <input type='radio' name='DROPWIRELESSINPUT' value='on' $checked{'DROPWIRELESSINPUT'}{'on'} />/
108 <input type='radio' name='DROPWIRELESSINPUT' value='off' $checked{'DROPWIRELESSINPUT'}{'off'} /> off</td></tr>
109 <tr><td align='left' width='60%'>$Lang::tr{'drop wirelessforward'}</td><td align='left'>on <input type='radio' name='DROPWIRELESSFORWARD' value='on' $checked{'DROPWIRELESSFORWARD'}{'on'} />/
110 <input type='radio' name='DROPWIRELESSFORWARD' value='off' $checked{'DROPWIRELESSFORWARD'}{'off'} /> off</td></tr>
111 </table>
112 <br />
113 <table width='95%' cellspacing='0'>
114 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw blue'}</b></td></tr>
115 <tr><td align='left' width='60%'>$Lang::tr{'drop proxy'}</td><td align='left'>on <input type='radio' name='DROPPROXY' value='on' $checked{'DROPPROXY'}{'on'} />/
116 <input type='radio' name='DROPPROXY' value='off' $checked{'DROPPROXY'}{'off'} /> off</td></tr>
117 <tr><td align='left' width='60%'>$Lang::tr{'drop samba'}</td><td align='left'>on <input type='radio' name='DROPSAMBA' value='on' $checked{'DROPSAMBA'}{'on'} />/
118 <input type='radio' name='DROPSAMBA' value='off' $checked{'DROPSAMBA'}{'off'} /> off</td></tr>
119 </table>
120 <br />
121 <table width='95%' cellspacing='0'>
122 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw default drop'}</b></td></tr>
123 <tr><td align='left' width='60%'>$Lang::tr{'drop action'}</td><td><select name='FWPOLICY'>
124 <option value='DROP' $selected{'FWPOLICY'}{'DROP'}>DROP</option>
125 <option value='REJECT' $selected{'FWPOLICY'}{'REJECT'}>REJECT</option></select>
126 </td></tr>
127 </table>
128
129 <br />
130 <table width='10%' cellspacing='0'>
131 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
132 <input type='submit' name='ACTION' value=$Lang::tr{'save'} />
133 </form></td></tr>
134 </table>
135 </form>
136 END
137 ;
138 &Header::closebox();
139 &Header::closebigbox();
140 &Header::closepage();