Forward Firewall: Updated outgoingfw-converter. redesign of the ruletable's defaultrules
[people/teissler/ipfire-2.x.git] / html / cgi-bin / optionsfw.cgi
CommitLineData
5595bc03
CS
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
19require '/var/ipfire/general-functions.pl';
20require "${General::swroot}/lang.pl";
21require "${General::swroot}/header.pl";
22
23
24my %checked =(); # Checkbox manipulations
25
26# File used
27my $filename = "${General::swroot}/optionsfw/settings";
28
29our %settings=();
3b2ad4a1
AM
30my %fwdfwsettings=();
31my %configfwdfw=();
32my %configoutgoingfw=();
33
34my $configfwdfw = "${General::swroot}/forward/config";
35my $configoutgoing = "${General::swroot}/forward/outgoing";
36
5595bc03
CS
37$settings{'DISABLEPING'} = 'NO';
38$settings{'DROPNEWNOTSYN'} = 'on';
39$settings{'DROPINPUT'} = 'on';
6be0579b 40$settings{'DROPFORWARD'} = 'on';
5d7faa45 41$settings{'DROPOUTGOING'} = 'on';
5595bc03 42$settings{'DROPPORTSCAN'} = 'on';
42dc0090
CS
43$settings{'DROPWIRELESSINPUT'} = 'on';
44$settings{'DROPWIRELESSFORWARD'} = 'on';
e28356b9 45$settings{'SHOWCOLORS'} = 'off';
96502a5a 46$settings{'SHOWREMARK'} = 'on';
770140a7 47$settings{'SHOWTABLES'} = 'on';
d9987841 48$settings{'SHOWDROPDOWN'} = 'off';
5595bc03
CS
49
50my $errormessage = '';
51my $warnmessage = '';
52
3b2ad4a1 53&General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
5595bc03
CS
54&Header::showhttpheaders();
55
56#Get GUI values
57&Header::getcgihash(\%settings);
7326051e 58&General::readhash("${General::swroot}/optionsfw/settings", \%settings);
3b2ad4a1
AM
59
60
5595bc03 61if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
3b2ad4a1
AM
62 if ($settings{'defpol'} ne '1'){
63 $errormessage = $Lang::tr{'new optionsfw later'};
64 delete $settings{'__CGI__'};
65 delete $settings{'x'};
66 delete $settings{'y'};
67 &General::writehash($filename, \%settings); # Save good settings
68 system("/usr/local/bin/forwardfwctrl");
69 }else{
70 if ($settings{'POLICY'} ne ''){
71 $fwdfwsettings{'POLICY'} = $settings{'POLICY'};
72 }
73 if ($settings{'POLICY1'} ne ''){
74 $fwdfwsettings{'POLICY1'} = $settings{'POLICY1'};
75 }
76 my $MODE = $fwdfwsettings{'POLICY'};
77 my $MODE1 = $fwdfwsettings{'POLICY1'};
78 %fwdfwsettings = ();
79 $fwdfwsettings{'POLICY'} = "$MODE";
80 $fwdfwsettings{'POLICY1'} = "$MODE1";
81 &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
82 &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
83 system("/usr/local/bin/forwardfwctrl");
84 }
62fc8511
AM
85 }else {
86 &General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
3b2ad4a1
AM
87}
88
5595bc03
CS
89&Header::openpage($Lang::tr{'options fw'}, 1, '');
90&Header::openbigbox('100%', 'left', '', $errormessage);
91
92if ($errormessage) {
93 &Header::openbox('100%', 'left', $Lang::tr{'warning messages'});
94 print "<font color='red'>$errormessage&nbsp;</font>";
95 &Header::closebox();
96}
97
98$checked{'DROPNEWNOTSYN'}{'off'} = '';
99$checked{'DROPNEWNOTSYN'}{'on'} = '';
100$checked{'DROPNEWNOTSYN'}{$settings{'DROPNEWNOTSYN'}} = "checked='checked'";
101$checked{'DROPINPUT'}{'off'} = '';
102$checked{'DROPINPUT'}{'on'} = '';
103$checked{'DROPINPUT'}{$settings{'DROPINPUT'}} = "checked='checked'";
6be0579b
AM
104$checked{'DROPFORWARD'}{'off'} = '';
105$checked{'DROPFORWARD'}{'on'} = '';
106$checked{'DROPFORWARD'}{$settings{'DROPFORWARD'}} = "checked='checked'";
5d7faa45
AM
107$checked{'DROPOUTGOING'}{'off'} = '';
108$checked{'DROPOUTGOING'}{'on'} = '';
109$checked{'DROPOUTGOING'}{$settings{'DROPOUTGOING'}} = "checked='checked'";
5595bc03
CS
110$checked{'DROPPORTSCAN'}{'off'} = '';
111$checked{'DROPPORTSCAN'}{'on'} = '';
112$checked{'DROPPORTSCAN'}{$settings{'DROPPORTSCAN'}} = "checked='checked'";
42dc0090
CS
113$checked{'DROPWIRELESSINPUT'}{'off'} = '';
114$checked{'DROPWIRELESSINPUT'}{'on'} = '';
115$checked{'DROPWIRELESSINPUT'}{$settings{'DROPWIRELESSINPUT'}} = "checked='checked'";
116$checked{'DROPWIRELESSFORWARD'}{'off'} = '';
117$checked{'DROPWIRELESSFORWARD'}{'on'} = '';
118$checked{'DROPWIRELESSFORWARD'}{$settings{'DROPWIRELESSFORWARD'}} = "checked='checked'";
0aaef8e9
CS
119$checked{'DROPPROXY'}{'off'} = '';
120$checked{'DROPPROXY'}{'on'} = '';
121$checked{'DROPPROXY'}{$settings{'DROPPROXY'}} = "checked='checked'";
122$checked{'DROPSAMBA'}{'off'} = '';
123$checked{'DROPSAMBA'}{'on'} = '';
124$checked{'DROPSAMBA'}{$settings{'DROPSAMBA'}} = "checked='checked'";
15add1c8
AM
125$checked{'SHOWCOLORS'}{'off'} = '';
126$checked{'SHOWCOLORS'}{'on'} = '';
127$checked{'SHOWCOLORS'}{$settings{'SHOWCOLORS'}} = "checked='checked'";
96502a5a
AM
128$checked{'SHOWREMARK'}{'off'} = '';
129$checked{'SHOWREMARK'}{'on'} = '';
130$checked{'SHOWREMARK'}{$settings{'SHOWREMARK'}} = "checked='checked'";
770140a7
AM
131$checked{'SHOWTABLES'}{'off'} = '';
132$checked{'SHOWTABLES'}{'on'} = '';
133$checked{'SHOWTABLES'}{$settings{'SHOWTABLES'}} = "checked='checked'";
d9987841
AM
134$checked{'SHOWDROPDOWN'}{'off'} = '';
135$checked{'SHOWDROPDOWN'}{'on'} = '';
136$checked{'SHOWDROPDOWN'}{$settings{'SHOWDROPDOWN'}} = "checked='checked'";
137$selected{'FWPOLICY'}{$settings{'FWPOLICY'}}= 'selected';
138$selected{'FWPOLICY1'}{$settings{'FWPOLICY1'}}= 'selected';
d47bb8a1 139$selected{'FWPOLICY2'}{$settings{'FWPOLICY2'}}= 'selected';
35fb9164 140
5595bc03
CS
141&Header::openbox('100%', 'center', $Lang::tr{'options fw'});
142print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
143
144print <<END
145<form method='post' action='$ENV{'SCRIPT_NAME'}'>
146<table width='95%' cellspacing='0'>
147<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw logging'}</b></td></tr>
0b06ad05 148<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'} />/
5595bc03 149 <input type='radio' name='DROPNEWNOTSYN' value='off' $checked{'DROPNEWNOTSYN'}{'off'} /> off</td></tr>
0b06ad05 150<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'} />/
5595bc03 151 <input type='radio' name='DROPINPUT' value='off' $checked{'DROPINPUT'}{'off'} /> off</td></tr>
6be0579b
AM
152<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'} />/
153 <input type='radio' name='DROPFORWARD' value='off' $checked{'DROPFORWARD'}{'off'} /> off</td></tr>
5d7faa45
AM
154<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'} />/
155 <input type='radio' name='DROPOUTGOING' value='off' $checked{'DROPOUTGOING'}{'off'} /> off</td></tr>
0b06ad05 156<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'} />/
5595bc03 157 <input type='radio' name='DROPPORTSCAN' value='off' $checked{'DROPPORTSCAN'}{'off'} /> off</td></tr>
0b06ad05 158<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'} />/
42dc0090 159 <input type='radio' name='DROPWIRELESSINPUT' value='off' $checked{'DROPWIRELESSINPUT'}{'off'} /> off</td></tr>
0b06ad05 160<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'} />/
42dc0090 161 <input type='radio' name='DROPWIRELESSFORWARD' value='off' $checked{'DROPWIRELESSFORWARD'}{'off'} /> off</td></tr>
5595bc03 162</table>
15add1c8
AM
163<br/>
164
0aaef8e9
CS
165<table width='95%' cellspacing='0'>
166<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw blue'}</b></td></tr>
0b06ad05 167<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'} />/
0aaef8e9 168 <input type='radio' name='DROPPROXY' value='off' $checked{'DROPPROXY'}{'off'} /> off</td></tr>
0b06ad05 169<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'} />/
0aaef8e9
CS
170 <input type='radio' name='DROPSAMBA' value='off' $checked{'DROPSAMBA'}{'off'} /> off</td></tr>
171</table>
15add1c8
AM
172<br>
173<table width='95%' cellspacing='0'>
174<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw settings'}</b></td></tr>
175<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'} />/
176 <input type='radio' name='SHOWCOLORS' value='off' $checked{'SHOWCOLORS'}{'off'} /> off</td></tr>
96502a5a 177<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'} />/
d9987841 178 <input type='radio' name='SHOWREMARK' value='off' $checked{'SHOWREMARK'}{'off'} /> off</td></tr>
e2619c15 179<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'} />/
770140a7 180 <input type='radio' name='SHOWTABLES' value='off' $checked{'SHOWTABLES'}{'off'} /> off</td></tr>
d9987841
AM
181<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'} />/
182 <input type='radio' name='SHOWDROPDOWN' value='off' $checked{'SHOWDROPDOWN'}{'off'} /> off</td></tr>
183</table>
62fc8511
AM
184<br />
185<table width='95%' cellspacing='0'>
186<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw default drop'}</b></td></tr>
d9987841
AM
187<tr><td align='left' width='60%'>$Lang::tr{'drop action'}</td><td><select name='FWPOLICY'>
188<option value='DROP' $selected{'FWPOLICY'}{'DROP'}>DROP</option>
189<option value='REJECT' $selected{'FWPOLICY'}{'REJECT'}>REJECT</option></select>
190</td></tr>
191<tr><td align='left' width='60%'>$Lang::tr{'drop action1'}</td><td><select name='FWPOLICY1'>
192<option value='DROP' $selected{'FWPOLICY1'}{'DROP'}>DROP</option>
193<option value='REJECT' $selected{'FWPOLICY1'}{'REJECT'}>REJECT</option></select>
194</td></tr>
d47bb8a1
AM
195<tr><td align='left' width='60%'>$Lang::tr{'drop action2'}</td><td><select name='FWPOLICY2'>
196<option value='DROP' $selected{'FWPOLICY2'}{'DROP'}>DROP</option>
197<option value='REJECT' $selected{'FWPOLICY2'}{'REJECT'}>REJECT</option></select>
198</td></tr>
62fc8511
AM
199</table>
200
0aaef8e9 201<br />
5595bc03
CS
202<table width='10%' cellspacing='0'>
203<tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
62fc8511
AM
204<input type='submit' name='ACTION' value=$Lang::tr{'save'} />
205</form></td></tr>
5595bc03
CS
206</table>
207</form>
208END
209;
210&Header::closebox();
3b2ad4a1
AM
211
212&Header::openbox('100%', 'center', $Lang::tr{'fwdfw pol title'});
213 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
214 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
215 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
216 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
217print <<END;
218 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
219 <table width='100%' border='0'>
220 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
221 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
222 <tr><td colspan='3'><hr /></td></tr>
223 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
224 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
225 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
226 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /><input type='hidden' name='defpol' value='1'></td>
227END
228 print "</tr></table></form>";
229 print"<br><br>";
230 print <<END;
231 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
232 <table width='100%' border='0'>
233 <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
234 <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
235 <tr><td colspan='3'><hr /></td></tr>
236 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
237 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
238 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
239 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /><input type='hidden' name='defpol' value='1'></td>
240END
241 print "</tr></table></form>";
242 &Header::closebox();
243
5595bc03
CS
244&Header::closebigbox();
245&Header::closepage();