]>
Commit | Line | Data |
---|---|---|
7bf83f9d AM |
1 | #!/usr/bin/perl |
2 | ############################################################################### | |
3 | # # | |
4 | # IPFire.org - A linux based firewall # | |
4f585d55 | 5 | # Copyright (C) 2013 # |
7bf83f9d AM |
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 | ############################################################################### | |
4f585d55 AM |
21 | # Author: Alexander Marx (Amarx@ipfire.org) # |
22 | ############################################################################### | |
7bf83f9d AM |
23 | |
24 | use strict; | |
25 | no warnings 'uninitialized'; | |
26 | # enable only the following on debugging purpose | |
27 | #use warnings; | |
28 | #use CGI::Carp 'fatalsToBrowser'; | |
29 | ||
30 | require '/var/ipfire/general-functions.pl'; | |
31 | require "${General::swroot}/lang.pl"; | |
32 | require "${General::swroot}/header.pl"; | |
33 | ||
34 | my $errormessage=''; | |
35 | my $p2pfile = "${General::swroot}/forward/p2protocols"; | |
36 | ||
37 | my @p2ps = (); | |
38 | my %fwdfwsettings=(); | |
39 | my %color=(); | |
40 | my %mainsettings=(); | |
41 | ||
42 | &General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings); | |
43 | &General::readhash("${General::swroot}/main/settings", \%mainsettings); | |
44 | &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); | |
45 | ||
7bf83f9d AM |
46 | &Header::showhttpheaders(); |
47 | &Header::getcgihash(\%fwdfwsettings); | |
48 | &Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); | |
0e430797 | 49 | &Header::openbigbox('100%', 'center', $errormessage); |
7bf83f9d | 50 | |
0e430797 | 51 | if ($fwdfwsettings{'ACTION'} eq 'togglep2p') { |
7bf83f9d AM |
52 | open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; |
53 | @p2ps = <FILE>; | |
54 | close FILE; | |
55 | open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile"; | |
56 | foreach my $p2pentry (sort @p2ps) | |
57 | { | |
58 | my @p2pline = split( /\;/, $p2pentry ); | |
59 | if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) { | |
60 | if($p2pline[2] eq 'on'){ | |
61 | $p2pline[2]='off'; | |
62 | }else{ | |
63 | $p2pline[2]='on'; | |
64 | } | |
65 | } | |
66 | print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; | |
67 | } | |
68 | close FILE; | |
7bf83f9d | 69 | |
0e430797 MT |
70 | &General::firewall_config_changed(); |
71 | &p2pblock(); | |
72 | } else { | |
73 | &p2pblock(); | |
74 | } | |
7bf83f9d AM |
75 | |
76 | sub p2pblock | |
77 | { | |
7bf83f9d AM |
78 | my $gif; |
79 | open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; | |
80 | @p2ps = <FILE>; | |
81 | close FILE; | |
82 | &Header::openbox('100%', 'center', 'P2P-Block'); | |
83 | print <<END; | |
84 | <table width='35%' border='0'> | |
85 | <tr bgcolor='$color{'color22'}'><td align=center colspan='2' ><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'status'}</b></td></tr> | |
86 | END | |
87 | foreach my $p2pentry (sort @p2ps) | |
88 | { | |
89 | my @p2pline = split( /\;/, $p2pentry ); | |
90 | if($p2pline[2] eq 'on'){ | |
91 | $gif="/images/on.gif" | |
92 | }else{ | |
93 | $gif="/images/off.gif" | |
94 | } | |
95 | print <<END; | |
96 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
97 | <tr bgcolor='$color{'color20'}'> | |
98 | <td align='center' colspan='2' >$p2pline[0]:</td><td align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /><input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' ><input type='hidden' name='ACTION' value='togglep2p'></td></tr></form> | |
99 | END | |
100 | } | |
101 | print"<tr><td><img src='/images/on.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p allow'}</td></tr>"; | |
102 | print"<tr><td><img src='/images/off.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p deny'}</td></tr></table>"; | |
515863e2 | 103 | print"<br><br><br><table width='100%'><tr><td align='left'>$Lang::tr{'fwdfw p2p txt'}</td></tr></table>"; |
7bf83f9d AM |
104 | &Header::closebox(); |
105 | } | |
0e430797 | 106 | |
7bf83f9d AM |
107 | &Header::closebigbox(); |
108 | &Header::closepage(); |