9e39fbfd3b4db69ac337a9cb46924fbfaeee7916
[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{'DROPOUTGOING'} = 'on';
35 $settings{'DROPPORTSCAN'} = 'on';
36 $settings{'DROPWIRELESSINPUT'} = 'on';
37 $settings{'DROPWIRELESSFORWARD'} = 'on';
38 $settings{'SHOWCOLORS'} = 'off';
39 $settings{'SHOWREMARK'} = 'on';
40 $settings{'SHOWTABLES'} = 'on';
41 $settings{'SHOWDROPDOWN'} = 'off';
42
43 my $errormessage = '';
44 my $warnmessage = '';
45
46 &Header::showhttpheaders();
47
48 #Get GUI values
49 &Header::getcgihash(\%settings);
50
51 if ($settings{'ACTION'} eq $Lang::tr{'save'}) {
52
53 $errormessage = $Lang::tr{'new optionsfw later'};
54 delete $settings{'__CGI__'};
55 delete $settings{'x'};
56 delete $settings{'y'};
57 &General::writehash($filename, \%settings); # Save good settings
58 }else {
59 &General::readhash($filename, \%settings); # Get saved settings and reset to good if needed
60 }
61 system("/usr/local/bin/forwardfwctrl");
62 &Header::openpage($Lang::tr{'options fw'}, 1, '');
63 &Header::openbigbox('100%', 'left', '', $errormessage);
64
65 if ($errormessage) {
66 &Header::openbox('100%', 'left', $Lang::tr{'warning messages'});
67 print "<font color='red'>$errormessage&nbsp;</font>";
68 &Header::closebox();
69 }
70
71 $checked{'DROPNEWNOTSYN'}{'off'} = '';
72 $checked{'DROPNEWNOTSYN'}{'on'} = '';
73 $checked{'DROPNEWNOTSYN'}{$settings{'DROPNEWNOTSYN'}} = "checked='checked'";
74 $checked{'DROPINPUT'}{'off'} = '';
75 $checked{'DROPINPUT'}{'on'} = '';
76 $checked{'DROPINPUT'}{$settings{'DROPINPUT'}} = "checked='checked'";
77 $checked{'DROPFORWARD'}{'off'} = '';
78 $checked{'DROPFORWARD'}{'on'} = '';
79 $checked{'DROPFORWARD'}{$settings{'DROPFORWARD'}} = "checked='checked'";
80 $checked{'DROPOUTGOING'}{'off'} = '';
81 $checked{'DROPOUTGOING'}{'on'} = '';
82 $checked{'DROPOUTGOING'}{$settings{'DROPOUTGOING'}} = "checked='checked'";
83 $checked{'DROPPORTSCAN'}{'off'} = '';
84 $checked{'DROPPORTSCAN'}{'on'} = '';
85 $checked{'DROPPORTSCAN'}{$settings{'DROPPORTSCAN'}} = "checked='checked'";
86 $checked{'DROPWIRELESSINPUT'}{'off'} = '';
87 $checked{'DROPWIRELESSINPUT'}{'on'} = '';
88 $checked{'DROPWIRELESSINPUT'}{$settings{'DROPWIRELESSINPUT'}} = "checked='checked'";
89 $checked{'DROPWIRELESSFORWARD'}{'off'} = '';
90 $checked{'DROPWIRELESSFORWARD'}{'on'} = '';
91 $checked{'DROPWIRELESSFORWARD'}{$settings{'DROPWIRELESSFORWARD'}} = "checked='checked'";
92 $checked{'DROPPROXY'}{'off'} = '';
93 $checked{'DROPPROXY'}{'on'} = '';
94 $checked{'DROPPROXY'}{$settings{'DROPPROXY'}} = "checked='checked'";
95 $checked{'DROPSAMBA'}{'off'} = '';
96 $checked{'DROPSAMBA'}{'on'} = '';
97 $checked{'DROPSAMBA'}{$settings{'DROPSAMBA'}} = "checked='checked'";
98 $checked{'SHOWCOLORS'}{'off'} = '';
99 $checked{'SHOWCOLORS'}{'on'} = '';
100 $checked{'SHOWCOLORS'}{$settings{'SHOWCOLORS'}} = "checked='checked'";
101 $checked{'SHOWREMARK'}{'off'} = '';
102 $checked{'SHOWREMARK'}{'on'} = '';
103 $checked{'SHOWREMARK'}{$settings{'SHOWREMARK'}} = "checked='checked'";
104 $checked{'SHOWTABLES'}{'off'} = '';
105 $checked{'SHOWTABLES'}{'on'} = '';
106 $checked{'SHOWTABLES'}{$settings{'SHOWTABLES'}} = "checked='checked'";
107 $checked{'SHOWDROPDOWN'}{'off'} = '';
108 $checked{'SHOWDROPDOWN'}{'on'} = '';
109 $checked{'SHOWDROPDOWN'}{$settings{'SHOWDROPDOWN'}} = "checked='checked'";
110 $selected{'FWPOLICY'}{$settings{'FWPOLICY'}}= 'selected';
111 $selected{'FWPOLICY1'}{$settings{'FWPOLICY1'}}= 'selected';
112 $selected{'FWPOLICY2'}{$settings{'FWPOLICY2'}}= 'selected';
113
114
115 &Header::openbox('100%', 'center', $Lang::tr{'options fw'});
116 print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>";
117
118 print <<END
119 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
120 <table width='95%' cellspacing='0'>
121 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw logging'}</b></td></tr>
122 <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'} />/
123 <input type='radio' name='DROPNEWNOTSYN' value='off' $checked{'DROPNEWNOTSYN'}{'off'} /> off</td></tr>
124 <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'} />/
125 <input type='radio' name='DROPINPUT' value='off' $checked{'DROPINPUT'}{'off'} /> off</td></tr>
126 <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'} />/
127 <input type='radio' name='DROPFORWARD' value='off' $checked{'DROPFORWARD'}{'off'} /> off</td></tr>
128 <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'} />/
129 <input type='radio' name='DROPOUTGOING' value='off' $checked{'DROPOUTGOING'}{'off'} /> off</td></tr>
130 <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'} />/
131 <input type='radio' name='DROPPORTSCAN' value='off' $checked{'DROPPORTSCAN'}{'off'} /> off</td></tr>
132 <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'} />/
133 <input type='radio' name='DROPWIRELESSINPUT' value='off' $checked{'DROPWIRELESSINPUT'}{'off'} /> off</td></tr>
134 <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'} />/
135 <input type='radio' name='DROPWIRELESSFORWARD' value='off' $checked{'DROPWIRELESSFORWARD'}{'off'} /> off</td></tr>
136 </table>
137 <br/>
138
139 <table width='95%' cellspacing='0'>
140 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw blue'}</b></td></tr>
141 <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'} />/
142 <input type='radio' name='DROPPROXY' value='off' $checked{'DROPPROXY'}{'off'} /> off</td></tr>
143 <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'} />/
144 <input type='radio' name='DROPSAMBA' value='off' $checked{'DROPSAMBA'}{'off'} /> off</td></tr>
145 </table>
146 <br>
147 <table width='95%' cellspacing='0'>
148 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw settings'}</b></td></tr>
149 <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'} />/
150 <input type='radio' name='SHOWCOLORS' value='off' $checked{'SHOWCOLORS'}{'off'} /> off</td></tr>
151 <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'} />/
152 <input type='radio' name='SHOWREMARK' value='off' $checked{'SHOWREMARK'}{'off'} /> off</td></tr>
153 <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'} />/
154 <input type='radio' name='SHOWTABLES' value='off' $checked{'SHOWTABLES'}{'off'} /> off</td></tr>
155 <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'} />/
156 <input type='radio' name='SHOWDROPDOWN' value='off' $checked{'SHOWDROPDOWN'}{'off'} /> off</td></tr>
157 </table>
158 <br />
159 <table width='95%' cellspacing='0'>
160 <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw default drop'}</b></td></tr>
161 <tr><td align='left' width='60%'>$Lang::tr{'drop action'}</td><td><select name='FWPOLICY'>
162 <option value='DROP' $selected{'FWPOLICY'}{'DROP'}>DROP</option>
163 <option value='REJECT' $selected{'FWPOLICY'}{'REJECT'}>REJECT</option></select>
164 </td></tr>
165 <tr><td align='left' width='60%'>$Lang::tr{'drop action1'}</td><td><select name='FWPOLICY1'>
166 <option value='DROP' $selected{'FWPOLICY1'}{'DROP'}>DROP</option>
167 <option value='REJECT' $selected{'FWPOLICY1'}{'REJECT'}>REJECT</option></select>
168 </td></tr>
169 <tr><td align='left' width='60%'>$Lang::tr{'drop action2'}</td><td><select name='FWPOLICY2'>
170 <option value='DROP' $selected{'FWPOLICY2'}{'DROP'}>DROP</option>
171 <option value='REJECT' $selected{'FWPOLICY2'}{'REJECT'}>REJECT</option></select>
172 </td></tr>
173 </table>
174
175 <br />
176 <table width='10%' cellspacing='0'>
177 <tr><td align='center'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
178 <input type='submit' name='ACTION' value=$Lang::tr{'save'} />
179 </form></td></tr>
180 </table>
181 </form>
182 END
183 ;
184 &Header::closebox();
185 &Header::closebigbox();
186 &Header::closepage();