]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
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 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. As a prerequisite i needed #
24 # something that makes sure the vpn roadwarrior are able to have a fixed #
25 # ip-address. So i developed the ccd extension for the vpn server. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
34 no warnings
'uninitialized';
35 # enable only the following on debugging purpose
37 #use CGI::Carp 'fatalsToBrowser';
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42 require "${General::swroot}/forward/bin/firewall-lib.pl";
44 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
48 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
52 my %defaultNetworks=();
56 my %customnetworks=();
58 my %customservicegrp=();
64 my %configoutgoingfw=();
76 my $confignet = "${General::swroot}/fwhosts/customnetworks";
77 my $confighost = "${General::swroot}/fwhosts/customhosts";
78 my $configgrp = "${General::swroot}/fwhosts/customgroups";
79 my $configsrv = "${General::swroot}/fwhosts/customservices";
80 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
81 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
82 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
83 my $configipsec = "${General::swroot}/vpn/config";
84 my $configipsecrw = "${General::swroot}/vpn/settings";
85 my $configfwdfw = "${General::swroot}/forward/config";
86 my $configinput = "${General::swroot}/forward/input";
87 my $configoutgoing = "${General::swroot}/forward/outgoing";
88 my $configovpn = "${General::swroot}/ovpn/settings";
89 my $fwoptions = "${General::swroot}/optionsfw/settings";
92 my $ipgrp="${General::swroot}/outgoing/groups";
95 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
96 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
97 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
98 &General
::readhash
($fwoptions, \
%optionsfw);
100 &Header
::showhttpheaders
();
101 &Header
::getcgihash
(\
%fwdfwsettings);
102 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
103 &Header
::openbigbox
('100%', 'center',$errormessage);
106 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
108 my $MODE = $fwdfwsettings{'POLICY'};
109 my $MODE1 = $fwdfwsettings{'POLICY1'};
111 $fwdfwsettings{'POLICY'} = "$MODE";
112 $fwdfwsettings{'POLICY1'} = "$MODE1";
113 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
116 if ($fwdfwsettings{'ACTION'} eq 'saverule')
118 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
119 &General
::readhasharray
("$configinput", \
%configinputfw);
120 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
121 $errormessage=&checksource
;
122 if(!$errormessage){&checktarget
;}
123 if(!$errormessage){&checkrule
;}
124 #check if we try to break rules
125 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
126 $errormessage.=$Lang::tr
{'fwdfw err same'};
129 if($fwdfwsettings{'grp2'} eq 'ipfire'){
130 $fwdfwsettings{'config'}=$configinput;
131 $fwdfwsettings{'chain'} = 'INPUTFW';
132 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
133 #check if we have an identical rule already
134 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
135 foreach my $key (sort keys %configinputfw){
136 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'}"
137 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]"){
138 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
139 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} eq ''){
141 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
142 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
144 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
145 $fwdfwsettings{'nosave'} = 'on';
150 #check Rulepos on new Rule
151 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
152 $fwdfwsettings{'oldrulenumber'}=$maxkey;
153 foreach my $key (sort keys %configinputfw){
154 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'}"
155 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]"){
156 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
160 #check if we just close a rule
161 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'} ) {
162 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
164 $fwdfwsettings{'nosave2'} = 'on';
167 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
168 if ($fwdfwsettings{'nobase'} ne 'on'){
169 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
171 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
172 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
173 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
174 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
175 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
176 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
178 if($fwdfwsettings{'nosave2'} ne 'on'){
179 &saverule
(\
%configinputfw,$configinput);
181 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
182 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
183 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
184 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
185 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
186 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
187 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
188 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
189 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
190 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
191 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
192 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
193 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
194 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
195 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
196 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
198 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
199 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
200 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
201 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
202 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' ){
204 $fwdfwsettings{'config'}=$configoutgoing;
205 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
206 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
207 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
208 foreach my $key (sort keys %configoutgoingfw){
209 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'}"
210 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]"){
211 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
212 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} eq ''){
214 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
215 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
217 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
218 $fwdfwsettings{'nosave'} = 'on';
223 #check Rulepos on new Rule
224 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
225 print"CHECK OUTGOING DOPPELTE REGEL<br>";
226 $fwdfwsettings{'oldrulenumber'}=$maxkey;
227 foreach my $key (sort keys %configoutgoingfw){
228 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'}"
229 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]"){
230 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
234 #check if we just close a rule
235 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'} ) {
236 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
237 $fwdfwsettings{'nosave2'} = 'on';
242 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
243 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
244 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
245 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
246 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
247 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
248 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
249 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
251 if ($fwdfwsettings{'nobase'} eq 'on'){
252 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
254 if ($fwdfwsettings{'nosave2'} ne 'on'){
255 &saverule
(\
%configoutgoingfw,$configoutgoing);
259 $fwdfwsettings{'config'}=$configfwdfw;
260 $fwdfwsettings{'chain'} = 'FORWARDFW';
261 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
262 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
263 #check if we have an identical rule already
264 foreach my $key (sort keys %configfwdfw){
265 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'}"
266 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}[17],$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]"){
267 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
268 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} eq ''){
270 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && $fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
271 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
273 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
274 $fwdfwsettings{'nosave'} = 'on';
279 #check Rulepos on new Rule
280 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
281 $fwdfwsettings{'oldrulenumber'}=$maxkey;
282 foreach my $key (sort keys %configfwdfw){
283 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'}"
284 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}[17],$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]"){
285 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
289 #check if we just close a rule
290 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'} ) {
291 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
292 $fwdfwsettings{'nosave2'} = 'on';
297 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
298 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
299 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
300 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
301 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
302 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
303 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
304 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
306 if ($fwdfwsettings{'nobase'} eq 'on'){
307 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
309 if ($fwdfwsettings{'nosave2'} ne 'on'){
310 &saverule
(\
%configfwdfw,$configfwdfw);
312 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
313 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
314 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
315 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
316 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
317 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
318 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
319 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
320 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
321 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
322 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
323 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
324 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
325 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
326 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
327 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
329 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
330 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
331 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
332 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
337 if($fwdfwsettings{'nosave2'} ne 'on'){
343 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
345 if($fwdfwsettings{'poltype'} eq 'forward'){
346 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
347 foreach my $key (sort keys %configfwdfw){
348 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
349 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
350 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
352 &General
::readhasharray
("$configinput", \
%configinputfw);
353 foreach my $key (sort keys %configinputfw){
354 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
355 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
356 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
359 system("rm ${General::swroot}/forward/config");
360 system("rm ${General::swroot}/forward/input");
361 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
362 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
363 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
364 my $MODE1=$fwdfwsettings{'POLICY1'};
366 $fwdfwsettings{'POLICY'}='MODE2';
367 $fwdfwsettings{'POLICY1'}=$MODE1;
368 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
371 &General
::readhasharray
("$configoutgoing", \
%configoutgoingfw);
372 foreach my $key (sort keys %configoutgoingfw){
373 &checkcounter
($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
374 &checkcounter
($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
375 &checkcounter
($configoutgoingfw{$key}[14],$configoutgoingfw{$key}[15],,);
377 system("rm ${General::swroot}/forward/outgoing");
378 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
379 unless (-e
"${General::swroot}/forward/outgoing") { system("touch ${General::swroot}/forward/outgoing"); }
380 my $MODE=$fwdfwsettings{'POLICY'};
382 $fwdfwsettings{'POLICY'}=$MODE;
383 $fwdfwsettings{'POLICY1'}='MODE2';
384 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
388 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
392 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
395 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
396 foreach my $key (sort keys %togglehash){
397 if ($key eq $fwdfwsettings{'key'}){
398 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
401 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
405 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
408 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
409 foreach my $key (sort keys %togglehash){
410 if ($key eq $fwdfwsettings{'key'}){
411 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
414 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
418 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
423 if ($fwdfwsettings{'ACTION'} eq 'editrule')
425 $fwdfwsettings{'updatefwrule'}='on';
428 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
432 if ($fwdfwsettings{'ACTION'} eq 'moveup')
437 if ($fwdfwsettings{'ACTION'} eq 'movedown')
442 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
444 $fwdfwsettings{'copyfwrule'}='on';
445 #$fwdfwsettings{'updatefwrule'}='on';
448 if ($fwdfwsettings{'ACTION'} eq '')
456 $fwdfwsettings{'updatefwrule'}='';
457 $fwdfwsettings{'config'}=$oldchain;
458 $fwdfwsettings{'nobase'}='on';
460 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
461 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
467 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
468 foreach my $key (sort keys %uphash){
469 if ($key eq $fwdfwsettings{'key'}) {
471 if (exists $uphash{$last}){
473 foreach my $y (0 .. $#{$uphash{$last}}) {
474 $tmp{0}[$y] = $uphash{$last}[$y];
476 #copy active rule to last
477 foreach my $i (0 .. $#{$uphash{$last}}) {
478 $uphash{$last}[$i] = $uphash{$key}[$i];
480 #copy saved rule to actual position
481 foreach my $x (0 .. $#{$tmp{0}}) {
482 $uphash{$key}[$x] = $tmp{0}[$x];
487 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
494 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
495 foreach my $key (sort keys %downhash){
496 if ($key eq $fwdfwsettings{'key'}) {
498 if (exists $downhash{$next}){
500 foreach my $y (0 .. $#{$downhash{$next}}) {
501 $tmp{0}[$y] = $downhash{$next}[$y];
503 #copy active rule to next
504 foreach my $i (0 .. $#{$downhash{$next}}) {
505 $downhash{$next}[$i] = $downhash{$key}[$i];
507 #copy saved rule to actual position
508 foreach my $x (0 .. $#{$tmp{0}}) {
509 $downhash{$key}[$x] = $tmp{0}[$x];
514 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
519 my ($base1,$val1,$base2,$val2) = @_;
521 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
522 &dec_counter
($confignet,\
%customnetwork,$val1);
523 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
524 &dec_counter
($confighost,\
%customhost,$val1);
525 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
526 &dec_counter
($configgrp,\
%customgrp,$val1);
527 }elsif($base1 eq 'cust_srv'){
528 &dec_counter
($configsrv,\
%customservice,$val1);
529 }elsif($base1 eq 'cust_srvgrp'){
530 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
533 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
534 &inc_counter
($confignet,\
%customnetwork,$val2);
535 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
536 &inc_counter
($confighost,\
%customhost,$val2);
537 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
538 &inc_counter
($configgrp,\
%customgrp,$val2);
539 }elsif($base2 eq 'cust_srv'){
540 &inc_counter
($configsrv,\
%customservice,$val2);
541 }elsif($base2 eq 'cust_srvgrp'){
542 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
552 &General
::readhasharray
($config, \
%hash);
553 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
554 if($hash{$key}[0] eq $val){
555 $pos=$#{$hash{$key}};
556 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
559 &General
::writehasharray
($config, \
%hash);
567 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
568 &General
::readhasharray
($config, \
%hash);
569 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
570 if($hash{$key}[0] eq $val){
571 $pos=$#{$hash{$key}};
572 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
575 &General
::writehasharray
($config, \
%hash);
579 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
580 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
581 if ($fwdfwsettings{'POLICY1'} eq 'MODE1'){ $selected{'POLICY1'}{'MODE1'} = 'selected'; } else { $selected{'POLICY1'}{'MODE1'} = ''; }
582 if ($fwdfwsettings{'POLICY1'} eq 'MODE2'){ $selected{'POLICY1'}{'MODE2'} = 'selected'; } else { $selected{'POLICY1'}{'MODE2'} = ''; }
586 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
588 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
589 <table width='100%' border='0'>
590 <tr><td colspan='3' style='font-weight:bold;color:red;'>FORWARD </td></tr>
591 <tr><td colspan='3'>$Lang::tr{'fwdfw pol text'}</td></tr>
592 <tr><td colspan='3'><hr /></td></tr>
593 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
594 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
595 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
596 <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
599 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
600 print "</table></form>";
603 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
604 <table width='100%' border='0'>
605 <tr><td colspan='3' style='font-weight:bold;color:red;'>OUTGOING </td></tr>
606 <tr><td colspan='3'>$Lang::tr{'fwdfw pol text1'}</td></tr>
607 <tr><td colspan='3'><hr /></td></tr>
608 <tr><td width='15%' align='left'> <select name='POLICY1' style="width: 100px">
609 <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
610 <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
611 <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
614 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
615 print "</table></form>";
621 if (-f
"${General::swroot}/forward/reread"){
622 print "<table border='0'><form method='post'><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: red; font-weight: bold;'>$Lang::tr{'fwhost reread'}</td></tr></table></form><hr><br>";
624 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
625 print "<form method='post'>";
626 print "<table border='0'>";
627 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
628 print"</tr></table></form><hr>";
635 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
636 foreach my $key (sort {$a <=> $b} keys %delhash){
637 if ($key == $fwdfwsettings{'key'}){
638 #check hosts/net and groups
639 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
640 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
641 #check services and groups
642 if ($delhash{$key}[11] eq 'ON'){
643 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
646 if ($key >= $fwdfwsettings{'key'}) {
648 if (exists $delhash{$next}) {
649 foreach my $i (0 .. $#{$delhash{$next}}) {
650 $delhash{$key}[$i] = $delhash{$next}[$i];
655 # Remove the very last entry.
656 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
657 delete $delhash{$last_key};
659 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
662 if($fwdfwsettings{'nobase'} ne 'on'){
669 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
670 foreach my $key (sort keys %configfwdfw){
672 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
675 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
682 #check ip-address if manual
683 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
684 #check if ip with subnet
685 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
686 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
687 $subnet = &General
::iporsubtocidr
($subnet);
688 $fwdfwsettings{'isip'}='on';
691 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
692 $ip=$fwdfwsettings{'src_addr'};
694 $fwdfwsettings{'isip'}='on';
697 if ($fwdfwsettings{'isip'} ne 'on'){
698 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
700 if ($fwdfwsettings{'isip'} eq 'on'){
701 #check and form valid IP
702 $ip=&General
::ip2dec
($ip);
703 $ip=&General
::dec2ip
($ip);
704 #check if net or broadcast
705 my @tmp= split (/\./,$ip);
706 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
708 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
710 $fwdfwsettings{'src_addr'}="$ip/$subnet";
712 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
713 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
716 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
717 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
719 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
720 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
721 return $errormessage;
725 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
727 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
728 $fwdfwsettings{'SRC_PORT'}='';
729 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
730 foreach my $key (keys %icmptypes){
731 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
732 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
735 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
736 $fwdfwsettings{'SRC_PORT'}='';
737 $fwdfwsettings{'ICMP_TYPES'}='';
738 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
739 $fwdfwsettings{'SRC_PORT'}='';
740 $fwdfwsettings{'ICMP_TYPES'}='';
741 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
742 $fwdfwsettings{'SRC_PORT'}='';
743 $fwdfwsettings{'ICMP_TYPES'}='';
744 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
745 $fwdfwsettings{'ICMP_TYPES'}='';
747 $fwdfwsettings{'ICMP_TYPES'}='';
748 $fwdfwsettings{'SRC_PORT'}='';
749 $fwdfwsettings{'PROT'}='';
752 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
753 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
757 if ($_ =~ /^(\d+)\:(\d+)$/) {
759 #change dashes with :
762 push(@values,"1:65535");
765 if ($_ =~ /^(\D)\:(\d+)$/) {
766 push(@values,"1:$2");
769 if ($_ =~ /^(\d+)\:(\D)$/) {
770 push(@values,"$1:65535");
773 $errormessage .= &General
::validportrange
($_, 'destination');
778 if (&General
::validport
($_)){
785 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
786 return $errormessage;
793 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
794 #check if ip with subnet
795 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
796 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
797 $subnet = &General
::iporsubtocidr
($subnet);
800 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
801 $ip=$fwdfwsettings{'tgt_addr'};
804 #check and form valid IP
805 $ip=&General
::ip2dec
($ip);
806 $ip=&General
::dec2ip
($ip);
808 ##check if net or broadcast
809 #my @tmp= split (/\./,$ip);
810 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
812 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
814 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
816 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
817 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
820 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
821 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
822 return $errormessage;
826 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
829 if ($fwdfwsettings{'USESRV'} eq 'ON'){
830 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
831 $fwdfwsettings{'TGT_PROT'}='';
832 $fwdfwsettings{'ICMP_TGT'}='';
834 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
835 $fwdfwsettings{'TGT_PROT'}='';
836 $fwdfwsettings{'ICMP_TGT'}='';
837 #check target service
838 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
839 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
842 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
843 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
844 if ($fwdfwsettings{'TGT_PORT'} ne ''){
845 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
849 if ($_ =~ /^(\d+)\:(\d+)$/) {
851 #change dashes with :
854 push(@values,"1:65535");
857 if ($_ =~ /^(\D)\:(\d+)$/) {
858 push(@values,"1:$2");
861 if ($_ =~ /^(\d+)\:(\D)$/) {
862 push(@values,"$1:65535");
865 $errormessage .= &General
::validportrange
($_, 'destination');
870 if (&General
::validport
($_)){
877 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
879 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
880 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
881 $fwdfwsettings{'TGT_PORT'} = '';
882 $fwdfwsettings{'ICMP_TGT'} = '';
883 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
884 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
885 $fwdfwsettings{'TGT_PORT'} = '';
886 $fwdfwsettings{'ICMP_TGT'}='';
887 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
888 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
889 $fwdfwsettings{'TGT_PORT'} = '';
890 $fwdfwsettings{'ICMP_TGT'}='';
891 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
892 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
893 $fwdfwsettings{'TGT_PORT'} = '';
894 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
895 foreach my $key (keys %icmptypes){
897 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
898 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
906 if ($fwdfwsettings{'USESRV'} ne 'ON'){
907 $fwdfwsettings{'grp3'}='';
908 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
909 $fwdfwsettings{'TGT_PROT'}='';
910 $fwdfwsettings{'ICMP_TGT'}='';
913 if($fwdfwsettings{'TIME'} eq 'ON'){
914 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 ''){
915 $errormessage=$Lang::tr
{'fwdfw err time'};
918 return $errormessage;
923 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
924 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
926 #check if source and target identical
927 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
928 $errormessage.=$Lang::tr
{'fwdfw err same'};
929 return $errormessage;
932 #get source and targetip address if possible
933 my ($sip,$scidr,$tip,$tcidr);
934 ($sip,$scidr)=&get_ip
("src","grp1");
935 ($tip,$tcidr)=&get_ip
("tgt","grp2");
937 #check same iprange in source and target
938 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
939 my $networkip1=&General
::getnetworkip
($sip,$scidr);
940 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
941 if ($scidr gt $tcidr){
942 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
943 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
945 }elsif($scidr eq $tcidr && $scidr eq '32'){
946 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
947 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
948 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
949 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
950 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
953 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
954 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
959 #check source and destination protocol if manual
960 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
961 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
962 $errormessage.=$Lang::tr
{'fwdfw err prot'};
964 #check source and destination protocol if source manual and dest servicegrp
965 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
966 &General
::readhasharray
("$configsrv", \
%customservice);
967 foreach my $key (sort keys %customservice){
968 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
969 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
970 $errormessage.=$Lang::tr
{'fwdfw err prot'};
984 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
985 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
986 if ($fwdfwsettings{$grp} eq $val.'_addr'){
987 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
988 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
989 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
990 $a=$netsettings{'GREEN_NETADDRESS'};
991 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
992 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
993 $a=$netsettings{'ORANGE_NETADDRESS'};
994 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
995 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
996 $a=$netsettings{'BLUE_NETADDRESS'};
997 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
998 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
999 &General
::readhash
("$configovpn",\
%ovpnsettings);
1000 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1001 $b=&General
::iporsubtocidr
($b);
1003 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1004 &General
::readhasharray
("$confignet", \
%customnetwork);
1005 foreach my $key (keys %customnetwork){
1006 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1007 $a=$customnetwork{$key}[1];
1008 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1011 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1012 &General
::readhasharray
("$confighost", \
%customhost);
1013 foreach my $key (keys %customhost){
1014 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1015 if ($customhost{$key}[1] eq 'ip'){
1016 ($a,$b)=split (/\//,$customhost{$key}[2]);
1017 $b=&General
::iporsubtocidr
($b);
1019 if ($grp eq 'grp2'){
1020 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1032 &General
::setup_default_networks
(\
%defaultNetworks);
1033 #read all configfiles
1034 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1035 &General
::readhasharray
("$confignet", \
%customnetwork);
1036 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1037 &General
::readhasharray
("$confighost", \
%customhost);
1038 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1039 &General
::readhasharray
("$configgrp", \
%customgrp);
1040 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1041 &General
::get_aliases
(\
%aliases);
1045 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1046 my $config=$fwdfwsettings{'config'};
1048 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1049 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1050 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1051 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1052 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1053 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1054 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1055 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1056 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1057 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1058 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1059 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1060 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1061 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1062 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1063 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1064 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1065 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1066 #check if update and get values
1067 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1068 &General
::readhasharray
("$config", \
%hash);
1069 foreach my $key (sort keys %hash){
1071 if ($key eq $fwdfwsettings{'key'}){
1072 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1073 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1074 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1075 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1076 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1077 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1078 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1079 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1080 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1081 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1082 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1083 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1084 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1085 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1086 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1087 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1088 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1089 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1090 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1091 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1092 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1093 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1094 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1095 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1096 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1097 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1098 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1099 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1100 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1101 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1102 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1103 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1104 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1105 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1106 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1107 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1108 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1109 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1110 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1111 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1112 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1113 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1114 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1115 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1116 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1117 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1120 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1121 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1122 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1123 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1124 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1125 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1126 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1127 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1129 $fwdfwsettings{'ACTIVE'}='ON';
1130 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1133 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1136 <form method="post">
1138 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1140 foreach ("ACCEPT","DROP","REJECT")
1142 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1144 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1145 print">$_</option>";
1147 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1148 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1151 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1153 print"<option selected>$_</option>";
1155 print"<option>$_</option>";
1159 print"</select></td></tr></table><hr>";
1161 &Header
::closebox
();
1162 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1163 #------SOURCE-------------------------------------------------------
1165 <table width='100%' border='0'>
1166 <tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td colspan='5'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' ></td></tr>
1167 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1168 <tr><td width='1%'><input type='radio' name='grp1' value='std_net_src' $checked{'grp1'}{'std_net_src'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_src' style='min-width:185px;'>
1170 foreach my $network (sort keys %defaultNetworks)
1172 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1173 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1174 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1175 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1176 print ">$network</option>";
1179 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_net_src' $checked{'grp1'}{'ovpn_net_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_src' style='min-width:185px;'>
1181 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1184 <tr><td><input type='radio' name='grp1' value='cust_net_src' $checked{'grp1'}{'cust_net_src'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_src' style='min-width:185px;'>
1186 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1188 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_host_src' $checked{'grp1'}{'ovpn_host_src'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_src' style='min-width:185px;'>
1190 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1192 if ($ccdhost{$key}[33] ne ''){
1194 print "<option value='$ccdhost{$key}[1]'";
1195 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1196 print ">$ccdhost{$key}[1]</option>";
1201 <tr><td valign='top'><input type='radio' name='grp1' value='cust_host_src' $checked{'grp1'}{'cust_host_src'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_src' style='min-width:185px;'>
1203 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1205 </select></td><td width='1%'><input type='radio' name='grp1' value='ovpn_n2n_src' $checked{'grp1'}{'ovpn_n2n_src'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_src' style='min-width:185px;'>
1207 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1208 if($ccdhost{$key}[3] eq 'net'){
1210 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1211 print ">$ccdhost{$key}[1]</option>";
1217 <tr><td valign='top'><input type='radio' name='grp1' value='cust_grp_src' $checked{'grp1'}{'cust_grp_src'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_src' style='min-width:185px;'>
1219 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1220 if($helper ne $customgrp{$key}[0]){
1222 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1223 print ">$customgrp{$key}[0]</option>";
1225 $helper=$customgrp{$key}[0];
1229 <td valign='top'><input type='radio' name='grp1' value='ipsec_net_src' $checked{'grp1'}{'ipsec_net_src'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_src' style='min-width:185px;'>
1231 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1232 if ($ipsecconf{$key}[3] eq 'net'){
1234 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1235 print ">$ipsecconf{$key}[1]</option>";
1243 # <td valign='top'><input type='radio' name='grp1' value='ipsec_host_src' $checked{'grp1'}{'ipsec_host_src'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_src' style='min-width:185px;'>
1245 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1246 # if ($ipsecconf{$key}[3] eq 'host'){
1248 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1249 # print ">$ipsecconf{$key}[1]</option>";
1253 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1254 <table width='100%' border='0'>
1255 <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'}></td><td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td>
1256 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1258 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1260 if ($_ eq $fwdfwsettings{'PROT'})
1262 print"<option selected>$_</option>";
1264 print"<option>$_</option>";
1267 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1269 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1270 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='width:230px;'>
1272 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1273 print"<option>All ICMP-Types</option>";
1274 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1275 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1276 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1278 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1282 </select></td></tr></table><br><hr>
1284 &Header
::closebox
();
1286 #---TARGET------------------------------------------------------
1287 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1289 <table width='100%' border='0'>
1290 <tr><td width='1%'><input type='radio' name='grp2' value='tgt_addr' checked></td><td colspan='2'>$Lang::tr{'fwdfw targetip'}<input type='TEXT' name='tgt_addr' value='$fwdfwsettings{'tgt_addr'}' size='16'><td><input type='radio' name='grp2' value='ipfire' $checked{'grp2'}{'ipfire'}></td><td><b>IPFire ($Lang::tr{'external access'})</b></td><td><select name='ipfire' style='min-width:185px;'>
1292 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1294 foreach my $alias (sort keys %aliases)
1296 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1301 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1302 <tr><td width='1%'><input type='radio' name='grp2' value='std_net_tgt' $checked{'grp2'}{'std_net_tgt'}></td><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost stdnet'}</td><td width='13%'><select name='std_net_tgt' style='min-width:185px;'>
1304 foreach my $network (sort keys %defaultNetworks)
1306 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1307 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1308 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1309 print ">$network</option>";
1312 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_net_tgt' $checked{'grp2'}{'ovpn_net_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_net_tgt' style='min-width:185px;'>
1314 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1317 <tr><td><input type='radio' name='grp2' value='cust_net_tgt' $checked{'grp2'}{'cust_net_tgt'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='cust_net_tgt' style='min-width:185px;'>
1319 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1321 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_host_tgt' $checked{'grp2'}{'ovpn_host_tgt'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='ovpn_host_tgt' style='min-width:185px;'>
1323 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1325 if ($ccdhost{$key}[33] ne ''){
1326 print "<option value='$ccdhost{$key}[1]' ";
1327 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1328 print ">$ccdhost{$key}[1]</option>";
1333 <tr><td valign='top'><input type='radio' name='grp2' value='cust_host_tgt' $checked{'grp2'}{'cust_host_tgt'}></td><td>$Lang::tr{'fwhost cust addr'}</td><td><select name='cust_host_tgt' style='min-width:185px;'>
1335 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1337 </select></td><td width='1%'><input type='radio' name='grp2' value='ovpn_n2n_tgt' $checked{'grp2'}{'ovpn_n2n_tgt'}></td><td >$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='ovpn_n2n_tgt' style='min-width:185px;'>
1339 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1340 if($ccdhost{$key}[3] eq 'net'){
1342 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1343 print ">$ccdhost{$key}[1]</option>";
1348 <tr><td valign='top'><input type='radio' name='grp2' value='cust_grp_tgt' $checked{'grp2'}{'cust_grp_tgt'}></td><td >$Lang::tr{'fwhost cust grp'}</td><td><select name='cust_grp_tgt' style='min-width:185px;'>
1351 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1352 if($helper ne $customgrp{$key}[0]){
1354 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1355 print">$customgrp{$key}[0]</option>";
1357 $helper=$customgrp{$key}[0];
1361 <td valign='top'><input type='radio' name='grp2' value='ipsec_net_tgt' $checked{'grp2'}{'ipsec_net_tgt'}></td><td >$Lang::tr{'fwhost ipsec net'}</td><td><select name='ipsec_net_tgt' style='min-width:185px;'>
1363 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1364 if ($ipsecconf{$key}[3] eq 'net'){
1366 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1367 print">$ipsecconf{$key}[1]</option>";
1373 # <td valign='top'><input type='radio' name='grp2' value='ipsec_host_tgt' $checked{'grp2'}{'ipsec_host_tgt'}></td><td >$Lang::tr{'fwhost ipsec host'}</td><td><select name='ipsec_host_tgt' style='min-width:185px;'>
1375 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1376 # if ($ipsecconf{$key}[3] eq 'host'){
1378 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1379 # print">$ipsecconf{$key}[1]</option>";
1384 <b>$Lang::tr{'fwhost attention'}:</b><br>
1385 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1387 <table width='100%' border='0'>
1388 <tr><td width='1%'><input type='checkbox' name='USESRV' value='ON' $checked{'USESRV'}{'ON'} ></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td><td width='1%'><input type='radio' name='grp3' 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;' >
1390 &General
::readhasharray
("$configsrv", \
%customservice);
1391 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1393 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1394 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1398 <tr><td colspan='2'></td><td><input type='radio' name='grp3' 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;' >
1400 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1402 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1403 if ($helper ne $customservicegrp{$key}[0]){
1405 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1406 print">$customservicegrp{$key}[0]</option>";
1408 $helper=$customservicegrp{$key}[0];
1412 <tr><td colspan='2'></td><td><input type='radio' name='grp3' value='TGT_PORT' $checked{'grp3'}{'TGT_PORT'}></td><td>$Lang::tr{'fwdfw man port'}</td><td><select name='TGT_PROT'>
1414 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1416 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1418 print"<option selected>$_</option>";
1420 print"<option>$_</option>";
1423 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1425 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1426 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT' style='min-width:230px;'>
1428 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1429 print"<option>All ICMP-Types</option>";
1430 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1431 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1432 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1434 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1443 #---Activate/logging/remark-------------------------------------
1444 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1446 <table width='100%' border='0'>
1447 <tr><td width='12%'>$Lang::tr{'remark'}:</td><td align='left'><input type='text' name='ruleremark' size='40' maxlength='255' value='$fwdfwsettings{'ruleremark'}'></td></tr>
1449 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1450 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1451 for (my $count =1; $count <= $sum; $count++){
1452 print"<option value='$count' ";
1453 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1454 print">$count</option>";
1456 print"</select></td></tr>";
1458 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1462 </table><table width='100%'>
1463 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1464 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1467 &Header
::closebox
();
1468 #---ADD TIMEFRAME-----------------------------------------------
1469 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1471 <table width='70%' border='0'>
1472 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1473 <tr><td colspan='7'> </td></tr>
1475 <td align='left'>$Lang::tr{'time'}:</td>
1476 <td width='30%' align='left'>$Lang::tr{'advproxy monday'} $Lang::tr{'advproxy tuesday'} $Lang::tr{'advproxy wednesday'} $Lang::tr{'advproxy thursday'} $Lang::tr{'advproxy friday'} $Lang::tr{'advproxy saturday'} $Lang::tr{'advproxy sunday'}</td>
1477 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1478 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1481 <td align='right'></td>
1482 <td width='30%' align='left'>
1483 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1484 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1485 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1486 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1487 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1488 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1489 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1491 <td><select name='TIME_FROM'>
1493 for (my $i=0;$i<=23;$i++) {
1494 $i = sprintf("%02s",$i);
1495 for (my $j=0;$j<=45;$j+=15) {
1496 $j = sprintf("%02s",$j);
1497 my $time = $i.":".$j;
1498 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1503 <td><select name='TIME_TO'>
1505 for (my $i=0;$i<=23;$i++) {
1506 $i = sprintf("%02s",$i);
1507 for (my $j=0;$j<=45;$j+=15) {
1508 $j = sprintf("%02s",$j);
1509 my $time = $i.":".$j;
1510 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1518 #---ACTION------------------------------------------------------
1519 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1521 <table border='0' width='100%'>
1522 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1523 <input type='hidden' name='config' value='$config' >
1524 <input type='hidden' name='ACTION' value='saverule' >
1525 </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>
1530 <table border='0' width='100%'>
1531 <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'}'>
1532 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1533 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1534 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1535 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1536 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1537 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1538 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1539 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1540 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1541 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1542 <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>
1546 &Header
::closebox
();
1552 &General
::readhasharray
("$config", $hash);
1553 if (!$errormessage){
1554 #check if we change an forward rule to an external access
1555 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1556 &changerule
($configfwdfw);
1558 #check if we change an forward rule to an outgoing
1559 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1560 &changerule
($configfwdfw);
1562 #check if we change an external access rule to a forward
1563 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1564 &changerule
($configinput);
1566 #check if we change an external access rule to a outgoing
1567 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1568 &changerule
($configinput);
1570 #check if we change an outgoing rule to a forward
1571 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' &&$fwdfwsettings{'updatefwrule'} eq 'on'){
1572 &changerule
($configoutgoing);
1574 #check if we change an outgoing rule to a external access
1575 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
1576 &changerule
($configoutgoing);
1578 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1579 my $key = &General
::findhasharraykey
($hash);
1580 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1581 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1582 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1583 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1584 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1585 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1586 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1587 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1588 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1589 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1590 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1591 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1592 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1593 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1594 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1595 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1596 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1597 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1598 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1599 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1600 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1601 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1602 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1603 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1604 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1605 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1606 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1607 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1608 &General
::writehasharray
("$config", $hash);
1610 foreach my $key (sort {$a <=> $b} keys %$hash){
1611 if($key eq $fwdfwsettings{'key'}){
1612 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1613 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1614 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1615 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1616 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1617 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1618 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1619 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1620 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1621 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1622 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1623 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1624 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1625 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1626 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1627 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1628 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1629 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1630 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1631 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1632 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1633 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1634 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1635 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1636 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1637 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1638 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1639 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1644 &General
::writehasharray
("$config", $hash);
1645 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1647 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1648 for (my $z=0;$z<$val;$z++){
1649 foreach my $key (sort {$a <=> $b} keys %$hash){
1650 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1652 if (exists $$hash{$last}){
1654 foreach my $y (0 .. $#{$$hash{$last}}) {
1655 $tmp{0}[$y] = $$hash{$last}[$y];
1657 #copy active rule to last
1658 foreach my $i (0 .. $#{$$hash{$last}}) {
1659 $$hash{$last}[$i] = $$hash{$key}[$i];
1661 #copy saved rule to actual position
1662 foreach my $x (0 .. $#{$tmp{0}}) {
1663 $$hash{$key}[$x] = $tmp{0}[$x];
1668 $fwdfwsettings{'oldrulenumber'}--;
1670 &General
::writehasharray
("$config", $hash);
1672 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1674 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1675 for (my $z=0;$z<$val;$z++){
1676 foreach my $key (sort {$a <=> $b} keys %$hash){
1677 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1678 my $next = $key + 1;
1679 if (exists $$hash{$next}){
1681 foreach my $y (0 .. $#{$$hash{$next}}) {
1682 $tmp{0}[$y] = $$hash{$next}[$y];
1684 #copy active rule to next
1685 foreach my $i (0 .. $#{$$hash{$next}}) {
1686 $$hash{$next}[$i] = $$hash{$key}[$i];
1688 #copy saved rule to actual position
1689 foreach my $x (0 .. $#{$tmp{0}}) {
1690 $$hash{$key}[$x] = $tmp{0}[$x];
1695 $fwdfwsettings{'oldrulenumber'}++;
1697 &General
::writehasharray
("$config", $hash);
1704 if ($errormessage) {
1705 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1706 print "<class name='base'>$errormessage\n";
1707 print " </class>\n";
1708 &Header
::closebox
();
1715 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1716 print "<class name='base'>$hint\n";
1717 print " </class>\n";
1718 &Header
::closebox
();
1725 &General
::setup_default_networks
(\
%defaultNetworks);
1726 foreach my $network (sort keys %defaultNetworks)
1728 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1733 # Checks a hostname against RFC1035
1736 # Each part should be at least two characters in length
1737 # but no more than 63 characters
1738 if (length ($remark) < 1 || length ($remark) > 255) {
1740 # Only valid characters are a-z, A-Z, 0-9 and -
1741 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
1743 # First character can only be a letter or a digit
1744 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1746 # Last character can only be a letter or a digit
1747 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
1753 my %hash=%{(shift)};
1755 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1756 $hash{$key}[10]=~ s/\|/,/g;
1757 print": $hash{$key}[10]";
1758 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1759 print": <br>$hash{$key}[9] ";
1764 my %hash=%{(shift)};
1768 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1769 if($hash{$key}[14] eq 'cust_srv'){
1770 &General
::readhasharray
("$configsrv", \
%customservice);
1771 foreach my $i (sort keys %customservice){
1772 if($customservice{$i}[0] eq $hash{$key}[15]){
1773 $service = $customservice{$i}[0];
1776 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1777 $service=$hash{$key}[15];
1778 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1779 $hash{$key}[15]=~ s/\|/,/g;
1780 $service=$hash{$key}[15];
1785 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1786 print":<br>$hash{$key}[13]";
1789 sub get_serviceports
1793 &General
::readhasharray
("$configsrv", \
%customservice);
1794 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1798 if($type eq 'service'){
1799 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1800 if ($customservice{$key}[0] eq $name){
1801 $protocols=$customservice{$key}[2];
1804 }elsif($type eq 'group'){
1805 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1806 if ($customservicegrp{$key}[0] eq $name){
1807 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1808 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1809 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1815 if($tcp && $udp){$protocols="TCP,UDP";
1816 }elsif($tcp){$protocols.="TCP";
1817 }elsif($udp){$protocols.="UDP";}
1822 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
1823 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1824 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1825 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
1834 &General
::get_aliases
(\
%aliases);
1835 &General
::readhasharray
("$config", $hash);
1837 &Header
::openbox
('100%', 'left',$title);
1845 print"<b>$title1</b><br>";
1846 print"<table width='100%' cellspacing='1' rules='none'; padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1847 print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'fwdfw time'}</td><td align='center' colspan='6'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1848 foreach my $key (sort {$a <=> $b} keys %$hash){
1851 #check if vpn hosts/nets have been deleted
1852 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1853 push (@tmpsrc,$$hash{$key}[4]);
1855 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1856 push (@tmpsrc,$$hash{$key}[6]);
1858 foreach my $host (@tmpsrc){
1859 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1860 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1862 &disable_rule
($key);
1865 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1866 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1868 &disable_rule
($key);
1871 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1872 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1874 &disable_rule
($key);
1877 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1878 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1880 &disable_rule
($key);
1884 #$$hash{$key}[3]='';
1885 #$$hash{$key}[5]='';
1887 $$hash{'ACTIVE'}=$$hash{$key}[2];
1889 if($coloryellow eq 'on'){
1890 print"<tr bgcolor='$color{'color14'}' >";
1892 }elsif($coloryellow eq ''){
1894 $color="$color{'color22'}";
1897 $color="$color{'color20'}";
1900 print"<tr bgcolor='$color' >";
1902 <td align='right' width='15'>$key</td>
1904 if ($$hash{$key}[0] eq 'ACCEPT'){
1907 $rulecolor=$color{'color17'};
1908 }elsif($$hash{$key}[0] eq 'DROP'){
1911 $rulecolor=$color{'color25'};
1912 }elsif($$hash{$key}[0] eq 'REJECT'){
1915 $rulecolor=$color{'color16'};
1917 print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
1918 &getcolor
($$hash{$key}[3],$$hash{$key}[4]);
1919 print"<td align='center' width='160' $tdcolor>";
1920 if ($$hash{$key}[3] eq 'std_net_src'){
1921 print &get_name
($$hash{$key}[4]);
1923 print $$hash{$key}[4];
1926 &getsrcport
(\
%$hash,$key);
1927 if ($$hash{$key}[17] eq 'ON'){
1928 $log="/images/on.gif";
1930 $log="/images/off.gif";
1934 <form method='post'>
1935 <td align='left' width='25'><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 ;'/>
1936 <input type='hidden' name='key' value='$key' />
1937 <input type='hidden' name='config' value='$config' />
1938 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1941 &getcolor
($$hash{$key}[5],$$hash{$key}[6]);
1943 <td align='center' width='160' $tdcolor>
1945 if ($$hash{$key}[5] eq 'std_net_tgt'){
1946 print &get_name
($$hash{$key}[6]);
1948 print $$hash{$key}[6];
1951 &gettgtport
(\
%$hash,$key);
1955 if ($$hash{$key}[12]){ #target prot if manual
1956 $prot=$$hash{$key}[12];
1957 }elsif($$hash{$key}[8]){ #source prot if manual
1958 $prot=$$hash{$key}[8];
1959 }elsif($$hash{$key}[14] eq 'cust_srv'){
1960 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1961 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1962 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1964 $prot=$Lang::tr
{'all'};
1966 print"<td align='center'>$prot</td>";
1967 if ($$hash{$key}[18] eq 'ON'){
1969 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1970 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1971 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1972 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1973 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1974 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1975 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1976 my $weekdays=join(",",@days);
1978 print"<td align='center' width='100'>$weekdays   $$hash{$key}[26] - $$hash{$key}[27]</td>";
1981 print"<td align='center'>24/7</td>";
1983 if($$hash{$key}[2] eq 'ON'){
1984 $gif="/images/on.gif"
1987 $gif="/images/off.gif"
1990 <form method='post'>
1991 <td width='25'><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;' />
1992 <input type='hidden' name='key' value='$key' />
1993 <input type='hidden' name='config' value='$config' />
1994 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1996 <form method='post'>
1997 <td width='25' ><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;' />
1998 <input type='hidden' name='key' value='$key' />
1999 <input type='hidden' name='config' value='$config' />
2000 <input type='hidden' name='ACTION' value='editrule' />
2002 <form method='post'>
2003 <td width='25'><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;' />
2004 <input type='hidden' name='key' value='$key' />
2005 <input type='hidden' name='config' value='$config' />
2006 <input type='hidden' name='ACTION' value='copyrule' />
2008 <form method='post'>
2009 <td width='25' ><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;' />
2010 <input type='hidden' name='key' value='$key' />
2011 <input type='hidden' name='config' value='$config' />
2012 <input type='hidden' name='ACTION' value='deleterule' />
2015 if (exists $$hash{$key-1}){
2017 <form method='post'>
2018 <td width='25'><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;' />
2019 <input type='hidden' name='key' value='$key' />
2020 <input type='hidden' name='config' value='$config' />
2021 <input type='hidden' name='ACTION' value='moveup' />
2025 print"<td width='25'><input type='image' img src='/images/up.gif' style='visibility:hidden;'></td>";
2027 if (exists $$hash{$key+1}){
2029 <form method='post'>
2030 <td width='25' ><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;' />
2031 <input type='hidden' name='key' value='$key' />
2032 <input type='hidden' name='config' value='$config' />
2033 <input type='hidden' name='ACTION' value='movedown' />
2034 </td></form></td></tr>
2037 print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
2040 print"<tr bgcolor='$color'><td colspan='13' style='border-bottom: 1px solid black'>";
2041 print"<b>$Lang::tr{'remark'}:</b> $$hash{$key}[16]</td></tr>";
2044 &Header
::closebox
();
2052 if($optionsfw{'SHOWCOLORS'} eq 'on'){
2053 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'){
2054 $tdcolor="style='border: 2px solid $Header::colourovpn;'";
2057 if ($nettype eq 'ipsec_net_src' || $nettype eq 'ipsec_net_tgt'){
2058 $tdcolor="style='border: 2px solid $Header::colourvpn;'";
2061 foreach my $alias (sort keys %aliases)
2063 if ($val eq $alias){
2064 $tdcolor="style='border: 2px solid red;'";
2068 if ($val eq 'GREEN'){
2069 $tdcolor="style='border: 2px solid $Header::colourgreen;'";
2070 }elsif ($val eq 'ORANGE'){
2071 $tdcolor="style='border: 2px solid $Header::colourorange;'";
2072 }elsif ($val eq 'BLUE'){
2073 $tdcolor="style='border: 2px solid $Header::colourblue;'";
2074 }elsif ($val eq 'RED'){
2075 $tdcolor="style='border: 2px solid $Header::colourred;'";
2076 }elsif ($val eq 'IPFire' ){
2077 $tdcolor="style='border: 2px solid $Header::colourred;'";
2078 }elsif($val =~ /^(.*?)\/(.*?
)$/){
2079 my ($sip,$scidr) = split ("/",$val);
2080 if ( &General
::IpInSubnet
($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
2081 $tdcolor="style='border: 2px solid $Header::colourorange;'";
2083 if ( &General
::IpInSubnet
($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
2084 $tdcolor="style='border: 2px solid $Header::colourgreen;'";
2086 if ( &General
::IpInSubnet
($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
2087 $tdcolor="style='border: 2px solid $Header::colourblue;'";
2089 }elsif ($val eq 'Default IP'){
2090 $tdcolor="style='border: 2px solid red;'";
2098 my %hash=%{(shift)};
2101 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
2102 if($hash{$key}[0] eq $val){
2103 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
2105 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
2111 if (!-f
"${General::swroot}/forward/reread"){
2112 system("touch ${General::swroot}/forward/reread");
2113 system("touch ${General::swroot}/fwhosts/reread");
2118 system("/usr/local/bin/forwardfwctrl");
2119 if ( -f
"${General::swroot}/forward/reread"){
2120 system("rm ${General::swroot}/forward/reread");
2121 system("rm ${General::swroot}/fwhosts/reread");
2124 &Header
::closebigbox
();
2125 &Header
::closepage
();