]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
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=();
67 my $confignet = "${General::swroot}/fwhosts/customnetworks";
68 my $confighost = "${General::swroot}/fwhosts/customhosts";
69 my $configgrp = "${General::swroot}/fwhosts/customgroups";
70 my $configsrv = "${General::swroot}/fwhosts/customservices";
71 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
72 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
73 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
74 my $configipsec = "${General::swroot}/vpn/config";
75 my $configipsecrw = "${General::swroot}/vpn/settings";
76 my $configfwdfw = "${General::swroot}/forward/config";
77 my $configinput = "${General::swroot}/forward/input";
78 my $configoutgoing = "${General::swroot}/forward/outgoing";
79 my $configovpn = "${General::swroot}/ovpn/settings";
80 my $fwoptions = "${General::swroot}/optionsfw/settings";
81 my $ifacesettings = "${General::swroot}/ethernet/settings";
84 my $ipgrp="${General::swroot}/outgoing/groups";
88 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
89 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
90 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
91 &General
::readhash
($fwoptions, \
%optionsfw);
92 &General
::readhash
($ifacesettings, \
%ifaces);
93 &General
::readhash
("$configovpn", \
%ovpnsettings);
94 &General
::readhash
("$configipsecrw", \
%ipsecsettings);
95 &General
::readhasharray
("$configipsec", \
%ipsecconf);
96 &Header
::showhttpheaders
();
97 &Header
::getcgihash
(\
%fwdfwsettings);
98 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
99 &Header
::openbigbox
('100%', 'center',$errormessage);
100 #### JAVA SCRIPT ####
103 \$(document).ready(function() {
104 // Automatically select radio buttons when corresponding
105 // dropdown menu changes.
106 \$("select").change(function() {
107 var id = \$(this).attr("name");
108 //When using SNAT or DNAT, check "USE NAT" Checkbox
109 if ( id === 'snat' || id === 'dnat') {
110 \$('#USE_NAT').prop('checked', true);
112 \$('#' + id).prop("checked", true);
115 function checkradio(a){
116 \$(a).attr('checked', true);
118 function toggle_elements( id ) {
119 if(document.getElementById(id).style.display== "none")
121 document.getElementById(id).style.display='block';
124 document.getElementById(id).style.display='none';
126 if(document.getElementById('targetport').style.display== "none" && document.getElementById('PROT').value === 'ICMP' )
128 document.getElementById('PROTOKOLL').style.display='block';
130 if(document.getElementById('targetport').style.display== "block" && document.getElementById('PROT').value === 'ICMP' )
132 document.getElementById('PROTOKOLL').style.display='none';
136 function hide_elements()
138 var elementNames = hide_elements.arguments;
139 for (var i=0; i<elementNames.length; i++)
141 var elementName = elementNames[i];
142 document.getElementById(elementName).style.display='none';
145 function getdropdown()
147 d = document.getElementById("PROT").value;
150 document.getElementById('PROTOKOLL').style.display='block';
154 document.getElementById('PROTOKOLL').style.display='none';
162 if ($fwdfwsettings{'ACTION'} eq 'saverule')
164 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
165 &General
::readhasharray
("$configinput", \
%configinputfw);
166 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
167 $errormessage=&checksource
;
168 if(!$errormessage){&checktarget
;}
169 if(!$errormessage){&checkrule
;}
170 #check if manual ip (source) is orange network
171 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
172 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
173 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
178 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
179 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
181 #check if we try to break rules
182 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
183 $errormessage=$Lang::tr
{'fwdfw err same'};
186 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
187 $fwdfwsettings{'config'}=$configinput;
188 $fwdfwsettings{'chain'} = 'INPUTFW';
189 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
190 #check if we have an identical rule already
191 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
192 foreach my $key (sort keys %configinputfw){
193 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'}"
194 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]"){
195 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
196 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
198 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
199 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
201 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
202 $fwdfwsettings{'nosave'} = 'on';
207 #check Rulepos on new Rule
208 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
209 $fwdfwsettings{'oldrulenumber'}=$maxkey;
210 foreach my $key (sort keys %configinputfw){
211 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'}"
212 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]"){
213 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
217 #check if we just close a rule
218 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'}) {
219 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
221 $fwdfwsettings{'nosave2'} = 'on';
225 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
226 if ($fwdfwsettings{'nobase'} ne 'on'){
227 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
229 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
230 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
231 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
232 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
233 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
234 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
236 if($fwdfwsettings{'nosave2'} ne 'on'){
237 &saverule
(\
%configinputfw,$configinput);
240 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
242 $fwdfwsettings{'config'}=$configoutgoing;
243 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
244 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
245 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
246 foreach my $key (sort keys %configoutgoingfw){
247 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'}"
248 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]"){
249 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
250 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
252 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
253 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
255 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
256 $fwdfwsettings{'nosave'} = 'on';
261 #check Rulepos on new Rule
262 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
263 print"CHECK OUTGOING DOPPELTE REGEL<br>";
264 $fwdfwsettings{'oldrulenumber'}=$maxkey;
265 foreach my $key (sort keys %configoutgoingfw){
266 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'}"
267 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]"){
268 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
272 #check if we just close a rule
273 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'}) {
274 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
275 $fwdfwsettings{'nosave2'} = 'on';
281 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
282 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
283 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
284 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
285 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
286 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
287 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
288 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
290 if ($fwdfwsettings{'nobase'} eq 'on'){
291 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
293 if ($fwdfwsettings{'nosave2'} ne 'on'){
294 &saverule
(\
%configoutgoingfw,$configoutgoing);
299 $fwdfwsettings{'config'}=$configfwdfw;
300 $fwdfwsettings{'chain'} = 'FORWARDFW';
301 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
302 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
303 #check if we have an identical rule already
304 foreach my $key (sort keys %configfwdfw){
305 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'}"
306 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]"){
307 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
308 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
310 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
311 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
313 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
314 $fwdfwsettings{'nosave'} = 'on';
319 #check Rulepos on new Rule
320 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
321 $fwdfwsettings{'oldrulenumber'}=$maxkey;
322 foreach my $key (sort keys %configfwdfw){
323 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'}"
324 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]"){
325 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
329 #check if we just close a rule
330 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'}) {
331 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
332 $fwdfwsettings{'nosave2'} = 'on';
338 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
339 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
340 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
341 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
342 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
343 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
344 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
345 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
347 if ($fwdfwsettings{'nobase'} eq 'on'){
348 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
350 if ($fwdfwsettings{'nosave2'} ne 'on'){
351 &saverule
(\
%configfwdfw,$configfwdfw);
358 if($fwdfwsettings{'nosave2'} ne 'on'){
364 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
368 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
371 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
372 foreach my $key (sort keys %togglehash){
373 if ($key eq $fwdfwsettings{'key'}){
374 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
377 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
381 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
384 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
385 foreach my $key (sort keys %togglehash){
386 if ($key eq $fwdfwsettings{'key'}){
387 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
390 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
394 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
399 if ($fwdfwsettings{'ACTION'} eq 'editrule')
401 $fwdfwsettings{'updatefwrule'}='on';
404 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
408 if ($fwdfwsettings{'ACTION'} eq 'moveup')
413 if ($fwdfwsettings{'ACTION'} eq 'movedown')
418 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
420 $fwdfwsettings{'copyfwrule'}='on';
423 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
431 if (-f
"${General::swroot}/forward/reread"){
432 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>";
434 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw menu'});
435 print "<form method='post'>";
436 print "<table border='0'>";
437 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
438 print"</tr></table></form><hr>";
450 $fwdfwsettings{'updatefwrule'}='';
451 $fwdfwsettings{'config'}=$oldchain;
452 $fwdfwsettings{'nobase'}='on';
454 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
455 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
460 #check ip-address if manual
461 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
462 #check if ip with subnet
463 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
464 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
465 $subnet = &General
::iporsubtocidr
($subnet);
466 $fwdfwsettings{'isip'}='on';
469 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
470 $ip=$fwdfwsettings{'src_addr'};
472 $fwdfwsettings{'isip'}='on';
475 if ($fwdfwsettings{'isip'} ne 'on'){
476 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
477 $fwdfwsettings{'ismac'}='on';
480 if ($fwdfwsettings{'isip'} eq 'on'){
481 ##check if ip is valid
482 if (! &General
::validip
($ip)){
483 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
484 return $errormessage;
486 #check and form valid IP
487 $ip=&General
::ip2dec
($ip);
488 $ip=&General
::dec2ip
($ip);
489 #check if net or broadcast
490 $fwdfwsettings{'src_addr'}="$ip/$subnet";
491 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
492 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
493 return $errormessage;
496 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
497 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
498 return $errormessage;
500 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
501 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
502 return $errormessage;
506 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
507 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
508 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
512 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
514 #change dashes with :
517 push(@values,"1:65535");
520 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
521 push(@values,"1:$2");
524 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
525 push(@values,"$1:65535");
528 $errormessage .= &General
::validportrange
($_, 'destination');
533 if (&General
::validport
($_)){
540 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
542 return $errormessage;
547 &General
::readhasharray
("$configsrv", \
%customservice);
548 #check DNAT settings (has to be single Host and single Port or portrange)
549 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
550 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
551 if ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'dnatport'} eq ''){
552 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
553 return $errormessage;
555 #check if manual ip is a single Host (if set)
556 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
557 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
558 my @tmp1= split ("/",$tmp[3]);
559 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
561 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
562 return $errormessage;
565 #check if Port is a single Port or portrange
566 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
567 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
568 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
569 return $errormessage;
571 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
572 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
573 return $errormessage;
577 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
578 return $errormessage;
581 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
582 #check if ip with subnet
583 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
584 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
585 $subnet = &General
::iporsubtocidr
($subnet);
588 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
589 $ip=$fwdfwsettings{'tgt_addr'};
592 #check if ip is valid
593 if (! &General
::validip
($ip)){
594 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
595 return $errormessage;
597 #check and form valid IP
598 $ip=&General
::ip2dec
($ip);
599 $ip=&General
::dec2ip
($ip);
600 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
601 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
602 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
603 return $errormessage;
605 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
606 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
607 return $errormessage;
610 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
612 if ($fwdfwsettings{'USESRV'} eq 'ON'){
613 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
614 $fwdfwsettings{'TGT_PROT'}='';
615 $fwdfwsettings{'ICMP_TGT'}='';
616 $fwdfwsettings{'TGT_PORT'}='';
618 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
619 $fwdfwsettings{'TGT_PROT'}='';
620 $fwdfwsettings{'ICMP_TGT'}='';
621 $fwdfwsettings{'TGT_PORT'}='';
622 #check target service
623 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
624 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
627 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
628 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
629 if ($fwdfwsettings{'TGT_PORT'} ne ''){
630 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
631 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
632 return $errormessage;
634 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
638 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
640 #change dashes with :
643 push(@values,"1:65535");
646 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
647 push(@values,"1:$2");
650 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
651 push(@values,"$1:65535");
654 $errormessage .= &General
::validportrange
($_, 'destination');
659 if (&General
::validport
($_)){
665 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
667 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
668 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
669 $fwdfwsettings{'TGT_PORT'} = '';
670 $fwdfwsettings{'ICMP_TGT'} = '';
671 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
672 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
673 $fwdfwsettings{'TGT_PORT'} = '';
674 $fwdfwsettings{'ICMP_TGT'}='';
675 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
676 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
677 $fwdfwsettings{'TGT_PORT'} = '';
678 $fwdfwsettings{'ICMP_TGT'}='';
679 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
680 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
681 $fwdfwsettings{'TGT_PORT'} = '';
686 if ($fwdfwsettings{'USESRV'} ne 'ON'){
687 $fwdfwsettings{'grp3'}='';
688 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
689 $fwdfwsettings{'ICMP_TGT'}='';
692 if($fwdfwsettings{'TIME'} eq 'ON'){
693 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 ''){
694 $errormessage=$Lang::tr
{'fwdfw err time'};
695 return $errormessage;
698 return $errormessage;
703 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
704 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
705 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
706 if ($fwdfwsettings{'dnatport'} eq "*") {
707 $fwdfwsettings{'dnatport'}="1:65535";
709 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
710 $fwdfwsettings{'dnatport'} = "1:$2";
712 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
713 $fwdfwsettings{'dnatport'} ="$1:65535";
718 if ($val =~ "," || $val>65536 || $val<0){
725 #check valid port for NAT
726 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
727 #if no port is given in nat area, take target host port
728 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
729 #check if port given in nat area is a single valid port or portrange
730 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
731 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
732 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
734 #get servcie Protocol and Port
735 foreach my $key (sort keys %customservice){
736 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
737 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
738 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
740 $custsrvport= $customservice{$key}[1];
743 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
745 #check if DNAT port is multiple
746 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
747 my @parts=split(",",$fwdfwsettings{'dnatport'});
751 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
753 #change dashes with :
756 push(@values,"1:65535");
759 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
760 push(@values,"1:$2");
763 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
764 push(@values,"$1:65535");
767 $errormessage .= &General
::validportrange
($_, 'destination');
772 if (&General
::validport
($_)){
779 $fwdfwsettings{'dnatport'}=join("|",@values);
783 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
784 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
786 #check if source and target identical
787 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
788 $errormessage=$Lang::tr
{'fwdfw err same'};
789 return $errormessage;
791 #get source and targetip address if possible
792 my ($sip,$scidr,$tip,$tcidr);
793 ($sip,$scidr)=&get_ip
("src","grp1");
794 ($tip,$tcidr)=&get_ip
("tgt","grp2");
795 #check same iprange in source and target
796 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
797 my $networkip1=&General
::getnetworkip
($sip,$scidr);
798 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
799 if ($scidr gt $tcidr){
800 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
801 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
803 }elsif($scidr eq $tcidr && $scidr eq '32'){
804 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
805 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
806 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
807 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
808 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
811 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
812 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
816 #When using source- or targetport, the protocol has to be TCP or UDP
817 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')){
818 $errormessage.=$Lang::tr
{'fwdfw err prot_port1'};
821 #when icmp selected, no targetport allowed
822 if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
823 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
826 #change protocol if prot not equal dest single service
827 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
828 foreach my $key (sort keys %customservice){
829 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
830 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
831 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
837 #check source and destination protocol if source manual and dest servicegroup
838 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
839 $fwdfwsettings{'PROT'} = '';
841 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
842 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
844 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
845 $fwdfwsettings{'USE_SRC_PORT'}='';
846 $fwdfwsettings{'SRC_PORT'}='';
847 #$fwdfwsettings{'USESRV'}='';
848 $fwdfwsettings{'TGT_PORT'}='';
849 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
850 foreach my $key (keys %icmptypes){
851 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
852 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
855 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
856 $fwdfwsettings{'USE_SRC_PORT'}='';
857 $fwdfwsettings{'SRC_PORT'}='';
858 $fwdfwsettings{'ICMP_TYPES'}='';
859 $fwdfwsettings{'USESRV'}='';
860 $fwdfwsettings{'TGT_PORT'}='';
861 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
862 $fwdfwsettings{'USE_SRC_PORT'}='';
863 $fwdfwsettings{'SRC_PORT'}='';
864 $fwdfwsettings{'ICMP_TYPES'}='';
865 $fwdfwsettings{'USESRV'}='';
866 $fwdfwsettings{'TGT_PORT'}='';
867 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
868 $fwdfwsettings{'USE_SRC_PORT'}='';
869 $fwdfwsettings{'SRC_PORT'}='';
870 $fwdfwsettings{'ICMP_TYPES'}='';
871 $fwdfwsettings{'USESRV'}='';
872 $fwdfwsettings{'TGT_PORT'}='';
873 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
874 $fwdfwsettings{'ICMP_TYPES'}='';
875 $fwdfwsettings{'PROT'} = '';
876 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
877 $fwdfwsettings{'ICMP_TYPES'}='';
882 my ($base1,$val1,$base2,$val2) = @_;
884 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
885 &dec_counter
($confignet,\
%customnetwork,$val1);
886 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
887 &dec_counter
($confighost,\
%customhost,$val1);
888 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
889 &dec_counter
($configgrp,\
%customgrp,$val1);
890 }elsif($base1 eq 'cust_srv'){
891 &dec_counter
($configsrv,\
%customservice,$val1);
892 }elsif($base1 eq 'cust_srvgrp'){
893 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
896 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
897 &inc_counter
($confignet,\
%customnetwork,$val2);
898 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
899 &inc_counter
($confighost,\
%customhost,$val2);
900 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
901 &inc_counter
($configgrp,\
%customgrp,$val2);
902 }elsif($base2 eq 'cust_srv'){
903 &inc_counter
($configsrv,\
%customservice,$val2);
904 }elsif($base2 eq 'cust_srvgrp'){
905 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
911 #Test if manual IP is part of static OpenVPN networks
912 &General
::readhasharray
("$configccdnet", \
%ccdnet);
913 foreach my $key (sort keys %ccdnet){
914 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
915 my $sub=&General
::iporsubtodec
($vpnsubnet);
916 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
920 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
921 # because if one creates a custom host with the ip, we need to check the color there!
922 # It does not make sense to check this here
924 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
925 # Is also checked in getcolor
927 # Test if manual ip is part of an IPsec Network is also checked in getcolor
937 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
938 foreach my $key (sort {$a <=> $b} keys %delhash){
939 if ($key == $fwdfwsettings{'key'}){
940 #check hosts/net and groups
941 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
942 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
943 #check services and groups
944 if ($delhash{$key}[11] eq 'ON'){
945 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
948 if ($key >= $fwdfwsettings{'key'}) {
950 if (exists $delhash{$next}) {
951 foreach my $i (0 .. $#{$delhash{$next}}) {
952 $delhash{$key}[$i] = $delhash{$next}[$i];
957 # Remove the very last entry.
958 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
959 delete $delhash{$last_key};
961 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
964 if($fwdfwsettings{'nobase'} ne 'on'){
971 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
972 foreach my $key (sort keys %configfwdfw){
974 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
977 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
986 &General
::readhasharray
($config, \
%hash);
987 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
988 if($hash{$key}[0] eq $val){
989 $pos=$#{$hash{$key}};
990 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
993 &General
::writehasharray
($config, \
%hash);
998 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
999 print "<class name='base'>$errormessage\n";
1000 print " </class>\n";
1001 &Header
::closebox
();
1007 my %hash=%{(shift)};
1010 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1011 if($hash{$key}[0] eq $val){
1012 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1014 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1024 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1025 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1026 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1027 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1028 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1029 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1030 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1031 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1032 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1033 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1034 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1035 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1036 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1037 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1038 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1039 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1040 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1041 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1042 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1044 <table width='100%' border='0'>
1045 <tr><td width='50%' valign='top'>
1046 <table width='100%' border='0'>
1047 <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;'>
1049 foreach my $network (sort keys %defaultNetworks)
1051 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1052 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1053 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1054 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1055 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1056 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1057 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1058 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1059 if ($ifaces{$defnet}){
1060 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1062 print ">$network</option>";
1065 print"</select></td></tr>";
1067 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1068 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;'>";
1069 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1070 print"</select></td>";
1073 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1074 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;'>";
1075 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1076 print"</select></td>";
1079 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1080 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;'>";
1081 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1082 if($helper ne $customgrp{$key}[0]){
1084 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1085 print ">$customgrp{$key}[0]</option>";
1087 $helper=$customgrp{$key}[0];
1089 print"</select></td>";
1091 #End left table. start right table (vpn)
1092 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1094 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1095 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;'>";
1096 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1097 print"</select></td></tr>";
1100 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1101 if ($ccdhost{$key}[33] ne '' ){
1102 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 '');
1104 print "<option value='$ccdhost{$key}[1]'";
1105 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1106 print ">$ccdhost{$key}[1]</option>";
1109 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1110 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>" ;
1112 if ($show eq '1'){$show='';print"</select></td></tr>";}
1114 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1115 if ($ccdhost{$key}[3] eq 'net'){
1116 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 '');
1118 print "<option value='$ccdhost{$key}[1]'";
1119 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1120 print ">$ccdhost{$key}[1]</option>";
1123 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1124 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>" ;
1126 if ($show eq '1'){$show='';print"</select></td></tr>";}
1128 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1129 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1130 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 '');
1133 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1134 print ">$ipsecconf{$key}[1]</option>";
1137 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1138 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>";
1140 if ($show eq '1'){$show='';print"</select></td></tr>";}
1143 print"</td></tr></table><br>";
1151 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1152 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1153 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1154 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1155 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1156 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1157 $a=$netsettings{'GREEN_NETADDRESS'};
1158 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1159 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1160 $a=$netsettings{'ORANGE_NETADDRESS'};
1161 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1162 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1163 $a=$netsettings{'BLUE_NETADDRESS'};
1164 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1165 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1166 &General
::readhash
("$configovpn",\
%ovpnsettings);
1167 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1168 $b=&General
::iporsubtocidr
($b);
1170 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1171 &General
::readhasharray
("$confignet", \
%customnetwork);
1172 foreach my $key (keys %customnetwork){
1173 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1174 $a=$customnetwork{$key}[1];
1175 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1178 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1179 &General
::readhasharray
("$confighost", \
%customhost);
1180 foreach my $key (keys %customhost){
1181 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1182 if ($customhost{$key}[1] eq 'ip'){
1183 ($a,$b)=split (/\//,$customhost{$key}[2]);
1184 $b=&General
::iporsubtocidr
($b);
1186 if ($grp eq 'grp2'){
1187 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1199 &General
::setup_default_networks
(\
%defaultNetworks);
1200 foreach my $network (sort keys %defaultNetworks)
1202 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1207 my %hash=%{(shift)};
1209 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1210 $hash{$key}[10]=~ s/\|/,/g;
1211 print": $hash{$key}[10]";
1212 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1213 print": <br>$hash{$key}[9] ";
1218 my %hash=%{(shift)};
1222 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1223 if($hash{$key}[14] eq 'cust_srv'){
1224 &General
::readhasharray
("$configsrv", \
%customservice);
1225 foreach my $i (sort keys %customservice){
1226 if($customservice{$i}[0] eq $hash{$key}[15]){
1227 $service = $customservice{$i}[0];
1230 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1231 $service=$hash{$key}[15];
1232 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1233 $hash{$key}[15]=~ s/\|/,/g;
1234 $service=$hash{$key}[15];
1241 sub get_serviceports
1245 &General
::readhasharray
("$configsrv", \
%customservice);
1246 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1251 if($type eq 'service'){
1252 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1253 if ($customservice{$key}[0] eq $name){
1254 push (@protocols,$customservice{$key}[2]);
1257 }elsif($type eq 'group'){
1258 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1259 if ($customservicegrp{$key}[0] eq $name){
1260 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1261 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1262 if($customservice{$key1}[2] eq 'TCP'){
1264 }elsif($customservice{$key1}[2] eq 'ICMP'){
1266 }elsif($customservice{$key1}[2] eq 'UDP'){
1274 if($tcp && $udp && $icmp){
1275 push (@protocols,"TCP,UDP, <br>ICMP");
1279 push (@protocols,"TCP");
1282 push (@protocols,"UDP");
1285 push (@protocols,"ICMP");
1294 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1296 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1297 foreach my $key (sort keys %$hash){
1298 if ($$hash{$key}[0] eq $val){
1299 $val=$$hash{$key}[2];
1304 if ($val eq 'GREEN'){
1305 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1307 }elsif ($val eq 'ORANGE'){
1308 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1310 }elsif ($val eq 'BLUE'){
1311 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1313 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1314 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1316 }elsif ($val eq 'IPFire' ){
1317 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1319 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1320 my ($sip,$scidr) = split ("/",$val);
1321 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1322 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1325 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1326 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1329 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1330 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1333 }elsif ($val eq 'Default IP'){
1334 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1337 #Check if a manual IP or custom host is part of a VPN
1338 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1339 #Check if IP is part of OpenVPN dynamic subnet
1340 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1341 my ($c,$d) = split("/",$val);
1342 if (&General
::IpInSubnet
($c,$a,$b)){
1343 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1346 #Check if IP is part of OpenVPN static subnet
1347 foreach my $key (sort keys %ccdnet){
1348 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1349 $b =&General
::iporsubtodec
($b);
1350 if (&General
::IpInSubnet
($c,$a,$b)){
1351 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1355 #Check if IP is part of OpenVPN N2N subnet
1356 foreach my $key (sort keys %ccdhost){
1357 if ($ccdhost{$key}[3] eq 'net'){
1358 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1359 if (&General
::IpInSubnet
($c,$a,$b)){
1360 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1365 #Check if IP is part of IPsec RW network
1366 if ($ipsecsettings{'RW_NET'} ne ''){
1367 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1368 $b=&General
::iporsubtodec
($b);
1369 if (&General
::IpInSubnet
($c,$a,$b)){
1370 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1374 #Check if IP is part of a IPsec N2N network
1375 foreach my $key (sort keys %ipsecconf){
1376 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1377 if (&General
::IpInSubnet
($c,$a,$b)){
1378 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1384 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'){
1385 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1388 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1389 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1393 foreach my $alias (sort keys %aliases)
1395 if ($val eq $alias){
1396 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1407 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1408 print "<class name='base'>$hint\n";
1409 print " </class>\n";
1410 &Header
::closebox
();
1417 my %hash=%{(shift)};
1421 &General
::readhasharray
($config, \
%hash);
1422 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1423 if($hash{$key}[0] eq $val){
1424 $pos=$#{$hash{$key}};
1425 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1428 &General
::writehasharray
($config, \
%hash);
1433 &General
::setup_default_networks
(\
%defaultNetworks);
1434 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1435 #read all configfiles
1436 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1437 &General
::readhasharray
("$confignet", \
%customnetwork);
1438 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1439 &General
::readhasharray
("$confighost", \
%customhost);
1440 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1441 &General
::readhasharray
("$configgrp", \
%customgrp);
1442 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1443 &General
::get_aliases
(\
%aliases);
1447 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1448 my $config=$fwdfwsettings{'config'};
1451 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1452 my $redip = <CONN1
>;
1454 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1455 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1456 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1457 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1458 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1459 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1460 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1461 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1462 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1463 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1464 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1465 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1466 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1467 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1468 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1469 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1470 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1471 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1472 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1473 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1474 #check if update and get values
1475 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1476 &General
::readhasharray
("$config", \
%hash);
1477 foreach my $key (sort keys %hash){
1479 if ($key eq $fwdfwsettings{'key'}){
1480 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1481 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1482 $fwdfwsettings{'chain'} = $hash{$key}[1];
1483 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1484 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1485 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1486 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1487 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1488 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1489 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1490 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1491 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1492 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1493 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1494 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1495 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1496 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1497 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1498 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1499 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1500 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1501 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1502 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1503 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1504 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1505 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1506 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1507 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1508 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1509 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1510 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1511 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1512 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1513 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1514 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1515 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1516 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1517 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1518 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1519 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1520 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1521 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1522 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1523 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1524 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1525 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1526 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1527 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1528 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1529 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1530 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1531 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1532 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1533 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1534 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1535 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1538 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1539 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1540 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1541 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1542 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1543 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1544 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1545 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1546 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1547 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1548 #check if manual ip (source) is orange network
1549 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1550 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1551 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1552 $fwdfwsettings{'oldorange'} ='on';
1556 $fwdfwsettings{'ACTIVE'}='ON';
1557 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1558 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1559 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1560 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1561 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1562 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1563 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1564 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1565 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1566 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1567 #check if manual ip (source) is orange network
1568 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1569 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1570 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1571 $fwdfwsettings{'oldorange'} ='on';
1575 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1576 print "<form method='post'>";
1577 &Header
::closebox
();
1578 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1579 #------SOURCE-------------------------------------------------------
1581 <table width='100%' border='0'>
1582 <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>
1584 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1585 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1586 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1587 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1588 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1589 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1590 if (! -z
"${General::swroot}/ethernet/aliases"){
1591 foreach my $alias (sort keys %aliases)
1593 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1598 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1600 &gen_dd_block
('src','grp1');
1602 &Header
::closebox
();
1603 #---SNAT / DNAT ------------------------------------------------
1604 &Header
::openbox
('100%', 'left', 'NAT');
1606 <table width='100%' border='0'>
1607 <tr><td width='1%'><input type='checkbox' name='USE_NAT' id='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'} onclick="toggle_elements('natpart')" ></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr></table>
1608 <div id="natpart" class="noscript">
1609 <table width=100%' border='0'><tr>
1610 <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>
1612 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1613 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1614 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1615 foreach my $alias (sort keys %aliases)
1617 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1619 print"</select></td></tr>";
1620 $fwdfwsettings{'dnatport'}=~ tr/|/,/;
1621 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>";
1622 print"<tr><td colspan='8'><br></td></tr>";
1624 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>";
1625 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1626 foreach my $alias (sort keys %aliases)
1628 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1630 foreach my $network (sort keys %defaultNetworks)
1632 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1633 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1634 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1635 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1636 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1637 print ">$network</option>";
1639 print"</select></td></tr></table>";
1640 print"</div><br><hr>";
1641 if ($fwdfwsettings{'USE_NAT'} ne 'ON'){
1642 print"<script language='JavaScript'>hide_elements('natpart');</script>";
1644 &Header
::closebox
();
1645 #---TARGET------------------------------------------------------
1646 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1648 <table width='100%' border='0'>
1649 <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>
1651 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1652 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1653 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1654 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1655 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1656 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1657 if (! -z
"${General::swroot}/ethernet/aliases"){
1658 foreach my $alias (sort keys %aliases)
1660 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1665 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1667 &gen_dd_block
('tgt','grp2');
1670 #---PROTOCOL------------------------------------------------------
1671 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1673 <table width='15%' border='0' style="float:left;">
1674 <tr><td><select name='PROT' id='PROT' onchange="getdropdown()">
1676 if ($fwdfwsettings{'PROT'} eq ''){
1677 print"<option value='' selected>$Lang::tr{'all'}</option>";
1679 print"<option value=''>$Lang::tr{'all'}</option>";
1681 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1683 if ($_ eq $fwdfwsettings{'PROT'})
1685 print"<option selected>$_</option>";
1687 print"<option>$_</option>";
1690 print"</select></td></tr></table>";
1692 <div id="PROTOKOLL" class="noscript"><table width='30%' border='0' style="float:left;"><tr><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='min-width:230px;'>
1694 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1695 print"<option>All ICMP-Types</option>";
1696 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1697 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1698 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1700 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1705 </table></div><br><br><br>
1707 if ($fwdfwsettings{'PROT'} ne 'ICMP'){
1708 print"<script language='JavaScript'>hide_elements('PROTOKOLL');</script>";
1712 <table width='100%'><tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></table>
1713 <table width='100%' border='0'>
1714 <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'} onclick="toggle_elements('srcport')"></td>
1715 <td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td></tr></table>
1716 <div id="srcport" class="noscript"><table width='100%' border='0'><tr>
1717 <td width='70%' nowrap='nowrap' align='right'>$Lang::tr{'fwdfw man port'}</td>
1719 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1721 <td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1724 if ($fwdfwsettings{'USE_SRC_PORT'} ne 'ON'){
1725 print"<script language='JavaScript'>hide_elements('srcport');</script>";
1729 <hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '><br>
1730 <table width='100%' border='0'>
1731 <tr><td width='1%'><input type='checkbox' name='USESRV' value='ON' $checked{'USESRV'}{'ON'} onclick="toggle_elements('targetport')"></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td></tr></table>
1732 <div id="targetport" class="noscript"><table width='100%' border='0'><tr><td width='80%'></td><td width='1%'><input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td width='1%' colspan='2'><select name='cust_srv' style='min-width:230px;' >
1734 &General
::readhasharray
("$configsrv", \
%customservice);
1735 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1737 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1738 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1742 <tr><td></td><td><input type='radio' name='grp3' id='cust_srvgrp' value='cust_srvgrp' $checked{'grp3'}{'cust_srvgrp'}></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust srvgrp'}</td><td colspan='2'><select name='cust_srvgrp' style='min-width:230px;' >
1744 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1746 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1747 if ($helper ne $customservicegrp{$key}[0]){
1749 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1750 print">$customservicegrp{$key}[0]</option>";
1752 $helper=$customservicegrp{$key}[0];
1756 <tr><td></td><td><input type='radio' name='grp3' id='TGT_PORT' value='TGT_PORT' $checked{'grp3'}{'TGT_PORT'}></td><td>$Lang::tr{'fwdfw man port'}</td>
1758 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1760 <td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' onclick='checkradio(\"#TGT_PORT\")'></td></tr>
1761 </table></div><br><hr>
1763 if ($fwdfwsettings{'USESRV'} ne 'ON'){
1764 print"<script language='JavaScript'>hide_elements('targetport');</script>";
1766 if ($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
1767 print"<script language='JavaScript'>hide_elements('PROTOKOLL');</script>";
1770 #---Activate/logging/remark-------------------------------------
1771 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1773 <table width='100%' border='0'>
1774 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1776 foreach ("ACCEPT","DROP","REJECT")
1778 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1779 print"<option value='$_'";
1780 print " selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1781 print">$Lang::tr{'fwdfw '.$_}</option>";
1783 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1784 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1786 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1788 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1790 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1794 print"</select></td></tr>";
1795 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>";
1796 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1797 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1798 for (my $count =1; $count <= $sum; $count++){
1799 print"<option value='$count' ";
1800 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1801 print">$count</option>";
1803 print"</select></td></tr>";
1805 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1809 </table><table width='100%'>
1810 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1811 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1814 &Header
::closebox
();
1815 #---ADD TIMEFRAME-----------------------------------------------
1816 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1818 <table width='70%' border='0'>
1819 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='9'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1820 <tr><td colspan='10'> </td></tr>
1822 <td align='left' >$Lang::tr{'time'}: </td>
1823 <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>
1824 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1825 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1828 <td align='right'></td>
1829 <td width='1%' align='left'><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
1830 <td width='1%' align='left'><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
1831 <td width='1%' align='left'><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
1832 <td width='1%' align='left'><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
1833 <td width='1%' align='left'><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
1834 <td width='1%' align='left'><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
1835 <td width='15%' align='left'><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
1836 <td><select name='TIME_FROM'>
1838 for (my $i=0;$i<=23;$i++) {
1839 $i = sprintf("%02s",$i);
1840 for (my $j=0;$j<=45;$j+=15) {
1841 $j = sprintf("%02s",$j);
1842 my $time = $i.":".$j;
1843 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1848 <td><select name='TIME_TO'>
1850 for (my $i=0;$i<=23;$i++) {
1851 $i = sprintf("%02s",$i);
1852 for (my $j=0;$j<=45;$j+=15) {
1853 $j = sprintf("%02s",$j);
1854 my $time = $i.":".$j;
1855 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1859 </select></td></tr></table><br><hr>
1861 #---ACTION------------------------------------------------------
1862 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1864 <table border='0' width='100%'>
1865 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1866 <input type='hidden' name='config' value='$config' >
1867 <input type='hidden' name='ACTION' value='saverule' ></form>
1868 <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>
1874 <table border='0' width='100%'>
1875 <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'}'>
1876 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1877 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1878 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1879 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1880 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1881 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1882 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1883 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1884 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1885 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1886 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1887 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1888 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1889 <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>
1893 &Header
::closebox
();
1899 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1900 foreach my $key (sort keys %uphash){
1901 if ($key eq $fwdfwsettings{'key'}) {
1903 if (exists $uphash{$last}){
1905 foreach my $y (0 .. $#{$uphash{$last}}) {
1906 $tmp{0}[$y] = $uphash{$last}[$y];
1908 #copy active rule to last
1909 foreach my $i (0 .. $#{$uphash{$last}}) {
1910 $uphash{$last}[$i] = $uphash{$key}[$i];
1912 #copy saved rule to actual position
1913 foreach my $x (0 .. $#{$tmp{0}}) {
1914 $uphash{$key}[$x] = $tmp{0}[$x];
1919 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1926 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1927 foreach my $key (sort keys %downhash){
1928 if ($key eq $fwdfwsettings{'key'}) {
1929 my $next = $key + 1;
1930 if (exists $downhash{$next}){
1932 foreach my $y (0 .. $#{$downhash{$next}}) {
1933 $tmp{0}[$y] = $downhash{$next}[$y];
1935 #copy active rule to next
1936 foreach my $i (0 .. $#{$downhash{$next}}) {
1937 $downhash{$next}[$i] = $downhash{$key}[$i];
1939 #copy saved rule to actual position
1940 foreach my $x (0 .. $#{$tmp{0}}) {
1941 $downhash{$key}[$x] = $tmp{0}[$x];
1946 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1951 if (!-f
"${General::swroot}/forward/reread"){
1952 system("touch ${General::swroot}/forward/reread");
1953 system("touch ${General::swroot}/fwhosts/reread");
1958 system("/usr/local/bin/forwardfwctrl");
1959 if ( -f
"${General::swroot}/forward/reread"){
1960 system("rm ${General::swroot}/forward/reread");
1961 system("rm ${General::swroot}/fwhosts/reread");
1968 &General
::readhasharray
("$config", $hash);
1969 if (!$errormessage){
1970 ################################################################
1971 #check if we change an INPUT rule to a OUTGOING
1972 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
1973 &changerule
($configinput);
1976 #check if we change an INPUT rule to a FORWARD
1977 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1978 &changerule
($configinput);
1981 ################################################################
1982 #check if we change an OUTGOING rule to an INPUT
1983 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
1984 &changerule
($configoutgoing);
1987 #check if we change an OUTGOING rule to a FORWARD
1988 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1989 &changerule
($configoutgoing);
1992 ################################################################
1993 #check if we change a FORWARD rule to an INPUT
1994 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
1995 &changerule
($configfwdfw);
1998 #check if we change a FORWARD rule to an OUTGOING
1999 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
2000 &changerule
($configfwdfw);
2003 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
2004 my $key = &General
::findhasharraykey
($hash);
2005 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2006 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2007 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2008 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2009 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2010 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2011 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2012 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2013 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2014 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2015 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2016 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2017 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2018 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2019 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2020 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2021 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2022 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2023 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2024 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2025 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2026 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2027 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2028 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2029 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2030 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2031 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2032 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2033 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2034 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2035 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2036 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2037 &General
::writehasharray
("$config", $hash);
2039 foreach my $key (sort {$a <=> $b} keys %$hash){
2040 if($key eq $fwdfwsettings{'key'}){
2041 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2042 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2043 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2044 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2045 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2046 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2047 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2048 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2049 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2050 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2051 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2052 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2053 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2054 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2055 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2056 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2057 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2058 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2059 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2060 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2061 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2062 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2063 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2064 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2065 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2066 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2067 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2068 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2069 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2070 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2071 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2072 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2077 &General
::writehasharray
("$config", $hash);
2078 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2080 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2081 for (my $z=0;$z<$val;$z++){
2082 foreach my $key (sort {$a <=> $b} keys %$hash){
2083 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2085 if (exists $$hash{$last}){
2087 foreach my $y (0 .. $#{$$hash{$last}}) {
2088 $tmp{0}[$y] = $$hash{$last}[$y];
2090 #copy active rule to last
2091 foreach my $i (0 .. $#{$$hash{$last}}) {
2092 $$hash{$last}[$i] = $$hash{$key}[$i];
2094 #copy saved rule to actual position
2095 foreach my $x (0 .. $#{$tmp{0}}) {
2096 $$hash{$key}[$x] = $tmp{0}[$x];
2101 $fwdfwsettings{'oldrulenumber'}--;
2103 &General
::writehasharray
("$config", $hash);
2105 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2107 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2108 for (my $z=0;$z<$val;$z++){
2109 foreach my $key (sort {$a <=> $b} keys %$hash){
2110 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2111 my $next = $key + 1;
2112 if (exists $$hash{$next}){
2114 foreach my $y (0 .. $#{$$hash{$next}}) {
2115 $tmp{0}[$y] = $$hash{$next}[$y];
2117 #copy active rule to next
2118 foreach my $i (0 .. $#{$$hash{$next}}) {
2119 $$hash{$next}[$i] = $$hash{$key}[$i];
2121 #copy saved rule to actual position
2122 foreach my $x (0 .. $#{$tmp{0}}) {
2123 $$hash{$key}[$x] = $tmp{0}[$x];
2128 $fwdfwsettings{'oldrulenumber'}++;
2130 &General
::writehasharray
("$config", $hash);
2137 # Checks a hostname against RFC1035
2140 # Each part should be at least two characters in length
2141 # but no more than 63 characters
2142 if (length ($remark) < 1 || length ($remark) > 255) {
2144 # Only valid characters are a-z, A-Z, 0-9 and -
2145 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2147 # First character can only be a letter or a digit
2148 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2150 # Last character can only be a letter or a digit
2151 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2157 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2158 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2159 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'fwdfw xt access'} );
2160 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2169 &General
::get_aliases
(\
%aliases);
2170 &General
::readhasharray
("$confighost", \
%customhost);
2171 &General
::readhasharray
("$config", $hash);
2172 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2173 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2175 &Header
::openbox
('100%', 'left',$title);
2183 print"<b>$title1</b><br>";
2184 print"<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
2185 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>";
2186 foreach my $key (sort {$a <=> $b} keys %$hash){
2189 #check if vpn hosts/nets have been deleted
2190 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2191 push (@tmpsrc,$$hash{$key}[4]);
2193 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2194 push (@tmpsrc,$$hash{$key}[6]);
2196 foreach my $host (@tmpsrc){
2197 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2198 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2200 &disable_rule
($key);
2203 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2204 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2206 &disable_rule
($key);
2209 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2210 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2212 &disable_rule
($key);
2215 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2216 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2218 &disable_rule
($key);
2223 $$hash{'ACTIVE'}=$$hash{$key}[2];
2225 if($coloryellow eq 'on'){
2226 print"<tr bgcolor='$color{'color14'}' >";
2228 }elsif($coloryellow eq ''){
2230 $color="$color{'color22'}";
2233 $color="$color{'color20'}";
2236 print"<tr bgcolor='$color' >";
2239 <td align='right' width='18'><b>$key </b></td>
2242 if ($$hash{$key}[0] eq 'ACCEPT'){
2245 $rulecolor=$color{'color17'};
2246 }elsif($$hash{$key}[0] eq 'DROP'){
2249 $rulecolor=$color{'color25'};
2250 }elsif($$hash{$key}[0] eq 'REJECT'){
2253 $rulecolor=$color{'color16'};
2255 print"<td bgcolor='$rulecolor' align='center' width='10'><span title='$tooltip'><b>$ruletype</b></span></td>";
2258 if ($$hash{$key}[8]){
2259 push (@protocols,$$hash{$key}[8]);
2260 }elsif($$hash{$key}[14] eq 'cust_srv'){
2261 &get_serviceports
("service",$$hash{$key}[15]);
2262 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2263 &get_serviceports
("group",$$hash{$key}[15]);
2265 push (@protocols,$Lang::tr
{'all'});
2267 my $protz=join(",",@protocols);
2268 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2269 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2270 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2271 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2272 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2277 print"<td align='center'>$protz</td>";
2282 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2283 print"<td align='center' width='160' $tdcolor>";
2284 if ($$hash{$key}[3] eq 'ipfire_src'){
2285 $ipfireiface='Interface ';
2287 if ($$hash{$key}[3] eq 'std_net_src'){
2288 print &get_name
($$hash{$key}[4]);
2289 }elsif ($$hash{$key}[3] eq 'src_addr'){
2290 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2291 if ($split2 eq '32'){
2294 print $$hash{$key}[4];
2296 }elsif ($$hash{$key}[4] eq 'RED1'){
2297 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2299 print "$$hash{$key}[4]";
2303 &getsrcport
(\
%$hash,$key);
2304 #Is this a SNAT rule?
2305 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2306 my $net=&get_name
($$hash{$key}[29]);
2307 if ( ! $net){ $net=$$hash{$key}[29];}
2309 if ($$hash{$key}[30] ne ''){
2310 print": $$hash{$key}[30]";
2313 if ($$hash{$key}[17] eq 'ON'){
2314 $log="/images/on.gif";
2316 $log="/images/off.gif";
2321 <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 ;'/>
2322 <input type='hidden' name='key' value='$key' />
2323 <input type='hidden' name='config' value='$config' />
2324 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2328 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2330 <td align='center' width='160' $tdcolor>
2332 #Is this a DNAT rule?
2333 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2334 print "Firewall ($$hash{$key}[29])";
2335 if($$hash{$key}[30] ne ''){
2336 $$hash{$key}[30]=~ tr/|/,/;
2337 print": $$hash{$key}[30]";
2341 if ($$hash{$key}[5] eq 'ipfire'){
2342 $ipfireiface='Interface';
2344 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' ){
2345 if ($$hash{$key}[6] eq 'RED1'){
2346 print "$ipfireiface $Lang::tr{'red1'}";
2347 }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL')
2349 print "$ipfireiface ".&get_name
($$hash{$key}[6]);
2351 print $$hash{$key}[6];
2353 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2354 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2355 if ($split2 eq '32'){
2358 print $$hash{$key}[6];
2361 print "$$hash{$key}[6]";
2365 &gettgtport
(\
%$hash,$key);
2368 if($$hash{$key}[2] eq 'ON'){
2369 $gif="/images/on.gif"
2372 $gif="/images/off.gif"
2375 <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;' />
2376 <input type='hidden' name='key' value='$key' />
2377 <input type='hidden' name='config' value='$config' />
2378 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2380 <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;' />
2381 <input type='hidden' name='key' value='$key' />
2382 <input type='hidden' name='config' value='$config' />
2383 <input type='hidden' name='ACTION' value='editrule' />
2385 <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;' />
2386 <input type='hidden' name='key' value='$key' />
2387 <input type='hidden' name='config' value='$config' />
2388 <input type='hidden' name='ACTION' value='copyrule' />
2390 <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;' />
2391 <input type='hidden' name='key' value='$key' />
2392 <input type='hidden' name='config' value='$config' />
2393 <input type='hidden' name='ACTION' value='deleterule' />
2396 if (exists $$hash{$key-1}){
2398 <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;' />
2399 <input type='hidden' name='key' value='$key' />
2400 <input type='hidden' name='config' value='$config' />
2401 <input type='hidden' name='ACTION' value='moveup' />
2405 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2407 if (exists $$hash{$key+1}){
2409 <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;' />
2410 <input type='hidden' name='key' value='$key' />
2411 <input type='hidden' name='config' value='$config' />
2412 <input type='hidden' name='ACTION' value='movedown' />
2416 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2419 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2420 print"<tr bgcolor='$color'>";
2421 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='10'> $$hash{$key}[16]</td></tr>";
2423 if ($$hash{$key}[18] eq 'ON'){
2425 if ($$hash{$key}[18] eq 'ON'){
2427 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2428 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2429 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2430 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2431 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2432 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2433 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2434 my $weekdays=join(",",@days);
2436 print"<tr bgcolor='$color'>";
2437 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27] </td></tr>";
2441 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2445 print "<table width='100%'rules='cols' border='1'>";
2447 if ($config eq '/var/ipfire/forward/config'){
2448 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2449 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2450 $col="bgcolor='darkred'";
2452 $col="bgcolor='green'";
2454 &show_defaultrules
($col,$pol);
2455 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2456 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2457 $col="bgcolor='darkred'";
2458 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>";
2460 $col="bgcolor='green'";
2461 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>";
2464 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>";
2469 &Header
::closebox
();
2471 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2472 print "<b>$title1</b><br>";
2473 print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table>";
2475 if ($config eq '/var/ipfire/forward/config'){
2476 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2477 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2478 $col="bgcolor='darkred'";
2480 $col="bgcolor='green'";
2482 &show_defaultrules
($col,$pol);
2483 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2484 print "<table width='100%' rules='cols' border='1'>";
2485 my $pol='fwdfw '.$fwdfwsettings{'POLICY1'};
2486 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2487 $col="bgcolor='darkred'";
2488 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>";
2490 $col="bgcolor='green'";
2491 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>";
2494 print "<table width='100%' rules='cols' border='1'>";
2495 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>";
2497 print"</table><br><br>";
2501 &Header
::closebigbox
();
2502 &Header
::closepage
();
2504 sub show_defaultrules
2508 #STANDARD RULES (From WIKI)
2510 if ($col eq "bgcolor='green'"){
2511 print "<br><table width='100%' rules='cols' border='1' >";
2512 my $blue = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::blue_used
());
2513 my $orange = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::orange_used
());
2514 my $blue1 = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::blue_used
());
2515 my $orange1 = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::orange_used
());
2516 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>";
2517 print"<td align='center'>$orange1</td>" if (&Header
::orange_used
());
2518 print"<td align='center'>$blue1</td>" if (&Header
::blue_used
());
2520 if (&Header
::orange_used
()){
2521 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>";
2522 print"<td align='center'>$blue</td>" if (&Header
::blue_used
());
2525 if (&Header
::blue_used
()){
2526 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>";
2527 print"<td align='center'>$orange</td>" if (&Header
::orange_used
());
2528 print"<td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
2531 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>";
2532 }elsif($col eq "bgcolor='darkred'"){
2533 print "<table width='100%' rules='cols' border='1' >";
2534 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>";