Forward Firewall: added GPL header to all files
[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 # Modifications for new Firewall (C) 2013 by amarx@ipfire.org
16 ########################################################################
17
18 # enable only the following on debugging purpose
19 #use warnings;
20 #use CGI::Carp 'fatalsToBrowser';
21
22 require '/var/ipfire/general-functions.pl';
23 require "${General::swroot}/lang.pl";
24 require "${General::swroot}/header.pl";
25
26
27 my %checked =(); # Checkbox manipulations
28 our %settings=();
29 my %fwdfwsettings=();
30 my %configfwdfw=();
31 my %configoutgoingfw=();
32
33 my $configfwdfw = "${General::swroot}/forward/config";
34 my $configoutgoing = "${General::swroot}/forward/outgoing";
35 my $errormessage = '';
36 my $warnmessage = '';
37 my $filename = "${General::swroot}/optionsfw/settings";
38
39 &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
40 &Header::showhttpheaders();
41
42 #Get GUI values
43 &Header::getcgihash(\%settings);
44 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
45 if ($settings{'defpol'} ne '1'){
46 $errormessage .= $Lang::tr{'new optionsfw later'};
47 &General::writehash($filename, \%settings); # Save good settings
48 system("/usr/local/bin/forwardfwctrl");
49 }else{
50 if ($settings{'POLICY'} ne ''){
51 $fwdfwsettings{'POLICY'} = $settings{'POLICY'};
52 }
53 if ($settings{'POLICY1'} ne ''){
54 $fwdfwsettings{'POLICY1'} = $settings{'POLICY1'};
55 }
56 my $MODE = $fwdfwsettings{'POLICY'};
57 my $MODE1 = $fwdfwsettings{'POLICY1'};
58 %fwdfwsettings = ();
59 $fwdfwsettings{'POLICY'} = "$MODE";
60 $fwdfwsettings{'POLICY1'} = "$MODE1";
61 &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
62 &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
63 system("/usr/local/bin/forwardfwctrl");
64 }
65 &General::readhash($filename, \%settings); # Load good settings
66 }
67
68 &Header::openpage($Lang::tr{'options fw'}, 1, '');
69 &Header::openbigbox('100%', 'left', '', $errormessage);
70 &General::readhash($filename, \%settings);
71 if ($errormessage) {
72 &Header::openbox('100%', 'left', $Lang::tr{'warning messages'});
73 print "<font color='red'>$errormessage&nbsp;</font>";
74 &Header::closebox();
75 }
76
77 $checked{'DROPNEWNOTSYN'}{'off'} = '';
78 $checked{'DROPNEWNOTSYN'}{'on'} = '';
79 $checked{'DROPNEWNOTSYN'}{$settings{'DROPNEWNOTSYN'}} = "checked='checked'";
80 $checked{'DROPINPUT'}{'off'} = '';
81 $checked{'DROPINPUT'}{'on'} = '';
82 $checked{'DROPINPUT'}{$settings{'DROPINPUT'}} = "checked='checked'";
83 $checked{'DROPFORWARD'}{'off'} = '';
84 $checked{'DROPFORWARD'}{'on'} = '';
85 $checked{'DROPFORWARD'}{$settings{'DROPFORWARD'}} = "checked='checked'";
86 $checked{'DROPOUTGOING'}{'off'} = '';
87 $checked{'DROPOUTGOING'}{'on'} = '';
88 $checked{'DROPOUTGOING'}{$settings{'DROPOUTGOING'}} = "checked='checked'";
89 $checked{'DROPPORTSCAN'}{'off'} = '';
90 $checked{'DROPPORTSCAN'}{'on'} = '';
91 $checked{'DROPPORTSCAN'}{$settings{'DROPPORTSCAN'}} = "checked='checked'";
92 $checked{'DROPWIRELESSINPUT'}{'off'} = '';
93 $checked{'DROPWIRELESSINPUT'}{'on'} = '';
94 $checked{'DROPWIRELESSINPUT'}{$settings{'DROPWIRELESSINPUT'}} = "checked='checked'";
95 $checked{'DROPWIRELESSFORWARD'}{'off'} = '';
96 $checked{'DROPWIRELESSFORWARD'}{'on'} = '';
97 $checked{'DROPWIRELESSFORWARD'}{$settings{'DROPWIRELESSFORWARD'}} = "checked='checked'";
98 $checked{'DROPPROXY'}{'off'} = '';
99 $checked{'DROPPROXY'}{'on'} = '';
100 $checked{'DROPPROXY'}{$settings{'DROPPROXY'}} = "checked='checked'";
101 $checked{'DROPSAMBA'}{'off'} = '';
102 $checked{'DROPSAMBA'}{'on'} = '';
103 $checked{'DROPSAMBA'}{$settings{'DROPSAMBA'}} = "checked='checked'";
104 $checked{'SHOWCOLORS'}{'off'} = '';
105 $checked{'SHOWCOLORS'}{'on'} = '';
106 $checked{'SHOWCOLORS'}{$settings{'SHOWCOLORS'}} = "checked='checked'";
107 $checked{'SHOWREMARK'}{'off'} = '';
108 $checked{'SHOWREMARK'}{'on'} = '';
109 $checked{'SHOWREMARK'}{$settings{'SHOWREMARK'}} = "checked='checked'";
110 $checked{'SHOWTABLES'}{'off'} = '';
111 $checked{'SHOWTABLES'}{'on'} = '';
112 $checked{'SHOWTABLES'}{$settings{'SHOWTABLES'}} = "checked='checked'";
113 $checked{'SHOWDROPDOWN'}{'off'} = '';
114 $checked{'SHOWDROPDOWN'}{'on'} = '';
115 $checked{'SHOWDROPDOWN'}{$settings{'SHOWDROPDOWN'}} = "checked='checked'";
116 $selected{'FWPOLICY'}{$settings{'FWPOLICY'}}= 'selected';
117 $selected{'FWPOLICY1'}{$settings{'FWPOLICY1'}}= 'selected';
118 $selected{'FWPOLICY2'}{$settings{'FWPOLICY2'}}= 'selected';
119
120 &Header::openbox('100%', 'center', $Lang::tr{'options fw'});
121 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
122
123 print <<END
124 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
125 <table width='95%' cellspacing='0'>
126 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw logging'}</b></td></tr>
127 <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'} />/
128 <input type='radio' name='DROPNEWNOTSYN' value='off' $checked{'DROPNEWNOTSYN'}{'off'} /> off</td></tr>
129 <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'} />/
130 <input type='radio' name='DROPINPUT' value='off' $checked{'DROPINPUT'}{'off'} /> off</td></tr>
131 <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'} />/
132 <input type='radio' name='DROPFORWARD' value='off' $checked{'DROPFORWARD'}{'off'} /> off</td></tr>
133 <tr><td align='left' width='60%'>$Lang::tr{'drop outgoing'}</td><td align='left'>on <input type='radio' name='DROPOUTGOING' value='on' $checked{'DROPOUTGOING'}{'on'} />/
134 <input type='radio' name='DROPOUTGOING' value='off' $checked{'DROPOUTGOING'}{'off'} /> off</td></tr>
135 <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'} />/
136 <input type='radio' name='DROPPORTSCAN' value='off' $checked{'DROPPORTSCAN'}{'off'} /> off</td></tr>
137 <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'} />/
138 <input type='radio' name='DROPWIRELESSINPUT' value='off' $checked{'DROPWIRELESSINPUT'}{'off'} /> off</td></tr>
139 <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'} />/
140 <input type='radio' name='DROPWIRELESSFORWARD' value='off' $checked{'DROPWIRELESSFORWARD'}{'off'} /> off</td></tr>
141 </table>
142 <br/>
143
144 <table width='95%' cellspacing='0'>
145 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw blue'}</b></td></tr>
146 <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'} />/
147 <input type='radio' name='DROPPROXY' value='off' $checked{'DROPPROXY'}{'off'} /> off</td></tr>
148 <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'} />/
149 <input type='radio' name='DROPSAMBA' value='off' $checked{'DROPSAMBA'}{'off'} /> off</td></tr>
150 </table>
151 <br>
152 <table width='95%' cellspacing='0'>
153 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw settings'}</b></td></tr>
154 <tr><td align='left' width='60%'>$Lang::tr{'fw settings color'}</td><td align='left'>on <input type='radio' name='SHOWCOLORS' value='on' $checked{'SHOWCOLORS'}{'on'} />/
155 <input type='radio' name='SHOWCOLORS' value='off' $checked{'SHOWCOLORS'}{'off'} /> off</td></tr>
156 <tr><td align='left' width='60%'>$Lang::tr{'fw settings remark'}</td><td align='left'>on <input type='radio' name='SHOWREMARK' value='on' $checked{'SHOWREMARK'}{'on'} />/
157 <input type='radio' name='SHOWREMARK' value='off' $checked{'SHOWREMARK'}{'off'} /> off</td></tr>
158 <tr><td align='left' width='60%'>$Lang::tr{'fw settings ruletable'}</td><td align='left'>on <input type='radio' name='SHOWTABLES' value='on' $checked{'SHOWTABLES'}{'on'} />/
159 <input type='radio' name='SHOWTABLES' value='off' $checked{'SHOWTABLES'}{'off'} /> off</td></tr>
160 <tr><td align='left' width='60%'>$Lang::tr{'fw settings dropdown'}</td><td align='left'>on <input type='radio' name='SHOWDROPDOWN' value='on' $checked{'SHOWDROPDOWN'}{'on'} />/
161 <input type='radio' name='SHOWDROPDOWN' value='off' $checked{'SHOWDROPDOWN'}{'off'} /> off</td></tr>
162 </table>
163 <br />
164 <table width='95%' cellspacing='0'>
165 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw default drop'}</b></td></tr>
166 <tr><td align='left' width='60%'>$Lang::tr{'drop action'}</td><td><select name='FWPOLICY'>
167 <option value='DROP' $selected{'FWPOLICY'}{'DROP'}>DROP</option>
168 <option value='REJECT' $selected{'FWPOLICY'}{'REJECT'}>REJECT</option></select>
169 </td></tr>
170 <tr><td align='left' width='60%'>$Lang::tr{'drop action1'}</td><td><select name='FWPOLICY1'>
171 <option value='DROP' $selected{'FWPOLICY1'}{'DROP'}>DROP</option>
172 <option value='REJECT' $selected{'FWPOLICY1'}{'REJECT'}>REJECT</option></select>
173 </td></tr>
174 <tr><td align='left' width='60%'>$Lang::tr{'drop action2'}</td><td><select name='FWPOLICY2'>
175 <option value='DROP' $selected{'FWPOLICY2'}{'DROP'}>DROP</option>
176 <option value='REJECT' $selected{'FWPOLICY2'}{'REJECT'}>REJECT</option></select>
177 </td></tr>
178 </table>
179
180 <br />
181 <table width='10%' cellspacing='0'>
182 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
183 <input type='submit' name='ACTION' value=$Lang::tr{'save'} />
184 </form></td></tr>
185 </table>
186 </form>
187 END
188 ;
189 &Header::closebox();
190
191 &Header::openbox('100%', 'center', $Lang::tr{'fwdfw pol title'});
192 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
193 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
194 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
195 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
196 print <<END;
197 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
198 <table width='100%' border='0'>
199 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
200 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
201 <tr><td colspan='3'><hr /></td></tr>
202 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
203 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
204 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
205 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /><input type='hidden' name='defpol' value='1'></td>
206 END
207 print "</tr></table></form>";
208 print"<br><br>";
209 print <<END;
210 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
211 <table width='100%' border='0'>
212 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
213 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
214 <tr><td colspan='3'><hr /></td></tr>
215 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
216 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
217 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
218 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /><input type='hidden' name='defpol' value='1'></td>
219 END
220 print "</tr></table></form>";
221 &Header::closebox();
222
223 &Header::closebigbox();
224 &Header::closepage();