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