]>
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 | ||
4a75efa5 | 34 | my $errormessage = ''; |
e9a05623 | 35 | my $notice; |
6d8eb5de | 36 | my $p2pfile = "${General::swroot}/firewall/p2protocols"; |
7bf83f9d AM |
37 | |
38 | my @p2ps = (); | |
4a75efa5 MT |
39 | my %fwdfwsettings = (); |
40 | my %color = (); | |
41 | my %mainsettings = (); | |
7bf83f9d | 42 | |
7bf83f9d AM |
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); | |
7bf83f9d | 48 | |
0e430797 | 49 | if ($fwdfwsettings{'ACTION'} eq 'togglep2p') { |
4a75efa5 | 50 | open( FILE, "<$p2pfile") or die "Unable to read $p2pfile"; |
7bf83f9d AM |
51 | @p2ps = <FILE>; |
52 | close FILE; | |
4a75efa5 MT |
53 | open( FILE, ">$p2pfile") or die "Unable to write $p2pfile"; |
54 | foreach my $p2pentry (sort @p2ps) { | |
55 | my @p2pline = split( /\;/, $p2pentry); | |
7bf83f9d | 56 | if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) { |
4a75efa5 MT |
57 | if ($p2pline[2] eq 'on') { |
58 | $p2pline[2] = 'off'; | |
59 | } else { | |
60 | $p2pline[2] = 'on'; | |
7bf83f9d AM |
61 | } |
62 | } | |
63 | print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; | |
64 | } | |
65 | close FILE; | |
7bf83f9d | 66 | |
0e430797 | 67 | &General::firewall_config_changed(); |
e9a05623 MT |
68 | |
69 | $notice = $Lang::tr{'p2p block save notice'}; | |
0e430797 | 70 | } |
7bf83f9d | 71 | |
e9a05623 MT |
72 | &Header::openpage($Lang::tr{'p2p block'}, 1, ''); |
73 | &Header::openbigbox('100%', 'center', $errormessage); | |
4a75efa5 | 74 | |
e9a05623 MT |
75 | if ($notice) { |
76 | &Header::openbox('100%', 'left', $Lang::tr{'notice'}); | |
77 | print "<font class='base'>$notice</font>"; | |
78 | &Header::closebox(); | |
79 | } | |
4a75efa5 | 80 | |
e9a05623 MT |
81 | my $gif; |
82 | ||
83 | open(FILE, "<$p2pfile") or die "Unable to read $p2pfile"; | |
84 | @p2ps = <FILE>; | |
85 | close FILE; | |
86 | ||
87 | &Header::openbox('100%', 'center', $Lang::tr{'p2p block'}); | |
88 | print <<END; | |
89 | <table width='35%' border='0'> | |
90 | <tr bgcolor='$color{'color22'}'> | |
91 | <td align=center colspan='2' > | |
92 | <b>$Lang::tr{'protocol'}</b> | |
93 | </td> | |
94 | <td align='center'> | |
95 | <b>$Lang::tr{'status'}</b> | |
96 | </td> | |
97 | </tr> | |
7bf83f9d | 98 | END |
4a75efa5 | 99 | |
e9a05623 MT |
100 | foreach my $p2pentry (sort @p2ps) { |
101 | my @p2pline = split( /\;/, $p2pentry); | |
102 | if ($p2pline[2] eq 'on') { | |
103 | $gif = "/images/on.gif" | |
104 | } else { | |
105 | $gif = "/images/off.gif" | |
7bf83f9d | 106 | } |
4a75efa5 MT |
107 | |
108 | print <<END; | |
e9a05623 MT |
109 | <tr bgcolor='$color{'color20'}'> |
110 | <td align='center' colspan='2'> | |
111 | $p2pline[0]: | |
112 | </td> | |
113 | <td align='center'> | |
114 | <form method='post' action='$ENV{'SCRIPT_NAME'}'> | |
115 | <input type='hidden' name='P2PROT' value='$p2pline[1]'> | |
116 | <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;'> | |
117 | <input type='hidden' name='ACTION' value='togglep2p'> | |
118 | </form> | |
119 | </td> | |
120 | </tr> | |
4a75efa5 | 121 | END |
7bf83f9d | 122 | } |
0e430797 | 123 | |
e9a05623 MT |
124 | print <<END; |
125 | <tr> | |
126 | <td> | |
127 | <img src='/images/on.gif'> | |
128 | </td> | |
129 | <td> | |
130 | $Lang::tr{'outgoing firewall p2p allow'} | |
131 | </td> | |
132 | </tr> | |
133 | <tr> | |
134 | <td> | |
135 | <img src='/images/off.gif'> | |
136 | </td> | |
137 | <td> | |
138 | $Lang::tr{'outgoing firewall p2p deny'} | |
139 | </td> | |
140 | </tr> | |
141 | </table> | |
142 | END | |
143 | ||
144 | &Header::closebox(); | |
145 | ||
7bf83f9d AM |
146 | &Header::closebigbox(); |
147 | &Header::closepage(); |