61441e4706194499c5557d8cb7e60df83ea6a3cc
[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 &Header::showhttpheaders();
55
56 #Get GUI values
57 &Header::getcgihash(\%settings);
58 &General::readhash("${General::swroot}/optionsfw/settings", \%settings);
59
60
61 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
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 }
85 }else {
86 &General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
87 }
88
89 &Header::openpage($Lang::tr{'options fw'}, 1, '');
90 &Header::openbigbox('100%', 'left', '', $errormessage);
91
92 if ($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'";
104 $checked{'DROPFORWARD'}{'off'} = '';
105 $checked{'DROPFORWARD'}{'on'} = '';
106 $checked{'DROPFORWARD'}{$settings{'DROPFORWARD'}} = "checked='checked'";
107 $checked{'DROPOUTGOING'}{'off'} = '';
108 $checked{'DROPOUTGOING'}{'on'} = '';
109 $checked{'DROPOUTGOING'}{$settings{'DROPOUTGOING'}} = "checked='checked'";
110 $checked{'DROPPORTSCAN'}{'off'} = '';
111 $checked{'DROPPORTSCAN'}{'on'} = '';
112 $checked{'DROPPORTSCAN'}{$settings{'DROPPORTSCAN'}} = "checked='checked'";
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'";
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'";
125 $checked{'SHOWCOLORS'}{'off'} = '';
126 $checked{'SHOWCOLORS'}{'on'} = '';
127 $checked{'SHOWCOLORS'}{$settings{'SHOWCOLORS'}} = "checked='checked'";
128 $checked{'SHOWREMARK'}{'off'} = '';
129 $checked{'SHOWREMARK'}{'on'} = '';
130 $checked{'SHOWREMARK'}{$settings{'SHOWREMARK'}} = "checked='checked'";
131 $checked{'SHOWTABLES'}{'off'} = '';
132 $checked{'SHOWTABLES'}{'on'} = '';
133 $checked{'SHOWTABLES'}{$settings{'SHOWTABLES'}} = "checked='checked'";
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';
139 $selected{'FWPOLICY2'}{$settings{'FWPOLICY2'}}= 'selected';
140
141 &Header::openbox('100%', 'center', $Lang::tr{'options fw'});
142 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
143
144 print <<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>
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'} />/
149 <input type='radio' name='DROPNEWNOTSYN' value='off' $checked{'DROPNEWNOTSYN'}{'off'} /> off</td></tr>
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'} />/
151 <input type='radio' name='DROPINPUT' value='off' $checked{'DROPINPUT'}{'off'} /> off</td></tr>
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>
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>
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'} />/
157 <input type='radio' name='DROPPORTSCAN' value='off' $checked{'DROPPORTSCAN'}{'off'} /> off</td></tr>
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'} />/
159 <input type='radio' name='DROPWIRELESSINPUT' value='off' $checked{'DROPWIRELESSINPUT'}{'off'} /> off</td></tr>
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'} />/
161 <input type='radio' name='DROPWIRELESSFORWARD' value='off' $checked{'DROPWIRELESSFORWARD'}{'off'} /> off</td></tr>
162 </table>
163 <br/>
164
165 <table width='95%' cellspacing='0'>
166 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw blue'}</b></td></tr>
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'} />/
168 <input type='radio' name='DROPPROXY' value='off' $checked{'DROPPROXY'}{'off'} /> off</td></tr>
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'} />/
170 <input type='radio' name='DROPSAMBA' value='off' $checked{'DROPSAMBA'}{'off'} /> off</td></tr>
171 </table>
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>
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'} />/
178 <input type='radio' name='SHOWREMARK' value='off' $checked{'SHOWREMARK'}{'off'} /> off</td></tr>
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'} />/
180 <input type='radio' name='SHOWTABLES' value='off' $checked{'SHOWTABLES'}{'off'} /> off</td></tr>
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>
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>
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>
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>
199 </table>
200
201 <br />
202 <table width='10%' cellspacing='0'>
203 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
204 <input type='submit' name='ACTION' value=$Lang::tr{'save'} />
205 </form></td></tr>
206 </table>
207 </form>
208 END
209 ;
210 &Header::closebox();
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'} = ''; }
217 print <<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>
227 END
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>
240 END
241 print "</tr></table></form>";
242 &Header::closebox();
243
244 &Header::closebigbox();
245 &Header::closepage();