]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
4c70a2503d30a71af81f5256e8eb7bf3043dcc21
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';
128 function hide_elements()
130 var elementNames = hide_elements.arguments;
131 for (var i=0; i<elementNames.length; i++)
133 var elementName = elementNames[i];
134 document.getElementById(elementName).style.display='none';
137 function getdropdown()
139 d = document.getElementById("PROT").value;
142 document.getElementById('PROTOKOLL').style.display='block';
146 document.getElementById('PROTOKOLL').style.display='none';
154 if ($fwdfwsettings{'ACTION'} eq 'saverule')
156 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
157 &General
::readhasharray
("$configinput", \
%configinputfw);
158 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
159 $errormessage=&checksource
;
160 if(!$errormessage){&checktarget
;}
161 if(!$errormessage){&checkrule
;}
162 #check if manual ip (source) is orange network
163 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
164 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
165 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
170 if( ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'ORANGE' || $checkorange eq 'on') && $fwdfwsettings{'grp2'} eq 'ipfire'){
171 $errormessage.=$Lang::tr
{'fwdfw useless rule'}."<br>";
173 #check if we try to break rules
174 if( $fwdfwsettings{'grp1'} eq 'ipfire_src' && $fwdfwsettings{'grp2'} eq 'ipfire'){
175 $errormessage=$Lang::tr
{'fwdfw err same'};
178 if($fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ORANGE'){
179 $fwdfwsettings{'config'}=$configinput;
180 $fwdfwsettings{'chain'} = 'INPUTFW';
181 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
182 #check if we have an identical rule already
183 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
184 foreach my $key (sort keys %configinputfw){
185 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'}"
186 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]"){
187 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
188 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
190 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
191 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
193 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
194 $fwdfwsettings{'nosave'} = 'on';
199 #check Rulepos on new Rule
200 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
201 $fwdfwsettings{'oldrulenumber'}=$maxkey;
202 foreach my $key (sort keys %configinputfw){
203 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'}"
204 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]"){
205 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
209 #check if we just close a rule
210 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'}) {
211 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
213 $fwdfwsettings{'nosave2'} = 'on';
217 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
218 if ($fwdfwsettings{'nobase'} ne 'on'){
219 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
221 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
222 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
223 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
224 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
225 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
226 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
228 if($fwdfwsettings{'nosave2'} ne 'on'){
229 &saverule
(\
%configinputfw,$configinput);
232 }elsif($fwdfwsettings{'grp1'} eq 'ipfire_src' ){
234 $fwdfwsettings{'config'}=$configoutgoing;
235 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
236 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
237 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
238 foreach my $key (sort keys %configoutgoingfw){
239 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'}"
240 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]"){
241 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
242 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
244 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
245 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
247 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
248 $fwdfwsettings{'nosave'} = 'on';
253 #check Rulepos on new Rule
254 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
255 print"CHECK OUTGOING DOPPELTE REGEL<br>";
256 $fwdfwsettings{'oldrulenumber'}=$maxkey;
257 foreach my $key (sort keys %configoutgoingfw){
258 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'}"
259 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]"){
260 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
264 #check if we just close a rule
265 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'}) {
266 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
267 $fwdfwsettings{'nosave2'} = 'on';
273 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
274 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
275 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
276 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
277 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
278 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
279 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
280 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
282 if ($fwdfwsettings{'nobase'} eq 'on'){
283 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
285 if ($fwdfwsettings{'nosave2'} ne 'on'){
286 &saverule
(\
%configoutgoingfw,$configoutgoing);
291 $fwdfwsettings{'config'}=$configfwdfw;
292 $fwdfwsettings{'chain'} = 'FORWARDFW';
293 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
294 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
295 #check if we have an identical rule already
296 foreach my $key (sort keys %configfwdfw){
297 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'}"
298 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]"){
299 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
300 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' ){
302 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
303 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
305 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
306 $fwdfwsettings{'nosave'} = 'on';
311 #check Rulepos on new Rule
312 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
313 $fwdfwsettings{'oldrulenumber'}=$maxkey;
314 foreach my $key (sort keys %configfwdfw){
315 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'}"
316 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]"){
317 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
321 #check if we just close a rule
322 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'}) {
323 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
324 $fwdfwsettings{'nosave2'} = 'on';
330 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
331 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
332 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
333 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
334 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
335 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
336 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
337 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
339 if ($fwdfwsettings{'nobase'} eq 'on'){
340 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
342 if ($fwdfwsettings{'nosave2'} ne 'on'){
343 &saverule
(\
%configfwdfw,$configfwdfw);
350 if($fwdfwsettings{'nosave2'} ne 'on'){
356 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
360 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
363 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
364 foreach my $key (sort keys %togglehash){
365 if ($key eq $fwdfwsettings{'key'}){
366 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
369 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
373 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
376 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
377 foreach my $key (sort keys %togglehash){
378 if ($key eq $fwdfwsettings{'key'}){
379 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
382 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
386 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
391 if ($fwdfwsettings{'ACTION'} eq 'editrule')
393 $fwdfwsettings{'updatefwrule'}='on';
396 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
400 if ($fwdfwsettings{'ACTION'} eq 'moveup')
405 if ($fwdfwsettings{'ACTION'} eq 'movedown')
410 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
412 $fwdfwsettings{'copyfwrule'}='on';
415 if ($fwdfwsettings{'ACTION'} eq '' or $fwdfwsettings{'ACTION'} eq 'reset')
423 if (-f
"${General::swroot}/forward/reread"){
424 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>";
426 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw menu'});
427 print "<form method='post'>";
428 print "<table border='0'>";
429 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
430 print"</tr></table></form><hr>";
442 $fwdfwsettings{'updatefwrule'}='';
443 $fwdfwsettings{'config'}=$oldchain;
444 $fwdfwsettings{'nobase'}='on';
446 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
447 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
452 #check ip-address if manual
453 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
454 #check if ip with subnet
455 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
456 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
457 $subnet = &General
::iporsubtocidr
($subnet);
458 $fwdfwsettings{'isip'}='on';
461 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
462 $ip=$fwdfwsettings{'src_addr'};
464 $fwdfwsettings{'isip'}='on';
467 if ($fwdfwsettings{'isip'} ne 'on'){
468 if (&General
::validmac
($fwdfwsettings{'src_addr'})){
469 $fwdfwsettings{'ismac'}='on';
472 if ($fwdfwsettings{'isip'} eq 'on'){
473 ##check if ip is valid
474 if (! &General
::validip
($ip)){
475 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
476 return $errormessage;
478 #check and form valid IP
479 $ip=&General
::ip2dec
($ip);
480 $ip=&General
::dec2ip
($ip);
481 #check if net or broadcast
482 $fwdfwsettings{'src_addr'}="$ip/$subnet";
483 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
484 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
485 return $errormessage;
488 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
489 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
490 return $errormessage;
492 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
493 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
494 return $errormessage;
498 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
499 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
500 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
504 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
506 #change dashes with :
509 push(@values,"1:65535");
512 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
513 push(@values,"1:$2");
516 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/ ) {
517 push(@values,"$1:65535");
520 $errormessage .= &General
::validportrange
($_, 'destination');
525 if (&General
::validport
($_)){
532 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
534 return $errormessage;
539 &General
::readhasharray
("$configsrv", \
%customservice);
540 #check DNAT settings (has to be single Host and single Port or portrange)
541 if ($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat'){
542 if($fwdfwsettings{'grp2'} eq 'tgt_addr' || $fwdfwsettings{'grp2'} eq 'cust_host_tgt' || $fwdfwsettings{'grp2'} eq 'ovpn_host_tgt'){
543 if ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'dnatport'} eq ''){
544 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
545 return $errormessage;
547 #check if manual ip is a single Host (if set)
548 if ($fwdfwsettings{'grp2'} eq 'tgt_addr'){
549 my @tmp= split (/\./,$fwdfwsettings{$fwdfwsettings{'grp2'}});
550 my @tmp1= split ("/",$tmp[3]);
551 if (($tmp1[0] eq "0") || ($tmp1[0] eq "255"))
553 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
554 return $errormessage;
557 #check if Port is a single Port or portrange
558 if ($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
559 if(($fwdfwsettings{'PROT'} ne 'TCP'|| $fwdfwsettings{'PROT'} ne 'UDP') && $fwdfwsettings{'TGT_PORT'} eq ''){
560 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
561 return $errormessage;
563 if (($fwdfwsettings{'PROT'} eq 'TCP'|| $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'TGT_PORT'})){
564 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
565 return $errormessage;
569 $errormessage=$Lang::tr
{'fwdfw dnat error'}."<br>";
570 return $errormessage;
573 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
574 #check if ip with subnet
575 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
576 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
577 $subnet = &General
::iporsubtocidr
($subnet);
580 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
581 $ip=$fwdfwsettings{'tgt_addr'};
584 #check if ip is valid
585 if (! &General
::validip
($ip)){
586 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
587 return $errormessage;
589 #check and form valid IP
590 $ip=&General
::ip2dec
($ip);
591 $ip=&General
::dec2ip
($ip);
592 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
593 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
594 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
595 return $errormessage;
597 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
598 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
599 return $errormessage;
602 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
604 if ($fwdfwsettings{'USESRV'} eq 'ON'){
605 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
606 $fwdfwsettings{'TGT_PROT'}='';
607 $fwdfwsettings{'ICMP_TGT'}='';
608 $fwdfwsettings{'TGT_PORT'}='';
610 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
611 $fwdfwsettings{'TGT_PROT'}='';
612 $fwdfwsettings{'ICMP_TGT'}='';
613 $fwdfwsettings{'TGT_PORT'}='';
614 #check target service
615 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
616 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
619 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
620 if ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP'){
621 if ($fwdfwsettings{'TGT_PORT'} ne ''){
622 if ($fwdfwsettings{'TGT_PORT'} =~ "," && $fwdfwsettings{'USE_NAT'} && $fwdfwsettings{'nat'} eq 'dnat') {
623 $errormessage=$Lang::tr
{'fwdfw dnat porterr'}."<br>";
624 return $errormessage;
626 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
630 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
632 #change dashes with :
635 push(@values,"1:65535");
638 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
639 push(@values,"1:$2");
642 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
643 push(@values,"$1:65535");
646 $errormessage .= &General
::validportrange
($_, 'destination');
651 if (&General
::validport
($_)){
657 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
659 }elsif ($fwdfwsettings{'PROT'} eq 'GRE'){
660 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
661 $fwdfwsettings{'TGT_PORT'} = '';
662 $fwdfwsettings{'ICMP_TGT'} = '';
663 }elsif ($fwdfwsettings{'PROT'} eq 'ESP'){
664 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
665 $fwdfwsettings{'TGT_PORT'} = '';
666 $fwdfwsettings{'ICMP_TGT'}='';
667 }elsif ($fwdfwsettings{'PROT'} eq 'AH'){
668 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
669 $fwdfwsettings{'TGT_PORT'} = '';
670 $fwdfwsettings{'ICMP_TGT'}='';
671 }elsif ($fwdfwsettings{'PROT'} eq 'ICMP'){
672 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
673 $fwdfwsettings{'TGT_PORT'} = '';
678 if ($fwdfwsettings{'USESRV'} ne 'ON'){
679 $fwdfwsettings{'grp3'}='';
680 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
681 $fwdfwsettings{'ICMP_TGT'}='';
684 if($fwdfwsettings{'TIME'} eq 'ON'){
685 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 ''){
686 $errormessage=$Lang::tr
{'fwdfw err time'};
687 return $errormessage;
690 return $errormessage;
695 if($fwdfwsettings{'USE_NAT'} eq 'ON' && $fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
696 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\-(\d+)$/) {
697 $fwdfwsettings{'dnatport'} =~ tr/-/:/;
698 if ($fwdfwsettings{'dnatport'} eq "*") {
699 $fwdfwsettings{'dnatport'}="1:65535";
701 if ($fwdfwsettings{'dnatport'} =~ /^(\D)\:(\d+)$/) {
702 $fwdfwsettings{'dnatport'} = "1:$2";
704 if ($fwdfwsettings{'dnatport'} =~ /^(\d+)\:(\D)$/) {
705 $fwdfwsettings{'dnatport'} ="$1:65535";
710 if ($val =~ "," || $val>65536 || $val<0){
717 #check valid port for NAT
718 if($fwdfwsettings{'USE_NAT'} eq 'ON'){
719 #if no port is given in nat area, take target host port
720 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'grp3'} eq 'TGT_PORT' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$fwdfwsettings{'TGT_PORT'};}
721 #check if port given in nat area is a single valid port or portrange
722 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'TGT_PORT'} ne '' && !&check_natport
($fwdfwsettings{'dnatport'})){
723 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
724 }elsif($fwdfwsettings{'USESRV'} eq 'ON' && $fwdfwsettings{'grp3'} eq 'cust_srv'){
726 #get servcie Protocol and Port
727 foreach my $key (sort keys %customservice){
728 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]){
729 if ($customservice{$key}[2] ne 'TCP' && $customservice{$key}[2] ne 'UDP'){
730 $errormessage=$Lang::tr
{'fwdfw target'}.": ".$Lang::tr
{'fwdfw dnat porterr'}."<br>";
732 $custsrvport= $customservice{$key}[1];
735 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} eq ''){$fwdfwsettings{'dnatport'}=$custsrvport;}
737 #check if DNAT port is multiple
738 if($fwdfwsettings{'nat'} eq 'dnat' && $fwdfwsettings{'dnatport'} ne ''){
739 my @parts=split(",",$fwdfwsettings{'dnatport'});
743 if ($_ =~ /^(\d+)\-(\d+)$/ || $_ =~ /^(\d+)\:(\d+)$/) {
745 #change dashes with :
748 push(@values,"1:65535");
751 if ($_ =~ /^(\D)\:(\d+)$/ || $_ =~ /^(\D)\-(\d+)$/) {
752 push(@values,"1:$2");
755 if ($_ =~ /^(\d+)\:(\D)$/ || $_ =~ /^(\d+)\-(\D)$/) {
756 push(@values,"$1:65535");
759 $errormessage .= &General
::validportrange
($_, 'destination');
764 if (&General
::validport
($_)){
771 $fwdfwsettings{'dnatport'}=join("|",@values);
775 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
776 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
778 #check if source and target identical
779 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
780 $errormessage=$Lang::tr
{'fwdfw err same'};
781 return $errormessage;
783 #get source and targetip address if possible
784 my ($sip,$scidr,$tip,$tcidr);
785 ($sip,$scidr)=&get_ip
("src","grp1");
786 ($tip,$tcidr)=&get_ip
("tgt","grp2");
787 #check same iprange in source and target
788 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
789 my $networkip1=&General
::getnetworkip
($sip,$scidr);
790 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
791 if ($scidr gt $tcidr){
792 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
793 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
795 }elsif($scidr eq $tcidr && $scidr eq '32'){
796 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
797 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
798 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
799 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
800 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
803 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
804 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
808 #When using source- or targetport, the protocol has to be TCP or UDP
809 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')){
810 $errormessage.=$Lang::tr
{'fwdfw err prot_port1'};
813 #when icmp selected, no targetport allowed
814 if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
815 $errormessage.=$Lang::tr
{'fwdfw err prot_port'};
818 #change protocol if prot not equal dest single service
819 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
820 foreach my $key (sort keys %customservice){
821 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
822 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
823 $fwdfwsettings{'PROT'} = $customservice{$key}[2];
829 #check source and destination protocol if source manual and dest servicegroup
830 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
831 $fwdfwsettings{'PROT'} = '';
833 #ATTENTION: $fwdfwsetting{'TGT_PROT'} deprecated since 30.09.2013
834 $fwdfwsettings{'TGT_PROT'}=''; #Set field empty (deprecated)
836 if ($fwdfwsettings{'PROT'} eq 'ICMP'){
837 $fwdfwsettings{'USE_SRC_PORT'}='';
838 $fwdfwsettings{'SRC_PORT'}='';
839 #$fwdfwsettings{'USESRV'}='';
840 $fwdfwsettings{'TGT_PORT'}='';
841 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
842 foreach my $key (keys %icmptypes){
843 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
844 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
847 }elsif($fwdfwsettings{'PROT'} eq 'GRE'){
848 $fwdfwsettings{'USE_SRC_PORT'}='';
849 $fwdfwsettings{'SRC_PORT'}='';
850 $fwdfwsettings{'ICMP_TYPES'}='';
851 $fwdfwsettings{'USESRV'}='';
852 $fwdfwsettings{'TGT_PORT'}='';
853 }elsif($fwdfwsettings{'PROT'} eq 'ESP'){
854 $fwdfwsettings{'USE_SRC_PORT'}='';
855 $fwdfwsettings{'SRC_PORT'}='';
856 $fwdfwsettings{'ICMP_TYPES'}='';
857 $fwdfwsettings{'USESRV'}='';
858 $fwdfwsettings{'TGT_PORT'}='';
859 }elsif($fwdfwsettings{'PROT'} eq 'AH'){
860 $fwdfwsettings{'USE_SRC_PORT'}='';
861 $fwdfwsettings{'SRC_PORT'}='';
862 $fwdfwsettings{'ICMP_TYPES'}='';
863 $fwdfwsettings{'USESRV'}='';
864 $fwdfwsettings{'TGT_PORT'}='';
865 }elsif($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP' && $fwdfwsettings{'PROT'} ne 'ICMP'){
866 $fwdfwsettings{'ICMP_TYPES'}='';
867 $fwdfwsettings{'PROT'} = '';
868 }elsif($fwdfwsettings{'PROT'} ne 'ICMP'){
869 $fwdfwsettings{'ICMP_TYPES'}='';
874 my ($base1,$val1,$base2,$val2) = @_;
876 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
877 &dec_counter
($confignet,\
%customnetwork,$val1);
878 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
879 &dec_counter
($confighost,\
%customhost,$val1);
880 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
881 &dec_counter
($configgrp,\
%customgrp,$val1);
882 }elsif($base1 eq 'cust_srv'){
883 &dec_counter
($configsrv,\
%customservice,$val1);
884 }elsif($base1 eq 'cust_srvgrp'){
885 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
888 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
889 &inc_counter
($confignet,\
%customnetwork,$val2);
890 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
891 &inc_counter
($confighost,\
%customhost,$val2);
892 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
893 &inc_counter
($configgrp,\
%customgrp,$val2);
894 }elsif($base2 eq 'cust_srv'){
895 &inc_counter
($configsrv,\
%customservice,$val2);
896 }elsif($base2 eq 'cust_srvgrp'){
897 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
903 #Test if manual IP is part of static OpenVPN networks
904 &General
::readhasharray
("$configccdnet", \
%ccdnet);
905 foreach my $key (sort keys %ccdnet){
906 my ($vpnip,$vpnsubnet) = split ("/",$ccdnet{$key}[1]);
907 my $sub=&General
::iporsubtodec
($vpnsubnet);
908 if (&General
::IpInSubnet
($ip,$vpnip,$sub)){
912 # A Test if manual ip is part of dynamic openvpn subnet is made in getcolor
913 # because if one creates a custom host with the ip, we need to check the color there!
914 # It does not make sense to check this here
916 # Test if manual IP is part of an OpenVPN N2N subnet does also not make sense here
917 # Is also checked in getcolor
919 # Test if manual ip is part of an IPsec Network is also checked in getcolor
929 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
930 foreach my $key (sort {$a <=> $b} keys %delhash){
931 if ($key == $fwdfwsettings{'key'}){
932 #check hosts/net and groups
933 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
934 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
935 #check services and groups
936 if ($delhash{$key}[11] eq 'ON'){
937 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
940 if ($key >= $fwdfwsettings{'key'}) {
942 if (exists $delhash{$next}) {
943 foreach my $i (0 .. $#{$delhash{$next}}) {
944 $delhash{$key}[$i] = $delhash{$next}[$i];
949 # Remove the very last entry.
950 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
951 delete $delhash{$last_key};
953 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
956 if($fwdfwsettings{'nobase'} ne 'on'){
963 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
964 foreach my $key (sort keys %configfwdfw){
966 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
969 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
978 &General
::readhasharray
($config, \
%hash);
979 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
980 if($hash{$key}[0] eq $val){
981 $pos=$#{$hash{$key}};
982 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
985 &General
::writehasharray
($config, \
%hash);
990 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
991 print "<class name='base'>$errormessage\n";
992 print " </class>\n";
1002 foreach my $key (sort { ncmp
($hash{$a}[0],$hash{$b}[0]) } keys %hash){
1003 if($hash{$key}[0] eq $val){
1004 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1006 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1016 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1017 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1018 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1019 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1020 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1021 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1022 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1023 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1024 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1025 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1026 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1027 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1028 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1029 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1030 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1031 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1032 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1033 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1034 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1036 <table width='100%' border='0'>
1037 <tr><td width='50%' valign='top'>
1038 <table width='100%' border='0'>
1039 <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;'>
1041 foreach my $network (sort keys %defaultNetworks)
1043 next if($defaultNetworks{$network}{'NAME'} eq "RED" && $srctgt eq 'src');
1044 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1045 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1046 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $defaultNetworks{$network}{'NAME'});
1047 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1048 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1049 my $defsub1=&General
::subtocidr
($ifaces{$defsub});
1050 $ifaces{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1051 if ($ifaces{$defnet}){
1052 print ">$network ($ifaces{$defnet}/$defsub1)</option>";
1054 print ">$network</option>";
1057 print"</select></td></tr>";
1059 if (! -z
$confignet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1060 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;'>";
1061 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{$grp}});
1062 print"</select></td>";
1065 if (! -z
$confighost || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1066 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;'>";
1067 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{$grp}});
1068 print"</select></td>";
1071 if (! -z
$configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1072 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;'>";
1073 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } keys %customgrp) {
1074 if($helper ne $customgrp{$key}[0]){
1076 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $customgrp{$key}[0]);
1077 print ">$customgrp{$key}[0]</option>";
1079 $helper=$customgrp{$key}[0];
1081 print"</select></td>";
1083 #End left table. start right table (vpn)
1084 print"</tr></table></td><td valign='top'><table width='100%' border='0'><tr>";
1086 if( ! -z
$configccdnet || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1087 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;'>";
1088 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{$grp}});
1089 print"</select></td></tr>";
1092 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost){
1093 if ($ccdhost{$key}[33] ne '' ){
1094 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 '');
1096 print "<option value='$ccdhost{$key}[1]'";
1097 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1098 print ">$ccdhost{$key}[1]</option>";
1101 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
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;'></select></td></tr>" ;
1104 if ($show eq '1'){$show='';print"</select></td></tr>";}
1106 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost){
1107 if ($ccdhost{$key}[3] eq 'net'){
1108 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 '');
1110 print "<option value='$ccdhost{$key}[1]'";
1111 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ccdhost{$key}[1]);
1112 print ">$ccdhost{$key}[1]</option>";
1115 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
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;'></select></td></tr>" ;
1118 if ($show eq '1'){$show='';print"</select></td></tr>";}
1120 foreach my $key (sort { ncmp
($ipsecconf{$a}[1],$ipsecconf{$b}[1]) } keys %ipsecconf) {
1121 if ($ipsecconf{$key}[3] eq 'net' || $optionsfw{'SHOWDROPDOWN'} eq 'on'){
1122 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 '');
1125 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{$grp}} eq $ipsecconf{$key}[1]);
1126 print ">$ipsecconf{$key}[1]</option>";
1129 if($optionsfw{'SHOWDROPDOWN'} eq 'on' && $show eq ''){
1130 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>";
1132 if ($show eq '1'){$show='';print"</select></td></tr>";}
1135 print"</td></tr></table><br>";
1143 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1144 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
1145 if ($fwdfwsettings{$grp} eq $val.'_addr'){
1146 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
1147 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1148 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1149 $a=$netsettings{'GREEN_NETADDRESS'};
1150 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1151 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1152 $a=$netsettings{'ORANGE_NETADDRESS'};
1153 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1154 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1155 $a=$netsettings{'BLUE_NETADDRESS'};
1156 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1157 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1158 &General
::readhash
("$configovpn",\
%ovpnsettings);
1159 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1160 $b=&General
::iporsubtocidr
($b);
1162 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1163 &General
::readhasharray
("$confignet", \
%customnetwork);
1164 foreach my $key (keys %customnetwork){
1165 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1166 $a=$customnetwork{$key}[1];
1167 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1170 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1171 &General
::readhasharray
("$confighost", \
%customhost);
1172 foreach my $key (keys %customhost){
1173 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1174 if ($customhost{$key}[1] eq 'ip'){
1175 ($a,$b)=split (/\//,$customhost{$key}[2]);
1176 $b=&General
::iporsubtocidr
($b);
1178 if ($grp eq 'grp2'){
1179 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1191 &General
::setup_default_networks
(\
%defaultNetworks);
1192 foreach my $network (sort keys %defaultNetworks)
1194 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1199 my %hash=%{(shift)};
1201 if($hash{$key}[7] eq 'ON' && $hash{$key}[10]){
1202 $hash{$key}[10]=~ s/\|/,/g;
1203 print": $hash{$key}[10]";
1204 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1205 print": <br>$hash{$key}[9] ";
1210 my %hash=%{(shift)};
1214 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1215 if($hash{$key}[14] eq 'cust_srv'){
1216 &General
::readhasharray
("$configsrv", \
%customservice);
1217 foreach my $i (sort keys %customservice){
1218 if($customservice{$i}[0] eq $hash{$key}[15]){
1219 $service = $customservice{$i}[0];
1222 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1223 $service=$hash{$key}[15];
1224 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1225 $hash{$key}[15]=~ s/\|/,/g;
1226 $service=$hash{$key}[15];
1233 sub get_serviceports
1237 &General
::readhasharray
("$configsrv", \
%customservice);
1238 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1243 if($type eq 'service'){
1244 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1245 if ($customservice{$key}[0] eq $name){
1246 push (@protocols,$customservice{$key}[2]);
1249 }elsif($type eq 'group'){
1250 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1251 if ($customservicegrp{$key}[0] eq $name){
1252 foreach my $key1 (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1253 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1254 if($customservice{$key1}[2] eq 'TCP'){
1256 }elsif($customservice{$key1}[2] eq 'ICMP'){
1258 }elsif($customservice{$key1}[2] eq 'UDP'){
1266 if($tcp && $udp && $icmp){
1267 push (@protocols,"TCP,UDP, <br>ICMP");
1271 push (@protocols,"TCP");
1274 push (@protocols,"UDP");
1277 push (@protocols,"ICMP");
1286 if($optionsfw{'SHOWCOLORS'} eq 'on'){
1288 if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1289 foreach my $key (sort keys %$hash){
1290 if ($$hash{$key}[0] eq $val){
1291 $val=$$hash{$key}[2];
1296 if ($val eq 'GREEN'){
1297 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1299 }elsif ($val eq 'ORANGE'){
1300 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1302 }elsif ($val eq 'BLUE'){
1303 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1305 }elsif ($val eq 'RED' ||$val eq 'RED1' ){
1306 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1308 }elsif ($val eq 'IPFire' ){
1309 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1311 }elsif($val =~ /^(.*?)\/(.*?
)$/){
1312 my ($sip,$scidr) = split ("/",$val);
1313 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1314 $tdcolor="style='background-color: $Header::colourorange;color:white;'";
1317 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
1318 $tdcolor="style='background-color: $Header::colourgreen;color:white;'";
1321 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
1322 $tdcolor="style='background-color: $Header::colourblue;color:white;'";
1325 }elsif ($val eq 'Default IP'){
1326 $tdcolor="style='background-color: $Header::colourred;color:white;'";
1329 #Check if a manual IP or custom host is part of a VPN
1330 if ($nettype eq 'src_addr' || $nettype eq 'tgt_addr' || $nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
1331 #Check if IP is part of OpenVPN dynamic subnet
1332 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1333 my ($c,$d) = split("/",$val);
1334 if (&General
::IpInSubnet
($c,$a,$b)){
1335 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1338 #Check if IP is part of OpenVPN static subnet
1339 foreach my $key (sort keys %ccdnet){
1340 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1341 $b =&General
::iporsubtodec
($b);
1342 if (&General
::IpInSubnet
($c,$a,$b)){
1343 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1347 #Check if IP is part of OpenVPN N2N subnet
1348 foreach my $key (sort keys %ccdhost){
1349 if ($ccdhost{$key}[3] eq 'net'){
1350 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1351 if (&General
::IpInSubnet
($c,$a,$b)){
1352 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1357 #Check if IP is part of IPsec RW network
1358 if ($ipsecsettings{'RW_NET'} ne ''){
1359 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1360 $b=&General
::iporsubtodec
($b);
1361 if (&General
::IpInSubnet
($c,$a,$b)){
1362 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1366 #Check if IP is part of a IPsec N2N network
1367 foreach my $key (sort keys %ipsecconf){
1368 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1369 if (&General
::IpInSubnet
($c,$a,$b)){
1370 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1376 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'){
1377 $tdcolor="style='background-color: $Header::colourovpn;color:white;'";
1380 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
1381 $tdcolor="style='background-color: $Header::colourvpn;color:white;'";
1385 foreach my $alias (sort keys %aliases)
1387 if ($val eq $alias){
1388 $tdcolor="style='background-color:$Header::colourred;color:white;'";
1399 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1400 print "<class name='base'>$hint\n";
1401 print " </class>\n";
1402 &Header
::closebox
();
1409 my %hash=%{(shift)};
1413 &General
::readhasharray
($config, \
%hash);
1414 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1415 if($hash{$key}[0] eq $val){
1416 $pos=$#{$hash{$key}};
1417 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
1420 &General
::writehasharray
($config, \
%hash);
1425 &General
::setup_default_networks
(\
%defaultNetworks);
1426 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1427 #read all configfiles
1428 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1429 &General
::readhasharray
("$confignet", \
%customnetwork);
1430 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1431 &General
::readhasharray
("$confighost", \
%customhost);
1432 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1433 &General
::readhasharray
("$configgrp", \
%customgrp);
1434 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1435 &General
::get_aliases
(\
%aliases);
1439 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1440 my $config=$fwdfwsettings{'config'};
1443 open (CONN1
,"/var/ipfire/red/local-ipaddress");
1444 my $redip = <CONN1
>;
1446 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1447 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1448 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1449 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1450 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1451 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1452 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1453 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1454 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1455 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1456 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1457 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1458 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1459 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1460 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1461 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1462 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1463 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1464 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1465 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1466 #check if update and get values
1467 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1468 &General
::readhasharray
("$config", \
%hash);
1469 foreach my $key (sort keys %hash){
1471 if ($key eq $fwdfwsettings{'key'}){
1472 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1473 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1474 $fwdfwsettings{'chain'} = $hash{$key}[1];
1475 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1476 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1477 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1478 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1479 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1480 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1481 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1482 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1483 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1484 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1485 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1486 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1487 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1488 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1489 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1490 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1491 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1492 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1493 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1494 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1495 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1496 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1497 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1498 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1499 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1500 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1501 $fwdfwsettings{'USE_NAT'} = $hash{$key}[28];
1502 $fwdfwsettings{'nat'} = $hash{$key}[31]; #changed order
1503 $fwdfwsettings{$fwdfwsettings{'nat'}} = $hash{$key}[29];
1504 $fwdfwsettings{'dnatport'} = $hash{$key}[30];
1505 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1506 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1507 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1508 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1509 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1510 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1511 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1512 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1513 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1514 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1515 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1516 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1517 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1518 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1519 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1520 $checked{'USE_NAT'}{$fwdfwsettings{'USE_NAT'}} = 'CHECKED';
1521 $checked{'nat'}{$fwdfwsettings{'nat'}} = 'CHECKED';
1522 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1523 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1524 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1525 $selected{'ipfire_src'}{$fwdfwsettings{$fwdfwsettings{'grp1'}}} ='selected';
1526 $selected{'dnat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1527 $selected{'snat'}{$fwdfwsettings{$fwdfwsettings{'nat'}}} ='selected';
1530 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1531 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1532 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1533 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1534 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1535 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1536 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1537 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1538 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1539 $fwdfwsettings{'oldruletype'}=$fwdfwsettings{'chain'};
1540 #check if manual ip (source) is orange network
1541 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1542 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1543 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1544 $fwdfwsettings{'oldorange'} ='on';
1548 $fwdfwsettings{'ACTIVE'}='ON';
1549 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1550 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1551 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1552 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1553 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1554 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1555 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1556 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1557 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1558 $fwdfwsettings{'oldnat'}=$fwdfwsettings{'USE_NAT'};
1559 #check if manual ip (source) is orange network
1560 if ($fwdfwsettings{'grp1'} eq 'src_addr'){
1561 my ($sip,$scidr) = split("/",$fwdfwsettings{$fwdfwsettings{'grp1'}});
1562 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
1563 $fwdfwsettings{'oldorange'} ='on';
1567 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1568 print "<form method='post'>";
1569 &Header
::closebox
();
1570 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1571 #------SOURCE-------------------------------------------------------
1573 <table width='100%' border='0'>
1574 <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>
1576 print"<td align='right'><select name='ipfire_src' style='width:200px;'>";
1577 print "<option value='ALL' $selected{'ipfire_src'}{'ALL'}>$Lang::tr{'all'}</option>";
1578 print "<option value='GREEN' $selected{'ipfire_src'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1579 print "<option value='ORANGE' $selected{'ipfire_src'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1580 print "<option value='BLUE' $selected{'ipfire_src'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>" if (&Header
::blue_used
());
1581 print "<option value='RED1' $selected{'ipfire_src'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1582 if (! -z
"${General::swroot}/ethernet/aliases"){
1583 foreach my $alias (sort keys %aliases)
1585 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1590 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1592 &gen_dd_block
('src','grp1');
1594 &Header
::closebox
();
1595 #---SNAT / DNAT ------------------------------------------------
1596 &Header
::openbox
('100%', 'left', 'NAT');
1598 <table width='100%' border='0'>
1599 <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>
1600 <div id="natpart" class="noscript">
1601 <table width=100%' border='0'><tr>
1602 <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>
1604 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
1605 print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
1606 print "<option value='Default IP' $selected{'dnat'}{'Default IP'}>Default IP</option>";
1607 foreach my $alias (sort keys %aliases)
1609 print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
1611 print"</select></td></tr>";
1612 $fwdfwsettings{'dnatport'}=~ tr/|/,/;
1613 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>";
1614 print"<tr><td colspan='8'><br></td></tr>";
1616 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>";
1617 print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
1618 foreach my $alias (sort keys %aliases)
1620 print "<option value='$alias' $selected{'snat'}{$alias}>$alias</option>";
1622 foreach my $network (sort keys %defaultNetworks)
1624 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1625 next if($defaultNetworks{$network}{'NAME'} eq "ALL");
1626 next if($defaultNetworks{$network}{'NAME'} =~ /OpenVPN/i);
1627 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1628 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'nat'}} eq $defaultNetworks{$network}{'NAME'});
1629 print ">$network</option>";
1631 print"</select></td></tr></table>";
1632 print"</div><br><hr>";
1633 if ($fwdfwsettings{'USE_NAT'} ne 'ON'){
1634 print"<script language='JavaScript'>hide_elements('natpart');</script>";
1636 &Header
::closebox
();
1637 #---TARGET------------------------------------------------------
1638 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1640 <table width='100%' border='0'>
1641 <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>
1643 print"<td align='right'><select name='ipfire' style='width:200px;'>";
1644 print "<option value='ALL' $selected{'ipfire'}{'ALL'}>$Lang::tr{'all'}</option>";
1645 print "<option value='GREEN' $selected{'ipfire'}{'GREEN'}>$Lang::tr{'green'} ($ifaces{'GREEN_ADDRESS'})</option>" if $ifaces{'GREEN_ADDRESS'};
1646 print "<option value='ORANGE' $selected{'ipfire'}{'ORANGE'}>$Lang::tr{'orange'} ($ifaces{'ORANGE_ADDRESS'})</option>" if (&Header
::orange_used
());
1647 print "<option value='BLUE' $selected{'ipfire'}{'BLUE'}>$Lang::tr{'blue'} ($ifaces{'BLUE_ADDRESS'})</option>"if (&Header
::blue_used
());
1648 print "<option value='RED1' $selected{'ipfire'}{'RED1'}>$Lang::tr{'red1'} ($redip)" if ($redip);
1649 if (! -z
"${General::swroot}/ethernet/aliases"){
1650 foreach my $alias (sort keys %aliases)
1652 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1657 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1659 &gen_dd_block
('tgt','grp2');
1662 #---PROTOCOL------------------------------------------------------
1663 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost prot'});
1665 <table width='15%' border='0' style="float:left;">
1666 <tr><td><select name='PROT' id='PROT' onchange="getdropdown()">
1668 if ($fwdfwsettings{'PROT'} eq ''){
1669 print"<option value='' selected>$Lang::tr{'all'}</option>";
1671 print"<option value=''>$Lang::tr{'all'}</option>";
1673 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1675 if ($_ eq $fwdfwsettings{'PROT'})
1677 print"<option selected>$_</option>";
1679 print"<option>$_</option>";
1682 print"</select></td></tr></table>";
1684 <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;'>
1686 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1687 print"<option>All ICMP-Types</option>";
1688 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1689 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1690 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1692 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1697 </table></div><br><br><br>
1699 if ($fwdfwsettings{'PROT'} ne 'ICMP'){
1700 print"<script language='JavaScript'>hide_elements('PROTOKOLL');</script>";
1704 <table width='100%'><tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></table>
1705 <table width='100%' border='0'>
1706 <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'} onclick="toggle_elements('srcport')"></td>
1707 <td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td></tr></table>
1708 <div id="srcport" class="noscript"><table width='100%' border='0'><tr>
1709 <td width='70%' nowrap='nowrap' align='right'>$Lang::tr{'fwdfw man port'}</td>
1711 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1713 <td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1716 if ($fwdfwsettings{'USE_SRC_PORT'} ne 'ON'){
1717 print"<script language='JavaScript'>hide_elements('srcport');</script>";
1721 <hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '><br>
1722 <table width='100%' border='0'>
1723 <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>
1724 <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;' >
1726 &General
::readhasharray
("$configsrv", \
%customservice);
1727 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice){
1729 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1730 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1734 <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;' >
1736 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1738 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1739 if ($helper ne $customservicegrp{$key}[0]){
1741 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1742 print">$customservicegrp{$key}[0]</option>";
1744 $helper=$customservicegrp{$key}[0];
1748 <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>
1750 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1752 <td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' onclick='checkradio(\"#TGT_PORT\")'></td></tr>
1753 </table></div><br><hr>
1755 if ($fwdfwsettings{'USESRV'} ne 'ON'){
1756 print"<script language='JavaScript'>hide_elements('targetport');</script>";
1759 #---Activate/logging/remark-------------------------------------
1760 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1762 <table width='100%' border='0'>
1763 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1765 foreach ("ACCEPT","DROP","REJECT")
1767 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1768 print"<option value='$_'";
1769 print " selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1770 print">$Lang::tr{'fwdfw '.$_}</option>";
1772 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1773 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1775 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1777 print"<option value='$_' selected>$Lang::tr{'fwdfw '.$_}</option>";
1779 print"<option value='$_'>$Lang::tr{'fwdfw '.$_}</option>";
1783 print"</select></td></tr>";
1784 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>";
1785 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1786 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1787 for (my $count =1; $count <= $sum; $count++){
1788 print"<option value='$count' ";
1789 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1790 print">$count</option>";
1792 print"</select></td></tr>";
1794 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1798 </table><table width='100%'>
1799 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1800 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1803 &Header
::closebox
();
1804 #---ADD TIMEFRAME-----------------------------------------------
1805 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1807 <table width='70%' border='0'>
1808 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='9'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1809 <tr><td colspan='10'> </td></tr>
1811 <td align='left' >$Lang::tr{'time'}: </td>
1812 <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>
1813 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1814 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1817 <td align='right'></td>
1818 <td width='1%' align='left'><input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} ></td>
1819 <td width='1%' align='left'><input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} ></td>
1820 <td width='1%' align='left'><input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} ></td>
1821 <td width='1%' align='left'><input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} ></td>
1822 <td width='1%' align='left'><input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} ></td>
1823 <td width='1%' align='left'><input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} ></td>
1824 <td width='15%' align='left'><input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} ></td>
1825 <td><select name='TIME_FROM'>
1827 for (my $i=0;$i<=23;$i++) {
1828 $i = sprintf("%02s",$i);
1829 for (my $j=0;$j<=45;$j+=15) {
1830 $j = sprintf("%02s",$j);
1831 my $time = $i.":".$j;
1832 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1837 <td><select name='TIME_TO'>
1839 for (my $i=0;$i<=23;$i++) {
1840 $i = sprintf("%02s",$i);
1841 for (my $j=0;$j<=45;$j+=15) {
1842 $j = sprintf("%02s",$j);
1843 my $time = $i.":".$j;
1844 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1848 </select></td></tr></table><br><hr>
1850 #---ACTION------------------------------------------------------
1851 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1853 <table border='0' width='100%'>
1854 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1855 <input type='hidden' name='config' value='$config' >
1856 <input type='hidden' name='ACTION' value='saverule' ></form>
1857 <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>
1863 <table border='0' width='100%'>
1864 <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'}'>
1865 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1866 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1867 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1868 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1869 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1870 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1871 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1872 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1873 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1874 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1875 <input type='hidden' name='oldorange' value='$fwdfwsettings{'oldorange'}' />
1876 <input type='hidden' name='oldnat' value='$fwdfwsettings{'oldnat'}' />
1877 <input type='hidden' name='oldruletype' value='$fwdfwsettings{'oldruletype'}' />
1878 <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>
1882 &Header
::closebox
();
1888 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
1889 foreach my $key (sort keys %uphash){
1890 if ($key eq $fwdfwsettings{'key'}) {
1892 if (exists $uphash{$last}){
1894 foreach my $y (0 .. $#{$uphash{$last}}) {
1895 $tmp{0}[$y] = $uphash{$last}[$y];
1897 #copy active rule to last
1898 foreach my $i (0 .. $#{$uphash{$last}}) {
1899 $uphash{$last}[$i] = $uphash{$key}[$i];
1901 #copy saved rule to actual position
1902 foreach my $x (0 .. $#{$tmp{0}}) {
1903 $uphash{$key}[$x] = $tmp{0}[$x];
1908 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
1915 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
1916 foreach my $key (sort keys %downhash){
1917 if ($key eq $fwdfwsettings{'key'}) {
1918 my $next = $key + 1;
1919 if (exists $downhash{$next}){
1921 foreach my $y (0 .. $#{$downhash{$next}}) {
1922 $tmp{0}[$y] = $downhash{$next}[$y];
1924 #copy active rule to next
1925 foreach my $i (0 .. $#{$downhash{$next}}) {
1926 $downhash{$next}[$i] = $downhash{$key}[$i];
1928 #copy saved rule to actual position
1929 foreach my $x (0 .. $#{$tmp{0}}) {
1930 $downhash{$key}[$x] = $tmp{0}[$x];
1935 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
1940 if (!-f
"${General::swroot}/forward/reread"){
1941 system("touch ${General::swroot}/forward/reread");
1942 system("touch ${General::swroot}/fwhosts/reread");
1947 system("/usr/local/bin/forwardfwctrl");
1948 if ( -f
"${General::swroot}/forward/reread"){
1949 system("rm ${General::swroot}/forward/reread");
1950 system("rm ${General::swroot}/fwhosts/reread");
1957 &General
::readhasharray
("$config", $hash);
1958 if (!$errormessage){
1959 ################################################################
1960 #check if we change an INPUT rule to a OUTGOING
1961 if($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW' ){
1962 &changerule
($configinput);
1965 #check if we change an INPUT rule to a FORWARD
1966 elsif($fwdfwsettings{'oldruletype'} eq 'INPUTFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1967 &changerule
($configinput);
1970 ################################################################
1971 #check if we change an OUTGOING rule to an INPUT
1972 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'INPUTFW' ){
1973 &changerule
($configoutgoing);
1976 #check if we change an OUTGOING rule to a FORWARD
1977 elsif($fwdfwsettings{'oldruletype'} eq 'OUTGOINGFW' && $fwdfwsettings{'chain'} eq 'FORWARDFW' ){
1978 &changerule
($configoutgoing);
1981 ################################################################
1982 #check if we change a FORWARD rule to an INPUT
1983 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'INPUTFW'){
1984 &changerule
($configfwdfw);
1987 #check if we change a FORWARD rule to an OUTGOING
1988 elsif($fwdfwsettings{'oldruletype'} eq 'FORWARDFW' && $fwdfwsettings{'chain'} eq 'OUTGOINGFW'){
1989 &changerule
($configfwdfw);
1992 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1993 my $key = &General
::findhasharraykey
($hash);
1994 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1995 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1996 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1997 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1998 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1999 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2000 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2001 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2002 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2003 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2004 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2005 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2006 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2007 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2008 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2009 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2010 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2011 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2012 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2013 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2014 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2015 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2016 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2017 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2018 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2019 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2020 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2021 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2022 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2023 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2024 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2025 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2026 &General
::writehasharray
("$config", $hash);
2028 foreach my $key (sort {$a <=> $b} keys %$hash){
2029 if($key eq $fwdfwsettings{'key'}){
2030 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
2031 $$hash{$key}[1] = $fwdfwsettings{'chain'};
2032 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
2033 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
2034 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
2035 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
2036 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
2037 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
2038 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
2039 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
2040 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
2041 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
2042 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
2043 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
2044 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
2045 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
2046 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
2047 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
2048 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
2049 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
2050 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
2051 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
2052 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
2053 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
2054 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
2055 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
2056 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
2057 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
2058 $$hash{$key}[28] = $fwdfwsettings{'USE_NAT'};
2059 $$hash{$key}[29] = $fwdfwsettings{$fwdfwsettings{'nat'}};
2060 $$hash{$key}[30] = $fwdfwsettings{'dnatport'};
2061 $$hash{$key}[31] = $fwdfwsettings{'nat'};
2066 &General
::writehasharray
("$config", $hash);
2067 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
2069 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
2070 for (my $z=0;$z<$val;$z++){
2071 foreach my $key (sort {$a <=> $b} keys %$hash){
2072 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2074 if (exists $$hash{$last}){
2076 foreach my $y (0 .. $#{$$hash{$last}}) {
2077 $tmp{0}[$y] = $$hash{$last}[$y];
2079 #copy active rule to last
2080 foreach my $i (0 .. $#{$$hash{$last}}) {
2081 $$hash{$last}[$i] = $$hash{$key}[$i];
2083 #copy saved rule to actual position
2084 foreach my $x (0 .. $#{$tmp{0}}) {
2085 $$hash{$key}[$x] = $tmp{0}[$x];
2090 $fwdfwsettings{'oldrulenumber'}--;
2092 &General
::writehasharray
("$config", $hash);
2094 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
2096 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
2097 for (my $z=0;$z<$val;$z++){
2098 foreach my $key (sort {$a <=> $b} keys %$hash){
2099 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
2100 my $next = $key + 1;
2101 if (exists $$hash{$next}){
2103 foreach my $y (0 .. $#{$$hash{$next}}) {
2104 $tmp{0}[$y] = $$hash{$next}[$y];
2106 #copy active rule to next
2107 foreach my $i (0 .. $#{$$hash{$next}}) {
2108 $$hash{$next}[$i] = $$hash{$key}[$i];
2110 #copy saved rule to actual position
2111 foreach my $x (0 .. $#{$tmp{0}}) {
2112 $$hash{$key}[$x] = $tmp{0}[$x];
2117 $fwdfwsettings{'oldrulenumber'}++;
2119 &General
::writehasharray
("$config", $hash);
2126 # Checks a hostname against RFC1035
2129 # Each part should be at least two characters in length
2130 # but no more than 63 characters
2131 if (length ($remark) < 1 || length ($remark) > 255) {
2133 # Only valid characters are a-z, A-Z, 0-9 and -
2134 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2136 # First character can only be a letter or a digit
2137 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2139 # Last character can only be a letter or a digit
2140 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2146 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
2147 &viewtablenew
(\
%configfwdfw,$configfwdfw,"","Forward" );
2148 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'fwdfw xt access'} );
2149 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
2158 &General
::get_aliases
(\
%aliases);
2159 &General
::readhasharray
("$confighost", \
%customhost);
2160 &General
::readhasharray
("$config", $hash);
2161 &General
::readhasharray
("$configccdnet", \
%ccdnet);
2162 &General
::readhasharray
("$configccdhost", \
%ccdhost);
2164 &Header
::openbox
('100%', 'left',$title);
2172 print"<b>$title1</b><br>";
2173 print"<table width='100%' cellspacing='0' cellpadding='0' border='0'>";
2174 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>";
2175 foreach my $key (sort {$a <=> $b} keys %$hash){
2178 #check if vpn hosts/nets have been deleted
2179 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
2180 push (@tmpsrc,$$hash{$key}[4]);
2182 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
2183 push (@tmpsrc,$$hash{$key}[6]);
2185 foreach my $host (@tmpsrc){
2186 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
2187 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
2189 &disable_rule
($key);
2192 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
2193 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
2195 &disable_rule
($key);
2198 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
2199 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
2201 &disable_rule
($key);
2204 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
2205 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
2207 &disable_rule
($key);
2212 $$hash{'ACTIVE'}=$$hash{$key}[2];
2214 if($coloryellow eq 'on'){
2215 print"<tr bgcolor='$color{'color14'}' >";
2217 }elsif($coloryellow eq ''){
2219 $color="$color{'color22'}";
2222 $color="$color{'color20'}";
2225 print"<tr bgcolor='$color' >";
2228 <td align='right' width='18'><b>$key </b></td>
2231 if ($$hash{$key}[0] eq 'ACCEPT'){
2234 $rulecolor=$color{'color17'};
2235 }elsif($$hash{$key}[0] eq 'DROP'){
2238 $rulecolor=$color{'color25'};
2239 }elsif($$hash{$key}[0] eq 'REJECT'){
2242 $rulecolor=$color{'color16'};
2244 print"<td bgcolor='$rulecolor' align='center' width='10'><span title='$tooltip'><b>$ruletype</b></span></td>";
2247 if ($$hash{$key}[8]){
2248 push (@protocols,$$hash{$key}[8]);
2249 }elsif($$hash{$key}[14] eq 'cust_srv'){
2250 &get_serviceports
("service",$$hash{$key}[15]);
2251 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
2252 &get_serviceports
("group",$$hash{$key}[15]);
2254 push (@protocols,$Lang::tr
{'all'});
2256 my $protz=join(",",@protocols);
2257 if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
2258 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
2259 foreach my $keyicmp (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
2260 if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){
2261 print "<td align='center'><span title='$icmptypes{$keyicmp}[0]'><b>$protz ($icmptypes{$keyicmp}[1])</b></span></td>";
2266 print"<td align='center'>$protz</td>";
2271 &getcolor
($$hash{$key}[3],$$hash{$key}[4],\
%customhost);
2272 print"<td align='center' width='160' $tdcolor>";
2273 if ($$hash{$key}[3] eq 'ipfire_src'){
2274 $ipfireiface='Interface ';
2276 if ($$hash{$key}[3] eq 'std_net_src'){
2277 print &get_name
($$hash{$key}[4]);
2278 }elsif ($$hash{$key}[3] eq 'src_addr'){
2279 my ($split1,$split2) = split("/",$$hash{$key}[4]);
2280 if ($split2 eq '32'){
2283 print $$hash{$key}[4];
2285 }elsif ($$hash{$key}[4] eq 'RED1'){
2286 print "$ipfireiface $Lang::tr{'fwdfw red'}";
2288 print "$$hash{$key}[4]";
2292 &getsrcport
(\
%$hash,$key);
2293 #Is this a SNAT rule?
2294 if ($$hash{$key}[31] eq 'snat' && $$hash{$key}[28] eq 'ON'){
2295 my $net=&get_name
($$hash{$key}[29]);
2296 if ( ! $net){ $net=$$hash{$key}[29];}
2298 if ($$hash{$key}[30] ne ''){
2299 print": $$hash{$key}[30]";
2302 if ($$hash{$key}[17] eq 'ON'){
2303 $log="/images/on.gif";
2305 $log="/images/off.gif";
2310 <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 ;'/>
2311 <input type='hidden' name='key' value='$key' />
2312 <input type='hidden' name='config' value='$config' />
2313 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
2317 &getcolor
($$hash{$key}[5],$$hash{$key}[6],\
%customhost);
2319 <td align='center' width='160' $tdcolor>
2321 #Is this a DNAT rule?
2322 if ($$hash{$key}[31] eq 'dnat' && $$hash{$key}[28] eq 'ON'){
2323 print "Firewall ($$hash{$key}[29])";
2324 if($$hash{$key}[30] ne ''){
2325 $$hash{$key}[30]=~ tr/|/,/;
2326 print": $$hash{$key}[30]";
2330 if ($$hash{$key}[5] eq 'ipfire'){
2331 $ipfireiface='Interface';
2333 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' ){
2334 if ($$hash{$key}[6] eq 'RED1'){
2335 print "$ipfireiface $Lang::tr{'red1'}";
2336 }elsif ($$hash{$key}[6] eq 'GREEN' || $$hash{$key}[6] eq 'ORANGE' || $$hash{$key}[6] eq 'BLUE'|| $$hash{$key}[6] eq 'ALL')
2338 print "$ipfireiface ".&get_name
($$hash{$key}[6]);
2340 print $$hash{$key}[6];
2342 }elsif ($$hash{$key}[5] eq 'tgt_addr'){
2343 my ($split1,$split2) = split("/",$$hash{$key}[6]);
2344 if ($split2 eq '32'){
2347 print $$hash{$key}[6];
2350 print "$$hash{$key}[6]";
2354 &gettgtport
(\
%$hash,$key);
2357 if($$hash{$key}[2] eq 'ON'){
2358 $gif="/images/on.gif"
2361 $gif="/images/off.gif"
2364 <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;' />
2365 <input type='hidden' name='key' value='$key' />
2366 <input type='hidden' name='config' value='$config' />
2367 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
2369 <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;' />
2370 <input type='hidden' name='key' value='$key' />
2371 <input type='hidden' name='config' value='$config' />
2372 <input type='hidden' name='ACTION' value='editrule' />
2374 <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;' />
2375 <input type='hidden' name='key' value='$key' />
2376 <input type='hidden' name='config' value='$config' />
2377 <input type='hidden' name='ACTION' value='copyrule' />
2379 <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;' />
2380 <input type='hidden' name='key' value='$key' />
2381 <input type='hidden' name='config' value='$config' />
2382 <input type='hidden' name='ACTION' value='deleterule' />
2385 if (exists $$hash{$key-1}){
2387 <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;' />
2388 <input type='hidden' name='key' value='$key' />
2389 <input type='hidden' name='config' value='$config' />
2390 <input type='hidden' name='ACTION' value='moveup' />
2394 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2396 if (exists $$hash{$key+1}){
2398 <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;' />
2399 <input type='hidden' name='key' value='$key' />
2400 <input type='hidden' name='config' value='$config' />
2401 <input type='hidden' name='ACTION' value='movedown' />
2405 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2408 if ($optionsfw{'SHOWREMARK'} eq 'on' && $$hash{$key}[16] ne ''){
2409 print"<tr bgcolor='$color'>";
2410 print"<td> </td><td bgcolor='$rulecolor'></td><td colspan='10'> $$hash{$key}[16]</td></tr>";
2412 if ($$hash{$key}[18] eq 'ON'){
2414 if ($$hash{$key}[18] eq 'ON'){
2416 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2417 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2418 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2419 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2420 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2421 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2422 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2423 my $weekdays=join(",",@days);
2425 print"<tr bgcolor='$color'>";
2426 print"<td> </td><td bgcolor='$rulecolor'></td><td align='left' colspan='10'> $weekdays $$hash{$key}[26] - $$hash{$key}[27] </td></tr>";
2430 print"<tr bgcolor='FFFFFF'><td colspan='13' height='1'></td></tr>";
2434 print "<table width='100%'rules='cols' border='1'>";
2436 if ($config eq '/var/ipfire/forward/config'){
2437 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2438 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2439 $col="bgcolor='darkred'";
2441 $col="bgcolor='green'";
2443 &show_defaultrules
($col,$pol);
2444 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2445 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2446 $col="bgcolor='darkred'";
2447 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>";
2449 $col="bgcolor='green'";
2450 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>";
2453 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>";
2458 &Header
::closebox
();
2460 if ($optionsfw{'SHOWTABLES'} eq 'on'){
2461 print "<b>$title1</b><br>";
2462 print"<table width='100%' border='0' rules='none'><tr><td height='30' bgcolor=$color{'color22'} align='center'>$Lang::tr{'fwhost empty'}</td></tr></table>";
2464 if ($config eq '/var/ipfire/forward/config'){
2465 my $pol='fwdfw '.$fwdfwsettings{'POLICY'};
2466 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){
2467 $col="bgcolor='darkred'";
2469 $col="bgcolor='green'";
2471 &show_defaultrules
($col,$pol);
2472 }elsif ($config eq '/var/ipfire/forward/outgoing'){
2473 print "<table width='100%' rules='cols' border='1'>";
2474 my $pol='fwdfw '.$fwdfwsettings{'POLICY1'};
2475 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){
2476 $col="bgcolor='darkred'";
2477 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>";
2479 $col="bgcolor='green'";
2480 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>";
2483 print "<table width='100%' rules='cols' border='1'>";
2484 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>";
2486 print"</table><br><br>";
2490 &Header
::closebigbox
();
2491 &Header
::closepage
();
2493 sub show_defaultrules
2497 #STANDARD RULES (From WIKI)
2499 if ($col eq "bgcolor='green'"){
2500 print "<br><table width='100%' rules='cols' border='1' >";
2501 my $blue = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::blue_used
());
2502 my $orange = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol block'})" if (&Header
::orange_used
());
2503 my $blue1 = "<font color=$Header::colourblue> $Lang::tr{'blue'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::blue_used
());
2504 my $orange1 = "<font color=$Header::colourorange> $Lang::tr{'orange'}</font> ($Lang::tr{'fwdfw pol allow'})" if (&Header
::orange_used
());
2505 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>";
2506 print"<td align='center'>$orange1</td>" if (&Header
::orange_used
());
2507 print"<td align='center'>$blue1</td>" if (&Header
::blue_used
());
2509 if (&Header
::orange_used
()){
2510 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>";
2511 print"<td align='center'>$blue</td>" if (&Header
::blue_used
());
2514 if (&Header
::blue_used
()){
2515 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>";
2516 print"<td align='center'>$orange</td>" if (&Header
::orange_used
());
2517 print"<td align='center'><font color=$Header::colourgreen> $Lang::tr{'green'}</font> ($Lang::tr{'fwdfw pol block'})</td>";
2520 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>";
2521 }elsif($col eq "bgcolor='darkred'"){
2522 print "<table width='100%' rules='cols' border='1' >";
2523 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>";