Add Atheros/Attansic atl1c ethernet driver.
[people/pmueller/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 #
5# Copyright (C) 2007 Michael Tremer & Christian Schmidt #
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
cb5e9c6c
CS
24#use warnings;
25#use 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
MT
75
76&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
77&Header::getcgihash(\%outfwsettings);
78
5595bc03
CS
79$checked{'MODE1LOG'}{'off'} = '';
80$checked{'MODE1LOG'}{'on'} = '';
81$checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'";
82
d9b7aa33
MT
83if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
84if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
85if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
86
87&Header::openpage('Ausgehende Firewall', 1, '');
d9b7aa33
MT
88&Header::openbigbox('100%', 'left', '', $errormessage);
89
90############################################################################################################################
91############################################################################################################################
92
93if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
94{
95 $outfwsettings{'POLICY'}='MODE0';
96 unlink $configfile;
9833e7d8 97 system("/usr/bin/touch $configfile");
9141bd34
CS
98 my $MODE = $outfwsettings{'POLICY'};
99 %outfwsettings = ();
100 $outfwsettings{'POLICY'} = "$MODE";
d9b7aa33
MT
101 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
102}
103if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
104{
9141bd34 105 my $MODE = $outfwsettings{'POLICY'};
5595bc03 106 my $MODE1LOG = $outfwsettings{'MODE1LOG'};
9141bd34
CS
107 %outfwsettings = ();
108 $outfwsettings{'POLICY'} = "$MODE";
5595bc03 109 $outfwsettings{'MODE1LOG'} = "$MODE1LOG";
d9b7aa33 110 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
9141bd34 111 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
112}
113if ($outfwsettings{'ACTION'} eq 'enable')
114{
115 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
116 @p2ps = <FILE>;
117 close FILE;
118 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
119 foreach $p2pentry (sort @p2ps)
120 {
121 @p2pline = split( /\;/, $p2pentry );
122 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
123 print FILE "$p2pline[0];$p2pline[1];on;\n";
124 } else {
125 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
126 }
127 }
128 close FILE;
9141bd34 129 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
130}
131if ($outfwsettings{'ACTION'} eq 'disable')
132{
133 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
134 @p2ps = <FILE>;
135 close FILE;
136 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
137 foreach $p2pentry (sort @p2ps)
138 {
139 @p2pline = split( /\;/, $p2pentry );
140 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
141 print FILE "$p2pline[0];$p2pline[1];off;\n";
142 } else {
143 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
144 }
145 }
146 close FILE;
9141bd34 147 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
148}
149if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'})
150{
151 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
152 @configs = <FILE>;
153 close FILE;
154 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
155 foreach $configentry (sort @configs)
156 {
157 @configline = split( /\;/, $configentry );
158 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
159 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
160 ($configline[2] eq $outfwsettings{'SNET'}) &&
161 ($configline[3] eq $outfwsettings{'PROT'}) &&
162 ($configline[4] eq $outfwsettings{'NAME'}) &&
163 ($configline[5] eq $outfwsettings{'SIP'}) &&
164 ($configline[6] eq $outfwsettings{'SMAC'}) &&
9141bd34
CS
165 ($configline[7] eq $outfwsettings{'DIP'}) &&
166 ($configline[9] eq $outfwsettings{'LOG'}) &&
d9b7aa33
MT
167 ($configline[8] eq $outfwsettings{'DPORT'}))
168 {
169 print FILE $configentry;
170 }
171 }
172 close FILE;
ebb9187c
MT
173 $selected{'SNET'}{"$outfwsettings{'SNET'}"} = 'selected';
174 $selected{'PROT'}{"$outfwsettings{'PROT'}"} = 'selected';
9141bd34 175 $selected{'LOG'}{"$outfwsettings{'LOG'}"} = 'selected';
d9b7aa33
MT
176 &addrule();
177 &Header::closebigbox();
178 &Header::closepage();
9141bd34
CS
179 exit
180 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
181}
182if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'})
183{
184 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
185 @configs = <FILE>;
186 close FILE;
187 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
188 foreach $configentry (sort @configs)
189 {
190 @configline = split( /\;/, $configentry );
191 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
192 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
193 ($configline[2] eq $outfwsettings{'SNET'}) &&
194 ($configline[3] eq $outfwsettings{'PROT'}) &&
195 ($configline[4] eq $outfwsettings{'NAME'}) &&
196 ($configline[5] eq $outfwsettings{'SIP'}) &&
197 ($configline[6] eq $outfwsettings{'SMAC'}) &&
198 ($configline[7] eq $outfwsettings{'DIP'}) &&
9141bd34 199 ($configline[9] eq $outfwsettings{'LOG'}) &&
d9b7aa33
MT
200 ($configline[8] eq $outfwsettings{'DPORT'}))
201 {
202 print FILE $configentry;
203 }
204 }
205 close FILE;
9141bd34 206 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
207}
208if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'})
209{
210 if ( $outfwsettings{'VALID'} eq 'yes' ) {
211 open( FILE, ">> $configfile" ) or die "Unable to write $configfile";
212 print FILE <<END
9141bd34 213$outfwsettings{'STATE'};$outfwsettings{'ENABLED'};$outfwsettings{'SNET'};$outfwsettings{'PROT'};$outfwsettings{'NAME'};$outfwsettings{'SIP'};$outfwsettings{'SMAC'};$outfwsettings{'DIP'};$outfwsettings{'DPORT'};$outfwsettings{'LOG'};
d9b7aa33
MT
214END
215;
216 close FILE;
9141bd34 217 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33 218 } else {
ebb9187c 219 $outfwsettings{'ACTION'} = 'Add rule';
d9b7aa33
MT
220 }
221}
ebb9187c 222if ($outfwsettings{'ACTION'} eq 'Add rule')
d9b7aa33
MT
223{
224 &addrule();
225 exit
226}
227
228&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
229
230if ($errormessage) {
231 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
232 print "<class name='base'>$errormessage\n";
233 print "&nbsp;</class>\n";
234 &Header::closebox();
235}
236
237############################################################################################################################
238############################################################################################################################
239
240if ($outfwsettings{'POLICY'} ne 'MODE0'){
241 &Header::openbox('100%', 'center', 'Rules');
242 print <<END
243 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
c41c2eb4 244 <input type='submit' name='ACTION' value='Add rule' />
ebb9187c 245 </form>
d9b7aa33
MT
246END
247;
248 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
249 @configs = <FILE>;
250 close FILE;
251 if (@configs) {
252 print <<END
c41c2eb4 253 <hr />
d9b7aa33 254 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1 255 <tr bgcolor='$color{'color22'}'>
e1e3dbe5
CS
256 <td width='14%' align='center'><b>$Lang::tr{'protocol'}</b></td>
257 <td width='14%' align='center'><b>$Lang::tr{'network'}</b></td>
258 <td width='14%' align='center'><b>$Lang::tr{'destination'}</b></td>
259 <td width='14%' align='center'><b>$Lang::tr{'description'}</b></td>
260 <td width='14%' align='center'><b>$Lang::tr{'policy'}</b></td>
261 <td width='16%' align='center'><b>$Lang::tr{'logging'}</b></td>
262 <td width='14%' align='center'><b>$Lang::tr{'action'}</b></td>
d9b7aa33
MT
263END
264;
265 foreach $configentry (sort @configs)
266 {
267 @configline = split( /\;/, $configentry );
268 $outfwsettings{'STATE'} = $configline[0];
269 $outfwsettings{'ENABLED'} = $configline[1];
270 $outfwsettings{'SNET'} = $configline[2];
271 $outfwsettings{'PROT'} = $configline[3];
272 $outfwsettings{'NAME'} = $configline[4];
273 $outfwsettings{'SIP'} = $configline[5];
274 $outfwsettings{'SMAC'} = $configline[6];
275 $outfwsettings{'DIP'} = $configline[7];
276 $outfwsettings{'DPORT'} = $configline[8];
9141bd34 277 $outfwsettings{'LOG'} = $configline[9];
d9b7aa33
MT
278 if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; }
279 if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; }
9141bd34
CS
280 if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY' />"; }
281 if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW' />"; }
d9b7aa33
MT
282 if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){
283 print <<END
f2fdd0c1 284 <tr bgcolor='$color{'color20'}'>
ebb9187c
MT
285 <td align='center'>$outfwsettings{'PROT'}
286 <td align='center'>$outfwsettings{'SNET'}
287 <td align='center'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'}
288 <td align='center'>$outfwsettings{'NAME'}
289 <td align='center'>$outfwsettings{'DISPLAY_STATE'}
9141bd34
CS
290 <td align='center'>$outfwsettings{'LOG'}
291 <td align='center'>
ebb9187c
MT
292 <table border='0' cellpadding='0' cellspacing='0'><tr>
293 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
294 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
295 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
296 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
297 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
298 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
299 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
300 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
301 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
302 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
303 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
304 <input type='hidden' name='ACTION' value=$Lang::tr{'edit'} />
305 <input type='image' src='/images/edit.gif' width="20" height="20" alt=$Lang::tr{'edit'} />
ebb9187c
MT
306 </form>
307 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
308 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
309 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
310 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
311 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
312 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
313 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
314 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
315 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
316 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
317 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
318 <input type='hidden' name='ACTION' value=$Lang::tr{'delete'} />
319 <input type='image' src='/images/delete.gif' width="20" height="20" alt=$Lang::tr{'delete'} />
ebb9187c 320 </form></table>
d9b7aa33
MT
321END
322;
323 if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) {
ebb9187c
MT
324 unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
325 unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
d9b7aa33 326 print <<END
e1e3dbe5 327 <tr><td width='14%' align='right'>$Lang::tr{'source ip'}:
ebb9187c 328 <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'}
ebb9187c 329 <td width='44%' colspan='2' align='center'>
d9b7aa33
MT
330END
331;
332 }
333 print <<END
334 </form>
335END
336;
337 }
338 }
5595bc03
CS
339if ($outfwsettings{'POLICY'} eq 'MODE1'){
340print <<END
341 <tr bgcolor='$color{'color20'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
342 <td align='center'>tcp&udp
343 <td align='center'>all
344 <td align='center'>ALL
345 <td align='center'>drop
346 <td align='center'><img src='/images/stock_stop.png' alt='DENY' />
347 <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
348 <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>
349 <table border='0' cellpadding='0' cellspacing='0'><tr>
350 <td>
351 <td></table>
352END
353;
354}
d9b7aa33
MT
355 print <<END
356 </table>
357END
358;
359
360 }
d9b7aa33
MT
361 &Header::closebox();
362}
363
9141bd34 364if ($outfwsettings{'POLICY'} ne 'MODE0'){
d9b7aa33
MT
365 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
366 @p2ps = <FILE>;
367 close FILE;
368 &Header::openbox('100%', 'center', 'P2P-Block');
369 print <<END
370 <table width='40%'>
e1e3dbe5
CS
371 <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>$Lang::tr{'protocol'}</b>
372 <td width='33%' align=center><b>$Lang::tr{'status'}</b>
d9b7aa33
MT
373END
374;
ebb9187c 375 my $id = 1;
d9b7aa33
MT
376 foreach $p2pentry (sort @p2ps)
377 {
378 @p2pline = split( /\;/, $p2pentry );
379 print <<END
380 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
ebb9187c
MT
381END
382;
9141bd34 383 print "\t\t\t<tr bgcolor='$color{'color20'}'>\n";
f2fdd0c1 384 print <<END
ebb9187c 385 <td width='66%' align='center'>$p2pline[0]:
9141bd34 386 <td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' />
d9b7aa33
MT
387END
388;
389 if ($p2pline[2] eq 'on') {
390 print <<END
9141bd34
CS
391 <input type='hidden' name='ACTION' value='disable' />
392 <input type='image' name='submit' src='/images/stock_ok.png' alt='' />
d9b7aa33
MT
393END
394;
395 } else {
396 print <<END
9141bd34
CS
397 <input type='hidden' name='ACTION' value='enable' />
398 <input type='image' name='submit' src='/images/stock_stop.png' alt='' />
d9b7aa33
MT
399END
400;
401 }
402 print <<END
403 </form>
404END
405;
406 }
407 print <<END
d9b7aa33 408 </table>
e1e3dbe5 409 <br />$Lang::tr{'outgoingfw p2p description'}
d9b7aa33
MT
410END
411;
412 &Header::closebox();
413}
414
415&Header::openbox('100%', 'center', 'Policy');
416print <<END
417 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
418 <table width='100%'>
e1e3dbe5
CS
419 <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>
420 <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>
421 <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 422 <tr><td colspan='3'><hr /></td></tr>
e1e3dbe5 423 <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 424 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
115340d2 425 <td width='45%' align='left'>
d9b7aa33
MT
426END
427;
428 if ($outfwsettings{'POLICY'} ne 'MODE0') {
429 print <<END
e1e3dbe5 430 $Lang::tr{'outgoingfw reset'}: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
d9b7aa33
MT
431END
432;
433 }
434print <<END
435 </table>
436 </form>
437END
438;
439&Header::closebox();
440
441&Header::closebigbox();
442&Header::closepage();
443
444############################################################################################################################
445############################################################################################################################
446
447sub addrule
448{
449 &Header::openbox('100%', 'center', 'Rules hinzufuegen');
450 if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; }
451 print <<END
452 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
453 <table width='80%'>
e1e3dbe5 454 <tr><td width='20%' align='right'>$Lang::tr{'description'}: <img src='/blob.gif' />
9141bd34 455 <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' />
e1e3dbe5 456 <td width='20%' align='right'>$Lang::tr{'active'}:
9141bd34 457 <td width='30%' align='left'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} />
e1e3dbe5 458 <tr><td width='20%' align='right'>$Lang::tr{'protocol'}:
7528c1be 459 <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>
e1e3dbe5 460 <td width='20%' align='right'>$Lang::tr{'policy'}:
d9b7aa33
MT
461 <td width='30%' align='left'>
462END
463;
464 if ($outfwsettings{'POLICY'} eq 'MODE1'){
9141bd34 465 print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW' />\n";
d9b7aa33 466 } elsif ($outfwsettings{'POLICY'} eq 'MODE2'){
9141bd34 467 print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n";
d9b7aa33
MT
468 }
469 print <<END
e1e3dbe5 470 <tr><td width='20%' align='right'>$Lang::tr{'source net'}:
d9b7aa33 471 <td width='30%' align='left'><select name='SNET'>
e1e3dbe5
CS
472 <option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option>
473 <option value='ip' $selected{'SNET'}{'ip'}>$Lang::tr{'source ip'}</option>
c41c2eb4 474 <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
d9b7aa33
MT
475END
476;
477 if (&Header::blue_used()){
c41c2eb4 478 print "\t\t\t<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>\n";
d9b7aa33
MT
479 }
480 if (&Header::orange_used()){
c41c2eb4 481 print "\t\t\t<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>\n";
d9b7aa33
MT
482 }
483 print <<END
484 </select>
e1e3dbe5 485 <td width='20%' align='right'>$Lang::tr{'source ip'}: <img src='/blob.gif' />
9141bd34 486 <td width='30%' align='left'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' />
e1e3dbe5 487 <tr><td width='20%' align='right'>$Lang::tr{'logging'}:
52485124
CS
488END
489;
490if ($outfwsettings{'POLICY'} eq 'MODE1'){
491 print "<td width='30%' align='left'><input type='text' name='LOG' maxlength='10' value='$Lang::tr{'inactive'}' readonly='true' /></td>";
492}
493else{
494 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>";
495}
496print <<END
e1e3dbe5
CS
497 <td width='20%' align='right' />
498 <td width='30%' align='left' />
499 <tr><td width='20%' align='right'>$Lang::tr{'destination ip'}: <img src='/blob.gif' />
9141bd34 500 <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' />
e1e3dbe5 501 <td width='20%' align='right'>$Lang::tr{'destination port'}: <img src='/blob.gif' />
9141bd34 502 <td width='30%' align='left'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' />
d9b7aa33 503 <tr><td colspan='4'>
9141bd34
CS
504 <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'}
505 <td width='60%' align='left' colspan='2'><input type='submit' name='ACTION' value=$Lang::tr{'add'} />
d9b7aa33
MT
506 </table></form>
507END
508;
509 &Header::closebox();
c41c2eb4 510
afbda815 511if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2')
c41c2eb4
CS
512{
513&Header::openbox('100%', 'center', 'Quick Add');
514
515 open( FILE, "< /var/ipfire/outgoing/defaultservices" ) or die "Unable to read default services";
516 my @defservices = <FILE>;
517 close FILE;
518
e1e3dbe5 519print "<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
520foreach my $serviceline(@defservices)
521 {
522 my @service = split(/,/,$serviceline);
523 print <<END
524 <tr><form method='post' action='$ENV{'SCRIPT_NAME'}'>
525 <td>$service[0]<input type='hidden' name='NAME' value='@service[0]' /></td>
526 <td>$service[3]</td>
527 <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>
528 <td>$service[2]<input type='hidden' name='PROT' value='@service[2]' /></td>
529 <td><select name='SNET'><option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option><option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
530END
531;
532 if (&Header::blue_used()){
533 print "<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>";
534 }
535 if (&Header::orange_used()){
536 print "<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>";
537 }
538 print <<END
9141bd34
CS
539 </select></td>
540 <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
541 <input type='hidden' name='ACTION' value=$Lang::tr{'add'} />
542 <input type='image' alt='$Lang::tr{'add'}' src='/images/add.gif' />
543 <input type='hidden' name='ENABLED' value='on' />
c41c2eb4
CS
544END
545;
9141bd34
CS
546 if ($outfwsettings{'POLICY'} eq 'MODE1'){ print "<input type='hidden' name='STATE' value='ALLOW' /></form></td></tr>";}
547 elsif ($outfwsettings{'POLICY'} eq 'MODE2'){print "<input type='hidden' name='STATE' value='DENY' /></form></td></tr>";}
c41c2eb4 548 }
9141bd34 549 print "</table>";
c41c2eb4 550 &Header::closebox();
9141bd34 551 }
c41c2eb4 552}