]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blob - html/cgi-bin/outgoingfw.cgi
Merge branch 'kernel2.6.32.8' into next
[people/pmueller/ipfire-2.x.git] / html / cgi-bin / outgoingfw.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 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 ###############################################################################
21
22 use strict;
23 # enable only the following on debugging purpose
24 #use warnings;
25 #use CGI::Carp 'fatalsToBrowser';
26
27 require '/var/ipfire/general-functions.pl';
28 require "${General::swroot}/lang.pl";
29 require "${General::swroot}/header.pl";
30
31 my %outfwsettings = ();
32 my %checked = ();
33 my %selected= () ;
34 my %netsettings = ();
35 my $errormessage = "";
36 my $configentry = "";
37 my @configs = ();
38 my @configline = ();
39 my $p2pentry = "";
40 my @p2ps = ();
41 my @p2pline = ();
42
43 my $configfile = "/var/ipfire/outgoing/rules";
44 my $p2pfile = "/var/ipfire/outgoing/p2protocols";
45 my $servicefile = "/var/ipfire/outgoing/defaultservices";
46
47 my %color = ();
48 my %mainsettings = ();
49 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
50 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
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'} = '';
73 $outfwsettings{'POLICY'} = 'MODE0';
74 $outfwsettings{'MODE1LOG'} = 'off';
75
76 $outfwsettings{'TIME_FROM'} = '00:00';
77 $outfwsettings{'TIME_TO'} = '00:00';
78
79 &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
80 &Header::getcgihash(\%outfwsettings);
81
82 ###############
83 # DEBUG DEBUG
84 #&Header::openbox('100%', 'left', 'DEBUG');
85 #my $debugCount = 0;
86 #foreach my $line (sort keys %outfwsettings) {
87 #print "$line = $outfwsettings{$line}<br />\n";
88 # $debugCount++;
89 #}
90 #print "&nbsp;Count: $debugCount\n";
91 #&Header::closebox();
92 # DEBUG DEBUG
93 ###############
94
95 $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'";
96 $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'";
97
98 $checked{'MODE1LOG'}{'off'} = '';
99 $checked{'MODE1LOG'}{'on'} = '';
100 $checked{'MODE1LOG'}{$outfwsettings{'MODE1LOG'}} = "checked='checked'";
101 $checked{'TIME_MON'}{'off'} = '';
102 $checked{'TIME_MON'}{'on'} = '';
103 $checked{'TIME_MON'}{$outfwsettings{'TIME_MON'}} = "checked='checked'";
104 $checked{'TIME_TUE'}{'off'} = '';
105 $checked{'TIME_TUE'}{'on'} = '';
106 $checked{'TIME_TUE'}{$outfwsettings{'TIME_TUE'}} = "checked='checked'";
107 $checked{'TIME_WED'}{'off'} = '';
108 $checked{'TIME_WED'}{'on'} = '';
109 $checked{'TIME_WED'}{$outfwsettings{'TIME_WED'}} = "checked='checked'";
110 $checked{'TIME_THU'}{'off'} = '';
111 $checked{'TIME_THU'}{'on'} = '';
112 $checked{'TIME_THU'}{$outfwsettings{'TIME_THU'}} = "checked='checked'";
113 $checked{'TIME_FRI'}{'off'} = '';
114 $checked{'TIME_FRI'}{'on'} = '';
115 $checked{'TIME_FRI'}{$outfwsettings{'TIME_FRI'}} = "checked='checked'";
116 $checked{'TIME_SAT'}{'off'} = '';
117 $checked{'TIME_SAT'}{'on'} = '';
118 $checked{'TIME_SAT'}{$outfwsettings{'TIME_SAT'}} = "checked='checked'";
119 $checked{'TIME_SUN'}{'off'} = '';
120 $checked{'TIME_SUN'}{'on'} = '';
121 $checked{'TIME_SUN'}{$outfwsettings{'TIME_SUN'}} = "checked='checked'";
122
123 if ($outfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
124 if ($outfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
125 if ($outfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
126
127 # This is a little hack if poeple donĀ“t mark any date then all will be selected, because they might have forgotten to select
128 # a valid day. A Rule without any matching day will never work, because the timeranges are new feature people might not notice
129 # that they have to select a day for the rule.
130
131 if ( $outfwsettings{'TIME_MON'} eq "" &&
132 $outfwsettings{'TIME_TUE'} eq "" &&
133 $outfwsettings{'TIME_WED'} eq "" &&
134 $outfwsettings{'TIME_THU'} eq "" &&
135 $outfwsettings{'TIME_FRI'} eq "" &&
136 $outfwsettings{'TIME_SAT'} eq "" &&
137 $outfwsettings{'TIME_SUN'} eq "" )
138 {
139 $outfwsettings{'TIME_MON'} = "on";
140 $outfwsettings{'TIME_TUE'} = "on";
141 $outfwsettings{'TIME_WED'} = "on";
142 $outfwsettings{'TIME_THU'} = "on";
143 $outfwsettings{'TIME_FRI'} = "on";
144 $outfwsettings{'TIME_SAT'} = "on";
145 $outfwsettings{'TIME_SUN'} = "on";
146 }
147
148 &Header::openpage('Ausgehende Firewall', 1, '');
149 &Header::openbigbox('100%', 'left', '', $errormessage);
150
151 ############################################################################################################################
152 ############################################################################################################################
153
154 if ($outfwsettings{'ACTION'} eq $Lang::tr{'reset'})
155 {
156 $outfwsettings{'POLICY'}='MODE0';
157 unlink $configfile;
158 system("/usr/bin/touch $configfile");
159 my $MODE = $outfwsettings{'POLICY'};
160 %outfwsettings = ();
161 $outfwsettings{'POLICY'} = "$MODE";
162 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
163 }
164 if ($outfwsettings{'ACTION'} eq $Lang::tr{'save'})
165 {
166 my $MODE = $outfwsettings{'POLICY'};
167 my $MODE1LOG = $outfwsettings{'MODE1LOG'};
168 %outfwsettings = ();
169 $outfwsettings{'POLICY'} = "$MODE";
170 $outfwsettings{'MODE1LOG'} = "$MODE1LOG";
171 &General::writehash("${General::swroot}/outgoing/settings", \%outfwsettings);
172 system("/usr/local/bin/outgoingfwctrl");
173 }
174 if ($outfwsettings{'ACTION'} eq 'enable')
175 {
176 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
177 @p2ps = <FILE>;
178 close FILE;
179 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
180 foreach $p2pentry (sort @p2ps)
181 {
182 @p2pline = split( /\;/, $p2pentry );
183 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
184 print FILE "$p2pline[0];$p2pline[1];on;\n";
185 } else {
186 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
187 }
188 }
189 close FILE;
190 system("/usr/local/bin/outgoingfwctrl");
191 }
192 if ($outfwsettings{'ACTION'} eq 'disable')
193 {
194 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
195 @p2ps = <FILE>;
196 close FILE;
197 open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile";
198 foreach $p2pentry (sort @p2ps)
199 {
200 @p2pline = split( /\;/, $p2pentry );
201 if ($p2pline[1] eq $outfwsettings{'P2PROT'}) {
202 print FILE "$p2pline[0];$p2pline[1];off;\n";
203 } else {
204 print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
205 }
206 }
207 close FILE;
208 system("/usr/local/bin/outgoingfwctrl");
209 }
210 if ($outfwsettings{'ACTION'} eq $Lang::tr{'edit'})
211 {
212 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
213 @configs = <FILE>;
214 close FILE;
215 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
216 foreach $configentry (sort @configs)
217 {
218 @configline = split( /\;/, $configentry );
219
220 $configline[10] = "on" if not exists $configline[11];
221 $configline[11] = "on" if not exists $configline[11];
222 $configline[12] = "on" if not exists $configline[12];
223 $configline[13] = "on" if not exists $configline[13];
224 $configline[14] = "on" if not exists $configline[14];
225 $configline[15] = "on" if not exists $configline[15];
226 $configline[16] = "on" if not exists $configline[16];
227 $configline[17] = "00:00" if not exists $configline[17];
228 $configline[18] = "00:00" if not exists $configline[18];
229
230 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
231 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
232 ($configline[2] eq $outfwsettings{'SNET'}) &&
233 ($configline[3] eq $outfwsettings{'PROT'}) &&
234 ($configline[4] eq $outfwsettings{'NAME'}) &&
235 ($configline[5] eq $outfwsettings{'SIP'}) &&
236 ($configline[6] eq $outfwsettings{'SMAC'}) &&
237 ($configline[7] eq $outfwsettings{'DIP'}) &&
238 ($configline[9] eq $outfwsettings{'LOG'}) &&
239 ($configline[8] eq $outfwsettings{'DPORT'}) &&
240 ($configline[10] eq $outfwsettings{'TIME_MON'}) &&
241 ($configline[11] eq $outfwsettings{'TIME_TUE'}) &&
242 ($configline[12] eq $outfwsettings{'TIME_WED'}) &&
243 ($configline[13] eq $outfwsettings{'TIME_THU'}) &&
244 ($configline[14] eq $outfwsettings{'TIME_FRI'}) &&
245 ($configline[15] eq $outfwsettings{'TIME_SAT'}) &&
246 ($configline[16] eq $outfwsettings{'TIME_SUN'}) &&
247 ($configline[17] eq $outfwsettings{'TIME_FROM'}) &&
248 ($configline[18] eq $outfwsettings{'TIME_TO'}))
249 {
250 print FILE $configentry;
251 }
252 }
253 close FILE;
254 $selected{'SNET'}{"$outfwsettings{'SNET'}"} = 'selected';
255 $selected{'PROT'}{"$outfwsettings{'PROT'}"} = 'selected';
256 $selected{'LOG'}{"$outfwsettings{'LOG'}"} = 'selected';
257 &addrule();
258 &Header::closebigbox();
259 &Header::closepage();
260 exit
261 system("/usr/local/bin/outgoingfwctrl");
262 }
263 if ($outfwsettings{'ACTION'} eq $Lang::tr{'delete'})
264 {
265 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
266 @configs = <FILE>;
267 close FILE;
268 open( FILE, "> $configfile" ) or die "Unable to write $configfile";
269 foreach $configentry (sort @configs)
270 {
271 @configline = split( /\;/, $configentry );
272
273 $configline[10] = "on" if not exists $configline[11];
274 $configline[11] = "on" if not exists $configline[11];
275 $configline[12] = "on" if not exists $configline[12];
276 $configline[13] = "on" if not exists $configline[13];
277 $configline[14] = "on" if not exists $configline[14];
278 $configline[15] = "on" if not exists $configline[15];
279 $configline[16] = "on" if not exists $configline[16];
280 $configline[17] = "00:00" if not exists $configline[17];
281 $configline[18] = "00:00" if not exists $configline[18];
282
283 unless (($configline[0] eq $outfwsettings{'STATE'}) &&
284 ($configline[1] eq $outfwsettings{'ENABLED'}) &&
285 ($configline[2] eq $outfwsettings{'SNET'}) &&
286 ($configline[3] eq $outfwsettings{'PROT'}) &&
287 ($configline[4] eq $outfwsettings{'NAME'}) &&
288 ($configline[5] eq $outfwsettings{'SIP'}) &&
289 ($configline[6] eq $outfwsettings{'SMAC'}) &&
290 ($configline[7] eq $outfwsettings{'DIP'}) &&
291 ($configline[9] eq $outfwsettings{'LOG'}) &&
292 ($configline[8] eq $outfwsettings{'DPORT'}) &&
293 ($configline[10] eq $outfwsettings{'TIME_MON'}) &&
294 ($configline[11] eq $outfwsettings{'TIME_TUE'}) &&
295 ($configline[12] eq $outfwsettings{'TIME_WED'}) &&
296 ($configline[13] eq $outfwsettings{'TIME_THU'}) &&
297 ($configline[14] eq $outfwsettings{'TIME_FRI'}) &&
298 ($configline[15] eq $outfwsettings{'TIME_SAT'}) &&
299 ($configline[16] eq $outfwsettings{'TIME_SUN'}) &&
300 ($configline[17] eq $outfwsettings{'TIME_FROM'}) &&
301 ($configline[18] eq $outfwsettings{'TIME_TO'}))
302 {
303 print FILE $configentry;
304 }
305 }
306 close FILE;
307 system("/usr/local/bin/outgoingfwctrl");
308 }
309 if ($outfwsettings{'ACTION'} eq $Lang::tr{'add'})
310 {
311 if ( $outfwsettings{'VALID'} eq 'yes' ) {
312 open( FILE, ">> $configfile" ) or die "Unable to write $configfile";
313 print FILE <<END
314 $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'};
315 END
316 ;
317 close FILE;
318 system("/usr/local/bin/outgoingfwctrl");
319 } else {
320 $outfwsettings{'ACTION'} = 'Add rule';
321 }
322 }
323 if ($outfwsettings{'ACTION'} eq 'Add rule')
324 {
325 &addrule();
326 exit
327 }
328
329 &General::readhash("${General::swroot}/outgoing/settings", \%outfwsettings);
330
331 if ($errormessage) {
332 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
333 print "<class name='base'>$errormessage\n";
334 print "&nbsp;</class>\n";
335 &Header::closebox();
336 }
337
338 ############################################################################################################################
339 ############################################################################################################################
340
341 if ($outfwsettings{'POLICY'} ne 'MODE0'){
342 &Header::openbox('100%', 'center', 'Rules');
343 print <<END
344 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
345 <input type='submit' name='ACTION' value='Add rule' />
346 </form>
347 END
348 ;
349 open( FILE, "< $configfile" ) or die "Unable to read $configfile";
350 @configs = <FILE>;
351 close FILE;
352 if (@configs) {
353 print <<END
354 <hr />
355 <table border='0' width='100%' cellspacing='0'>
356 <tr bgcolor='$color{'color22'}'>
357 <td width='14%' align='center'><b>$Lang::tr{'protocol'}</b></td>
358 <td width='14%' align='center'><b>$Lang::tr{'network'}</b></td>
359 <td width='14%' align='center'><b>$Lang::tr{'destination'}</b></td>
360 <td width='14%' align='center'><b>$Lang::tr{'description'}</b></td>
361 <td width='14%' align='center'><b>$Lang::tr{'policy'}</b></td>
362 <td width='16%' align='center'><b>$Lang::tr{'logging'}</b></td>
363 <td width='14%' align='center'><b>$Lang::tr{'action'}</b></td>
364 END
365 ;
366 foreach $configentry (sort @configs)
367 {
368 @configline = split( /\;/, $configentry );
369 $outfwsettings{'STATE'} = $configline[0];
370 $outfwsettings{'ENABLED'} = $configline[1];
371 $outfwsettings{'SNET'} = $configline[2];
372 $outfwsettings{'PROT'} = $configline[3];
373 $outfwsettings{'NAME'} = $configline[4];
374 $outfwsettings{'SIP'} = $configline[5];
375 $outfwsettings{'SMAC'} = $configline[6];
376 $outfwsettings{'DIP'} = $configline[7];
377 $outfwsettings{'DPORT'} = $configline[8];
378 $outfwsettings{'LOG'} = $configline[9];
379
380 $configline[10] = "on" if not exists $configline[11];
381 $configline[11] = "on" if not exists $configline[11];
382 $configline[12] = "on" if not exists $configline[12];
383 $configline[13] = "on" if not exists $configline[13];
384 $configline[14] = "on" if not exists $configline[14];
385 $configline[15] = "on" if not exists $configline[15];
386 $configline[16] = "on" if not exists $configline[16];
387 $configline[17] = "00:00" if not exists $configline[17];
388 $configline[18] = "00:00" if not exists $configline[18];
389
390 $outfwsettings{'TIME_MON'} = $configline[10];
391 $outfwsettings{'TIME_TUE'} = $configline[11];
392 $outfwsettings{'TIME_WED'} = $configline[12];
393 $outfwsettings{'TIME_THU'} = $configline[13];
394 $outfwsettings{'TIME_FRI'} = $configline[14];
395 $outfwsettings{'TIME_SAT'} = $configline[15];
396 $outfwsettings{'TIME_SUN'} = $configline[16];
397 $outfwsettings{'TIME_FROM'} = $configline[17];
398 $outfwsettings{'TIME_TO'} = $configline[18];
399
400 if ($outfwsettings{'DIP'} eq ''){ $outfwsettings{'DISPLAY_DIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DIP'} = $outfwsettings{'DIP'}; }
401 if ($outfwsettings{'DPORT'} eq ''){ $outfwsettings{'DISPLAY_DPORT'} = 'ALL'; } else { $outfwsettings{'DISPLAY_DPORT'} = $outfwsettings{'DPORT'}; }
402 if ($outfwsettings{'STATE'} eq 'DENY'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_stop.png' alt='DENY' />"; }
403 if ($outfwsettings{'STATE'} eq 'ALLOW'){ $outfwsettings{'DISPLAY_STATE'} = "<img src='/images/stock_ok.png' alt='ALLOW' />"; }
404 if ((($outfwsettings{'POLICY'} eq 'MODE1') && ($outfwsettings{'STATE'} eq 'ALLOW')) || (($outfwsettings{'POLICY'} eq 'MODE2') && ($outfwsettings{'STATE'} eq 'DENY'))){
405 print <<END
406 <tr bgcolor='$color{'color20'}'>
407 <td align='center'>$outfwsettings{'PROT'}
408 <td align='center'>$outfwsettings{'SNET'}
409 <td align='center'>$outfwsettings{'DISPLAY_DIP'}:$outfwsettings{'DISPLAY_DPORT'}
410 <td align='center'>$outfwsettings{'NAME'}
411 <td align='center'>$outfwsettings{'DISPLAY_STATE'}
412 <td align='center'>$outfwsettings{'LOG'}
413 <td align='center'>
414 <table border='0' cellpadding='0' cellspacing='0'><tr>
415 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
416 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
417 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
418 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
419 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
420 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
421 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
422 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
423 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
424 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
425 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
426 <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' />
427 <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' />
428 <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' />
429 <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' />
430 <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' />
431 <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' />
432 <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' />
433 <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' />
434 <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' />
435 <input type='hidden' name='ACTION' value=$Lang::tr{'edit'} />
436 <input type='image' src='/images/edit.gif' width="20" height="20" alt=$Lang::tr{'edit'} />
437 </form>
438 <td><form method='post' action='$ENV{'SCRIPT_NAME'}'>
439 <input type='hidden' name='PROT' value='$outfwsettings{'PROT'}' />
440 <input type='hidden' name='STATE' value='$outfwsettings{'STATE'}' />
441 <input type='hidden' name='SNET' value='$outfwsettings{'SNET'}' />
442 <input type='hidden' name='DPORT' value='$outfwsettings{'DPORT'}' />
443 <input type='hidden' name='DIP' value='$outfwsettings{'DIP'}' />
444 <input type='hidden' name='SIP' value='$outfwsettings{'SIP'}' />
445 <input type='hidden' name='NAME' value='$outfwsettings{'NAME'}' />
446 <input type='hidden' name='SMAC' value='$outfwsettings{'SMAC'}' />
447 <input type='hidden' name='ENABLED' value='$outfwsettings{'ENABLED'}' />
448 <input type='hidden' name='LOG' value='$outfwsettings{'LOG'}' />
449 <input type='hidden' name='TIME_MON' value='$outfwsettings{'TIME_MON'}' />
450 <input type='hidden' name='TIME_TUE' value='$outfwsettings{'TIME_TUE'}' />
451 <input type='hidden' name='TIME_WED' value='$outfwsettings{'TIME_WED'}' />
452 <input type='hidden' name='TIME_THU' value='$outfwsettings{'TIME_THU'}' />
453 <input type='hidden' name='TIME_FRI' value='$outfwsettings{'TIME_FRI'}' />
454 <input type='hidden' name='TIME_SAT' value='$outfwsettings{'TIME_SAT'}' />
455 <input type='hidden' name='TIME_SUN' value='$outfwsettings{'TIME_SUN'}' />
456 <input type='hidden' name='TIME_FROM' value='$outfwsettings{'TIME_FROM'}' />
457 <input type='hidden' name='TIME_TO' value='$outfwsettings{'TIME_TO'}' />
458 <input type='hidden' name='ACTION' value=$Lang::tr{'delete'} />
459 <input type='image' src='/images/delete.gif' width="20" height="20" alt=$Lang::tr{'delete'} />
460 </form></table>
461 END
462 ;
463 if (($outfwsettings{'SIP'}) || ($outfwsettings{'SMAC'})) {
464 unless ($outfwsettings{'SIP'}) { $outfwsettings{'DISPLAY_SIP'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SIP'} = $outfwsettings{'SIP'}; }
465 unless ($outfwsettings{'SMAC'}) { $outfwsettings{'DISPLAY_SMAC'} = 'ALL'; } else { $outfwsettings{'DISPLAY_SMAC'} = $outfwsettings{'SMAC'}; }
466 print <<END
467 <tr><td width='14%' align='right'>$Lang::tr{'source ip'}:
468 <td width='14%' align='left'>$outfwsettings{'DISPLAY_SIP'}
469 <td width='44%' colspan='2' align='center'>
470 END
471 ;
472 }
473 print <<END
474 <tr><td width='14%' align='right'>$Lang::tr{'time'} - </td>
475 <td width='14%' align='left'>
476 END
477 ;
478 if ($outfwsettings{'TIME_MON'} eq 'on') { print "<font color='$Header::colourgreen'>";}
479 else { print "<font color='$Header::colourred'>";}
480 print "$Lang::tr{'advproxy monday'}</font>,";
481 if ($outfwsettings{'TIME_TUE'} eq 'on') { print "<font color='$Header::colourgreen'>";}
482 else { print "<font color='$Header::colourred'>";}
483 print "$Lang::tr{'advproxy tuesday'}</font>,";
484 if ($outfwsettings{'TIME_WED'} eq 'on') { print "<font color='$Header::colourgreen'>";}
485 else { print "<font color='$Header::colourred'>";}
486 print "$Lang::tr{'advproxy wednesday'}</font>,";
487 if ($outfwsettings{'TIME_THU'} eq 'on') { print "<font color='$Header::colourgreen'>";}
488 else { print "<font color='$Header::colourred'>";}
489 print "$Lang::tr{'advproxy thursday'}</font>,";
490 if ($outfwsettings{'TIME_FRI'} eq 'on') { print "<font color='$Header::colourgreen'>";}
491 else { print "<font color='$Header::colourred'>";}
492 print "$Lang::tr{'advproxy friday'}</font>,";
493 if ($outfwsettings{'TIME_SAT'} eq 'on') { print "<font color='$Header::colourgreen'>";}
494 else { print "<font color='$Header::colourred'>";}
495 print "$Lang::tr{'advproxy saturday'}</font>,";
496 if ($outfwsettings{'TIME_SUN'} eq 'on') { print "<font color='$Header::colourgreen'>";}
497 else { print "<font color='$Header::colourred'>";}
498 print "$Lang::tr{'advproxy sunday'}</font>";
499 print <<END
500 </td>
501 <td width='22%' align='center'>$Lang::tr{'advproxy from'} $outfwsettings{'TIME_FROM'}</td>
502 <td width='22%' align='center'>$Lang::tr{'advproxy to'} $outfwsettings{'TIME_TO'}</td>
503 </form>
504 END
505 ;
506 }
507 }
508 if ($outfwsettings{'POLICY'} eq 'MODE1'){
509 print <<END
510 <tr bgcolor='$color{'color20'}'><form method='post' action='$ENV{'SCRIPT_NAME'}'>
511 <td align='center'>all
512 <td align='center'>all
513 <td align='center'>ALL
514 <td align='center'>drop
515 <td align='center'><img src='/images/stock_stop.png' alt='DENY' />
516 <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
517 <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>
518 <table border='0' cellpadding='0' cellspacing='0'><tr>
519 <td>
520 <td></table>
521 END
522 ;
523 }
524 print <<END
525 </table>
526 END
527 ;
528
529 }
530 &Header::closebox();
531 }
532
533 if ($outfwsettings{'POLICY'} ne 'MODE0'){
534 open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
535 @p2ps = <FILE>;
536 close FILE;
537 &Header::openbox('100%', 'center', 'P2P-Block');
538 print <<END
539 <table width='40%'>
540 <tr bgcolor='$color{'color22'}'><td width='66%' align=center><b>$Lang::tr{'protocol'}</b>
541 <td width='33%' align=center><b>$Lang::tr{'status'}</b>
542 END
543 ;
544 my $id = 1;
545 foreach $p2pentry (sort @p2ps)
546 {
547 @p2pline = split( /\;/, $p2pentry );
548 print <<END
549 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
550 END
551 ;
552 print "\t\t\t<tr bgcolor='$color{'color20'}'>\n";
553 print <<END
554 <td width='66%' align='center'>$p2pline[0]:
555 <td width='33%' align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' />
556 END
557 ;
558 if ($p2pline[2] eq 'on') {
559 print <<END
560 <input type='hidden' name='ACTION' value='disable' />
561 <input type='image' name='submit' src='/images/stock_ok.png' alt='' />
562 END
563 ;
564 } else {
565 print <<END
566 <input type='hidden' name='ACTION' value='enable' />
567 <input type='image' name='submit' src='/images/stock_stop.png' alt='' />
568 END
569 ;
570 }
571 print <<END
572 </form>
573 END
574 ;
575 }
576 print <<END
577 </table>
578 <br />$Lang::tr{'outgoingfw p2p description'}
579 END
580 ;
581 &Header::closebox();
582 }
583
584 &Header::openbox('100%', 'center', 'Policy');
585 print <<END
586 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
587 <table width='100%'>
588 <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>
589 <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>
590 <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>
591 <tr><td colspan='3'><hr /></td></tr>
592 <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>
593 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
594 <td width='45%' align='left'>
595 END
596 ;
597 if ($outfwsettings{'POLICY'} ne 'MODE0') {
598 print <<END
599 $Lang::tr{'outgoingfw reset'}: <input type='submit' name='ACTION' value=$Lang::tr{'reset'} />
600 END
601 ;
602 }
603 print <<END
604 </table>
605 </form>
606 END
607 ;
608 &Header::closebox();
609
610 &Header::closebigbox();
611 &Header::closepage();
612
613 ############################################################################################################################
614 ############################################################################################################################
615
616 sub addrule
617 {
618 &Header::openbox('100%', 'center', 'Rules hinzufuegen');
619 if ($outfwsettings{'EDIT'} eq 'no') { $selected{'ENABLED'} = 'checked'; }
620 $selected{'TIME_FROM'}{$outfwsettings{'TIME_FROM'}} = "selected='selected'";
621 $selected{'TIME_TO'}{$outfwsettings{'TIME_TO'}} = "selected='selected'";
622 print <<END
623 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
624 <table width='80%'>
625 <tr><td width='20%' align='right'>$Lang::tr{'description'}: <img src='/blob.gif' />
626 <td width='30%' align='left'><input type='text' name='NAME' maxlength='30' value='$outfwsettings{'NAME'}' />
627 <td width='20%' align='right' colspan='2'>$Lang::tr{'active'}:
628 <td width='30%' align='left' colspan='2'><input type='checkbox' name='ENABLED' $selected{'ENABLED'} />
629 <tr><td width='20%' align='right'>$Lang::tr{'protocol'}:
630 <td width='30%' align='left'>
631 <select name='PROT'>
632 <option value='all' $selected{'PROT'}{'all'}>All</option>
633 <option value='tcp' $selected{'PROT'}{'tcp'}>TCP</option>
634 <option value='udp' $selected{'PROT'}{'udp'}>UDP</option>
635 <option value='gre' $selected{'PROT'}{'gre'}>GRE</option>
636 <option value='esp' $selected{'PROT'}{'esp'}>ESP</option>
637 </select>
638 <td width='20%' align='right' colspan='2'>$Lang::tr{'policy'}:
639 <td width='30%' align='left' colspan='2'>
640 END
641 ;
642 if ($outfwsettings{'POLICY'} eq 'MODE1'){
643 print "\t\t\tALLOW<input type='hidden' name='STATE' value='ALLOW' />\n";
644 } elsif ($outfwsettings{'POLICY'} eq 'MODE2'){
645 print "\t\t\tDENY<input type='hidden' name='STATE' value='DENY' />\n";
646 }
647 print <<END
648 <tr><td width='20%' align='right'>$Lang::tr{'source net'}:
649 <td width='30%' align='left'><select name='SNET'>
650 <option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option>
651 <option value='ip' $selected{'SNET'}{'ip'}>$Lang::tr{'source ip'}</option>
652 <option value='red' $selected{'SNET'}{'red'}>$Lang::tr{'red'} IP</option>
653 <option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
654 END
655 ;
656 if (&Header::blue_used()){
657 print "\t\t\t<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>\n";
658 }
659 if (&Header::orange_used()){
660 print "\t\t\t<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>\n";
661 }
662 print <<END
663 </select>
664 <td width='20%' align='right' colspan='2'>$Lang::tr{'source ip'}: <img src='/blob.gif' />
665 <td width='30%' align='left' colspan='2'><input type='text' name='SIP' maxlength='15' value='$outfwsettings{'SIP'}' />
666 <tr><td width='20%' align='right'>$Lang::tr{'logging'}:
667 <td width='30%' align='left'><select name='LOG'>
668 <option value='$Lang::tr{'active'}' $selected{'LOG'}{$Lang::tr{'active'}}>$Lang::tr{'active'}</option>
669 <option value='$Lang::tr{'inactive'}' $selected{'LOG'}{$Lang::tr{'inactive'}}>$Lang::tr{'inactive'}</option>
670 </select></td>
671 <td width='20%' align='right' colspan='2' />
672 <td width='30%' align='left' colspan='2' />
673 <tr><td width='20%' align='right'>$Lang::tr{'destination ip'}: <img src='/blob.gif' />
674 <td width='30%' align='left'><input type='text' name='DIP' maxlength='15' value='$outfwsettings{'DIP'}' />
675 <td width='20%' align='right' colspan='2'>$Lang::tr{'destination port'}: <img src='/blob.gif' />
676 <td width='30%' align='left' colspan='2'><input type='text' name='DPORT' maxlength='11' value='$outfwsettings{'DPORT'}' />
677 <tr><td width='20%' align='right'>$Lang::tr{'time'}:</td>
678 <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>
679 <td width='20%' align='right' colspan='2' />
680 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
681 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td></tr>
682 <tr><td width='20%' align='right'></td>
683 <td width='30%' align='left'><input type='checkbox' name='TIME_MON' $checked{'TIME_MON'}{'on'} />
684 <input type='checkbox' name='TIME_TUE' $checked{'TIME_TUE'}{'on'} />
685 <input type='checkbox' name='TIME_WED' $checked{'TIME_WED'}{'on'} />
686 <input type='checkbox' name='TIME_THU' $checked{'TIME_THU'}{'on'} />
687 <input type='checkbox' name='TIME_FRI' $checked{'TIME_FRI'}{'on'} />
688 <input type='checkbox' name='TIME_SAT' $checked{'TIME_SAT'}{'on'} />
689 <input type='checkbox' name='TIME_SUN' $checked{'TIME_SUN'}{'on'} /></td>
690 <td width='20%' align='right' colspan='2' />
691 <td width='15%' align='left'><select name='TIME_FROM'>
692 END
693 ;
694 for (my $i=0;$i<=23;$i++) {
695 $i = sprintf("%02s",$i);
696 for (my $j=0;$j<=45;$j+=15) {
697 $j = sprintf("%02s",$j);
698 my $time = $i.":".$j;
699 print "<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
700 }
701 }
702 print <<END
703 </select></td>
704 <td width='15%' align='left'><select name='TIME_TO'>
705 END
706 ;
707 for (my $i=0;$i<=23;$i++) {
708 $i = sprintf("%02s",$i);
709 for (my $j=0;$j<=45;$j+=15) {
710 $j = sprintf("%02s",$j);
711 my $time = $i.":".$j;
712 print "<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
713 }
714 }
715 print <<END
716 </select></td></tr>
717 <tr><td colspan='6'>
718 <tr><td width='40%' align='right' colspan='2'><img src='/blob.gif' />$Lang::tr{'this field may be blank'}
719 <td width='60%' align='left' colspan='4'><input type='submit' name='ACTION' value=$Lang::tr{'add'} />
720 </table></form>
721 END
722 ;
723 &Header::closebox();
724
725 if ($outfwsettings{'POLICY'} eq 'MODE1' || $outfwsettings{'POLICY'} eq 'MODE2')
726 {
727 &Header::openbox('100%', 'center', 'Quick Add');
728
729 open( FILE, "< /var/ipfire/outgoing/defaultservices" ) or die "Unable to read default services";
730 my @defservices = <FILE>;
731 close FILE;
732
733 print "<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>";
734 foreach my $serviceline(@defservices)
735 {
736 my @service = split(/,/,$serviceline);
737 print <<END
738 <tr><form method='post' action='$ENV{'SCRIPT_NAME'}'>
739 <td>$service[0]<input type='hidden' name='NAME' value='@service[0]' /></td>
740 <td>$service[3]</td>
741 <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>
742 <td>$service[2]<input type='hidden' name='PROT' value='@service[2]' /></td>
743 <td><select name='SNET'><option value='all' $selected{'SNET'}{'ALL'}>$Lang::tr{'all'}</option><option value='green' $selected{'SNET'}{'green'}>$Lang::tr{'green'}</option>
744 END
745 ;
746 if (&Header::blue_used()){
747 print "<option value='blue' $selected{'SNET'}{'blue'}>$Lang::tr{'wireless'}</option>";
748 }
749 if (&Header::orange_used()){
750 print "<option value='orange' $selected{'SNET'}{'orange'}>$Lang::tr{'dmz'}</option>";
751 }
752 print <<END
753 </select></td>
754 <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>
755 <input type='hidden' name='ACTION' value=$Lang::tr{'add'} />
756 <input type='image' alt='$Lang::tr{'add'}' src='/images/add.gif' />
757 <input type='hidden' name='ENABLED' value='on' />
758 END
759 ;
760 if ($outfwsettings{'POLICY'} eq 'MODE1'){ print "<input type='hidden' name='STATE' value='ALLOW' /></form></td></tr>";}
761 elsif ($outfwsettings{'POLICY'} eq 'MODE2'){print "<input type='hidden' name='STATE' value='DENY' /></form></td></tr>";}
762 }
763 print "</table>";
764 &Header::closebox();
765 }
766 }