]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blame - html/cgi-bin/outgoingfw.cgi
Added enhancements for outgoing fw to core34.
[people/teissler/ipfire-2.x.git] / html / cgi-bin / outgoingfw.cgi
CommitLineData
d9b7aa33 1#!/usr/bin/perl
70df8302
MT
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
39008af7 5# Copyright (C) 2009 Michael Tremer & Christian Schmidt #
70df8302
MT
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
d9b7aa33
MT
21
22use strict;
23# enable only the following on debugging purpose
39008af7
CS
24use warnings;
25use CGI::Carp 'fatalsToBrowser';
d9b7aa33
MT
26
27require '/var/ipfire/general-functions.pl';
28require "${General::swroot}/lang.pl";
29require "${General::swroot}/header.pl";
30
31my %outfwsettings = ();
32my %checked = ();
33my %selected= () ;
34my %netsettings = ();
35my $errormessage = "";
36my $configentry = "";
37my @configs = ();
38my @configline = ();
39my $p2pentry = "";
40my @p2ps = ();
41my @p2pline = ();
42
43my $configfile = "/var/ipfire/outgoing/rules";
44my $p2pfile = "/var/ipfire/outgoing/p2protocols";
f2fdd0c1
CS
45my $servicefile = "/var/ipfire/outgoing/defaultservices";
46
47my %color = ();
48my %mainsettings = ();
49&General::readhash("${General::swroot}/main/settings", \%mainsettings);
50&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
d9b7aa33
MT
51
52&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
53
54&Header::showhttpheaders();
55
56### Values that have to be initialized
57$outfwsettings{'ACTION'} = '';
58$outfwsettings{'VALID'} = 'yes';
59$outfwsettings{'EDIT'} = 'no';
60$outfwsettings{'NAME'} = '';
61$outfwsettings{'SNET'} = '';
62$outfwsettings{'SIP'} = '';
63$outfwsettings{'SPORT'} = '';
64$outfwsettings{'SMAC'} = '';
65$outfwsettings{'DIP'} = '';
66$outfwsettings{'DPORT'} = '';
67$outfwsettings{'PROT'} = '';
68$outfwsettings{'STATE'} = '';
69$outfwsettings{'DISPLAY_DIP'} = '';
70$outfwsettings{'DISPLAY_DPORT'} = '';
71$outfwsettings{'DISPLAY_SMAC'} = '';
72$outfwsettings{'DISPLAY_SIP'} = '';
1fde937c 73$outfwsettings{'POLICY'} = 'MODE0';
5595bc03 74$outfwsettings{'MODE1LOG'} = 'off';
d9b7aa33 75
39008af7
CS
76$outfwsettings{'TIME_FROM'} = '00:00';
77$outfwsettings{'TIME_TO'} = '00:00';
78
d9b7aa33
MT
79&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
80&Header::getcgihash(\%outfwsettings);
81
39008af7
CS
82$selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'";
83$selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'";
84
5595bc03
CS
85$checked{'MODE1LOG'}{'off'} = '';
86$checked{'MODE1LOG'}{'on'} = '';
87$checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'";
39008af7
CS
88$checked{'TIME_MON'}{'off'} = '';
89$checked{'TIME_MON'}{'on'} = '';
90$checked{'TIME_MON'}{$outfwsettings{'TIME_MON'}} = "checked='checked'";
91$checked{'TIME_TUE'}{'off'} = '';
92$checked{'TIME_TUE'}{'on'} = '';
93$checked{'TIME_TUE'}{$outfwsettings{'TIME_TUE'}} = "checked='checked'";
94$checked{'TIME_WED'}{'off'} = '';
95$checked{'TIME_WED'}{'on'} = '';
96$checked{'TIME_WED'}{$outfwsettings{'TIME_WED'}} = "checked='checked'";
97$checked{'TIME_THU'}{'off'} = '';
98$checked{'TIME_THU'}{'on'} = '';
99$checked{'TIME_THU'}{$outfwsettings{'TIME_THU'}} = "checked='checked'";
100$checked{'TIME_FRI'}{'off'} = '';
101$checked{'TIME_FRI'}{'on'} = '';
102$checked{'TIME_FRI'}{$outfwsettings{'TIME_FRI'}} = "checked='checked'";
103$checked{'TIME_SAT'}{'off'} = '';
104$checked{'TIME_SAT'}{'on'} = '';
105$checked{'TIME_SAT'}{$outfwsettings{'TIME_SAT'}} = "checked='checked'";
106$checked{'TIME_SUN'}{'off'} = '';
107$checked{'TIME_SUN'}{'on'} = '';
108$checked{'TIME_SUN'}{$outfwsettings{'TIME_SUN'}} = "checked='checked'";
5595bc03 109
d9b7aa33
MT
110if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
111if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
112if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
113
114&Header::openpage('Ausgehende Firewall', 1, '');
d9b7aa33
MT
115&Header::openbigbox('100%', 'left', '', $errormessage);
116
117############################################################################################################################
118############################################################################################################################
119
120if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
121{
122 $outfwsettings{'POLICY'}='MODE0';
123 unlink $configfile;
9833e7d8 124 system("/usr/bin/touch $configfile");
9141bd34
CS
125 my $MODE = $outfwsettings{'POLICY'};
126 %outfwsettings = ();
127 $outfwsettings{'POLICY'} = "$MODE";
d9b7aa33
MT
128 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
129}
130if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
131{
9141bd34 132 my $MODE = $outfwsettings{'POLICY'};
5595bc03 133 my $MODE1LOG = $outfwsettings{'MODE1LOG'};
9141bd34
CS
134 %outfwsettings = ();
135 $outfwsettings{'POLICY'} = "$MODE";
5595bc03 136 $outfwsettings{'MODE1LOG'} = "$MODE1LOG";
d9b7aa33 137 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
9141bd34 138 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
139}
140if ($outfwsettings{'ACTION'} eq 'enable')
141{
142 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
143 @p2ps = <FILE>;
144 close FILE;
145 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
146 foreach $p2pentry (sort @p2ps)
147 {
148 @p2pline = split( /\;/, $p2pentry );
149 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
150 print FILE "$p2pline[0];$p2pline[1];on;\n";
151 } else {
152 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
153 }
154 }
155 close FILE;
9141bd34 156 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
157}
158if ($outfwsettings{'ACTION'} eq 'disable')
159{
160 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
161 @p2ps = <FILE>;
162 close FILE;
163 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
164 foreach $p2pentry (sort @p2ps)
165 {
166 @p2pline = split( /\;/, $p2pentry );
167 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
168 print FILE "$p2pline[0];$p2pline[1];off;\n";
169 } else {
170 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
171 }
172 }
173 close FILE;
9141bd34 174 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
175}
176if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'})
177{
178 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
179 @configs = <FILE>;
180 close FILE;
181 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
182 foreach $configentry (sort @configs)
183 {
184 @configline = split( /\;/, $configentry );
185 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
186 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
187 ($configline[2] eq $outfwsettings{'SNET'}) &&
188 ($configline[3] eq $outfwsettings{'PROT'}) &&
189 ($configline[4] eq $outfwsettings{'NAME'}) &&
190 ($configline[5] eq $outfwsettings{'SIP'}) &&
191 ($configline[6] eq $outfwsettings{'SMAC'}) &&
9141bd34
CS
192 ($configline[7] eq $outfwsettings{'DIP'}) &&
193 ($configline[9] eq $outfwsettings{'LOG'}) &&
39008af7
CS
194 ($configline[8] eq $outfwsettings{'DPORT'}) &&
195 ($configline[10] eq $outfwsettings{'TIME_MON'}) &&
196 ($configline[11] eq $outfwsettings{'TIME_TUE'}) &&
197 ($configline[12] eq $outfwsettings{'TIME_WED'}) &&
198 ($configline[13] eq $outfwsettings{'TIME_THU'}) &&
199 ($configline[14] eq $outfwsettings{'TIME_FRI'}) &&
200 ($configline[15] eq $outfwsettings{'TIME_SAT'}) &&
201 ($configline[16] eq $outfwsettings{'TIME_SUN'}) &&
202 ($configline[17] eq $outfwsettings{'TIME_FROM'}) &&
203 ($configline[18] eq $outfwsettings{'TIME_TO'}))
d9b7aa33
MT
204 {
205 print FILE $configentry;
206 }
207 }
208 close FILE;
ebb9187c
MT
209 $selected{'SNET'}{"$outfwsettings{'SNET'}"} = 'selected';
210 $selected{'PROT'}{"$outfwsettings{'PROT'}"} = 'selected';
9141bd34 211 $selected{'LOG'}{"$outfwsettings{'LOG'}"} = 'selected';
d9b7aa33
MT
212 &addrule();
213 &Header::closebigbox();
214 &Header::closepage();
9141bd34
CS
215 exit
216 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
217}
218if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'})
219{
220 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
221 @configs = <FILE>;
222 close FILE;
223 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
224 foreach $configentry (sort @configs)
225 {
226 @configline = split( /\;/, $configentry );
227 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
228 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
229 ($configline[2] eq $outfwsettings{'SNET'}) &&
230 ($configline[3] eq $outfwsettings{'PROT'}) &&
231 ($configline[4] eq $outfwsettings{'NAME'}) &&
232 ($configline[5] eq $outfwsettings{'SIP'}) &&
233 ($configline[6] eq $outfwsettings{'SMAC'}) &&
234 ($configline[7] eq $outfwsettings{'DIP'}) &&
9141bd34 235 ($configline[9] eq $outfwsettings{'LOG'}) &&
39008af7
CS
236 ($configline[8] eq $outfwsettings{'DPORT'}) &&
237 ($configline[10] eq $outfwsettings{'TIME_MON'}) &&
238 ($configline[11] eq $outfwsettings{'TIME_TUE'}) &&
239 ($configline[12] eq $outfwsettings{'TIME_WED'}) &&
240 ($configline[13] eq $outfwsettings{'TIME_THU'}) &&
241 ($configline[14] eq $outfwsettings{'TIME_FRI'}) &&
242 ($configline[15] eq $outfwsettings{'TIME_SAT'}) &&
243 ($configline[16] eq $outfwsettings{'TIME_SUN'}) &&
244 ($configline[17] eq $outfwsettings{'TIME_FROM'}) &&
245 ($configline[18] eq $outfwsettings{'TIME_TO'}))
d9b7aa33
MT
246 {
247 print FILE $configentry;
248 }
249 }
250 close FILE;
9141bd34 251 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
252}
253if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'})
254{
255 if ( $outfwsettings{'VALID'} eq 'yes' ) {
256 open( FILE, ">> $configfile" ) or die "Unable to write $configfile";
257 print FILE <<END
39008af7 258$outfwsettings{'STATE'};$outfwsettings{'ENABLED'};$outfwsettings{'SNET'};$outfwsettings{'PROT'};$outfwsettings{'NAME'};$outfwsettings{'SIP'};$outfwsettings{'SMAC'};$outfwsettings{'DIP'};$outfwsettings{'DPORT'};$outfwsettings{'LOG'};$outfwsettings{'TIME_MON'};$outfwsettings{'TIME_TUE'};$outfwsettings{'TIME_WED'};$outfwsettings{'TIME_THU'};$outfwsettings{'TIME_FRI'};$outfwsettings{'TIME_SAT'};$outfwsettings{'TIME_SUN'};$outfwsettings{'TIME_FROM'};$outfwsettings{'TIME_TO'};
d9b7aa33
MT
259END
260;
261 close FILE;
9141bd34 262 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33 263 } else {
ebb9187c 264 $outfwsettings{'ACTION'} = 'Add rule';
d9b7aa33
MT
265 }
266}
ebb9187c 267if ($outfwsettings{'ACTION'} eq 'Add rule')
d9b7aa33
MT
268{
269 &addrule();
270 exit
271}
272
273&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
274
275if ($errormessage) {
276 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
277 print "<class name='base'>$errormessage\n";
278 print "&nbsp;</class>\n";
279 &Header::closebox();
280}
281
282############################################################################################################################
283############################################################################################################################
284
285if ($outfwsettings{'POLICY'} ne 'MODE0'){
286 &Header::openbox('100%', 'center', 'Rules');
287 print <<END
288 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
c41c2eb4 289 <input type='submit' name='ACTION' value='Add rule' />
ebb9187c 290 </form>
d9b7aa33
MT
291END
292;
293 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
294 @configs = <FILE>;
295 close FILE;
296 if (@configs) {
297 print <<END
c41c2eb4 298 <hr />
d9b7aa33 299 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1 300 <tr bgcolor='$color{'color22'}'>
e1e3dbe5
CS
301 <td width='14%' align='center'><b>$Lang::tr{'protocol'}</b></td>
302 <td width='14%' align='center'><b>$Lang::tr{'network'}</b></td>
303 <td width='14%' align='center'><b>$Lang::tr{'destination'}</b></td>
304 <td width='14%' align='center'><b>$Lang::tr{'description'}</b></td>
305 <td width='14%' align='center'><b>$Lang::tr{'policy'}</b></td>
306 <td width='16%' align='center'><b>$Lang::tr{'logging'}</b></td>
307 <td width='14%' align='center'><b>$Lang::tr{'action'}</b></td>
d9b7aa33
MT
308END
309;
310 foreach $configentry (sort @configs)
311 {
312 @configline = split( /\;/, $configentry );
313 $outfwsettings{'STATE'} = $configline[0];
314 $outfwsettings{'ENABLED'} = $configline[1];
315 $outfwsettings{'SNET'} = $configline[2];
316 $outfwsettings{'PROT'} = $configline[3];
317 $outfwsettings{'NAME'} = $configline[4];
318 $outfwsettings{'SIP'} = $configline[5];
319 $outfwsettings{'SMAC'} = $configline[6];
320 $outfwsettings{'DIP'} = $configline[7];
321 $outfwsettings{'DPORT'} = $configline[8];
9141bd34 322 $outfwsettings{'LOG'} = $configline[9];
39008af7
CS
323 $outfwsettings{'TIME_MON'} = $configline[10];
324 $outfwsettings{'TIME_TUE'} = $configline[11];
325 $outfwsettings{'TIME_WED'} = $configline[12];
326 $outfwsettings{'TIME_THU'} = $configline[13];
327 $outfwsettings{'TIME_FRI'} = $configline[14];
328 $outfwsettings{'TIME_SAT'} = $configline[15];
329 $outfwsettings{'TIME_SUN'} = $configline[16];
330 $outfwsettings{'TIME_FROM'} = $configline[17];
331 $outfwsettings{'TIME_TO'} = $configline[18];
332
d9b7aa33
MT
333 if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; }
334 if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; }
9141bd34
CS
335 if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY' />"; }
336 if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW' />"; }
d9b7aa33
MT
337 if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){
338 print <<END
f2fdd0c1 339 <tr bgcolor='$color{'color20'}'>
ebb9187c
MT
340 <td align='center'>$outfwsettings{'PROT'}
341 <td align='center'>$outfwsettings{'SNET'}
342 <td align='center'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'}
343 <td align='center'>$outfwsettings{'NAME'}
344 <td align='center'>$outfwsettings{'DISPLAY_STATE'}
9141bd34
CS
345 <td align='center'>$outfwsettings{'LOG'}
346 <td align='center'>
ebb9187c
MT
347 <table border='0' cellpadding='0' cellspacing='0'><tr>
348 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
349 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
350 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
351 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
352 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
353 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
354 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
355 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
356 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
357 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
358 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
39008af7
CS
359 <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' />
360 <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' />
361 <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' />
362 <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' />
363 <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' />
364 <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' />
365 <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' />
366 <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' />
367 <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' />
9141bd34
CS
368 <input type='hidden' name='ACTION' value=$Lang::tr{'edit'} />
369 <input type='image' src='/images/edit.gif' width="20" height="20" alt=$Lang::tr{'edit'} />
ebb9187c
MT
370 </form>
371 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
372 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
373 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
374 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
375 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
376 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
377 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
378 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
379 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
380 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
381 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
39008af7
CS
382 <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' />
383 <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' />
384 <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' />
385 <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' />
386 <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' />
387 <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' />
388 <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' />
389 <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' />
390 <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' />
9141bd34
CS
391 <input type='hidden' name='ACTION' value=$Lang::tr{'delete'} />
392 <input type='image' src='/images/delete.gif' width="20" height="20" alt=$Lang::tr{'delete'} />
ebb9187c 393 </form></table>
d9b7aa33
MT
394END
395;
396 if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) {
ebb9187c
MT
397 unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
398 unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
d9b7aa33 399 print <<END
e1e3dbe5 400 <tr><td width='14%' align='right'>$Lang::tr{'source ip'}:
ebb9187c 401 <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'}
ebb9187c 402 <td width='44%' colspan='2' align='center'>
d9b7aa33
MT
403END
404;
405 }
39008af7
CS
406 print <<END
407 <tr><td width='14%' align='right'>$Lang::tr{'time'} - </td>
408 <td width='14%' align='left'>
409END
410;
411 if ($outfwsettings{'TIME_MON'} eq 'on') { print "<font color='$Header::colourgreen'>";}
412 else { print "<font color='$Header::colourred'>";}
413 print "$Lang::tr{'advproxy monday'}</font>,";
414 if ($outfwsettings{'TIME_TUE'} eq 'on') { print "<font color='$Header::colourgreen'>";}
415 else { print "<font color='$Header::colourred'>";}
416 print "$Lang::tr{'advproxy tuesday'}</font>,";
417 if ($outfwsettings{'TIME_WED'} eq 'on') { print "<font color='$Header::colourgreen'>";}
418 else { print "<font color='$Header::colourred'>";}
419 print "$Lang::tr{'advproxy wednesday'}</font>,";
420 if ($outfwsettings{'TIME_THU'} eq 'on') { print "<font color='$Header::colourgreen'>";}
421 else { print "<font color='$Header::colourred'>";}
422 print "$Lang::tr{'advproxy thursday'}</font>,";
423 if ($outfwsettings{'TIME_FRI'} eq 'on') { print "<font color='$Header::colourgreen'>";}
424 else { print "<font color='$Header::colourred'>";}
425 print "$Lang::tr{'advproxy friday'}</font>,";
426 if ($outfwsettings{'TIME_SAT'} eq 'on') { print "<font color='$Header::colourgreen'>";}
427 else { print "<font color='$Header::colourred'>";}
428 print "$Lang::tr{'advproxy saturday'}</font>,";
429 if ($outfwsettings{'TIME_SUN'} eq 'on') { print "<font color='$Header::colourgreen'>";}
430 else { print "<font color='$Header::colourred'>";}
431 print "$Lang::tr{'advproxy sunday'}</font>";
432 print <<END
433 </td>
434 <td width='22%' align='center'>$Lang::tr{'advproxy from'} $outfwsettings{'TIME_FROM'}</td>
435 <td width='22%' align='center'>$Lang::tr{'advproxy to'} $outfwsettings{'TIME_TO'}</td>
d9b7aa33
MT
436 </form>
437END
438;
439 }
440 }
5595bc03
CS
441if ($outfwsettings{'POLICY'} eq 'MODE1'){
442print <<END
443 <tr bgcolor='$color{'color20'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
444 <td align='center'>tcp&udp
445 <td align='center'>all
446 <td align='center'>ALL
447 <td align='center'>drop
448 <td align='center'><img src='/images/stock_stop.png' alt='DENY' />
449 <td align='center'>on <input type='radio' name='MODE1LOG' value='on' $checked{'MODE1LOG'}{'on'} /><input type='radio' name='MODE1LOG' value='off' $checked{'MODE1LOG'}{'off'} /> off
450 <td align='center'><input type='hidden' name='ACTION' value=$Lang::tr{'save'} /><input type='image' src='/images/media-floppy.png' width="18" height="18" alt=$Lang::tr{'save'} /></form></tr>
451 <table border='0' cellpadding='0' cellspacing='0'><tr>
452 <td>
453 <td></table>
454END
455;
456}
d9b7aa33
MT
457 print <<END
458 </table>
459END
460;
461
462 }
d9b7aa33
MT
463 &Header::closebox();
464}
465
9141bd34 466if ($outfwsettings{'POLICY'} ne 'MODE0'){
d9b7aa33
MT
467 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
468 @p2ps = <FILE>;
469 close FILE;
470 &Header::openbox('100%', 'center', 'P2P-Block');
471 print <<END
472 <table width='40%'>
e1e3dbe5
CS
473 <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>$Lang::tr{'protocol'}</b>
474 <td width='33%' align=center><b>$Lang::tr{'status'}</b>
d9b7aa33
MT
475END
476;
ebb9187c 477 my $id = 1;
d9b7aa33
MT
478 foreach $p2pentry (sort @p2ps)
479 {
480 @p2pline = split( /\;/, $p2pentry );
481 print <<END
482 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
ebb9187c
MT
483END
484;
9141bd34 485 print "\t\t\t<tr bgcolor='$color{'color20'}'>\n";
f2fdd0c1 486 print <<END
ebb9187c 487 <td width='66%' align='center'>$p2pline[0]:
9141bd34 488 <td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' />
d9b7aa33
MT
489END
490;
491 if ($p2pline[2] eq 'on') {
492 print <<END
9141bd34
CS
493 <input type='hidden' name='ACTION' value='disable' />
494 <input type='image' name='submit' src='/images/stock_ok.png' alt='' />
d9b7aa33
MT
495END
496;
497 } else {
498 print <<END
9141bd34
CS
499 <input type='hidden' name='ACTION' value='enable' />
500 <input type='image' name='submit' src='/images/stock_stop.png' alt='' />
d9b7aa33
MT
501END
502;
503 }
504 print <<END
505 </form>
506END
507;
508 }
509 print <<END
d9b7aa33 510 </table>
e1e3dbe5 511 <br />$Lang::tr{'outgoingfw p2p description'}
d9b7aa33
MT
512END
513;
514 &Header::closebox();
515}
516
517&Header::openbox('100%', 'center', 'Policy');
518print <<END
519 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
520 <table width='100%'>
e1e3dbe5
CS
521 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode0'}</td></tr>
522 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode1'}</td></tr>
523 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoingfw mode2'}</td></tr>
9141bd34 524 <tr><td colspan='3'><hr /></td></tr>
e1e3dbe5 525 <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select>
c41c2eb4 526 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
115340d2 527 <td width='45%' align='left'>
d9b7aa33
MT
528END
529;
530 if ($outfwsettings{'POLICY'} ne 'MODE0') {
531 print <<END
e1e3dbe5 532 $Lang::tr{'outgoingfw reset'}: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
d9b7aa33
MT
533END
534;
535 }
536print <<END
537 </table>
538 </form>
539END
540;
541&Header::closebox();
542
543&Header::closebigbox();
544&Header::closepage();
545
546############################################################################################################################
547############################################################################################################################
548
549sub addrule
550{
551 &Header::openbox('100%', 'center', 'Rules hinzufuegen');
552 if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; }
39008af7
CS
553 $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'";
554 $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'";
d9b7aa33
MT
555 print <<END
556 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
557 <table width='80%'>
e1e3dbe5 558 <tr><td width='20%' align='right'>$Lang::tr{'description'}: <img src='/blob.gif' />
9141bd34 559 <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' />
39008af7
CS
560 <td width='20%' align='right' colspan='2'>$Lang::tr{'active'}:
561 <td width='30%' align='left' colspan='2'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} />
e1e3dbe5 562 <tr><td width='20%' align='right'>$Lang::tr{'protocol'}:
7528c1be 563 <td width='30%' align='left'><select name='PROT'><option value='all' $selected{'PROT'}{'all'}>All</option><option value='tcp' $selected{'PROT'}{'tcp'}>TCP</option><option value='tcp&udp' $selected{'PROT'}{'tcp&udp'}>TCP & UDP</option><option value='udp' $selected{'PROT'}{'udp'}>UDP</option></select>
39008af7
CS
564 <td width='20%' align='right' colspan='2'>$Lang::tr{'policy'}:
565 <td width='30%' align='left' colspan='2'>
d9b7aa33
MT
566END
567;
568 if ($outfwsettings{'POLICY'} eq 'MODE1'){
9141bd34 569 print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW' />\n";
d9b7aa33 570 } elsif ($outfwsettings{'POLICY'} eq 'MODE2'){
9141bd34 571 print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n";
d9b7aa33
MT
572 }
573 print <<END
e1e3dbe5 574 <tr><td width='20%' align='right'>$Lang::tr{'source net'}:
d9b7aa33 575 <td width='30%' align='left'><select name='SNET'>
e1e3dbe5
CS
576 <option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option>
577 <option value='ip' $selected{'SNET'}{'ip'}>$Lang::tr{'source ip'}</option>
39008af7 578 <option value='red' $selected{'SNET'}{'red'}>$Lang::tr{'red'} IP</option>
c41c2eb4 579 <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
d9b7aa33
MT
580END
581;
582 if (&Header::blue_used()){
c41c2eb4 583 print "\t\t\t<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>\n";
d9b7aa33
MT
584 }
585 if (&Header::orange_used()){
c41c2eb4 586 print "\t\t\t<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>\n";
d9b7aa33
MT
587 }
588 print <<END
589 </select>
39008af7
CS
590 <td width='20%' align='right' colspan='2'>$Lang::tr{'source ip'}: <img src='/blob.gif' />
591 <td width='30%' align='left' colspan='2'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' />
e1e3dbe5 592 <tr><td width='20%' align='right'>$Lang::tr{'logging'}:
52485124
CS
593END
594;
595if ($outfwsettings{'POLICY'} eq 'MODE1'){
596 print "<td width='30%' align='left'><input type='text' name='LOG' maxlength='10' value='$Lang::tr{'inactive'}' readonly='true' /></td>";
597}
598else{
599 print "<td width='30%' align='left'><select name='LOG'><option value='$Lang::tr{'active'}' $selected{'LOG'}{$Lang::tr{'active'}}>$Lang::tr{'active'}</option><option value='$Lang::tr{'inactive'}' $selected{'LOG'}{$Lang::tr{'inactive'}}>$Lang::tr{'inactive'}</option></select></td>";
600}
601print <<END
39008af7
CS
602 <td width='20%' align='right' colspan='2' />
603 <td width='30%' align='left' colspan='2' />
e1e3dbe5 604 <tr><td width='20%' align='right'>$Lang::tr{'destination ip'}: <img src='/blob.gif' />
9141bd34 605 <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' />
39008af7
CS
606 <td width='20%' align='right' colspan='2'>$Lang::tr{'destination port'}: <img src='/blob.gif' />
607 <td width='30%' align='left' colspan='2'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' />
608 <tr><td width='20%' align='right'>$Lang::tr{'time'}:</td>
609 <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td>
610 <td width='20%' align='right' colspan='2' />
611 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
612 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td></tr>
613 <tr><td width='20%' align='right'></td>
614 <td width='30%' align='left'><input type='checkbox' name='TIME_MON' $checked{'TIME_MON'}{'on'} />
615 <input type='checkbox' name='TIME_TUE' $checked{'TIME_TUE'}{'on'} />
616 <input type='checkbox' name='TIME_WED' $checked{'TIME_WED'}{'on'} />
617 <input type='checkbox' name='TIME_THU' $checked{'TIME_THU'}{'on'} />
618 <input type='checkbox' name='TIME_FRI' $checked{'TIME_FRI'}{'on'} />
619 <input type='checkbox' name='TIME_SAT' $checked{'TIME_SAT'}{'on'} />
620 <input type='checkbox' name='TIME_SUN' $checked{'TIME_SUN'}{'on'} /></td>
621 <td width='20%' align='right' colspan='2' />
622 <td width='15%' align='left'><select name='TIME_FROM'>
623END
624;
625for (my $i=0;$i<=23;$i++) {
626 $i = sprintf("%02s",$i);
627 for (my $j=0;$j<=45;$j+=15) {
628 $j = sprintf("%02s",$j);
629 my $time = $i.":".$j;
630 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
631 }
632}
633print <<END
634 </select></td>
635 <td width='15%' align='left'><select name='TIME_TO'>
636END
637;
638for (my $i=0;$i<=23;$i++) {
639 $i = sprintf("%02s",$i);
640 for (my $j=0;$j<=45;$j+=15) {
641 $j = sprintf("%02s",$j);
642 my $time = $i.":".$j;
643 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
644 }
645}
646print <<END
647 </select></td></tr>
648 <tr><td colspan='6'>
9141bd34 649 <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'}
39008af7 650 <td width='60%' align='left' colspan='4'><input type='submit' name='ACTION' value=$Lang::tr{'add'} />
d9b7aa33
MT
651 </table></form>
652END
653;
654 &Header::closebox();
c41c2eb4 655
afbda815 656if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2')
c41c2eb4
CS
657{
658&Header::openbox('100%', 'center', 'Quick Add');
659
660 open( FILE, "< /var/ipfire/outgoing/defaultservices" ) or die "Unable to read default services";
661 my @defservices = <FILE>;
662 close FILE;
663
e1e3dbe5 664print "<table width='100%'><tr bgcolor='$color{'color20'}'><td><b>$Lang::tr{'service'}</b></td><td><b>$Lang::tr{'description'}</b></td><td><b>$Lang::tr{'port'}</b></td><td><b>$Lang::tr{'protocol'}</b></td><td><b>$Lang::tr{'source net'}</b></td><td><b>$Lang::tr{'logging'}</b></td><td><b>$Lang::tr{'action'}</b></td></tr>";
c41c2eb4
CS
665foreach my $serviceline(@defservices)
666 {
667 my @service = split(/,/,$serviceline);
668 print <<END
669 <tr><form method='post' action='$ENV{'SCRIPT_NAME'}'>
670 <td>$service[0]<input type='hidden' name='NAME' value='@service[0]' /></td>
671 <td>$service[3]</td>
672 <td><a href='http://isc.sans.org/port_details.php?port=$service[1]' target='top'>$service[1]</a><input type='hidden' name='DPORT' value='@service[1]' /></td>
673 <td>$service[2]<input type='hidden' name='PROT' value='@service[2]' /></td>
674 <td><select name='SNET'><option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option><option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
675END
676;
677 if (&Header::blue_used()){
678 print "<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>";
679 }
680 if (&Header::orange_used()){
681 print "<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>";
682 }
683 print <<END
9141bd34
CS
684 </select></td>
685 <td><select name='LOG'><option value='$Lang::tr{'active'}'>$Lang::tr{'active'}</option><option value='$Lang::tr{'inactive'}' 'selected'>$Lang::tr{'inactive'}</option></select></td><td>
c41c2eb4
CS
686 <input type='hidden' name='ACTION' value=$Lang::tr{'add'} />
687 <input type='image' alt='$Lang::tr{'add'}' src='/images/add.gif' />
688 <input type='hidden' name='ENABLED' value='on' />
c41c2eb4
CS
689END
690;
9141bd34
CS
691 if ($outfwsettings{'POLICY'} eq 'MODE1'){ print "<input type='hidden' name='STATE' value='ALLOW' /></form></td></tr>";}
692 elsif ($outfwsettings{'POLICY'} eq 'MODE2'){print "<input type='hidden' name='STATE' value='DENY' /></form></td></tr>";}
c41c2eb4 693 }
9141bd34 694 print "</table>";
c41c2eb4 695 &Header::closebox();
9141bd34 696 }
39008af7 697}