Pakfire laedt die Listen jetzt besser und hat eine veraenderte Oberflaeche bekommen.
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / outgoingfw.cgi
CommitLineData
d9b7aa33
MT
1#!/usr/bin/perl
2#
3# IPFire CGIs
4#
5# This code is distributed under the terms of the GPL
6#
7# (c) The IPFire Team
8#
9
10use strict;
11# enable only the following on debugging purpose
cb5e9c6c
CS
12#use warnings;
13#use CGI::Carp 'fatalsToBrowser';
d9b7aa33
MT
14
15require '/var/ipfire/general-functions.pl';
16require "${General::swroot}/lang.pl";
17require "${General::swroot}/header.pl";
18
19my %outfwsettings = ();
20my %checked = ();
21my %selected= () ;
22my %netsettings = ();
23my $errormessage = "";
24my $configentry = "";
25my @configs = ();
26my @configline = ();
27my $p2pentry = "";
28my @p2ps = ();
29my @p2pline = ();
30
31my $configfile = "/var/ipfire/outgoing/rules";
32my $p2pfile = "/var/ipfire/outgoing/p2protocols";
f2fdd0c1
CS
33my $servicefile = "/var/ipfire/outgoing/defaultservices";
34
35my %color = ();
36my %mainsettings = ();
37&General::readhash("${General::swroot}/main/settings", \%mainsettings);
38&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
d9b7aa33
MT
39
40&General::readhash("${General::swroot}/ethernet/settings", \%netsettings);
41
42&Header::showhttpheaders();
43
44### Values that have to be initialized
45$outfwsettings{'ACTION'} = '';
46$outfwsettings{'VALID'} = 'yes';
47$outfwsettings{'EDIT'} = 'no';
48$outfwsettings{'NAME'} = '';
49$outfwsettings{'SNET'} = '';
50$outfwsettings{'SIP'} = '';
51$outfwsettings{'SPORT'} = '';
52$outfwsettings{'SMAC'} = '';
53$outfwsettings{'DIP'} = '';
54$outfwsettings{'DPORT'} = '';
55$outfwsettings{'PROT'} = '';
56$outfwsettings{'STATE'} = '';
57$outfwsettings{'DISPLAY_DIP'} = '';
58$outfwsettings{'DISPLAY_DPORT'} = '';
59$outfwsettings{'DISPLAY_SMAC'} = '';
60$outfwsettings{'DISPLAY_SIP'} = '';
1fde937c 61$outfwsettings{'POLICY'} = 'MODE0';
d9b7aa33
MT
62
63&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
64&Header::getcgihash(\%outfwsettings);
65
66if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
67if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
68if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
69
70&Header::openpage('Ausgehende Firewall', 1, '');
d9b7aa33
MT
71&Header::openbigbox('100%', 'left', '', $errormessage);
72
73############################################################################################################################
74############################################################################################################################
75
76if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
77{
78 $outfwsettings{'POLICY'}='MODE0';
79 unlink $configfile;
9833e7d8 80 system("/usr/bin/touch $configfile");
9141bd34
CS
81 my $MODE = $outfwsettings{'POLICY'};
82 %outfwsettings = ();
83 $outfwsettings{'POLICY'} = "$MODE";
d9b7aa33
MT
84 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
85}
86if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
87{
9141bd34
CS
88 my $MODE = $outfwsettings{'POLICY'};
89 %outfwsettings = ();
90 $outfwsettings{'POLICY'} = "$MODE";
d9b7aa33 91 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
9141bd34 92 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
93}
94if ($outfwsettings{'ACTION'} eq 'enable')
95{
96 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
97 @p2ps = <FILE>;
98 close FILE;
99 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
100 foreach $p2pentry (sort @p2ps)
101 {
102 @p2pline = split( /\;/, $p2pentry );
103 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
104 print FILE "$p2pline[0];$p2pline[1];on;\n";
105 } else {
106 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
107 }
108 }
109 close FILE;
9141bd34 110 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
111}
112if ($outfwsettings{'ACTION'} eq 'disable')
113{
114 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
115 @p2ps = <FILE>;
116 close FILE;
117 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
118 foreach $p2pentry (sort @p2ps)
119 {
120 @p2pline = split( /\;/, $p2pentry );
121 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
122 print FILE "$p2pline[0];$p2pline[1];off;\n";
123 } else {
124 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
125 }
126 }
127 close FILE;
9141bd34 128 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
129}
130if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'})
131{
132 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
133 @configs = <FILE>;
134 close FILE;
135 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
136 foreach $configentry (sort @configs)
137 {
138 @configline = split( /\;/, $configentry );
139 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
140 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
141 ($configline[2] eq $outfwsettings{'SNET'}) &&
142 ($configline[3] eq $outfwsettings{'PROT'}) &&
143 ($configline[4] eq $outfwsettings{'NAME'}) &&
144 ($configline[5] eq $outfwsettings{'SIP'}) &&
145 ($configline[6] eq $outfwsettings{'SMAC'}) &&
9141bd34
CS
146 ($configline[7] eq $outfwsettings{'DIP'}) &&
147 ($configline[9] eq $outfwsettings{'LOG'}) &&
d9b7aa33
MT
148 ($configline[8] eq $outfwsettings{'DPORT'}))
149 {
150 print FILE $configentry;
151 }
152 }
153 close FILE;
ebb9187c
MT
154 $selected{'SNET'}{"$outfwsettings{'SNET'}"} = 'selected';
155 $selected{'PROT'}{"$outfwsettings{'PROT'}"} = 'selected';
9141bd34 156 $selected{'LOG'}{"$outfwsettings{'LOG'}"} = 'selected';
d9b7aa33
MT
157 &addrule();
158 &Header::closebigbox();
159 &Header::closepage();
9141bd34
CS
160 exit
161 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
162}
163if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'})
164{
165 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
166 @configs = <FILE>;
167 close FILE;
168 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
169 foreach $configentry (sort @configs)
170 {
171 @configline = split( /\;/, $configentry );
172 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
173 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
174 ($configline[2] eq $outfwsettings{'SNET'}) &&
175 ($configline[3] eq $outfwsettings{'PROT'}) &&
176 ($configline[4] eq $outfwsettings{'NAME'}) &&
177 ($configline[5] eq $outfwsettings{'SIP'}) &&
178 ($configline[6] eq $outfwsettings{'SMAC'}) &&
179 ($configline[7] eq $outfwsettings{'DIP'}) &&
9141bd34 180 ($configline[9] eq $outfwsettings{'LOG'}) &&
d9b7aa33
MT
181 ($configline[8] eq $outfwsettings{'DPORT'}))
182 {
183 print FILE $configentry;
184 }
185 }
186 close FILE;
9141bd34 187 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33
MT
188}
189if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'})
190{
191 if ( $outfwsettings{'VALID'} eq 'yes' ) {
192 open( FILE, ">> $configfile" ) or die "Unable to write $configfile";
193 print FILE <<END
9141bd34 194$outfwsettings{'STATE'};$outfwsettings{'ENABLED'};$outfwsettings{'SNET'};$outfwsettings{'PROT'};$outfwsettings{'NAME'};$outfwsettings{'SIP'};$outfwsettings{'SMAC'};$outfwsettings{'DIP'};$outfwsettings{'DPORT'};$outfwsettings{'LOG'};
d9b7aa33
MT
195END
196;
197 close FILE;
9141bd34 198 system("/usr/local/bin/outgoingfwctrl");
d9b7aa33 199 } else {
ebb9187c 200 $outfwsettings{'ACTION'} = 'Add rule';
d9b7aa33
MT
201 }
202}
ebb9187c 203if ($outfwsettings{'ACTION'} eq 'Add rule')
d9b7aa33
MT
204{
205 &addrule();
206 exit
207}
208
209&General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
210
211if ($errormessage) {
212 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
213 print "<class name='base'>$errormessage\n";
214 print "&nbsp;</class>\n";
215 &Header::closebox();
216}
217
218############################################################################################################################
219############################################################################################################################
220
221if ($outfwsettings{'POLICY'} ne 'MODE0'){
222 &Header::openbox('100%', 'center', 'Rules');
223 print <<END
224 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
c41c2eb4 225 <input type='submit' name='ACTION' value='Add rule' />
ebb9187c 226 </form>
d9b7aa33
MT
227END
228;
229 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
230 @configs = <FILE>;
231 close FILE;
232 if (@configs) {
233 print <<END
c41c2eb4 234 <hr />
d9b7aa33 235 <table border='0' width='100%' cellspacing='0'>
f2fdd0c1
CS
236 <tr bgcolor='$color{'color22'}'>
237 <td width='14%' align='center'><b>Protokoll</b>
238 <td width='14%' align='center'><b>Netzwerk</b>
239 <td width='14%' align='center'><b>Ziel</b>
240 <td width='14%' align='center'><b>Anmerkung</b>
241 <td width='14%' align='center'><b>Politik</b>
9141bd34
CS
242 <td width='16%' align='center'><b>Logging</b>
243 <td width='14%' align='center'><b>Aktionen</b>
d9b7aa33
MT
244END
245;
246 foreach $configentry (sort @configs)
247 {
248 @configline = split( /\;/, $configentry );
249 $outfwsettings{'STATE'} = $configline[0];
250 $outfwsettings{'ENABLED'} = $configline[1];
251 $outfwsettings{'SNET'} = $configline[2];
252 $outfwsettings{'PROT'} = $configline[3];
253 $outfwsettings{'NAME'} = $configline[4];
254 $outfwsettings{'SIP'} = $configline[5];
255 $outfwsettings{'SMAC'} = $configline[6];
256 $outfwsettings{'DIP'} = $configline[7];
257 $outfwsettings{'DPORT'} = $configline[8];
9141bd34 258 $outfwsettings{'LOG'} = $configline[9];
d9b7aa33
MT
259 if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; }
260 if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; }
9141bd34
CS
261 if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY' />"; }
262 if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW' />"; }
d9b7aa33
MT
263 if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){
264 print <<END
f2fdd0c1 265 <tr bgcolor='$color{'color20'}'>
ebb9187c
MT
266 <td align='center'>$outfwsettings{'PROT'}
267 <td align='center'>$outfwsettings{'SNET'}
268 <td align='center'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'}
269 <td align='center'>$outfwsettings{'NAME'}
270 <td align='center'>$outfwsettings{'DISPLAY_STATE'}
9141bd34
CS
271 <td align='center'>$outfwsettings{'LOG'}
272 <td align='center'>
ebb9187c
MT
273 <table border='0' cellpadding='0' cellspacing='0'><tr>
274 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
275 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
276 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
277 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
278 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
279 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
280 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
281 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
282 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
283 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
284 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
285 <input type='hidden' name='ACTION' value=$Lang::tr{'edit'} />
286 <input type='image' src='/images/edit.gif' width="20" height="20" alt=$Lang::tr{'edit'} />
ebb9187c
MT
287 </form>
288 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
9141bd34
CS
289 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
290 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
291 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
292 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
293 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
294 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
295 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
296 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
297 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
298 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
299 <input type='hidden' name='ACTION' value=$Lang::tr{'delete'} />
300 <input type='image' src='/images/delete.gif' width="20" height="20" alt=$Lang::tr{'delete'} />
ebb9187c 301 </form></table>
d9b7aa33
MT
302END
303;
304 if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) {
ebb9187c
MT
305 unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
306 unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
d9b7aa33 307 print <<END
ebb9187c
MT
308 <tr><td width='14%' align='right'>Quell-IP-Adresse:
309 <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'}
310 <td width='14%' align='right'>Quell-MAC-Adresse:
311 <td width='14%' align='left'>$outfwsettings{'DISPLAY_SMAC'}
312 <td width='44%' colspan='2' align='center'>
d9b7aa33
MT
313END
314;
315 }
316 print <<END
317 </form>
318END
319;
320 }
321 }
322 print <<END
323 </table>
324END
325;
326
327 }
d9b7aa33
MT
328 &Header::closebox();
329}
330
9141bd34 331if ($outfwsettings{'POLICY'} ne 'MODE0'){
d9b7aa33
MT
332 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
333 @p2ps = <FILE>;
334 close FILE;
335 &Header::openbox('100%', 'center', 'P2P-Block');
336 print <<END
337 <table width='40%'>
9141bd34
CS
338 <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>Protokoll</b>
339 <td width='33%' align=center><b>Status</b>
d9b7aa33
MT
340END
341;
ebb9187c 342 my $id = 1;
d9b7aa33
MT
343 foreach $p2pentry (sort @p2ps)
344 {
345 @p2pline = split( /\;/, $p2pentry );
346 print <<END
347 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
ebb9187c
MT
348END
349;
9141bd34 350 print "\t\t\t<tr bgcolor='$color{'color20'}'>\n";
f2fdd0c1 351 print <<END
ebb9187c 352 <td width='66%' align='center'>$p2pline[0]:
9141bd34 353 <td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' />
d9b7aa33
MT
354END
355;
356 if ($p2pline[2] eq 'on') {
357 print <<END
9141bd34
CS
358 <input type='hidden' name='ACTION' value='disable' />
359 <input type='image' name='submit' src='/images/stock_ok.png' alt='' />
d9b7aa33
MT
360END
361;
362 } else {
363 print <<END
9141bd34
CS
364 <input type='hidden' name='ACTION' value='enable' />
365 <input type='image' name='submit' src='/images/stock_stop.png' alt='' />
d9b7aa33
MT
366END
367;
368 }
369 print <<END
370 </form>
371END
372;
373 }
374 print <<END
d9b7aa33 375 </table>
9141bd34 376 <br />Klicken Sie auf die Symbole um das entsprechende iptables P2P-Blockmodul zu (de-)aktivieren.
d9b7aa33
MT
377END
378;
379 &Header::closebox();
380}
381
382&Header::openbox('100%', 'center', 'Policy');
383print <<END
384 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
385 <table width='100%'>
9141bd34
CS
386 <tr><td width='10%' align='left'><b>Modus 0:</b><td width='90%' align='left' colspan='2'>In diesem Modus ist es allen Rechnern im Netzwerk uneingeschraenkt moeglich Verbindungen ins Internet aufzubauen.</td></tr>
387 <tr><td width='10%' align='left'><b>Modus 1:</b><td width='90%' align='left' colspan='2'>In diesem Modus werden nur Verbindungen nach den oben definierten Regeln zugelassen.</td></tr>
388 <tr><td width='10%' align='left'><b>Modus 2:</b><td width='90%' align='left' colspan='2'>In diesem Modus werden saemtliche Verbindungen erlaubt, bis auf die oben definierten Block-Regeln.</td></tr>
389 <tr><td colspan='3'><hr /></td></tr>
115340d2 390 <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>Modus 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>Modus 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>Modus 2</option></select>
c41c2eb4 391 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
115340d2 392 <td width='45%' align='left'>
d9b7aa33
MT
393END
394;
395 if ($outfwsettings{'POLICY'} ne 'MODE0') {
396 print <<END
c41c2eb4 397 Alle Regeln loeschen: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
d9b7aa33
MT
398END
399;
400 }
401print <<END
402 </table>
403 </form>
404END
405;
406&Header::closebox();
407
408&Header::closebigbox();
409&Header::closepage();
410
411############################################################################################################################
412############################################################################################################################
413
414sub addrule
415{
416 &Header::openbox('100%', 'center', 'Rules hinzufuegen');
417 if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; }
418 print <<END
419 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
420 <table width='80%'>
9141bd34
CS
421 <tr><td width='20%' align='right'>Anmerkung: <img src='/blob.gif' />
422 <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' />
d9b7aa33 423 <td width='20%' align='right'>Aktiviert:
9141bd34 424 <td width='30%' align='left'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} />
d9b7aa33 425 <tr><td width='20%' align='right'>Protokoll:
ebb9187c 426 <td width='30%' align='left'><select name='PROT'><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>
d9b7aa33
MT
427 <td width='20%' align='right'>Sicherheitspolitik:
428 <td width='30%' align='left'>
429END
430;
431 if ($outfwsettings{'POLICY'} eq 'MODE1'){
9141bd34 432 print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW' />\n";
d9b7aa33 433 } elsif ($outfwsettings{'POLICY'} eq 'MODE2'){
9141bd34 434 print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n";
d9b7aa33
MT
435 }
436 print <<END
437 <tr><td width='20%' align='right'>Quellnetz:
438 <td width='30%' align='left'><select name='SNET'>
439 <option value='all' $selected{'SNET'}{'ALL'}>alle</option>
ebb9187c 440 <option value='ip' $selected{'SNET'}{'ip'}>Quell-IP/MAC benutzen</option>
c41c2eb4 441 <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
d9b7aa33
MT
442END
443;
444 if (&Header::blue_used()){
c41c2eb4 445 print "\t\t\t<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>\n";
d9b7aa33
MT
446 }
447 if (&Header::orange_used()){
c41c2eb4 448 print "\t\t\t<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>\n";
d9b7aa33
MT
449 }
450 print <<END
451 </select>
9141bd34
CS
452 <td width='20%' align='right'>Quell-IP-Adresse: <img src='/blob.gif' />
453 <td width='30%' align='left'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' />
454 <tr><td width='20%' align='right'>Logging:
455 <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>
456 <td width='20%' align='right'>Quell-MAC-Adresse: <img src='/blob.gif' />
457 <td width='30%' align='left'><input type='text' name='SMAC' maxlength='23' value='$outfwsettings{'SMAC'}' />
458 <tr><td width='20%' align='right'>Ziel-IP-Adresse: <img src='/blob.gif' />
459 <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' />
460 <td width='20%' align='right'>Ziel-Port: <img src='/blob.gif' />
461 <td width='30%' align='left'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' />
d9b7aa33 462 <tr><td colspan='4'>
9141bd34
CS
463 <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'}
464 <td width='60%' align='left' colspan='2'><input type='submit' name='ACTION' value=$Lang::tr{'add'} />
d9b7aa33
MT
465 </table></form>
466END
467;
468 &Header::closebox();
c41c2eb4 469
afbda815 470if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2')
c41c2eb4
CS
471{
472&Header::openbox('100%', 'center', 'Quick Add');
473
474 open( FILE, "< /var/ipfire/outgoing/defaultservices" ) or die "Unable to read default services";
475 my @defservices = <FILE>;
476 close FILE;
477
9141bd34 478print "<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></td></tr>";
c41c2eb4
CS
479foreach my $serviceline(@defservices)
480 {
481 my @service = split(/,/,$serviceline);
482 print <<END
483 <tr><form method='post' action='$ENV{'SCRIPT_NAME'}'>
484 <td>$service[0]<input type='hidden' name='NAME' value='@service[0]' /></td>
485 <td>$service[3]</td>
486 <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>
487 <td>$service[2]<input type='hidden' name='PROT' value='@service[2]' /></td>
488 <td><select name='SNET'><option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option><option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
489END
490;
491 if (&Header::blue_used()){
492 print "<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>";
493 }
494 if (&Header::orange_used()){
495 print "<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>";
496 }
497 print <<END
9141bd34
CS
498 </select></td>
499 <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
500 <input type='hidden' name='ACTION' value=$Lang::tr{'add'} />
501 <input type='image' alt='$Lang::tr{'add'}' src='/images/add.gif' />
502 <input type='hidden' name='ENABLED' value='on' />
c41c2eb4
CS
503END
504;
9141bd34
CS
505 if ($outfwsettings{'POLICY'} eq 'MODE1'){ print "<input type='hidden' name='STATE' value='ALLOW' /></form></td></tr>";}
506 elsif ($outfwsettings{'POLICY'} eq 'MODE2'){print "<input type='hidden' name='STATE' value='DENY' /></form></td></tr>";}
c41c2eb4 507 }
9141bd34 508 print "</table>";
c41c2eb4 509 &Header::closebox();
9141bd34 510 }
c41c2eb4 511}