]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
3810b8b324a35b905b0f86e4b6fc58ab559be4b6
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
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. #
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. #
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/>. #
20 ###############################################################################
24 no warnings
'uninitialized';
25 # enable only the following on debugging purpose
27 #use CGI::Carp 'fatalsToBrowser';
29 require '/var/ipfire/general-functions.pl';
30 require "${General::swroot}/lang.pl";
31 require "${General::swroot}/header.pl";
32 require "${General::swroot}/forward/bin/firewall-lib.pl";
34 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
35 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
36 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
37 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
38 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
42 my %defaultNetworks=();
46 my %customnetworks=();
48 my %customservicegrp=();
54 my %configoutgoingfw=();
66 my @PROTOCOLS = ("TCP", "UDP", "ICMP", "IGMP", "AH", "ESP", "GRE");
69 my $confignet = "${General::swroot}/fwhosts/customnetworks";
70 my $confighost = "${General::swroot}/fwhosts/customhosts";
71 my $configgrp = "${General::swroot}/fwhosts/customgroups";
72 my $configsrv = "${General::swroot}/fwhosts/customservices";
73 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
74 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
75 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
76 my $configipsec = "${General::swroot}/vpn/config";
77 my $configipsecrw = "${General::swroot}/vpn/settings";
78 my $configfwdfw = "${General::swroot}/forward/config";
79 my $configinput = "${General::swroot}/forward/input";
80 my $configoutgoing = "${General::swroot}/forward/outgoing";
81 my $configovpn = "${General::swroot}/ovpn/settings";
82 my $fwoptions = "${General::swroot}/optionsfw/settings";
83 my $ifacesettings = "${General::swroot}/ethernet/settings";
86 my $ipgrp="${General::swroot}/outgoing/groups";
90 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
91 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
92 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
93 &General
::readhash
($fwoptions, \
%optionsfw);
94 &General
::readhash
($ifacesettings, \
%ifaces);
95 &General
::readhash
("$configovpn", \
%ovpnsettings);
96 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
97 &General
::readhasharray
("$configipsec", \
%ipsecconf);
98 &Header
::showhttpheaders
();
99 &Header
::getcgihash
(\
%fwdfwsettings);
100 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
101 &Header
::openbigbox
('100%', 'center',$errormessage);
102 #### JAVA SCRIPT ####
105 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
107 var update_protocol = function() {
108 var protocol = \$("#protocol").val();
110 if (protocol === undefined)
113 // Check if a template is/should be used.
114 if (protocol === "template") {
115 \$("#PROTOCOL_TEMPLATE").show();
117 \$("#PROTOCOL_TEMPLATE").hide();
120 // Check if we are dealing with a protocol, that knows ports.
121 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
122 \$("#PROTOCOL_PORTS").show();
124 \$("#PROTOCOL_PORTS").hide();
128 if (protocol === "ICMP") {
129 \$("#PROTOCOL_ICMP_TYPES").show();
131 \$("#PROTOCOL_ICMP_TYPES").hide();
135 \$(document).ready(function() {
136 \$("#protocol").change(update_protocol);
139 // When nat not used, hide it
140 if (\$("#nat").attr("checked")) {
141 \$("#natpart").show();
144 // Show NAT area when "use nat" checkbox is clicked
145 \$("#nat").change(function() {
146 \$("#natpart").toggle();
149 // Automatically select radio buttons when corresponding
150 // dropdown menu changes.
151 \$("select").change(function() {
152 var id = \$(this).attr("name");
154 // When using SNAT or DNAT, check "USE NAT" Checkbox
155 if (id === 'snat' || id === 'dnat') {
156 \$('#USE_NAT').prop('checked', true);
158 \$('#' + id).prop("checked", true);
166 if ($fwdfwsettings{'ACTION'} eq 'saverule')
168 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
169 &General
::readhasharray
("$configinput", \
%configinputfw);
170 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
171 $errormessage=&checksource
;
172 if(!$errormessage){&checktarget
;}
173 if(!$errormessage){&checkrule
;}
174 #check if manual ip (source) is orange network
175 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
176 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
177 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
182 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
183 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
185 #check if we try to break rules
186 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
187 $errormessage=$Lang::tr
{'fwdfw err same'};
190 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
191 $fwdfwsettings{'config'}=$configinput;
192 $fwdfwsettings{'chain'} = 'INPUTFW';
193 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
194 #check if we have an identical rule already
195 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
196 foreach my $key (sort keys %configinputfw){
197 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
198 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31]"){
199 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
200 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
202 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
203 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
205 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
206 $fwdfwsettings{'nosave'} = 'on';
211 #check Rulepos on new Rule
212 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
213 $fwdfwsettings{'oldrulenumber'}=$maxkey;
214 foreach my $key (sort keys %configinputfw){
215 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
216 eq "$configinputfw{$key}[0],$configinputfw{$key}[2],$configinputfw{$key}[3],$configinputfw{$key}[4],$configinputfw{$key}[5],$configinputfw{$key}[6],$configinputfw{$key}[7],$configinputfw{$key}[8],$configinputfw{$key}[9],$configinputfw{$key}[10],$configinputfw{$key}[11],$configinputfw{$key}[12],$configinputfw{$key}[13],$configinputfw{$key}[14],$configinputfw{$key}[15],$configinputfw{$key}[17],$configinputfw{$key}[18],$configinputfw{$key}[19],$configinputfw{$key}[20],$configinputfw{$key}[21],$configinputfw{$key}[22],$configinputfw{$key}[23],$configinputfw{$key}[24],$configinputfw{$key}[25],$configinputfw{$key}[26],$configinputfw{$key}[27],$configinputfw{$key}[28],$configinputfw{$key}[29],$configinputfw{$key}[30],$configinputfw{$key}[31]"){
217 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
221 #check if we just close a rule
222 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
223 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
225 $fwdfwsettings{'nosave2'} = 'on';
229 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
230 if ($fwdfwsettings{'nobase'} ne 'on'){
231 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
233 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
234 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
235 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
236 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
237 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
238 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
240 if($fwdfwsettings{'nosave2'} ne 'on'){
241 &saverule
(\
%configinputfw,$configinput);
244 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
246 $fwdfwsettings{'config'}=$configoutgoing;
247 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
248 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
249 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
250 foreach my $key (sort keys %configoutgoingfw){
251 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
252 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27],$configoutgoingfw{$key}[28],$configoutgoingfw{$key}[29],$configoutgoingfw{$key}[30],$configoutgoingfw{$key}[31]"){
253 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
254 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
256 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
257 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
259 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
260 $fwdfwsettings{'nosave'} = 'on';
265 #check Rulepos on new Rule
266 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
267 print"CHECK OUTGOING DOPPELTE REGEL<br>";
268 $fwdfwsettings{'oldrulenumber'}=$maxkey;
269 foreach my $key (sort keys %configoutgoingfw){
270 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
271 eq "$configoutgoingfw{$key}[0],$configoutgoingfw{$key}[2],$configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],$configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],$configoutgoingfw{$key}[7],$configoutgoingfw{$key}[8],$configoutgoingfw{$key}[9],$configoutgoingfw{$key}[10],$configoutgoingfw{$key}[11],$configoutgoingfw{$key}[12],$configoutgoingfw{$key}[13],$configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],$configoutgoingfw{$key}[17],$configoutgoingfw{$key}[18],$configoutgoingfw{$key}[19],$configoutgoingfw{$key}[20],$configoutgoingfw{$key}[21],$configoutgoingfw{$key}[22],$configoutgoingfw{$key}[23],$configoutgoingfw{$key}[24],$configoutgoingfw{$key}[25],$configoutgoingfw{$key}[26],$configoutgoingfw{$key}[27],$configoutgoingfw{$key}[28],$configoutgoingfw{$key}[29],$configoutgoingfw{$key}[30],$configoutgoingfw{$key}[31]"){
272 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
276 #check if we just close a rule
277 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
278 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
279 $fwdfwsettings{'nosave2'} = 'on';
285 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
286 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
287 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
288 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
289 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
290 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
291 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
292 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
294 if ($fwdfwsettings{'nobase'} eq 'on'){
295 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
297 if ($fwdfwsettings{'nosave2'} ne 'on'){
298 &saverule
(\
%configoutgoingfw,$configoutgoing);
303 $fwdfwsettings{'config'}=$configfwdfw;
304 $fwdfwsettings{'chain'} = 'FORWARDFW';
305 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
306 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
307 #check if we have an identical rule already
308 foreach my $key (sort keys %configfwdfw){
309 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
310 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27],$configfwdfw{$key}[28],$configfwdfw{$key}[29],$configfwdfw{$key}[30],$configfwdfw{$key}[31]"){
311 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
312 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
314 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
315 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
317 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
318 $fwdfwsettings{'nosave'} = 'on';
323 #check Rulepos on new Rule
324 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
325 $fwdfwsettings{'oldrulenumber'}=$maxkey;
326 foreach my $key (sort keys %configfwdfw){
327 if ( "$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'},$fwdfwsettings{'USE_NAT'},$fwdfwsettings{$fwdfwsettings{'nat'}},$fwdfwsettings{'dnatport'},$fwdfwsettings{'nat'}"
328 eq "$configfwdfw{$key}[0],$configfwdfw{$key}[2],$configfwdfw{$key}[3],$configfwdfw{$key}[4],$configfwdfw{$key}[5],$configfwdfw{$key}[6],$configfwdfw{$key}[7],$configfwdfw{$key}[8],$configfwdfw{$key}[9],$configfwdfw{$key}[10],$configfwdfw{$key}[11],$configfwdfw{$key}[12],$configfwdfw{$key}[13],$configfwdfw{$key}[14],$configfwdfw{$key}[15],$configfwdfw{$key}[18],$configfwdfw{$key}[19],$configfwdfw{$key}[20],$configfwdfw{$key}[21],$configfwdfw{$key}[22],$configfwdfw{$key}[23],$configfwdfw{$key}[24],$configfwdfw{$key}[25],$configfwdfw{$key}[26],$configfwdfw{$key}[27],$configfwdfw{$key}[28],$configfwdfw{$key}[29],$configfwdfw{$key}[30],$configfwdfw{$key}[31]"){
329 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
333 #check if we just close a rule
334 if( $fwdfwsettings{'oldgrp1a'} eq $fwdfwsettings{'grp1'} && $fwdfwsettings{'oldgrp1b'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'oldgrp2a'} eq $fwdfwsettings{'grp2'} && $fwdfwsettings{'oldgrp2b'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'oldgrp3a'} eq $fwdfwsettings{'grp3'} && $fwdfwsettings{'oldgrp3b'} eq $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'oldruletype'} eq $fwdfwsettings{'chain'}) {
335 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
336 $fwdfwsettings{'nosave2'} = 'on';
342 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
343 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
344 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
345 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
346 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
347 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
348 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
349 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
351 if ($fwdfwsettings{'nobase'} eq 'on'){
352 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
354 if ($fwdfwsettings{'nosave2'} ne 'on'){
355 &saverule
(\
%configfwdfw,$configfwdfw);
362 if($fwdfwsettings{'nosave2'} ne 'on'){
368 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
372 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
375 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
376 foreach my $key (sort keys %togglehash){
377 if ($key eq $fwdfwsettings{'key'}){
378 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
381 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
385 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
388 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
389 foreach my $key (sort keys %togglehash){
390 if ($key eq $fwdfwsettings{'key'}){
391 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
394 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
398 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
403 if ($fwdfwsettings{'ACTION'} eq 'editrule')
405 $fwdfwsettings{'updatefwrule'}='on';
408 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
412 if ($fwdfwsettings{'ACTION'} eq 'moveup')
417 if ($fwdfwsettings{'ACTION'} eq 'movedown')
422 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
424 $fwdfwsettings{'copyfwrule'}='on';
427 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
435 if (-f
"${General::swroot}/forward/reread"){
436 print "<table border='1' rules='groups' bgcolor='lightgreen' width='100%'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: green; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</div></td></tr></table></form><br>";
438 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw menu'});
439 print "<form method='post'>";
440 print "<table border='0'>";
441 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
442 print"</tr></table></form><hr>";
454 $fwdfwsettings{'updatefwrule'}='';
455 $fwdfwsettings{'config'}=$oldchain;
456 $fwdfwsettings{'nobase'}='on';
458 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
459 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
464 #check ip-address if manual
465 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
466 #check if ip with subnet
467 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
468 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
469 $subnet = &General
::iporsubtocidr
($subnet);
470 $fwdfwsettings{'isip'}='on';
473 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
474 $ip=$fwdfwsettings{'src_addr'};
476 $fwdfwsettings{'isip'}='on';
479 if ($fwdfwsettings{'isip'} ne 'on'){
480 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
481 $fwdfwsettings{'ismac'}='on';
484 if ($fwdfwsettings{'isip'} eq 'on'){
485 ##check if ip is valid
486 if (! &General
::validip
($ip)){
487 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
488 return $errormessage;
490 #check and form valid IP
491 $ip=&General
::ip2dec
($ip);
492 $ip=&General
::dec2ip
($ip);
493 #check if net or broadcast
494 $fwdfwsettings{'src_addr'}="$ip/$subnet";
495 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
496 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
497 return $errormessage;
500 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
501 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
502 return $errormessage;
504 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
505 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
506 return $errormessage;
510 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
511 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
512 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
516 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
518 #change dashes with :
521 push(@values,"1:65535");
524 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
525 push(@values,"1:$2");
528 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
529 push(@values,"$1:65535");
532 $errormessage .= &General
::validportrange
($_, 'destination');
537 if (&General
::validport
($_)){
544 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
546 return $errormessage;
551 &General
::readhasharray
("$configsrv", \
%customservice);
552 #check DNAT settings (has to be single Host and single Port or portrange)
553 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
554 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
555 if ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'dnatport'} eq ''){
556 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
557 return $errormessage;
559 #check if manual ip is a single Host (if set)
560 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
561 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
562 my @tmp1= split ("/",$tmp[3]);
563 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
565 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
566 return $errormessage;
569 #check if Port is a single Port or portrange
570 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
571 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
572 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
573 return $errormessage;
575 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
576 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
577 return $errormessage;
581 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
582 return $errormessage;
585 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
586 #check if ip with subnet
587 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
588 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
589 $subnet = &General
::iporsubtocidr
($subnet);
592 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
593 $ip=$fwdfwsettings{'tgt_addr'};
596 #check if ip is valid
597 if (! &General
::validip
($ip)){
598 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
599 return $errormessage;
601 #check and form valid IP
602 $ip=&General
::ip2dec
($ip);
603 $ip=&General
::dec2ip
($ip);
604 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
605 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
606 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
607 return $errormessage;
609 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
610 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
611 return $errormessage;
614 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
616 if ($fwdfwsettings{'USESRV'} eq 'ON'){
617 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
618 $fwdfwsettings{'TGT_PROT'}='';
619 $fwdfwsettings{'ICMP_TGT'}='';
620 $fwdfwsettings{'TGT_PORT'}='';
622 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
623 $fwdfwsettings{'TGT_PROT'}='';
624 $fwdfwsettings{'ICMP_TGT'}='';
625 $fwdfwsettings{'TGT_PORT'}='';
626 #check target service
627 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
628 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
631 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
632 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
633 if ($fwdfwsettings{'TGT_PORT'} ne ''){
634 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
635 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
636 return $errormessage;
638 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
642 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
644 #change dashes with :
647 push(@values,"1:65535");
650 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
651 push(@values,"1:$2");
654 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
655 push(@values,"$1:65535");
658 $errormessage .= &General
::validportrange
($_, 'destination');
663 if (&General
::validport
($_)){
669 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
671 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
672 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
673 $fwdfwsettings{'TGT_PORT'} = '';
674 $fwdfwsettings{'ICMP_TGT'} = '';
675 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
676 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
677 $fwdfwsettings{'TGT_PORT'} = '';
678 $fwdfwsettings{'ICMP_TGT'}='';
679 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
680 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
681 $fwdfwsettings{'TGT_PORT'} = '';
682 $fwdfwsettings{'ICMP_TGT'}='';
683 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
684 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
685 $fwdfwsettings{'TGT_PORT'} = '';
690 if ($fwdfwsettings{'USESRV'} ne 'ON'){
691 $fwdfwsettings{'grp3'}='';
692 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
693 $fwdfwsettings{'ICMP_TGT'}='';
696 if($fwdfwsettings{'TIME'} eq 'ON'){
697 if($fwdfwsettings{'TIME_MON'} eq '' && $fwdfwsettings{'TIME_TUE'} eq '' && $fwdfwsettings{'TIME_WED'} eq '' && $fwdfwsettings{'TIME_THU'} eq '' && $fwdfwsettings{'TIME_FRI'} eq '' && $fwdfwsettings{'TIME_SAT'} eq '' && $fwdfwsettings{'TIME_SUN'} eq ''){
698 $errormessage=$Lang::tr
{'fwdfw err time'};
699 return $errormessage;
702 return $errormessage;
707 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
708 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
709 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
710 if ($fwdfwsettings{'dnatport'} eq "*") {
711 $fwdfwsettings{'dnatport'}="1:65535";
713 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
714 $fwdfwsettings{'dnatport'} = "1:$2";
716 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
717 $fwdfwsettings{'dnatport'} ="$1:65535";
722 if ($val =~ "," || $val>65536 || $val<0){
729 #check valid port for NAT
730 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
731 #if no port is given in nat area, take target host port
732 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
733 #check if port given in nat area is a single valid port or portrange
734 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
735 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
736 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
738 #get servcie Protocol and Port
739 foreach my $key (sort keys %customservice){
740 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
741 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
742 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
744 $custsrvport= $customservice{$key}[1];
747 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
749 #check if DNAT port is multiple
750 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
751 my @parts=split(",",$fwdfwsettings{'dnatport'});
755 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
757 #change dashes with :
760 push(@values,"1:65535");
763 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
764 push(@values,"1:$2");
767 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
768 push(@values,"$1:65535");
771 $errormessage .= &General
::validportrange
($_, 'destination');
776 if (&General
::validport
($_)){
783 $fwdfwsettings{'dnatport'}=join("|",@values);
787 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
788 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
790 #check if source and target identical
791 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
792 $errormessage=$Lang::tr
{'fwdfw err same'};
793 return $errormessage;
795 #get source and targetip address if possible
796 my ($sip,$scidr,$tip,$tcidr);
797 ($sip,$scidr)=&get_ip
("src","grp1");
798 ($tip,$tcidr)=&get_ip
("tgt","grp2");
799 #check same iprange in source and target
800 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
801 my $networkip1=&General
::getnetworkip
($sip,$scidr);
802 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
803 if ($scidr gt $tcidr){
804 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
805 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
807 }elsif($scidr eq $tcidr && $scidr eq '32'){
808 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
809 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
810 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
811 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
812 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
815 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
816 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
820 #When using source- or targetport, the protocol has to be TCP or UDP
821 if (($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON') && ($fwdfwsettings{'SRC_PORT'} ne '' || $fwdfwsettings{'TGT_PORT'} ne '') && ($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP')){
822 $errormessage.=$Lang::tr
{'fwdfw err prot_port1'};
825 #when icmp selected, no targetport allowed
826 if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
827 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
830 #change protocol if prot not equal dest single service
831 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
832 foreach my $key (sort keys %customservice){
833 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
834 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
835 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
841 #check source and destination protocol if source manual and dest servicegroup
842 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
843 $fwdfwsettings{'PROT'} = '';
845 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
846 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
848 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
849 $fwdfwsettings{'USE_SRC_PORT'}='';
850 $fwdfwsettings{'SRC_PORT'}='';
851 #$fwdfwsettings{'USESRV'}='';
852 $fwdfwsettings{'TGT_PORT'}='';
853 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
854 foreach my $key (keys %icmptypes){
855 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
856 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
859 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
860 $fwdfwsettings{'USE_SRC_PORT'}='';
861 $fwdfwsettings{'SRC_PORT'}='';
862 $fwdfwsettings{'ICMP_TYPES'}='';
863 $fwdfwsettings{'USESRV'}='';
864 $fwdfwsettings{'TGT_PORT'}='';
865 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
866 $fwdfwsettings{'USE_SRC_PORT'}='';
867 $fwdfwsettings{'SRC_PORT'}='';
868 $fwdfwsettings{'ICMP_TYPES'}='';
869 $fwdfwsettings{'USESRV'}='';
870 $fwdfwsettings{'TGT_PORT'}='';
871 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
872 $fwdfwsettings{'USE_SRC_PORT'}='';
873 $fwdfwsettings{'SRC_PORT'}='';
874 $fwdfwsettings{'ICMP_TYPES'}='';
875 $fwdfwsettings{'USESRV'}='';
876 $fwdfwsettings{'TGT_PORT'}='';
877 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
878 $fwdfwsettings{'ICMP_TYPES'}='';
879 $fwdfwsettings{'PROT'} = '';
880 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
881 $fwdfwsettings{'ICMP_TYPES'}='';
886 my ($base1,$val1,$base2,$val2) = @_;
888 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
889 &dec_counter
($confignet,\
%customnetwork,$val1);
890 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
891 &dec_counter
($confighost,\
%customhost,$val1);
892 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
893 &dec_counter
($configgrp,\
%customgrp,$val1);
894 }elsif($base1 eq 'cust_srv'){
895 &dec_counter
($configsrv,\
%customservice,$val1);
896 }elsif($base1 eq 'cust_srvgrp'){
897 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
900 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
901 &inc_counter
($confignet,\
%customnetwork,$val2);
902 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
903 &inc_counter
($confighost,\
%customhost,$val2);
904 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
905 &inc_counter
($configgrp,\
%customgrp,$val2);
906 }elsif($base2 eq 'cust_srv'){
907 &inc_counter
($configsrv,\
%customservice,$val2);
908 }elsif($base2 eq 'cust_srvgrp'){
909 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
915 #Test if manual IP is part of static OpenVPN networks
916 &General
::readhasharray
("$configccdnet", \
%ccdnet);
917 foreach my $key (sort keys %ccdnet){
918 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
919 my $sub=&General
::iporsubtodec
($vpnsubnet);
920 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
924 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
925 # because if one creates a custom host with the ip, we need to check the color there!
926 # It does not make sense to check this here
928 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
929 # Is also checked in getcolor
931 # Test if manual ip is part of an IPsec Network is also checked in getcolor
941 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
942 foreach my $key (sort {$a <=> $b} keys %delhash){
943 if ($key == $fwdfwsettings{'key'}){
944 #check hosts/net and groups
945 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
946 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
947 #check services and groups
948 if ($delhash{$key}[11] eq 'ON'){
949 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
952 if ($key >= $fwdfwsettings{'key'}) {
954 if (exists $delhash{$next}) {
955 foreach my $i (0 .. $#{$delhash{$next}}) {
956 $delhash{$key}[$i] = $delhash{$next}[$i];
961 # Remove the very last entry.
962 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
963 delete $delhash{$last_key};
965 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
968 if($fwdfwsettings{'nobase'} ne 'on'){
975 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
976 foreach my $key (sort keys %configfwdfw){
978 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
981 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
990 &General
::readhasharray
($config, \
%hash);
991 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
992 if($hash{$key}[0] eq $val){
993 $pos=$#{$hash{$key}};
994 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
997 &General
::writehasharray
($config, \
%hash);
1001 if ($errormessage) {
1002 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1003 print "<class name='base'>$errormessage\n";
1004 print " </class>\n";
1005 &Header
::closebox
();
1011 my %hash=%{(shift)};
1014 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1015 if($hash{$key}[0] eq $val){
1016 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1018 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1028 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1029 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1030 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1031 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1032 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1033 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1034 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1035 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1036 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1037 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1038 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1039 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1040 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1041 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1042 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1043 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1044 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1045 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1046 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1048 <table width='100%' border='0'>
1049 <tr><td width='50%' valign='top'>
1050 <table width='100%' border='0'>
1051 <tr><td width='1%'><input type='radio' name='$grp' id='std_net_$srctgt' value='std_net_$srctgt' $checked{$grp}{'std_net_'.$srctgt}></td><td>$Lang::tr{'fwhost stdnet'}</td><td align='right'><select name='std_net_$srctgt' style='width:200px;'>
1053 foreach my $network (sort keys %defaultNetworks)
1055 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1056 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1057 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1058 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1059 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1060 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1061 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1062 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1063 if ($ifaces{$defnet}){
1064 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1066 print ">$network</option>";
1069 print"</select></td></tr>";
1071 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1072 print"<tr><td><input type='radio' name='$grp' id='cust_net_$srctgt' value='cust_net_$srctgt' $checked{$grp}{'cust_net_'.$srctgt}></td><td>$Lang::tr{'fwhost cust net'}</td><td align='right'><select name='cust_net_$srctgt' style='width:200px;'>";
1073 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1074 print"</select></td>";
1077 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1078 print"<tr><td><input type='radio' name='$grp' id='cust_host_$srctgt' value='cust_host_$srctgt' $checked{$grp}{'cust_host_'.$srctgt}></td><td>$Lang::tr{'fwhost cust addr'}</td><td align='right'><select name='cust_host_$srctgt' style='width:200px;'>";
1079 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1080 print"</select></td>";
1083 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1084 print"<tr><td valign='top'><input type='radio' name='$grp' id='cust_grp_$srctgt' value='cust_grp_$srctgt' $checked{$grp}{'cust_grp_'.$srctgt}></td><td >$Lang::tr{'fwhost cust grp'}</td><td align='right'><select name='cust_grp_$srctgt' style='width:200px;'>";
1085 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1086 if($helper ne $customgrp{$key}[0]){
1088 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1089 print ">$customgrp{$key}[0]</option>";
1091 $helper=$customgrp{$key}[0];
1093 print"</select></td>";
1095 #End left table. start right table (vpn)
1096 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1098 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1099 print"<td width='1%'><input type='radio' name='$grp' id='ovpn_net_$srctgt' value='ovpn_net_$srctgt' $checked{$grp}{'ovpn_net_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_net_$srctgt' style='width:200px;'>";
1100 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1101 print"</select></td></tr>";
1104 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1105 if ($ccdhost{$key}[33] ne '' ){
1106 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'>" if ($show eq '');
1108 print "<option value='$ccdhost{$key}[1]'";
1109 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1110 print ">$ccdhost{$key}[1]</option>";
1113 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1114 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_host_$srctgt' value='ovpn_host_$srctgt' $checked{$grp}{'ovpn_host_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_host_$srctgt' style='width:200px;'></select></td></tr>" ;
1116 if ($show eq '1'){$show='';print"</select></td></tr>";}
1118 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1119 if ($ccdhost{$key}[3] eq 'net'){
1120 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}:</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'>" if ($show eq '');
1122 print "<option value='$ccdhost{$key}[1]'";
1123 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1124 print ">$ccdhost{$key}[1]</option>";
1127 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1128 print"<tr><td width='1%'><input type='radio' name='$grp' id='ovpn_n2n_$srctgt' value='ovpn_n2n_$srctgt' $checked{$grp}{'ovpn_n2n_'.$srctgt}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ovpn_n2n'}</td><td nowrap='nowrap' width='1%' align='right'><select name='ovpn_n2n_$srctgt' style='width:200px;'></select></td></tr>" ;
1130 if ($show eq '1'){$show='';print"</select></td></tr>";}
1132 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1133 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1134 print"<tr><td valign='top'><input type='radio' name='$grp' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'>" if ($show eq '');
1137 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1138 print ">$ipsecconf{$key}[1]</option>";
1141 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1142 print"<tr><td valign='top'><input type='radio' name='$grp' id='ipsec_net_$srctgt' value='ipsec_net_$srctgt' $checked{$grp}{'ipsec_net_'.$srctgt}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td align='right'><select name='ipsec_net_$srctgt' style='width:200px;'><select></td></tr>";
1144 if ($show eq '1'){$show='';print"</select></td></tr>";}
1147 print"</td></tr></table><br>";
1155 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1156 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1157 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1158 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1159 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1160 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1161 $a=$netsettings{'GREEN_NETADDRESS'};
1162 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1163 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1164 $a=$netsettings{'ORANGE_NETADDRESS'};
1165 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1166 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1167 $a=$netsettings{'BLUE_NETADDRESS'};
1168 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1169 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1170 &General
::readhash
("$configovpn",\
%ovpnsettings);
1171 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1172 $b=&General
::iporsubtocidr
($b);
1174 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1175 &General
::readhasharray
("$confignet", \
%customnetwork);
1176 foreach my $key (keys %customnetwork){
1177 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1178 $a=$customnetwork{$key}[1];
1179 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1182 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1183 &General
::readhasharray
("$confighost", \
%customhost);
1184 foreach my $key (keys %customhost){
1185 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1186 if ($customhost{$key}[1] eq 'ip'){
1187 ($a,$b)=split (/\//,$customhost{$key}[2]);
1188 $b=&General
::iporsubtocidr
($b);
1190 if ($grp eq 'grp2'){
1191 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1203 &General
::setup_default_networks
(\
%defaultNetworks);
1204 foreach my $network (sort keys %defaultNetworks)
1206 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1211 my %hash=%{(shift)};
1213 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1214 $hash{$key}[10]=~ s/\|/,/g;
1215 print": $hash{$key}[10]";
1216 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1217 print": <br>$hash{$key}[9] ";
1222 my %hash=%{(shift)};
1226 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1227 if($hash{$key}[14] eq 'cust_srv'){
1228 &General
::readhasharray
("$configsrv", \
%customservice);
1229 foreach my $i (sort keys %customservice){
1230 if($customservice{$i}[0] eq $hash{$key}[15]){
1231 $service = $customservice{$i}[0];
1234 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1235 $service=$hash{$key}[15];
1236 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1237 $hash{$key}[15]=~ s/\|/,/g;
1238 $service=$hash{$key}[15];
1245 sub get_serviceports
1249 &General
::readhasharray
("$configsrv", \
%customservice);
1250 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1255 if($type eq 'service'){
1256 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1257 if ($customservice{$key}[0] eq $name){
1258 push (@protocols,$customservice{$key}[2]);
1261 }elsif($type eq 'group'){
1262 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1263 if ($customservicegrp{$key}[0] eq $name){
1264 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1265 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1266 if($customservice{$key1}[2] eq 'TCP'){
1268 }elsif($customservice{$key1}[2] eq 'ICMP'){
1270 }elsif($customservice{$key1}[2] eq 'UDP'){
1278 if($tcp && $udp && $icmp){
1279 push (@protocols,"TCP,UDP, <br>ICMP");
1283 push (@protocols,"TCP");
1286 push (@protocols,"UDP");
1289 push (@protocols,"ICMP");
1298 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1300 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1301 foreach my $key (sort keys %$hash){
1302 if ($$hash{$key}[0] eq $val){
1303 $val=$$hash{$key}[2];
1308 if ($val eq 'GREEN'){
1309 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1311 }elsif ($val eq 'ORANGE'){
1312 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1314 }elsif ($val eq 'BLUE'){
1315 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1317 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1318 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1320 }elsif ($val eq 'IPFire' ){
1321 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1323 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1324 my ($sip,$scidr) = split ("/",$val);
1325 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1326 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1329 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1330 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1333 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1334 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1337 }elsif ($val eq 'Default IP'){
1338 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1341 #Check if a manual IP or custom host is part of a VPN
1342 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1343 #Check if IP is part of OpenVPN dynamic subnet
1344 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1345 my ($c,$d) = split("/",$val);
1346 if (&General
::IpInSubnet
($c,$a,$b)){
1347 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1350 #Check if IP is part of OpenVPN static subnet
1351 foreach my $key (sort keys %ccdnet){
1352 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1353 $b =&General
::iporsubtodec
($b);
1354 if (&General
::IpInSubnet
($c,$a,$b)){
1355 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1359 #Check if IP is part of OpenVPN N2N subnet
1360 foreach my $key (sort keys %ccdhost){
1361 if ($ccdhost{$key}[3] eq 'net'){
1362 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1363 if (&General
::IpInSubnet
($c,$a,$b)){
1364 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1369 #Check if IP is part of IPsec RW network
1370 if ($ipsecsettings{'RW_NET'} ne ''){
1371 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1372 $b=&General
::iporsubtodec
($b);
1373 if (&General
::IpInSubnet
($c,$a,$b)){
1374 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1378 #Check if IP is part of a IPsec N2N network
1379 foreach my $key (sort keys %ipsecconf){
1380 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1381 if (&General
::IpInSubnet
($c,$a,$b)){
1382 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1388 if ($nettype eq 'ovpn_n2n_src' || $nettype eq 'ovpn_n2n_tgt' || $nettype eq 'ovpn_net_src' || $nettype eq 'ovpn_net_tgt'|| $nettype eq 'ovpn_host_src' || $nettype eq 'ovpn_host_tgt'){
1389 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1392 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1393 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1397 foreach my $alias (sort keys %aliases)
1399 if ($val eq $alias){
1400 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1411 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1412 print "<class name='base'>$hint\n";
1413 print " </class>\n";
1414 &Header
::closebox
();
1421 my %hash=%{(shift)};
1425 &General
::readhasharray
($config, \
%hash);
1426 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1427 if($hash{$key}[0] eq $val){
1428 $pos=$#{$hash{$key}};
1429 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1432 &General
::writehasharray
($config, \
%hash);
1437 &General
::setup_default_networks
(\
%defaultNetworks);
1438 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1439 #read all configfiles
1440 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1441 &General
::readhasharray
("$confignet", \
%customnetwork);
1442 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1443 &General
::readhasharray
("$confighost", \
%customhost);
1444 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1445 &General
::readhasharray
("$configgrp", \
%customgrp);
1446 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1447 &General
::get_aliases
(\
%aliases);
1451 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1452 my $config=$fwdfwsettings{'config'};
1455 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1456 my $redip = <CONN1
>;
1458 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1459 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1460 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1461 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1462 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1463 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1464 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1465 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1466 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1467 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1468 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1469 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1470 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1471 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1472 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1473 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1474 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1475 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1476 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1477 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1478 #check if update and get values
1479 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1480 &General
::readhasharray
("$config", \
%hash);
1481 foreach my $key (sort keys %hash){
1483 if ($key eq $fwdfwsettings{'key'}){
1484 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1485 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1486 $fwdfwsettings{'chain'} = $hash{$key}[1];
1487 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1488 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1489 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1490 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1491 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1492 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1493 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1494 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1495 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1496 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1497 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1498 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1499 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1500 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1501 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1502 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1503 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1504 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1505 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1506 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1507 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1508 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1509 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1510 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1511 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1512 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1513 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1514 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1515 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1516 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1517 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1518 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1519 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1520 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1521 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1522 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1523 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1524 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1525 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1526 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1527 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1528 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1529 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1530 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1531 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1532 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1533 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1534 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1535 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1536 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1537 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1538 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1539 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1542 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1543 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1544 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1545 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1546 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1547 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1548 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1549 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1550 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1551 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1552 #check if manual ip (source) is orange network
1553 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1554 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1555 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1556 $fwdfwsettings{'oldorange'} ='on';
1560 $fwdfwsettings{'ACTIVE'}='ON';
1561 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1562 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1563 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1564 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1565 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1566 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1567 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1568 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1569 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1570 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1571 #check if manual ip (source) is orange network
1572 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1573 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1574 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1575 $fwdfwsettings{'oldorange'} ='on';
1579 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1580 &Header
::closebox
();
1581 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1582 #------SOURCE-------------------------------------------------------
1583 print "<form method='post'>";
1585 <table width='100%' border='0'>
1586 <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td width='60%'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' size='16' maxlength='18' ></td><td width='1%'><input type='radio' name='grp1' id='ipfire_src' value='ipfire_src' $checked{'grp1'}{'ipfire_src'}></td><td><b>Firewall</b></td>
1588 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1589 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1590 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1591 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1592 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1593 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1594 if (! -z
"${General::swroot}/ethernet/aliases"){
1595 foreach my $alias (sort keys %aliases)
1597 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1602 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1604 &gen_dd_block
('src','grp1');
1606 &Header
::closebox
();
1607 #---SNAT / DNAT ------------------------------------------------
1608 &Header
::openbox
('100%', 'left', 'NAT');
1610 <div id="nat"><table width='100%' border='0'>
1611 <tr><td width='1%'><input type='checkbox' name='USE_NAT' id='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'} ></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr></table></div>
1612 <div id="natpart" class="noscript">
1613 <table width=100%' border='0'><tr>
1614 <tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' id='dnat' value='dnat' checked ></td><td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
1616 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1617 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1618 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1619 foreach my $alias (sort keys %aliases)
1621 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1623 print"</select></td></tr>";
1624 $fwdfwsettings{'dnatport'}=~ tr/|/,/;
1625 print"<tr><td colspan='4'></td><td>Port: </td><td align='right'><input type='text' name='dnatport' style='width:130px;' value=\"$fwdfwsettings{'dnatport'}\"> </td></tr>";
1626 print"<tr><td colspan='8'><br></td></tr>";
1628 print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' id='snat' value='snat' $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
1629 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1630 foreach my $alias (sort keys %aliases)
1632 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1634 foreach my $network (sort keys %defaultNetworks)
1636 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1637 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1638 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1639 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1640 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1641 print ">$network</option>";
1643 print"</select></td></tr></table>";
1644 print"</div><br><hr>";
1645 &Header
::closebox
();
1646 #---TARGET------------------------------------------------------
1647 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1649 <table width='100%' border='0'>
1650 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td width='60%' nowrap='nowrap'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16' maxlength='18'><td width='1%'><input type='radio' name='grp2' id='ipfire' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>Firewall</b></td>
1652 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1653 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1654 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1655 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1656 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1657 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1658 if (! -z
"${General::swroot}/ethernet/aliases"){
1659 foreach my $alias (sort keys %aliases)
1661 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1666 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1668 &gen_dd_block
('tgt','grp2');
1671 #---PROTOCOL------------------------------------------------------
1672 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1675 <table width='15%' border='0' style="float:left;">
1678 <select name='PROT' id='protocol'>
1680 print "<option value=\"\"";
1681 if ($fwdfwsettings{'PROT'} eq '') {
1682 print " selected=\"selected\"";
1684 print ">$Lang::tr{'all'}</option>";
1686 print "<option value=\"template\"";
1688 print ">- $Lang::tr{'template'} -</option>";
1690 foreach (@PROTOCOLS) {
1691 print"<option value=\"$_\"";
1692 if ($_ eq $fwdfwsettings{'PROT'}) {
1693 print " selected=\"selected\"";
1695 print ">$_</option>";
1704 <div id="PROTOCOL_ICMP_TYPES">
1705 <table width='30%' border='0' style="float:left;">
1707 <td>$Lang::tr{'fwhost icmptype'}</td>
1709 <select name='ICMP_TYPES' style='min-width:230px;'>
1711 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1712 print"<option>All ICMP-Types</option>";
1713 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1714 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1715 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1717 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1729 $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
1730 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1734 <div id="PROTOCOL_PORTS">
1737 <!-- #SOURCEPORT -->
1739 $Lang::tr{'fwdfw man port'}
1742 <input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18'>
1745 <!-- #TARGETPORT -->
1747 $Lang::tr{'fwdfw man port'}
1750 <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
1756 <div id="PROTOCOL_TEMPLATE">
1760 <input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked>
1761 $Lang::tr{'fwhost cust service'}
1764 <select name='cust_srv' style='min-width: 230px;'>
1766 &General
::readhasharray
("$configsrv", \
%customservice);
1767 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1769 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1770 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1779 <input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}>
1780 $Lang::tr{'fwhost cust srvgrp'}
1783 <select name='cust_srvgrp' style='min-width:230px;'>
1786 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1788 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1789 if ($helper ne $customservicegrp{$key}[0]){
1791 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1792 print">$customservicegrp{$key}[0]</option>";
1794 $helper=$customservicegrp{$key}[0];
1807 #---Activate/logging/remark-------------------------------------
1808 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1810 <table width='100%' border='0'>
1811 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1813 foreach ("ACCEPT","DROP","REJECT")
1815 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1816 print"<option value='$_'";
1817 print " selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1818 print">$Lang::tr{'fwdfw '.$_}</option>";
1820 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1821 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1823 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1825 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1827 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1831 print"</select></td></tr>";
1832 print"<tr><td width='12%'>$Lang::tr{'remark'}:</td><td width='88%' align='left'><input type='text' name='ruleremark' maxlength='255' value='$fwdfwsettings{'ruleremark'}' style='width:99%;'></td></tr>";
1833 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1834 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1835 for (my $count =1; $count <= $sum; $count++){
1836 print"<option value='$count' ";
1837 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1838 print">$count</option>";
1840 print"</select></td></tr>";
1842 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1846 </table><table width='100%'>
1847 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1848 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1851 &Header
::closebox
();
1852 #---ADD TIMEFRAME-----------------------------------------------
1853 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1855 <table width='70%' border='0'>
1856 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='9'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1857 <tr><td colspan='10'> </td></tr>
1859 <td align='left' >$Lang::tr{'time'}: </td>
1860 <td>$Lang::tr{'advproxy monday'}</td><td> $Lang::tr{'advproxy tuesday'} </td><td>$Lang::tr{'advproxy wednesday'}</td><td> $Lang::tr{'advproxy thursday'}</td><td> $Lang::tr{'advproxy friday'}</td><td> $Lang::tr{'advproxy saturday'}</td><td> $Lang::tr{'advproxy sunday'}</td>
1861 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1862 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1865 <td align='right'></td>
1866 <td width='1%' align='left'><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
1867 <td width='1%' align='left'><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
1868 <td width='1%' align='left'><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
1869 <td width='1%' align='left'><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
1870 <td width='1%' align='left'><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
1871 <td width='1%' align='left'><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
1872 <td width='15%' align='left'><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
1873 <td><select name='TIME_FROM'>
1875 for (my $i=0;$i<=23;$i++) {
1876 $i = sprintf("%02s",$i);
1877 for (my $j=0;$j<=45;$j+=15) {
1878 $j = sprintf("%02s",$j);
1879 my $time = $i.":".$j;
1880 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1885 <td><select name='TIME_TO'>
1887 for (my $i=0;$i<=23;$i++) {
1888 $i = sprintf("%02s",$i);
1889 for (my $j=0;$j<=45;$j+=15) {
1890 $j = sprintf("%02s",$j);
1891 my $time = $i.":".$j;
1892 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1896 </select></td></tr></table><br><hr>
1898 #---ACTION------------------------------------------------------
1899 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1901 <table border='0' width='100%'>
1902 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1903 <input type='hidden' name='config' value='$config' >
1904 <input type='hidden' name='ACTION' value='saverule' ></form>
1905 <form method='post' style='display:inline;'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='reset'></form></td></tr>
1911 <table border='0' width='100%'>
1912 <tr><td align='right'><input type='submit' value='$Lang::tr{'fwdfw change'}' style='min-width:100px;' /><input type='hidden' name='updatefwrule' value='$fwdfwsettings{'updatefwrule'}'><input type='hidden' name='key' value='$fwdfwsettings{'key'}'>
1913 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1914 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1915 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1916 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1917 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1918 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1919 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1920 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1921 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1922 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1923 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1924 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1925 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1926 <input type='hidden' name='ACTION' value='saverule' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value'reset'></td></td>
1930 &Header
::closebox
();
1936 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1937 foreach my $key (sort keys %uphash){
1938 if ($key eq $fwdfwsettings{'key'}) {
1940 if (exists $uphash{$last}){
1942 foreach my $y (0 .. $#{$uphash{$last}}) {
1943 $tmp{0}[$y] = $uphash{$last}[$y];
1945 #copy active rule to last
1946 foreach my $i (0 .. $#{$uphash{$last}}) {
1947 $uphash{$last}[$i] = $uphash{$key}[$i];
1949 #copy saved rule to actual position
1950 foreach my $x (0 .. $#{$tmp{0}}) {
1951 $uphash{$key}[$x] = $tmp{0}[$x];
1956 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1963 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1964 foreach my $key (sort keys %downhash){
1965 if ($key eq $fwdfwsettings{'key'}) {
1966 my $next = $key + 1;
1967 if (exists $downhash{$next}){
1969 foreach my $y (0 .. $#{$downhash{$next}}) {
1970 $tmp{0}[$y] = $downhash{$next}[$y];
1972 #copy active rule to next
1973 foreach my $i (0 .. $#{$downhash{$next}}) {
1974 $downhash{$next}[$i] = $downhash{$key}[$i];
1976 #copy saved rule to actual position
1977 foreach my $x (0 .. $#{$tmp{0}}) {
1978 $downhash{$key}[$x] = $tmp{0}[$x];
1983 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1988 if (!-f
"${General::swroot}/forward/reread"){
1989 system("touch ${General::swroot}/forward/reread");
1990 system("touch ${General::swroot}/fwhosts/reread");
1995 system("/usr/local/bin/forwardfwctrl");
1996 if ( -f
"${General::swroot}/forward/reread"){
1997 system("rm ${General::swroot}/forward/reread");
1998 system("rm ${General::swroot}/fwhosts/reread");
2005 &General
::readhasharray
("$config", $hash);
2006 if (!$errormessage){
2007 ################################################################
2008 #check if we change an INPUT rule to a OUTGOING
2009 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
2010 &changerule
($configinput);
2013 #check if we change an INPUT rule to a FORWARD
2014 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2015 &changerule
($configinput);
2018 ################################################################
2019 #check if we change an OUTGOING rule to an INPUT
2020 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
2021 &changerule
($configoutgoing);
2024 #check if we change an OUTGOING rule to a FORWARD
2025 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
2026 &changerule
($configoutgoing);
2029 ################################################################
2030 #check if we change a FORWARD rule to an INPUT
2031 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
2032 &changerule
($configfwdfw);
2035 #check if we change a FORWARD rule to an OUTGOING
2036 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2037 &changerule
($configfwdfw);
2040 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2041 my $key = &General
::findhasharraykey
($hash);
2042 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2043 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2044 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2045 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2046 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2047 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2048 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2049 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2050 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2051 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2052 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2053 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2054 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2055 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2056 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2057 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2058 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2059 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2060 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2061 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2062 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2063 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2064 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2065 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2066 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2067 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2068 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2069 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2070 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2071 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2072 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2073 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2074 &General
::writehasharray
("$config", $hash);
2076 foreach my $key (sort {$a <=> $b} keys %$hash){
2077 if($key eq $fwdfwsettings{'key'}){
2078 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2079 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2080 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2081 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2082 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2083 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2084 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2085 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2086 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2087 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2088 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2089 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2090 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2091 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2092 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2093 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2094 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2095 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2096 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2097 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2098 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2099 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2100 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2101 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2102 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2103 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2104 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2105 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2106 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2107 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2108 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2109 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2114 &General
::writehasharray
("$config", $hash);
2115 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2117 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2118 for (my $z=0;$z<$val;$z++){
2119 foreach my $key (sort {$a <=> $b} keys %$hash){
2120 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2122 if (exists $$hash{$last}){
2124 foreach my $y (0 .. $#{$$hash{$last}}) {
2125 $tmp{0}[$y] = $$hash{$last}[$y];
2127 #copy active rule to last
2128 foreach my $i (0 .. $#{$$hash{$last}}) {
2129 $$hash{$last}[$i] = $$hash{$key}[$i];
2131 #copy saved rule to actual position
2132 foreach my $x (0 .. $#{$tmp{0}}) {
2133 $$hash{$key}[$x] = $tmp{0}[$x];
2138 $fwdfwsettings{'oldrulenumber'}--;
2140 &General
::writehasharray
("$config", $hash);
2142 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2144 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2145 for (my $z=0;$z<$val;$z++){
2146 foreach my $key (sort {$a <=> $b} keys %$hash){
2147 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2148 my $next = $key + 1;
2149 if (exists $$hash{$next}){
2151 foreach my $y (0 .. $#{$$hash{$next}}) {
2152 $tmp{0}[$y] = $$hash{$next}[$y];
2154 #copy active rule to next
2155 foreach my $i (0 .. $#{$$hash{$next}}) {
2156 $$hash{$next}[$i] = $$hash{$key}[$i];
2158 #copy saved rule to actual position
2159 foreach my $x (0 .. $#{$tmp{0}}) {
2160 $$hash{$key}[$x] = $tmp{0}[$x];
2165 $fwdfwsettings{'oldrulenumber'}++;
2167 &General
::writehasharray
("$config", $hash);
2174 # Checks a hostname against RFC1035
2177 # Each part should be at least two characters in length
2178 # but no more than 63 characters
2179 if (length ($remark) < 1 || length ($remark) > 255) {
2181 # Only valid characters are a-z, A-Z, 0-9 and -
2182 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2184 # First character can only be a letter or a digit
2185 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2187 # Last character can only be a letter or a digit
2188 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2194 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2195 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2196 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'fwdfw xt access'} );
2197 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2206 &General
::get_aliases
(\
%aliases);
2207 &General
::readhasharray
("$confighost", \
%customhost);
2208 &General
::readhasharray
("$config", $hash);
2209 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2210 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2212 &Header
::openbox
('100%', 'left',$title);
2220 print"<b>$title1</b><br>";
2221 print"<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
2222 print"<tr><td align='center'><b>#</b></td><td></td><td align='center' width='25'></td><td align='center'><b>$Lang::tr{'fwdfw source'}</b></td><td width='1%'><b>Log</b></td><td align='center'><b>$Lang::tr{'fwdfw target'}</b></td><td align='center' colspan='6' width='1%'><b>$Lang::tr{'fwdfw action'}</b></td></tr>";
2223 foreach my $key (sort {$a <=> $b} keys %$hash){
2226 #check if vpn hosts/nets have been deleted
2227 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2228 push (@tmpsrc,$$hash{$key}[4]);
2230 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2231 push (@tmpsrc,$$hash{$key}[6]);
2233 foreach my $host (@tmpsrc){
2234 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2235 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2237 &disable_rule
($key);
2240 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2241 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2243 &disable_rule
($key);
2246 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2247 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2249 &disable_rule
($key);
2252 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2253 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2255 &disable_rule
($key);
2260 $$hash{'ACTIVE'}=$$hash{$key}[2];
2262 if($coloryellow eq 'on'){
2263 print"<tr bgcolor='$color{'color14'}' >";
2265 }elsif($coloryellow eq ''){
2267 $color="$color{'color22'}";
2270 $color="$color{'color20'}";
2273 print"<tr bgcolor='$color' >";
2276 <td align='right' width='18'><b>$key </b></td>
2279 if ($$hash{$key}[0] eq 'ACCEPT'){
2282 $rulecolor=$color{'color17'};
2283 }elsif($$hash{$key}[0] eq 'DROP'){
2286 $rulecolor=$color{'color25'};
2287 }elsif($$hash{$key}[0] eq 'REJECT'){
2290 $rulecolor=$color{'color16'};
2292 print"<td bgcolor='$rulecolor' align='center' width='10'><span title='$tooltip'><b>$ruletype</b></span></td>";
2295 if ($$hash{$key}[8]){
2296 push (@protocols,$$hash{$key}[8]);
2297 }elsif($$hash{$key}[14] eq 'cust_srv'){
2298 &get_serviceports
("service",$$hash{$key}[15]);
2299 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2300 &get_serviceports
("group",$$hash{$key}[15]);
2302 push (@protocols,$Lang::tr
{'all'});
2304 my $protz=join(",",@protocols);
2305 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2306 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2307 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2308 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2309 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2314 print"<td align='center'>$protz</td>";
2319 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2320 print"<td align='center' width='160' $tdcolor>";
2321 if ($$hash{$key}[3] eq 'ipfire_src'){
2322 $ipfireiface='Interface ';
2324 if ($$hash{$key}[3] eq 'std_net_src'){
2325 print &get_name
($$hash{$key}[4]);
2326 }elsif ($$hash{$key}[3] eq 'src_addr'){
2327 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2328 if ($split2 eq '32'){
2331 print $$hash{$key}[4];
2333 }elsif ($$hash{$key}[4] eq 'RED1'){
2334 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2336 print "$$hash{$key}[4]";
2340 &getsrcport
(\
%$hash,$key);
2341 #Is this a SNAT rule?
2342 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2343 my $net=&get_name
($$hash{$key}[29]);
2344 if ( ! $net){ $net=$$hash{$key}[29];}
2346 if ($$hash{$key}[30] ne ''){
2347 print": $$hash{$key}[30]";
2350 if ($$hash{$key}[17] eq 'ON'){
2351 $log="/images/on.gif";
2353 $log="/images/off.gif";
2358 <td align='left' width='25'><form method='post'><input type='image' img src='$log' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw togglelog'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'/>
2359 <input type='hidden' name='key' value='$key' />
2360 <input type='hidden' name='config' value='$config' />
2361 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2365 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2367 <td align='center' width='160' $tdcolor>
2369 #Is this a DNAT rule?
2370 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2371 print "Firewall ($$hash{$key}[29])";
2372 if($$hash{$key}[30] ne ''){
2373 $$hash{$key}[30]=~ tr/|/,/;
2374 print": $$hash{$key}[30]";
2378 if ($$hash{$key}[5] eq 'ipfire'){
2379 $ipfireiface='Interface';
2381 if ($$hash{$key}[5] eq 'std_net_tgt' || $$hash{$key}[5] eq 'ipfire' || $$hash{$key}[6] eq 'RED1' || $$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE' ){
2382 if ($$hash{$key}[6] eq 'RED1'){
2383 print "$ipfireiface $Lang::tr{'red1'}";
2384 }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL')
2386 print "$ipfireiface ".&get_name
($$hash{$key}[6]);
2388 print $$hash{$key}[6];
2390 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2391 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2392 if ($split2 eq '32'){
2395 print $$hash{$key}[6];
2398 print "$$hash{$key}[6]";
2402 &gettgtport
(\
%$hash,$key);
2405 if($$hash{$key}[2] eq 'ON'){
2406 $gif="/images/on.gif"
2409 $gif="/images/off.gif"
2412 <td width='25'><form method='post'><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;' />
2413 <input type='hidden' name='key' value='$key' />
2414 <input type='hidden' name='config' value='$config' />
2415 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2417 <td width='25' ><form method='post'><input type='image' img src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'fwdfw edit'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2418 <input type='hidden' name='key' value='$key' />
2419 <input type='hidden' name='config' value='$config' />
2420 <input type='hidden' name='ACTION' value='editrule' />
2422 <td width='25'><form method='post'><input type='image' img src='/images/addblue.gif' alt='$Lang::tr{'fwdfw copy'}' title='$Lang::tr{'fwdfw copy'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2423 <input type='hidden' name='key' value='$key' />
2424 <input type='hidden' name='config' value='$config' />
2425 <input type='hidden' name='ACTION' value='copyrule' />
2427 <td width='25' ><form method='post'><input type='image' img src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'fwdfw delete'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2428 <input type='hidden' name='key' value='$key' />
2429 <input type='hidden' name='config' value='$config' />
2430 <input type='hidden' name='ACTION' value='deleterule' />
2433 if (exists $$hash{$key-1}){
2435 <td width='25'><form method='post'><input type='image' img src='/images/up.gif' alt='$Lang::tr{'fwdfw moveup'}' title='$Lang::tr{'fwdfw moveup'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2436 <input type='hidden' name='key' value='$key' />
2437 <input type='hidden' name='config' value='$config' />
2438 <input type='hidden' name='ACTION' value='moveup' />
2442 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2444 if (exists $$hash{$key+1}){
2446 <td width='25' ><form method='post'><input type='image' img src='/images/down.gif' alt='$Lang::tr{'fwdfw movedown'}' title='$Lang::tr{'fwdfw movedown'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' />
2447 <input type='hidden' name='key' value='$key' />
2448 <input type='hidden' name='config' value='$config' />
2449 <input type='hidden' name='ACTION' value='movedown' />
2453 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2456 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2457 print"<tr bgcolor='$color'>";
2458 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='10'> $$hash{$key}[16]</td></tr>";
2460 if ($$hash{$key}[18] eq 'ON'){
2462 if ($$hash{$key}[18] eq 'ON'){
2464 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2465 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2466 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2467 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2468 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2469 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2470 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2471 my $weekdays=join(",",@days);
2473 print"<tr bgcolor='$color'>";
2474 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27] </td></tr>";
2478 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2482 print "<table width='100%'rules='cols' border='1'>";
2484 if ($config eq '/var/ipfire/forward/config'){
2485 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2486 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2487 $col="bgcolor='darkred'";
2489 $col="bgcolor='green'";
2491 &show_defaultrules
($col,$pol);
2492 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2493 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2494 $col="bgcolor='darkred'";
2495 print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF' >$Lang::tr{'fwdfw pol block'}</font></td></tr>";
2497 $col="bgcolor='green'";
2498 print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF' >$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
2501 print"<tr><td bgcolor='darkred' width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td bgcolor='darkred' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
2506 &Header
::closebox
();
2508 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2509 print "<b>$title1</b><br>";
2510 print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table>";
2512 if ($config eq '/var/ipfire/forward/config'){
2513 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2514 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2515 $col="bgcolor='darkred'";
2517 $col="bgcolor='green'";
2519 &show_defaultrules
($col,$pol);
2520 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2521 print "<table width='100%' rules='cols' border='1'>";
2522 my $pol='fwdfw '.$fwdfwsettings{'POLICY1'};
2523 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2524 $col="bgcolor='darkred'";
2525 print"<tr><td $col align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
2527 $col="bgcolor='green'";
2528 print"<tr><td $col align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
2531 print "<table width='100%' rules='cols' border='1'>";
2532 print"<tr><td bgcolor='darkred' align='center' width='20%'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td align='center' bgcolor='darkred'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";
2534 print"</table><br><br>";
2538 &Header
::closebigbox
();
2539 &Header
::closepage
();
2541 sub show_defaultrules
2545 #STANDARD RULES (From WIKI)
2547 if ($col eq "bgcolor='green'"){
2548 print "<br><table width='100%' rules='cols' border='1' >";
2549 my $blue = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::blue_used
());
2550 my $orange = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::orange_used
());
2551 my $blue1 = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::blue_used
());
2552 my $orange1 = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::orange_used
());
2553 print"<tr><td align='center'><font color='#000000'>$Lang::tr{'green'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td>";
2554 print"<td align='center'>$orange1</td>" if (&Header
::orange_used
());
2555 print"<td align='center'>$blue1</td>" if (&Header
::blue_used
());
2557 if (&Header
::orange_used
()){
2558 print"<tr><td align='center' width='20%'><font color='#000000'>$Lang::tr{'orange'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td><td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
2559 print"<td align='center'>$blue</td>" if (&Header
::blue_used
());
2562 if (&Header
::blue_used
()){
2563 print"<tr><td align='center'><font color='#000000'>$Lang::tr{'blue'}</td><td align='center'> <font color=$Header::colourred> $Lang::tr{'red'}</font> ($Lang::tr{'fwdfw pol allow'})</td>";
2564 print"<td align='center'>$orange</td>" if (&Header
::orange_used
());
2565 print"<td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
2568 print"<tr><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'} </font></td><td $col colspan='3' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol allow'}</font></td></tr>";
2569 }elsif($col eq "bgcolor='darkred'"){
2570 print "<table width='100%' rules='cols' border='1' >";
2571 print"<tr><td $col width='20%' align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw final_rule'}</td><td $col align='center'><font color='#FFFFFF'>$Lang::tr{'fwdfw pol block'}</font></td></tr>";