]>
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 $p2pfile = "${General::swroot}/forward/p2protocols";
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);
99 &Header
::showhttpheaders
();
100 &Header
::getcgihash
(\
%fwdfwsettings);
101 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
102 &Header
::openbigbox
('100%', 'center',$errormessage);
105 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
107 my $MODE = $fwdfwsettings{'POLICY'};
109 $fwdfwsettings{'POLICY'} = "$MODE";
110 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
113 if ($fwdfwsettings{'ACTION'} eq 'saverule')
115 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
116 &General
::readhasharray
("$configinput", \
%configinputfw);
117 &General
::readhasharray
("$configinput", \
%configoutgoingfw);
118 $errormessage=&checksource
;
119 if(!$errormessage){&checktarget
;}
120 if(!$errormessage){&checkrule
;}
122 #check if we change an forward rule to an external access
123 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
124 &changerule
($configfwdfw);
126 #check if we change an forward rule to an outgoing
127 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'oldgrp1b'} ne 'IPFire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
128 &changerule
($configfwdfw);
130 #check if we change an external access rule to a forward
131 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
132 &changerule
($configinput);
134 #check if we change an external access rule to a outgoing
135 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
136 &changerule
($configinput);
138 #check if we change an outgoing rule to a forward
139 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} ne 'ipfire' &&$fwdfwsettings{'updatefwrule'} eq 'on'){
140 &changerule
($configoutgoing);
142 #check if we change an outgoing rule to a external access
143 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'IPFire' && $fwdfwsettings{'oldgrp1b'} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
144 &changerule
($configoutgoing);
146 #check if we try to break rules
147 if( $fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire' && $fwdfwsettings{'grp2'} eq 'ipfire'){
148 $errormessage.=$Lang::tr
{'fwdfw err same'};
151 if($fwdfwsettings{'grp2'} eq 'ipfire'){
152 $fwdfwsettings{'config'}=$configinput;
153 $fwdfwsettings{'chain'} = 'INPUTFW';
154 my $maxkey=&General
::findhasharraykey
(\
%configinputfw);
155 #check if we have an identical rule already
156 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
157 foreach my $key (sort keys %configinputfw){
158 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'}"
159 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]"){
160 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
161 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
163 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
164 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
166 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
167 $fwdfwsettings{'nosave'} = 'on';
172 #check Rulepos on new Rule
173 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
174 $fwdfwsettings{'oldrulenumber'}=$maxkey;
175 foreach my $key (sort keys %configinputfw){
176 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'}"
177 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]"){
178 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
182 #check if we just close a rule
183 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'} ) {
184 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
186 $fwdfwsettings{'nosave2'} = 'on';
189 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
190 if ($fwdfwsettings{'nobase'} ne 'on'){
191 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
193 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
194 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
195 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
196 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
197 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
198 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
200 if($fwdfwsettings{'nosave2'} ne 'on'){
201 &saverule
(\
%configinputfw,$configinput);
203 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
204 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
205 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
206 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
207 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
208 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
209 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
210 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
211 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
212 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
213 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
214 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
215 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
216 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
217 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
218 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
220 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
221 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
222 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
223 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
224 }elsif($fwdfwsettings{$fwdfwsettings{'grp1'}} eq 'IPFire'){
225 $fwdfwsettings{'config'}=$configoutgoing;
226 $fwdfwsettings{'chain'} = 'OUTGOINGFW';
227 my $maxkey=&General
::findhasharraykey
(\
%configoutgoingfw);
228 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
229 foreach my $key (sort keys %configoutgoingfw){
230 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'}"
231 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]"){
232 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
233 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
235 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
236 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
238 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
239 $fwdfwsettings{'nosave'} = 'on';
244 #check Rulepos on new Rule
245 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
246 $fwdfwsettings{'oldrulenumber'}=$maxkey;
247 foreach my $key (sort keys %configoutgoingfw){
248 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'}"
249 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]"){
250 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
254 #check if we just close a rule
255 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'} ) {
256 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
257 $fwdfwsettings{'nosave2'} = 'on';
262 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
263 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
264 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
265 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
266 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
267 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
268 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
269 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
271 if ($fwdfwsettings{'nobase'} eq 'on'){
272 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
274 if ($fwdfwsettings{'nosave2'} ne 'on'){
275 &saverule
(\
%configoutgoingfw,$configoutgoing);
279 $fwdfwsettings{'config'}=$configfwdfw;
280 $fwdfwsettings{'chain'} = 'FORWARDFW';
281 my $maxkey=&General
::findhasharraykey
(\
%configfwdfw);
282 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
283 #check if we have an identical rule already
284 foreach my $key (sort keys %configfwdfw){
285 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'}"
286 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]"){
287 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
288 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && &validremark
($fwdfwsettings{'ruleremark'})){
290 }elsif($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on' && !&validremark
($fwdfwsettings{'ruleremark'})){
291 $errormessage=$Lang::tr
{'fwdfw err remark'}."<br>";
293 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
294 $fwdfwsettings{'nosave'} = 'on';
299 #check Rulepos on new Rule
300 if($fwdfwsettings{'rulepos'} > 0 && !$fwdfwsettings{'oldrulenumber'}){
301 $fwdfwsettings{'oldrulenumber'}=$maxkey;
302 foreach my $key (sort keys %configfwdfw){
303 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'}"
304 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]"){
305 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
309 #check if we just close a rule
310 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'} ) {
311 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
312 $fwdfwsettings{'nosave2'} = 'on';
317 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
318 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
319 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
320 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
321 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
322 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
323 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
324 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
326 if ($fwdfwsettings{'nobase'} eq 'on'){
327 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
329 if ($fwdfwsettings{'nosave2'} ne 'on'){
330 &saverule
(\
%configfwdfw,$configfwdfw);
332 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
333 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
334 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
335 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
336 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
337 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
338 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
339 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
340 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
341 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
342 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
343 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
344 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
345 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
346 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
347 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
349 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
350 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
351 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
352 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
357 if($fwdfwsettings{'nosave2'} ne 'on'){
363 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
365 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
366 foreach my $key (sort keys %configfwdfw){
367 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
368 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
369 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
371 &General
::readhasharray
("$configinput", \
%configinputfw);
372 foreach my $key (sort keys %configinputfw){
373 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
374 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
375 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
378 system("rm ${General::swroot}/forward/config");
379 system("rm ${General::swroot}/forward/input");
380 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
381 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
382 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
384 $fwdfwsettings{'POLICY'}='MODE2';
385 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
389 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
393 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
396 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
397 foreach my $key (sort keys %togglehash){
398 if ($key eq $fwdfwsettings{'key'}){
399 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
402 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
406 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
409 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
410 foreach my $key (sort keys %togglehash){
411 if ($key eq $fwdfwsettings{'key'}){
412 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
415 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
419 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
424 if ($fwdfwsettings{'ACTION'} eq 'editrule')
426 $fwdfwsettings{'updatefwrule'}='on';
429 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
433 if ($fwdfwsettings{'ACTION'} eq 'moveup')
438 if ($fwdfwsettings{'ACTION'} eq 'movedown')
443 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
445 $fwdfwsettings{'copyfwrule'}='on';
446 #$fwdfwsettings{'updatefwrule'}='on';
449 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
451 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
452 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
455 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
456 foreach my $p2pentry (sort @p2ps)
458 my @p2pline = split( /\;/, $p2pentry );
459 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
460 if($p2pline[2] eq 'on'){
466 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
472 if ($fwdfwsettings{'ACTION'} eq '')
480 $fwdfwsettings{'updatefwrule'}='';
481 $fwdfwsettings{'config'}=$oldchain;
482 $fwdfwsettings{'nobase'}='on';
484 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
485 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
493 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
494 foreach my $key (sort keys %uphash){
495 if ($key eq $fwdfwsettings{'key'}) {
497 if (exists $uphash{$last}){
499 foreach my $y (0 .. $#{$uphash{$last}}) {
500 $tmp{0}[$y] = $uphash{$last}[$y];
502 #copy active rule to last
503 foreach my $i (0 .. $#{$uphash{$last}}) {
504 $uphash{$last}[$i] = $uphash{$key}[$i];
506 #copy saved rule to actual position
507 foreach my $x (0 .. $#{$tmp{0}}) {
508 $uphash{$key}[$x] = $tmp{0}[$x];
513 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
520 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
521 foreach my $key (sort keys %downhash){
522 if ($key eq $fwdfwsettings{'key'}) {
524 if (exists $downhash{$next}){
526 foreach my $y (0 .. $#{$downhash{$next}}) {
527 $tmp{0}[$y] = $downhash{$next}[$y];
529 #copy active rule to next
530 foreach my $i (0 .. $#{$downhash{$next}}) {
531 $downhash{$next}[$i] = $downhash{$key}[$i];
533 #copy saved rule to actual position
534 foreach my $x (0 .. $#{$tmp{0}}) {
535 $downhash{$key}[$x] = $tmp{0}[$x];
540 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
545 my ($base1,$val1,$base2,$val2) = @_;
547 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
548 &dec_counter
($confignet,\
%customnetwork,$val1);
549 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
550 &dec_counter
($confighost,\
%customhost,$val1);
551 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
552 &dec_counter
($configgrp,\
%customgrp,$val1);
553 }elsif($base1 eq 'cust_srv'){
554 &dec_counter
($configsrv,\
%customservice,$val1);
555 }elsif($base1 eq 'cust_srvgrp'){
556 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
559 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
560 &inc_counter
($confignet,\
%customnetwork,$val2);
561 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
562 &inc_counter
($confighost,\
%customhost,$val2);
563 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
564 &inc_counter
($configgrp,\
%customgrp,$val2);
565 }elsif($base2 eq 'cust_srv'){
566 &inc_counter
($configsrv,\
%customservice,$val2);
567 }elsif($base2 eq 'cust_srvgrp'){
568 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
578 &General
::readhasharray
($config, \
%hash);
579 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
580 if($hash{$key}[0] eq $val){
581 $pos=$#{$hash{$key}};
582 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
585 &General
::writehasharray
($config, \
%hash);
593 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
594 &General
::readhasharray
($config, \
%hash);
595 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
596 if($hash{$key}[0] eq $val){
597 $pos=$#{$hash{$key}};
598 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
601 &General
::writehasharray
($config, \
%hash);
605 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
606 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
610 &Header
::openbox
('100%', 'center', $Lang::tr
{'fwdfw pol title'});
612 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
613 <table width='100%' border='0'>
614 <tr><td colspan='3'>$Lang::tr{'fwdfw pol text'}</td></tr>
616 <tr><td colspan='3'><hr /></td></tr>
617 <tr><td width='15%' align='left'> <select name='POLICY' style="width: 100px">
618 <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
619 <option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
620 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
621 <td width='45%' align='left'>
623 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
624 print "</table></form>";
630 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
632 print "<form method='post'>";
633 print "<table border='0'>";
634 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
635 if (-f
"${General::swroot}/forward/reread"){
636 print "<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>";
638 print"</tr></table></form><hr>";
646 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
647 foreach my $key (sort {$a <=> $b} keys %delhash){
648 if ($key == $fwdfwsettings{'key'}){
649 #check hosts/net and groups
650 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
651 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
652 #check services and groups
653 if ($delhash{$key}[11] eq 'ON'){
654 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
657 if ($key >= $fwdfwsettings{'key'}) {
659 if (exists $delhash{$next}) {
660 foreach my $i (0 .. $#{$delhash{$next}}) {
661 $delhash{$key}[$i] = $delhash{$next}[$i];
666 # Remove the very last entry.
667 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
668 delete $delhash{$last_key};
670 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
673 if($fwdfwsettings{'nobase'} ne 'on'){
680 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
681 foreach my $key (sort keys %configfwdfw){
683 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
686 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
693 #check ip-address if manual
694 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
695 #check if ip with subnet
696 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
697 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
698 $subnet = &General
::iporsubtocidr
($subnet);
699 $fwdfwsettings{'isip'}='on';
702 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
703 $ip=$fwdfwsettings{'src_addr'};
705 $fwdfwsettings{'isip'}='on';
708 if ($fwdfwsettings{'isip'} ne 'on'){
709 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
711 if ($fwdfwsettings{'isip'} eq 'on'){
712 #check and form valid IP
713 $ip=&General
::ip2dec
($ip);
714 $ip=&General
::dec2ip
($ip);
715 #check if net or broadcast
716 my @tmp= split (/\./,$ip);
717 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
719 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
721 $fwdfwsettings{'src_addr'}="$ip/$subnet";
723 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
724 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
727 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
728 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
730 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
731 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
732 return $errormessage;
736 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
738 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
739 $fwdfwsettings{'SRC_PORT'}='';
740 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
741 foreach my $key (keys %icmptypes){
742 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
743 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
746 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
747 $fwdfwsettings{'SRC_PORT'}='';
748 $fwdfwsettings{'ICMP_TYPES'}='';
749 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
750 $fwdfwsettings{'SRC_PORT'}='';
751 $fwdfwsettings{'ICMP_TYPES'}='';
752 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
753 $fwdfwsettings{'SRC_PORT'}='';
754 $fwdfwsettings{'ICMP_TYPES'}='';
755 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
756 $fwdfwsettings{'ICMP_TYPES'}='';
758 $fwdfwsettings{'ICMP_TYPES'}='';
759 $fwdfwsettings{'SRC_PORT'}='';
760 $fwdfwsettings{'PROT'}='';
763 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && ($fwdfwsettings{'PROT'} eq 'TCP' || $fwdfwsettings{'PROT'} eq 'UDP') && $fwdfwsettings{'SRC_PORT'} ne ''){
764 my @parts=split(",",$fwdfwsettings{'SRC_PORT'});
768 if ($_ =~ /^(\d+)\:(\d+)$/) {
770 #change dashes with :
773 push(@values,"1:65535");
776 if ($_ =~ /^(\D)\:(\d+)$/) {
777 push(@values,"1:$2");
780 if ($_ =~ /^(\d+)\:(\D)$/) {
781 push(@values,"$1:65535");
784 $errormessage .= &General
::validportrange
($_, 'destination');
789 if (&General
::validport
($_)){
796 $fwdfwsettings{'SRC_PORT'}=join("|",@values);
797 return $errormessage;
804 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
805 #check if ip with subnet
806 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
807 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
808 $subnet = &General
::iporsubtocidr
($subnet);
811 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
812 $ip=$fwdfwsettings{'tgt_addr'};
815 #check and form valid IP
816 $ip=&General
::ip2dec
($ip);
817 $ip=&General
::dec2ip
($ip);
819 ##check if net or broadcast
820 #my @tmp= split (/\./,$ip);
821 #if ($tmp[3] eq "0" || ($tmp[3] eq "255"))
823 #$errormessage=$Lang::tr{'fwhost err hostip'}."<br>";
825 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
827 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
828 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
831 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
832 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
833 return $errormessage;
837 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
840 if ($fwdfwsettings{'USESRV'} eq 'ON'){
841 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
842 $fwdfwsettings{'TGT_PROT'}='';
843 $fwdfwsettings{'ICMP_TGT'}='';
845 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
846 $fwdfwsettings{'TGT_PROT'}='';
847 $fwdfwsettings{'ICMP_TGT'}='';
848 #check target service
849 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
850 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
853 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
854 if ($fwdfwsettings{'TGT_PROT'} eq 'TCP' || $fwdfwsettings{'TGT_PROT'} eq 'UDP'){
855 if ($fwdfwsettings{'TGT_PORT'} ne ''){
856 my @parts=split(",",$fwdfwsettings{'TGT_PORT'});
860 if ($_ =~ /^(\d+)\:(\d+)$/) {
862 #change dashes with :
865 push(@values,"1:65535");
868 if ($_ =~ /^(\D)\:(\d+)$/) {
869 push(@values,"1:$2");
872 if ($_ =~ /^(\d+)\:(\D)$/) {
873 push(@values,"$1:65535");
876 $errormessage .= &General
::validportrange
($_, 'destination');
881 if (&General
::validport
($_)){
888 $fwdfwsettings{'TGT_PORT'}=join("|",@values);
890 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
891 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
892 $fwdfwsettings{'TGT_PORT'} = '';
893 $fwdfwsettings{'ICMP_TGT'} = '';
894 }elsif($fwdfwsettings{'TGT_PROT'} eq 'ESP'){
895 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
896 $fwdfwsettings{'TGT_PORT'} = '';
897 $fwdfwsettings{'ICMP_TGT'}='';
898 }elsif($fwdfwsettings{'TGT_PROT'} eq 'AH'){
899 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
900 $fwdfwsettings{'TGT_PORT'} = '';
901 $fwdfwsettings{'ICMP_TGT'}='';
902 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
903 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
904 $fwdfwsettings{'TGT_PORT'} = '';
905 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
906 foreach my $key (keys %icmptypes){
908 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
909 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
917 if ($fwdfwsettings{'USESRV'} ne 'ON'){
918 $fwdfwsettings{'grp3'}='';
919 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
920 $fwdfwsettings{'TGT_PROT'}='';
921 $fwdfwsettings{'ICMP_TGT'}='';
924 if($fwdfwsettings{'TIME'} eq 'ON'){
925 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 ''){
926 $errormessage=$Lang::tr
{'fwdfw err time'};
929 return $errormessage;
934 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
935 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
937 #check if source and target identical
938 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{$fwdfwsettings{'grp1'}} ne 'ALL'){
939 $errormessage.=$Lang::tr
{'fwdfw err same'};
940 return $errormessage;
943 #get source and targetip address if possible
944 my ($sip,$scidr,$tip,$tcidr);
945 ($sip,$scidr)=&get_ip
("src","grp1");
946 ($tip,$tcidr)=&get_ip
("tgt","grp2");
948 #check same iprange in source and target
949 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
950 my $networkip1=&General
::getnetworkip
($sip,$scidr);
951 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
952 if ($scidr gt $tcidr){
953 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr))){
954 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
956 }elsif($scidr eq $tcidr && $scidr eq '32'){
957 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
958 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
959 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
960 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
961 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
964 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
965 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
970 #check source and destination protocol if manual
971 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
972 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
973 $errormessage.=$Lang::tr
{'fwdfw err prot'};
975 #check source and destination protocol if source manual and dest servicegrp
976 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
977 &General
::readhasharray
("$configsrv", \
%customservice);
978 foreach my $key (sort keys %customservice){
979 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
980 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
981 $errormessage.=$Lang::tr
{'fwdfw err prot'};
995 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
996 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
997 if ($fwdfwsettings{$grp} eq $val.'_addr'){
998 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
999 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
1000 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
1001 $a=$netsettings{'GREEN_NETADDRESS'};
1002 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
1003 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
1004 $a=$netsettings{'ORANGE_NETADDRESS'};
1005 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
1006 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
1007 $a=$netsettings{'BLUE_NETADDRESS'};
1008 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
1009 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
1010 &General
::readhash
("$configovpn",\
%ovpnsettings);
1011 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
1012 $b=&General
::iporsubtocidr
($b);
1014 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
1015 &General
::readhasharray
("$confignet", \
%customnetwork);
1016 foreach my $key (keys %customnetwork){
1017 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1018 $a=$customnetwork{$key}[1];
1019 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
1022 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
1023 &General
::readhasharray
("$confighost", \
%customhost);
1024 foreach my $key (keys %customhost){
1025 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
1026 if ($customhost{$key}[1] eq 'ip'){
1027 ($a,$b)=split (/\//,$customhost{$key}[2]);
1028 $b=&General
::iporsubtocidr
($b);
1030 if ($grp eq 'grp2'){
1031 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
1043 &General
::setup_default_networks
(\
%defaultNetworks);
1044 #read all configfiles
1045 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1046 &General
::readhasharray
("$confignet", \
%customnetwork);
1047 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1048 &General
::readhasharray
("$confighost", \
%customhost);
1049 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1050 &General
::readhasharray
("$configgrp", \
%customgrp);
1051 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1052 &General
::get_aliases
(\
%aliases);
1056 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
1057 my $config=$fwdfwsettings{'config'};
1059 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1060 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1061 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1062 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1063 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1064 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1065 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1066 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1067 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1068 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1069 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1070 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1071 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1072 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1073 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1074 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1075 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1076 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1077 #check if update and get values
1078 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
1079 &General
::readhasharray
("$config", \
%hash);
1080 foreach my $key (sort keys %hash){
1082 if ($key eq $fwdfwsettings{'key'}){
1083 $fwdfwsettings{'oldrulenumber'} = $fwdfwsettings{'key'};
1084 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
1085 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
1086 $fwdfwsettings{'grp1'} = $hash{$key}[3];
1087 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
1088 $fwdfwsettings{'grp2'} = $hash{$key}[5];
1089 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
1090 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
1091 $fwdfwsettings{'PROT'} = $hash{$key}[8];
1092 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
1093 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
1094 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
1095 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
1096 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
1097 $fwdfwsettings{'grp3'} = $hash{$key}[14];
1098 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
1099 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
1100 $fwdfwsettings{'LOG'} = $hash{$key}[17];
1101 $fwdfwsettings{'TIME'} = $hash{$key}[18];
1102 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
1103 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
1104 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
1105 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
1106 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
1107 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
1108 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
1109 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
1110 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
1111 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
1112 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
1113 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
1114 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
1115 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
1116 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1117 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
1118 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
1119 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
1120 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
1121 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
1122 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
1123 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
1124 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
1125 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
1126 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
1127 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
1128 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
1131 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
1132 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
1133 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
1134 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
1135 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
1136 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
1137 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
1138 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
1140 $fwdfwsettings{'ACTIVE'}='ON';
1141 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1144 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1147 <form method="post">
1149 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1151 foreach ("ACCEPT","DROP","REJECT")
1153 if($fwdfwsettings{'updatefwrule'} eq 'on'){
1155 print "selected='selected'" if ($fwdfwsettings{'RULE_ACTION'} eq $_);
1156 print">$_</option>";
1158 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1159 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1162 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1164 print"<option selected>$_</option>";
1166 print"<option>$_</option>";
1170 print"</select></td></tr></table><hr>";
1172 &Header
::closebox
();
1173 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1174 #------SOURCE-------------------------------------------------------
1176 <table width='100%' border='0'>
1177 <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>
1178 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1179 <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;'>
1181 foreach my $network (sort keys %defaultNetworks)
1183 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1184 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1185 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1186 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1187 print ">$network</option>";
1190 </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;'>
1192 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1195 <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;'>
1197 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1199 </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;'>
1201 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1203 if ($ccdhost{$key}[33] ne ''){
1205 print "<option value='$ccdhost{$key}[1]'";
1206 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1207 print ">$ccdhost{$key}[1]</option>";
1212 <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;'>
1214 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1216 </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;'>
1218 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1219 if($ccdhost{$key}[3] eq 'net'){
1221 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1222 print ">$ccdhost{$key}[1]</option>";
1228 <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;'>
1230 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1231 if($helper ne $customgrp{$key}[0]){
1233 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1234 print ">$customgrp{$key}[0]</option>";
1236 $helper=$customgrp{$key}[0];
1240 <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;'>
1242 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1243 if ($ipsecconf{$key}[3] eq 'net'){
1245 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1246 print ">$ipsecconf{$key}[1]</option>";
1254 # <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;'>
1256 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1257 # if ($ipsecconf{$key}[3] eq 'host'){
1259 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1260 # print ">$ipsecconf{$key}[1]</option>";
1264 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1265 <table width='100%' border='0'>
1266 <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>
1267 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1269 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1271 if ($_ eq $fwdfwsettings{'PROT'})
1273 print"<option selected>$_</option>";
1275 print"<option>$_</option>";
1278 $fwdfwsettings{'SRC_PORT'}=~ s/\|/,/g;
1280 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
1281 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1283 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1284 print"<option>All ICMP-Types</option>";
1285 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1286 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1287 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1289 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1293 </select></td></tr></table><hr>
1295 &Header
::closebox
();
1297 #---TARGET------------------------------------------------------
1298 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1300 <table width='100%' border='0'>
1301 <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;'>
1303 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1305 foreach my $alias (sort keys %aliases)
1307 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1312 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1313 <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;'>
1315 foreach my $network (sort keys %defaultNetworks)
1317 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1318 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1319 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1320 print ">$network</option>";
1323 </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;'>
1325 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1328 <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;'>
1330 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1332 </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;'>
1334 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1336 if ($ccdhost{$key}[33] ne ''){
1337 print "<option value='$ccdhost{$key}[1]' ";
1338 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1339 print ">$ccdhost{$key}[1]</option>";
1344 <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;'>
1346 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1348 </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;'>
1350 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1351 if($ccdhost{$key}[3] eq 'net'){
1353 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1354 print ">$ccdhost{$key}[1]</option>";
1359 <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;'>
1362 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1363 if($helper ne $customgrp{$key}[0]){
1365 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1366 print">$customgrp{$key}[0]</option>";
1368 $helper=$customgrp{$key}[0];
1372 <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;'>
1374 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1375 if ($ipsecconf{$key}[3] eq 'net'){
1377 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1378 print">$ipsecconf{$key}[1]</option>";
1384 # <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;'>
1386 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1387 # if ($ipsecconf{$key}[3] eq 'host'){
1389 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1390 # print">$ipsecconf{$key}[1]</option>";
1395 <b>$Lang::tr{'fwhost attention'}:</b><br>
1396 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1398 <table width='100%' border='0'>
1399 <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;' >
1401 &General
::readhasharray
("$configsrv", \
%customservice);
1402 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1404 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1405 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1409 <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;' >
1411 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1413 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1414 if ($helper ne $customservicegrp{$key}[0]){
1416 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1417 print">$customservicegrp{$key}[0]</option>";
1419 $helper=$customservicegrp{$key}[0];
1423 <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'>
1425 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1427 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1429 print"<option selected>$_</option>";
1431 print"<option>$_</option>";
1434 $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
1436 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' ></td></tr>
1437 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1439 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1440 print"<option>All ICMP-Types</option>";
1441 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1442 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1443 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1445 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1450 </table><hr><br><br>
1453 #---Activate/logging/remark-------------------------------------
1454 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1456 <table width='100%' border='0'>
1457 <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>
1459 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1460 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1461 for (my $count =1; $count <= $sum; $count++){
1462 print"<option value='$count' ";
1463 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1464 print">$count</option>";
1466 print"</select></td></tr>";
1468 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><input type='text' name='rulepos' size='2'></td></tr>";
1472 </table><table width='100%'>
1473 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1474 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1477 &Header
::closebox
();
1478 #---ADD TIMEFRAME-----------------------------------------------
1479 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1481 <table width='70%' border='0'>
1482 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1483 <tr><td colspan='7'> </td></tr>
1485 <td align='left'>$Lang::tr{'time'}:</td>
1486 <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>
1487 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1488 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1491 <td align='right'></td>
1492 <td width='30%' align='left'>
1493 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1494 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1495 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1496 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1497 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1498 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1499 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{'on'} />
1501 <td><select name='TIME_FROM'>
1503 for (my $i=0;$i<=23;$i++) {
1504 $i = sprintf("%02s",$i);
1505 for (my $j=0;$j<=45;$j+=15) {
1506 $j = sprintf("%02s",$j);
1507 my $time = $i.":".$j;
1508 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1513 <td><select name='TIME_TO'>
1515 for (my $i=0;$i<=23;$i++) {
1516 $i = sprintf("%02s",$i);
1517 for (my $j=0;$j<=45;$j+=15) {
1518 $j = sprintf("%02s",$j);
1519 my $time = $i.":".$j;
1520 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1527 &Header
::closebox
();
1528 #---ACTION------------------------------------------------------
1529 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1531 <table border='0' width='100%'>
1532 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1533 <input type='hidden' name='config' value='$config' >
1534 <input type='hidden' name='ACTION' value='saverule' >
1535 </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>
1540 <table border='0' width='100%'>
1541 <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'}'>
1542 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1543 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1544 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1545 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1546 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1547 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1548 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1549 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1550 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1551 <input type='hidden' name='oldruleremark' value='$fwdfwsettings{'oldruleremark'}' />
1552 <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>
1556 &Header
::closebox
();
1562 &General
::readhasharray
("$config", $hash);
1563 if (!$errormessage){
1564 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1565 my $key = &General
::findhasharraykey
($hash);
1566 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1567 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1568 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1569 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1570 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1571 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1572 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1573 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1574 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1575 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1576 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1577 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1578 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1579 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1580 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1581 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1582 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1583 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1584 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1585 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1586 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1587 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1588 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1589 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1590 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1591 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1592 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1593 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1594 &General
::writehasharray
("$config", $hash);
1596 foreach my $key (sort {$a <=> $b} keys %$hash){
1597 if($key eq $fwdfwsettings{'key'}){
1598 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1599 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1600 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1601 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1602 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1603 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1604 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1605 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1606 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1607 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1608 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1609 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1610 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1611 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1612 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1613 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1614 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1615 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1616 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1617 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1618 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1619 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1620 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1621 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1622 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1623 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1624 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1625 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1630 &General
::writehasharray
("$config", $hash);
1631 if($fwdfwsettings{'oldrulenumber'} > $fwdfwsettings{'rulepos'}){
1633 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1634 for (my $z=0;$z<$val;$z++){
1635 foreach my $key (sort {$a <=> $b} keys %$hash){
1636 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1638 if (exists $$hash{$last}){
1640 foreach my $y (0 .. $#{$$hash{$last}}) {
1641 $tmp{0}[$y] = $$hash{$last}[$y];
1643 #copy active rule to last
1644 foreach my $i (0 .. $#{$$hash{$last}}) {
1645 $$hash{$last}[$i] = $$hash{$key}[$i];
1647 #copy saved rule to actual position
1648 foreach my $x (0 .. $#{$tmp{0}}) {
1649 $$hash{$key}[$x] = $tmp{0}[$x];
1654 $fwdfwsettings{'oldrulenumber'}--;
1656 &General
::writehasharray
("$config", $hash);
1658 }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
1660 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1661 for (my $z=0;$z<$val;$z++){
1662 foreach my $key (sort {$a <=> $b} keys %$hash){
1663 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1664 my $next = $key + 1;
1665 if (exists $$hash{$next}){
1667 foreach my $y (0 .. $#{$$hash{$next}}) {
1668 $tmp{0}[$y] = $$hash{$next}[$y];
1670 #copy active rule to next
1671 foreach my $i (0 .. $#{$$hash{$next}}) {
1672 $$hash{$next}[$i] = $$hash{$key}[$i];
1674 #copy saved rule to actual position
1675 foreach my $x (0 .. $#{$tmp{0}}) {
1676 $$hash{$key}[$x] = $tmp{0}[$x];
1681 $fwdfwsettings{'oldrulenumber'}++;
1683 &General
::writehasharray
("$config", $hash);
1690 if ($errormessage) {
1691 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1692 print "<class name='base'>$errormessage\n";
1693 print " </class>\n";
1694 &Header
::closebox
();
1701 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1702 print "<class name='base'>$hint\n";
1703 print " </class>\n";
1704 &Header
::closebox
();
1711 &General
::setup_default_networks
(\
%defaultNetworks);
1712 foreach my $network (sort keys %defaultNetworks)
1714 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1719 # Checks a hostname against RFC1035
1722 # Each part should be at least two characters in length
1723 # but no more than 63 characters
1724 if (length ($remark) < 1 || length ($remark) > 255) {
1726 # Only valid characters are a-z, A-Z, 0-9 and -
1727 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;_\/\s
]*$/) {
1729 # First character can only be a letter or a digit
1730 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1732 # Last character can only be a letter or a digit
1733 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1739 my %hash=%{(shift)};
1741 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne '' && $hash{$key}[10]){
1742 $hash{$key}[10]=~ s/\|/,/g;
1743 print": $hash{$key}[10]";
1744 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1745 print": <br>$hash{$key}[9] ";
1750 my %hash=%{(shift)};
1754 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1755 if($hash{$key}[14] eq 'cust_srv'){
1756 &General
::readhasharray
("$configsrv", \
%customservice);
1757 foreach my $i (sort keys %customservice){
1758 if($customservice{$i}[0] eq $hash{$key}[15]){
1759 $service = $customservice{$i}[0];
1762 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1763 $service=$hash{$key}[15];
1764 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1765 $hash{$key}[15]=~ s/\|/,/g;
1766 $service=$hash{$key}[15];
1771 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1772 print":<br>$hash{$key}[13]";
1775 sub get_serviceports
1779 &General
::readhasharray
("$configsrv", \
%customservice);
1780 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1784 if($type eq 'service'){
1785 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1786 if ($customservice{$key}[0] eq $name){
1787 $protocols=$customservice{$key}[2];
1790 }elsif($type eq 'group'){
1791 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1792 if ($customservicegrp{$key}[0] eq $name){
1793 foreach my $key1 (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1794 if ($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1795 if($customservice{$key1}[2] eq 'TCP'){$tcp='TCP';}else{$udp='UDP';}
1801 if($tcp && $udp){$protocols="TCP,UDP";
1802 }elsif($tcp){$protocols.="TCP";
1803 }elsif($udp){$protocols.="UDP";}
1809 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1810 &viewtablenew
(\
%configfwdfw,$configfwdfw,'',"DMZ" );
1811 &viewtablenew
(\
%configfwdfw,$configfwdfw,'',"WLAN" );
1812 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1813 &viewtablenew
(\
%configoutgoingfw,$configoutgoing,"","Outgoing" );
1822 &General
::readhasharray
("$config", $hash);
1823 #check if there are DMZ entries
1824 if ($title1 eq 'DMZ'){
1825 foreach my $key (keys %$hash){
1826 if ($$hash{$key}[4] eq 'ORANGE'){$go='on';last}
1828 }elsif($title1 eq 'WLAN'){
1829 foreach my $key (keys %$hash){
1830 if ($$hash{$key}[4] eq 'BLUE'){$go='on';last}
1832 }elsif($title1 eq 'Forward'){
1833 foreach my $key (keys %$hash){
1834 if (($$hash{$key}[4] ne 'ORANGE' && $$hash{$key}[4] ne 'BLUE')){$go='on';last}
1836 }elsif( ! -z
$config){
1840 &Header
::openbox
('100%', 'left',$title);
1848 print"<b>$title1</b><br>";
1849 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1850 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' ><b>$Lang::tr{'fwdfw source'}</td><td width='1%'><b>Log</td><td align='center' width='20%'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1851 foreach my $key (sort {$a <=> $b} keys %$hash){
1852 #check if we have a FORWARDFW OR DMZ RULE
1853 if ($title1 eq 'DMZ' && ($$hash{$key}[4] ne 'ORANGE')){next;}
1854 if ($title1 eq 'WLAN' && ($$hash{$key}[4] ne 'BLUE')){next;}
1855 if ($title1 eq 'Forward' && ($$hash{$key}[4] eq 'ORANGE' || $$hash{$key}[4] eq 'BLUE')){next;}
1857 #check if vpn hosts/nets have been deleted
1858 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1859 push (@tmpsrc,$$hash{$key}[4]);
1861 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1862 push (@tmpsrc,$$hash{$key}[6]);
1864 foreach my $host (@tmpsrc){
1865 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1866 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1868 &disable_rule
($key);
1871 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1872 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1874 &disable_rule
($key);
1877 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1878 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1880 &disable_rule
($key);
1883 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1884 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1886 &disable_rule
($key);
1893 $$hash{'ACTIVE'}=$$hash{$key}[2];
1895 if($coloryellow eq 'on'){
1896 print"<tr bgcolor='$color{'color14'}' >";
1898 }elsif($coloryellow eq ''){
1900 print"<tr bgcolor='$color{'color22'}' >";
1903 print"<tr bgcolor='$color{'color20'}' >";
1907 <td align='right'>$key</td>
1909 if ($$hash{$key}[0] eq 'ACCEPT'){
1912 $rulecolor=$color{'color17'};
1913 }elsif($$hash{$key}[0] eq 'DROP'){
1916 $rulecolor=$color{'color25'};
1917 }elsif($$hash{$key}[0] eq 'REJECT'){
1920 $rulecolor=$color{'color16'};
1922 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1923 print"<td align='center' nowrap='nowrap'>";
1924 if ($$hash{$key}[3] eq 'std_net_src'){
1925 print &get_name
($$hash{$key}[4]);
1927 print $$hash{$key}[4];
1929 &getsrcport
(\
%$hash,$key);
1930 if ($$hash{$key}[17] eq 'ON'){
1931 $log="/images/on.gif";
1933 $log="/images/off.gif";
1937 <form method='post'>
1938 <td width='1%' align='left'><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 ;'/>
1939 <input type='hidden' name='key' value='$key' />
1940 <input type='hidden' name='config' value='$config' />
1941 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1945 <td align='center' nowrap='nowrap'>
1947 if ($$hash{$key}[5] eq 'std_net_tgt'){
1948 print &get_name
($$hash{$key}[6]);
1950 print $$hash{$key}[6];
1952 &gettgtport
(\
%$hash,$key);
1953 ################################################################################
1957 if ($$hash{$key}[12]){ #target prot if manual
1958 $prot=$$hash{$key}[12];
1959 }elsif($$hash{$key}[8]){ #source prot if manual
1960 $prot=$$hash{$key}[8];
1961 }elsif($$hash{$key}[14] eq 'cust_srv'){
1962 $prot=&get_serviceports
("service",$$hash{$key}[15]);
1963 }elsif($$hash{$key}[14] eq 'cust_srvgrp'){
1964 $prot=&get_serviceports
("group",$$hash{$key}[15]);
1966 $prot=$Lang::tr
{'all'};
1968 print"<td align='center'>$prot</td>";
1970 print"<td width='20%'>$$hash{$key}[16]</td>";
1972 if($$hash{$key}[2] eq 'ON'){
1973 $gif="/images/on.gif"
1976 $gif="/images/off.gif"
1979 <form method='post'>
1980 <td width='1%'><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;' />
1981 <input type='hidden' name='key' value='$key' />
1982 <input type='hidden' name='config' value='$config' />
1983 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1985 <form method='post'>
1986 <td width='1%' ><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;' />
1987 <input type='hidden' name='key' value='$key' />
1988 <input type='hidden' name='config' value='$config' />
1989 <input type='hidden' name='ACTION' value='editrule' />
1991 <form method='post'>
1992 <td width='1%'><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;' />
1993 <input type='hidden' name='key' value='$key' />
1994 <input type='hidden' name='config' value='$config' />
1995 <input type='hidden' name='ACTION' value='copyrule' />
1997 <form method='post'>
1998 <td width='1%' ><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;' />
1999 <input type='hidden' name='key' value='$key' />
2000 <input type='hidden' name='config' value='$config' />
2001 <input type='hidden' name='ACTION' value='deleterule' />
2004 if (exists $$hash{$key-1}){
2006 <form method='post'>
2007 <td width='1%'><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;' />
2008 <input type='hidden' name='key' value='$key' />
2009 <input type='hidden' name='config' value='$config' />
2010 <input type='hidden' name='ACTION' value='moveup' />
2016 if (exists $$hash{$key+1}){
2018 <form method='post'>
2019 <td width='1%' ><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;' />
2020 <input type='hidden' name='key' value='$key' />
2021 <input type='hidden' name='config' value='$config' />
2022 <input type='hidden' name='ACTION' value='movedown' />
2023 </td></form></td></tr>
2026 print"<td></td></tr>";
2028 #if timeframe set, print new line in table
2029 if ($$hash{$key}[18] eq 'ON'){
2031 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
2032 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
2033 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
2034 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
2035 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
2036 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
2037 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
2038 my $weekdays=join(",",@days);
2040 print"<tr bgcolor='#FFE4B5'><td colspan='6'>$Lang::tr{'fwdfw time'} ";
2042 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
2047 &Header
::closebox
();
2053 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
2056 &Header
::openbox
('100%', 'center', 'P2P-Block');
2058 <table width='35%' border='0'>
2059 <tr bgcolor='$color{'color22'}'><td align=center colspan='2' ><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'status'}</b></td></tr>
2061 foreach my $p2pentry (sort @p2ps)
2063 my @p2pline = split( /\;/, $p2pentry );
2064 if($p2pline[2] eq 'on'){
2065 $gif="/images/on.gif"
2067 $gif="/images/off.gif"
2070 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
2071 <tr bgcolor='$color{'color20'}'>
2072 <td align='center' colspan='2' >$p2pline[0]:</td><td align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /><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;' ><input type='hidden' name='ACTION' value='togglep2p'></td></tr></form>
2075 print"<tr><td><img src='/images/on.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p allow'}</td></tr>";
2076 print"<tr><td><img src='/images/off.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p deny'}</td></tr></table>";
2077 &Header
::closebox
();
2081 my %hash=%{(shift)};
2084 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
2085 if($hash{$key}[0] eq $val){
2086 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
2088 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
2094 if (!-f
"${General::swroot}/forward/reread"){
2095 system("touch ${General::swroot}/forward/reread");
2100 system("/usr/local/bin/forwardfwctrl");
2101 if ( -f
"${General::swroot}/forward/reread"){
2102 system("rm ${General::swroot}/forward/reread");
2105 &Header
::closebigbox
();
2106 &Header
::closepage
();