]>
git.ipfire.org Git - people/ms/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"); }
51 my %defaultNetworks=();
55 my %customnetworks=();
57 my %customservicegrp=();
73 my $confignet = "${General::swroot}/fwhosts/customnetworks";
74 my $confighost = "${General::swroot}/fwhosts/customhosts";
75 my $configgrp = "${General::swroot}/fwhosts/customgroups";
76 my $configsrv = "${General::swroot}/fwhosts/customservices";
77 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
78 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
79 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
80 my $configipsec = "${General::swroot}/vpn/config";
81 my $configipsecrw = "${General::swroot}/vpn/settings";
82 my $configfwdfw = "${General::swroot}/forward/config";
83 my $configinput = "${General::swroot}/forward/input";
84 my $configovpn = "${General::swroot}/ovpn/settings";
85 my $p2pfile = "${General::swroot}/forward/p2protocols";
88 my $ipgrp="${General::swroot}/outgoing/groups";
91 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
92 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
93 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
95 &Header
::showhttpheaders
();
96 &Header
::getcgihash
(\
%fwdfwsettings);
97 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
98 &Header
::openbigbox
('100%', 'center',$errormessage);
101 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
103 my $MODE = $fwdfwsettings{'POLICY'};
105 $fwdfwsettings{'POLICY'} = "$MODE";
106 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
109 if ($fwdfwsettings{'ACTION'} eq 'saverule')
111 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
112 &General
::readhasharray
("$configinput", \
%configinputfw);
113 $errormessage=&checksource
;
114 if(!$errormessage){&checktarget
;}
115 if(!$errormessage){&checkrule
;}
116 #check if we change an forward rule to an external access
117 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
118 $fwdfwsettings{'updatefwrule'}='';
119 $fwdfwsettings{'config'}=$configfwdfw;
120 $fwdfwsettings{'nobase'}='on';
122 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
123 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
125 #check if we change an external access rule to an forward
126 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
127 $fwdfwsettings{'updatefwrule'}='';
128 $fwdfwsettings{'config'}=$configinput;
129 $fwdfwsettings{'nobase'}='on';
131 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
132 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
135 if($fwdfwsettings{'grp2'} eq 'ipfire'){
136 $fwdfwsettings{'chain'} = 'INPUTFW';
137 #check if we have an identical rule already
138 if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){
139 foreach my $key (sort keys %configinputfw){
140 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'}"
141 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]"){
142 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
143 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
146 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
147 $fwdfwsettings{'nosave'} = 'on';
152 #check if we just close a rule
153 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'} ) {
154 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
156 $fwdfwsettings{'nosave2'} = 'on';
159 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
160 if ($fwdfwsettings{'nobase'} ne 'on'){
161 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
163 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
164 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
165 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
166 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
167 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
168 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
170 if($fwdfwsettings{'nosave2'} ne 'on'){
171 &saverule
(\
%configinputfw,$configinput);
173 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
174 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
175 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
176 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
177 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
178 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
179 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
180 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
181 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
182 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
183 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
184 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
185 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
186 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
187 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
188 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
190 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
191 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
192 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
193 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
195 $fwdfwsettings{'chain'} = 'FORWARDFW';
196 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
197 #check if we have an identical rule already
198 foreach my $key (sort keys %configfwdfw){
199 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'}"
200 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]"){
201 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
202 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
205 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
206 $fwdfwsettings{'nosave'} = 'on';
211 #check if we just close a rule
212 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'} ) {
213 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
214 $fwdfwsettings{'nosave2'} = 'on';
219 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
220 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
221 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
222 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
223 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
224 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
225 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
226 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
228 if ($fwdfwsettings{'nobase'} eq 'on'){
229 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
231 if ($fwdfwsettings{'nosave2'} ne 'on'){
232 &saverule
(\
%configfwdfw,$configfwdfw);
234 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
235 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
236 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
237 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
238 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
239 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
240 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
241 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
242 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
243 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
244 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
245 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
246 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
247 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
248 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
249 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
251 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
252 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
253 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
254 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
259 if($fwdfwsettings{'nosave2'} ne 'on'){
265 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
267 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
268 foreach my $key (sort keys %configfwdfw){
269 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
270 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
271 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
273 &General
::readhasharray
("$configinput", \
%configinputfw);
274 foreach my $key (sort keys %configinputfw){
275 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
276 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
277 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
279 $fwdfwsettings{'POLICY'}='MODE0';
280 system("rm ${General::swroot}/forward/config");
281 system("rm ${General::swroot}/forward/input");
282 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
283 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
284 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
289 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
293 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
296 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
297 foreach my $key (sort keys %togglehash){
298 if ($key eq $fwdfwsettings{'key'}){
299 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
302 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
306 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
309 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
310 foreach my $key (sort keys %togglehash){
311 if ($key eq $fwdfwsettings{'key'}){
312 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
315 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
319 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
324 if ($fwdfwsettings{'ACTION'} eq 'editrule')
326 $fwdfwsettings{'updatefwrule'}='on';
329 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
333 if ($fwdfwsettings{'ACTION'} eq 'moveup')
338 if ($fwdfwsettings{'ACTION'} eq 'movedown')
343 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
345 $fwdfwsettings{'copyfwrule'}='on';
346 #$fwdfwsettings{'updatefwrule'}='on';
349 if ($fwdfwsettings{'ACTION'} eq 'togglep2p')
351 #$errormessage="Toggle $fwdfwsettings{'P2PROT'}<br>";
352 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
355 open( FILE
, "> $p2pfile" ) or die "Unable to write $p2pfile";
356 foreach my $p2pentry (sort @p2ps)
358 my @p2pline = split( /\;/, $p2pentry );
359 if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
360 if($p2pline[2] eq 'on'){
366 print FILE
"$p2pline[0];$p2pline[1];$p2pline[2];\n";
372 if ($fwdfwsettings{'ACTION'} eq '')
381 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
382 foreach my $key (sort keys %uphash){
383 if ($key eq $fwdfwsettings{'key'}) {
385 if (exists $uphash{$last}){
387 foreach my $y (0 .. $#{$uphash{$last}}) {
388 $tmp{0}[$y] = $uphash{$last}[$y];
390 #copy active rule to last
391 foreach my $i (0 .. $#{$uphash{$last}}) {
392 $uphash{$last}[$i] = $uphash{$key}[$i];
394 #copy saved rule to actual position
395 foreach my $x (0 .. $#{$tmp{0}}) {
396 $uphash{$key}[$x] = $tmp{0}[$x];
401 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
408 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
409 foreach my $key (sort keys %downhash){
410 if ($key eq $fwdfwsettings{'key'}) {
412 if (exists $downhash{$next}){
414 foreach my $y (0 .. $#{$downhash{$next}}) {
415 $tmp{0}[$y] = $downhash{$next}[$y];
417 #copy active rule to next
418 foreach my $i (0 .. $#{$downhash{$next}}) {
419 $downhash{$next}[$i] = $downhash{$key}[$i];
421 #copy saved rule to actual position
422 foreach my $x (0 .. $#{$tmp{0}}) {
423 $downhash{$key}[$x] = $tmp{0}[$x];
428 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
433 my ($base1,$val1,$base2,$val2) = @_;
435 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
436 &dec_counter
($confignet,\
%customnetwork,$val1);
437 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
438 &dec_counter
($confighost,\
%customhost,$val1);
439 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
440 &dec_counter
($configgrp,\
%customgrp,$val1);
441 }elsif($base1 eq 'cust_srv'){
442 &dec_counter
($configsrv,\
%customservice,$val1);
443 }elsif($base1 eq 'cust_srvgrp'){
444 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
447 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
448 &inc_counter
($confignet,\
%customnetwork,$val2);
449 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
450 &inc_counter
($confighost,\
%customhost,$val2);
451 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
452 &inc_counter
($configgrp,\
%customgrp,$val2);
453 }elsif($base2 eq 'cust_srv'){
454 &inc_counter
($configsrv,\
%customservice,$val2);
455 }elsif($base2 eq 'cust_srvgrp'){
456 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
466 &General
::readhasharray
($config, \
%hash);
467 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
468 if($hash{$key}[0] eq $val){
469 $pos=$#{$hash{$key}};
470 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
473 &General
::writehasharray
($config, \
%hash);
481 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
482 &General
::readhasharray
($config, \
%hash);
483 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
484 if($hash{$key}[0] eq $val){
485 $pos=$#{$hash{$key}};
486 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
489 &General
::writehasharray
($config, \
%hash);
493 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
494 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
495 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
498 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
502 #print"<table width='100' border='1'><tr>";
505 #print"<td bgcolor='$color{$i}'>$_</td>";
507 #print"</tr></table>";
508 if ($fwdfwsettings{'POLICY'} eq 'MODE1' || $fwdfwsettings{'POLICY'} eq 'MODE2' ) {
511 &Header
::openbox
('100%', 'center', 'Policy');
513 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
515 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 0:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode0'}</td></tr>
516 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 1:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode1'}</td></tr>
517 <tr><td width='10%' align='left'><b>$Lang::tr{'mode'} 2:</b><td width='90%' align='left' colspan='2'>$Lang::tr{'outgoing firewall mode2'}</td></tr>
518 <tr><td colspan='3'><hr /></td></tr>
519 <tr><td width='10%' align='left'> <select name='POLICY' style="width: 85px"><option value='MODE0' $selected{'POLICY'}{'MODE0'}>$Lang::tr{'mode'} 0</option><option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'mode'} 1</option><option value='MODE2' $selected{'POLICY'}{'MODE2'}>$Lang::tr{'mode'} 2</option></select>
520 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
521 <td width='45%' align='left'>
523 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
524 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
526 print "</table></form>";
532 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
534 print "<form method='post'>";
535 print "<table border='0'>";
536 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
537 if (-f
"${General::swroot}/forward/reread"){
538 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
540 print"</tr></table></form><hr>";
548 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
549 foreach my $key (sort {$a <=> $b} keys %delhash){
550 if ($key == $fwdfwsettings{'key'}){
551 #check hosts/net and groups
552 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
553 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
554 #check services and groups
555 if ($delhash{$key}[11] eq 'ON'){
556 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
559 if ($key >= $fwdfwsettings{'key'}) {
561 if (exists $delhash{$next}) {
562 foreach my $i (0 .. $#{$delhash{$next}}) {
563 $delhash{$key}[$i] = $delhash{$next}[$i];
568 # Remove the very last entry.
569 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
570 delete $delhash{$last_key};
572 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
575 if($fwdfwsettings{'nobase'} ne 'on'){
582 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
583 foreach my $key (sort keys %configfwdfw){
585 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
588 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
595 #check ip-address if manual
596 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
597 #check if ip with subnet
598 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
599 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
600 $subnet = &General
::iporsubtocidr
($subnet);
601 $fwdfwsettings{'isip'}='on';
604 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
605 $ip=$fwdfwsettings{'src_addr'};
607 $fwdfwsettings{'isip'}='on';
610 if ($fwdfwsettings{'isip'} ne 'on'){
611 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
613 if ($fwdfwsettings{'isip'} eq 'on'){
614 #check and form valid IP
615 $ip=&General
::ip2dec
($ip);
616 $ip=&General
::dec2ip
($ip);
617 #check if net or broadcast
618 my @tmp= split (/\./,$ip);
619 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
621 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
623 $fwdfwsettings{'src_addr'}="$ip/$subnet";
625 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
626 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
629 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
630 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
632 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
633 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
634 return $errormessage;
638 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
640 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
641 $fwdfwsettings{'SRC_PORT'}='';
642 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
643 foreach my $key (keys %icmptypes){
644 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
645 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
648 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
649 $fwdfwsettings{'SRC_PORT'}='';
650 $fwdfwsettings{'ICMP_TYPES'}='';
651 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
652 $fwdfwsettings{'SRC_PORT'}='';
653 $fwdfwsettings{'ICMP_TYPES'}='';
654 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'AH'){
655 $fwdfwsettings{'SRC_PORT'}='';
656 $fwdfwsettings{'ICMP_TYPES'}='';
657 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
658 $fwdfwsettings{'ICMP_TYPES'}='';
660 $fwdfwsettings{'ICMP_TYPES'}='';
661 $fwdfwsettings{'SRC_PORT'}='';
662 $fwdfwsettings{'PROT'}='';
665 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
666 #change dashes with :
667 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
669 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
670 $fwdfwsettings{'SRC_PORT'} = "1:65535";
672 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
673 $fwdfwsettings{'SRC_PORT'} = "1:$2";
675 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
676 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
679 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
681 return $errormessage;
687 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
688 #check if ip with subnet
689 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
690 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
691 $subnet = &General
::iporsubtocidr
($subnet);
694 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
695 $ip=$fwdfwsettings{'tgt_addr'};
698 #check and form valid IP
699 $ip=&General
::ip2dec
($ip);
700 $ip=&General
::dec2ip
($ip);
702 #check if net or broadcast
703 my @tmp= split (/\./,$ip);
704 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
706 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
708 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
710 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
711 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
714 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
715 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
716 return $errormessage;
720 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
723 if ($fwdfwsettings{'USESRV'} eq 'ON'){
724 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
725 $fwdfwsettings{'TGT_PROT'}='';
726 $fwdfwsettings{'ICMP_TGT'}='';
728 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
729 $fwdfwsettings{'TGT_PROT'}='';
730 $fwdfwsettings{'ICMP_TGT'}='';
731 #check target service
732 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
733 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
736 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
737 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){
738 if ($fwdfwsettings{'TGT_PORT'} ne ''){
739 #change dashes with :
740 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
741 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
742 $fwdfwsettings{'TGT_PORT'} = "1:65535";
744 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
745 $fwdfwsettings{'TGT_PORT'} = "1:$2";
747 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
748 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
750 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
752 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
753 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
754 $fwdfwsettings{'ICMP_TGT'} = '';
755 }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){
756 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
757 $fwdfwsettings{'ICMP_TGT'}='';
758 }elsif($fwdfwsettings{'TGT_PORT'} eq 'AH'){
759 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
760 $fwdfwsettings{'ICMP_TGT'}='';
761 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
762 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
763 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
764 foreach my $key (keys %icmptypes){
766 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
767 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
775 if ($fwdfwsettings{'USESRV'} ne 'ON'){
776 $fwdfwsettings{'grp3'}='';
777 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
778 $fwdfwsettings{'TGT_PROT'}='';
779 $fwdfwsettings{'ICMP_TGT'}='';
782 if($fwdfwsettings{'TIME'} eq 'ON'){
783 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 ''){
784 $errormessage=$Lang::tr
{'fwdfw err time'};
787 return $errormessage;
792 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
793 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
795 #check if source and target identical
796 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
797 $errormessage.=$Lang::tr
{'fwdfw err same'};
798 return $errormessage;
801 #get source and targetip address if possible
802 my ($sip,$scidr,$tip,$tcidr);
803 ($sip,$scidr)=&get_ip
("src","grp1");
804 ($tip,$tcidr)=&get_ip
("tgt","grp2");
806 #check same iprange in source and target
807 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
808 my $networkip1=&General
::getnetworkip
($sip,$scidr);
809 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
810 if ($scidr gt $tcidr){
811 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
812 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
814 }elsif($scidr eq $tcidr && $scidr eq '32'){
815 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
816 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
817 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
818 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
819 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
822 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
823 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
828 #check source and destination protocol if manual
829 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
830 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
831 $errormessage.=$Lang::tr
{'fwdfw err prot'};
833 #check source and destination protocol if source manual and dest servicegrp
834 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
835 &General
::readhasharray
("$configsrv", \
%customservice);
836 foreach my $key (sort keys %customservice){
837 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
838 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
839 $errormessage.=$Lang::tr
{'fwdfw err prot'};
853 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
854 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
855 if ($fwdfwsettings{$grp} eq $val.'_addr'){
856 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
857 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
858 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
859 $a=$netsettings{'GREEN_NETADDRESS'};
860 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
861 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
862 $a=$netsettings{'ORANGE_NETADDRESS'};
863 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
864 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
865 $a=$netsettings{'BLUE_NETADDRESS'};
866 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
867 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
868 &General
::readhash
("$configovpn",\
%ovpnsettings);
869 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
870 $b=&General
::iporsubtocidr
($b);
872 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
873 &General
::readhasharray
("$confignet", \
%customnetwork);
874 foreach my $key (keys %customnetwork){
875 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
876 $a=$customnetwork{$key}[1];
877 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
880 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
881 &General
::readhasharray
("$confighost", \
%customhost);
882 foreach my $key (keys %customhost){
883 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
884 if ($customhost{$key}[1] eq 'ip'){
885 ($a,$b)=split (/\//,$customhost{$key}[2]);
886 $b=&General
::iporsubtocidr
($b);
889 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
901 &General
::setup_default_networks
(\
%defaultNetworks);
902 #read all configfiles
903 &General
::readhasharray
("$configccdnet", \
%ccdnet);
904 &General
::readhasharray
("$confignet", \
%customnetwork);
905 &General
::readhasharray
("$configccdhost", \
%ccdhost);
906 &General
::readhasharray
("$confighost", \
%customhost);
907 &General
::readhasharray
("$configccdhost", \
%ccdhost);
908 &General
::readhasharray
("$configgrp", \
%customgrp);
909 &General
::readhasharray
("$configipsec", \
%ipsecconf);
910 &General
::get_aliases
(\
%aliases);
914 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
915 my $config=$fwdfwsettings{'config'};
917 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
918 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
919 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
920 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
921 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
922 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
923 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
924 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
925 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
926 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
927 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
928 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
929 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
930 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
931 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
932 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
933 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
934 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
935 #check if update and get values
936 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
937 &General
::readhasharray
("$config", \
%hash);
938 foreach my $key (sort keys %hash){
940 if ($key eq $fwdfwsettings{'key'}){
941 $fwdfwsettings{'oldrulenumber'} = $key;
942 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
943 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
944 $fwdfwsettings{'grp1'} = $hash{$key}[3];
945 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
946 $fwdfwsettings{'grp2'} = $hash{$key}[5];
947 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
948 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
949 $fwdfwsettings{'PROT'} = $hash{$key}[8];
950 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
951 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
952 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
953 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
954 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
955 $fwdfwsettings{'grp3'} = $hash{$key}[14];
956 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
957 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
958 $fwdfwsettings{'LOG'} = $hash{$key}[17];
959 $fwdfwsettings{'TIME'} = $hash{$key}[18];
960 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
961 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
962 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
963 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
964 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
965 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
966 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
967 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
968 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
969 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
970 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
971 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
972 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
973 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
974 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
975 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
976 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
977 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
978 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
979 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
980 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
981 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
982 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
983 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
984 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
985 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
986 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
989 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
990 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
991 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
992 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
993 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
994 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
995 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
996 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
998 $fwdfwsettings{'ACTIVE'}='ON';
999 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
1002 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
1005 <form method="post">
1007 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
1009 foreach ("ACCEPT","DROP","REJECT")
1011 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
1012 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
1015 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
1017 print"<option selected>$_</option>";
1019 print"<option>$_</option>";
1022 print"</select></td></tr></table><hr>";
1024 &Header
::closebox
();
1025 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1027 #------SOURCE-------------------------------------------------------
1029 <table width='100%' border='0'>
1030 <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>
1031 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1032 <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;'>
1034 foreach my $network (sort keys %defaultNetworks)
1036 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1037 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1038 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1039 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1040 print ">$network</option>";
1043 </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;'>
1045 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1048 <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;'>
1050 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1052 </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;'>
1054 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1056 if ($ccdhost{$key}[33] ne ''){
1058 print "<option value='$ccdhost{$key}[1]'";
1059 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1060 print ">$ccdhost{$key}[1]</option>";
1065 <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;'>
1067 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1069 </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;'>
1071 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1072 if($ccdhost{$key}[3] eq 'net'){
1074 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1075 print ">$ccdhost{$key}[1]</option>";
1081 <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;'>
1083 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1084 if($helper ne $customgrp{$key}[0]){
1086 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1087 print ">$customgrp{$key}[0]</option>";
1089 $helper=$customgrp{$key}[0];
1093 <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;'>
1095 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1096 if ($ipsecconf{$key}[3] eq 'net'){
1098 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1099 print ">$ipsecconf{$key}[1]</option>";
1107 # <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;'>
1109 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1110 # if ($ipsecconf{$key}[3] eq 'host'){
1112 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1113 # print ">$ipsecconf{$key}[1]</option>";
1117 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1118 <table width='100%' border='0'>
1119 <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>
1120 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1122 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1124 if ($_ eq $fwdfwsettings{'PROT'})
1126 print"<option selected>$_</option>";
1128 print"<option>$_</option>";
1132 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1133 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1135 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1136 print"<option>All ICMP-Types</option>";
1137 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1138 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1139 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1141 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1145 </select></td></tr></table><hr>
1147 &Header
::closebox
();
1149 #---TARGET------------------------------------------------------
1150 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1152 <table width='100%' border='0'>
1153 <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;'>
1155 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1157 foreach my $alias (sort keys %aliases)
1159 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1164 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1165 <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;'>
1167 foreach my $network (sort keys %defaultNetworks)
1169 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1170 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1171 print ">$network</option>";
1174 </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;'>
1176 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1179 <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;'>
1181 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1183 </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;'>
1185 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1187 if ($ccdhost{$key}[33] ne ''){
1188 print "<option value='$ccdhost{$key}[1]' ";
1189 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1190 print ">$ccdhost{$key}[1]</option>";
1195 <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;'>
1197 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1199 </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;'>
1201 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1202 if($ccdhost{$key}[3] eq 'net'){
1204 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1205 print ">$ccdhost{$key}[1]</option>";
1210 <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;'>
1213 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1214 if($helper ne $customgrp{$key}[0]){
1216 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1217 print">$customgrp{$key}[0]</option>";
1219 $helper=$customgrp{$key}[0];
1223 <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;'>
1225 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1226 if ($ipsecconf{$key}[3] eq 'net'){
1228 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1229 print">$ipsecconf{$key}[1]</option>";
1235 # <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;'>
1237 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1238 # if ($ipsecconf{$key}[3] eq 'host'){
1240 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1241 # print">$ipsecconf{$key}[1]</option>";
1246 <b>$Lang::tr{'fwhost attention'}:</b><br>
1247 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1249 <table width='100%' border='0'>
1250 <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;' >
1252 &General
::readhasharray
("$configsrv", \
%customservice);
1253 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1255 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1256 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1260 <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;' >
1262 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1264 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1265 if ($helper ne $customservicegrp{$key}[0]){
1267 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1268 print">$customservicegrp{$key}[0]</option>";
1270 $helper=$customservicegrp{$key}[0];
1274 <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'>
1276 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1278 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1280 print"<option selected>$_</option>";
1282 print"<option>$_</option>";
1286 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1287 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1289 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1290 print"<option>All ICMP-Types</option>";
1291 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1292 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1293 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1295 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1300 </table><hr><br><br>
1303 #---Activate/logging/remark-------------------------------------
1304 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1306 <table width='100%' border='0'>
1307 <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>
1309 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1310 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1311 for (my $count =1; $count <= $sum; $count++){
1312 print"<option value='$count' ";
1313 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1314 print">$count</option>";
1316 print"</select></td></tr>";
1320 </table><table width='100%'>
1321 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1322 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1325 &Header
::closebox
();
1326 #---ADD TIMEFRAME-----------------------------------------------
1327 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1329 <table width='70%' border='0'>
1330 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1331 <tr><td colspan='7'> </td></tr>
1333 <td align='left'>$Lang::tr{'time'}:</td>
1334 <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>
1335 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1336 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1339 <td align='right'></td>
1340 <td width='30%' align='left'>
1341 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1342 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1343 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1344 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1345 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1346 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1347 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1349 <td><select name='TIME_FROM'>
1351 for (my $i=0;$i<=23;$i++) {
1352 $i = sprintf("%02s",$i);
1353 for (my $j=0;$j<=45;$j+=15) {
1354 $j = sprintf("%02s",$j);
1355 my $time = $i.":".$j;
1356 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1361 <td><select name='TIME_TO'>
1363 for (my $i=0;$i<=23;$i++) {
1364 $i = sprintf("%02s",$i);
1365 for (my $j=0;$j<=45;$j+=15) {
1366 $j = sprintf("%02s",$j);
1367 my $time = $i.":".$j;
1368 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1375 &Header
::closebox
();
1376 #---ACTION------------------------------------------------------
1377 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1379 <table border='0' width='100%'>
1380 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1381 <input type='hidden' name='config' value='$config' >
1382 <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>
1387 <table border='0' width='100%'>
1388 <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'}'>
1389 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1390 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1391 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1392 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1393 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1394 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1395 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1396 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1397 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1398 <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>
1402 &Header
::closebox
();
1408 &General
::readhasharray
("$config", $hash);
1409 if (!$errormessage){
1410 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1411 my $key = &General
::findhasharraykey
($hash);
1412 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1413 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1414 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1415 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1416 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1417 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1418 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1419 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1420 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1421 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1422 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1423 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1424 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1425 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1426 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1427 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1428 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1429 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1430 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1431 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1432 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1433 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1434 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1435 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1436 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1437 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1438 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1439 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1440 &General
::writehasharray
("$config", $hash);
1442 foreach my $key (sort {$a <=> $b} keys %$hash){
1443 if($key eq $fwdfwsettings{'key'}){
1444 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1445 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1446 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1447 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1448 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1449 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1450 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1451 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1452 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1453 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1454 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1455 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1456 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1457 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1458 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1459 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1460 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1461 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1462 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1463 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1464 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1465 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1466 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1467 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1468 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1469 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1470 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1471 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1476 &General
::writehasharray
("$config", $hash);
1477 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1479 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1480 for (my $z=0;$z<$val;$z++){
1481 foreach my $key (sort {$a <=> $b} keys %$hash){
1482 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1484 if (exists $$hash{$last}){
1486 foreach my $y (0 .. $#{$$hash{$last}}) {
1487 $tmp{0}[$y] = $$hash{$last}[$y];
1489 #copy active rule to last
1490 foreach my $i (0 .. $#{$$hash{$last}}) {
1491 $$hash{$last}[$i] = $$hash{$key}[$i];
1493 #copy saved rule to actual position
1494 foreach my $x (0 .. $#{$tmp{0}}) {
1495 $$hash{$key}[$x] = $tmp{0}[$x];
1500 $fwdfwsettings{'oldrulenumber'}--;
1502 &General
::writehasharray
("$config", $hash);
1504 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1506 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1507 for (my $z=0;$z<$val;$z++){
1508 foreach my $key (sort {$a <=> $b} keys %$hash){
1509 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1510 my $next = $key + 1;
1511 if (exists $$hash{$next}){
1513 foreach my $y (0 .. $#{$$hash{$next}}) {
1514 $tmp{0}[$y] = $$hash{$next}[$y];
1516 #copy active rule to next
1517 foreach my $i (0 .. $#{$$hash{$next}}) {
1518 $$hash{$next}[$i] = $$hash{$key}[$i];
1520 #copy saved rule to actual position
1521 foreach my $x (0 .. $#{$tmp{0}}) {
1522 $$hash{$key}[$x] = $tmp{0}[$x];
1527 $fwdfwsettings{'oldrulenumber'}++;
1529 &General
::writehasharray
("$config", $hash);
1536 if ($errormessage) {
1537 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1538 print "<class name='base'>$errormessage\n";
1539 print " </class>\n";
1540 &Header
::closebox
();
1547 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1548 print "<class name='base'>$hint\n";
1549 print " </class>\n";
1550 &Header
::closebox
();
1557 &General
::setup_default_networks
(\
%defaultNetworks);
1558 foreach my $network (sort keys %defaultNetworks)
1560 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1565 # Checks a hostname against RFC1035
1568 # Each part should be at least two characters in length
1569 # but no more than 63 characters
1570 if (length ($remark) < 1 || length ($remark) > 255) {
1572 # Only valid characters are a-z, A-Z, 0-9 and -
1573 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1575 # First character can only be a letter or a digit
1576 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1578 # Last character can only be a letter or a digit
1579 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1585 my %hash=%{(shift)};
1587 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1588 print" : ($hash{$key}[8]) $hash{$key}[10]";
1589 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1590 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1595 my %hash=%{(shift)};
1600 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1601 if($hash{$key}[14] eq 'cust_srv'){
1602 &General
::readhasharray
("$configsrv", \
%customservice);
1603 foreach my $i (sort keys %customservice){
1604 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1605 if($customservice{$i}[0] eq $hash{$key}[15]){
1606 $prot = $hash{$key}[12];
1607 $service = $customservice{$i}[0];
1610 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1612 $service=$hash{$key}[15];
1613 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1614 $service=$hash{$key}[15];
1615 $prot=$hash{$key}[12];
1617 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1618 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1621 if ($prot ne '' || $service ne ''){
1631 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1632 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1641 if ( ! -z
"$config"){
1642 &Header
::openbox
('100%', 'left',$title);
1650 &General
::readhasharray
("$config", $hash);
1651 print"<b>$title1</b><br>";
1652 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1653 print"<tr><td align='center' width='1%'><b>#</td><td width='1%'></td><td align='center' width='20%'><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' width='70%'><b>$Lang::tr{'remark'}</td><td align='center' colspan='3' width='1%'><b>$Lang::tr{'fwdfw action'}</td></tr>";
1654 foreach my $key (sort {$a <=> $b} keys %$hash){
1656 #check if vpn hosts/nets have been deleted
1657 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1658 push (@tmpsrc,$$hash{$key}[4]);
1660 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1661 push (@tmpsrc,$$hash{$key}[6]);
1663 foreach my $host (@tmpsrc){
1664 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1665 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1667 &disable_rule
($key);
1670 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1671 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1673 &disable_rule
($key);
1676 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1677 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1679 &disable_rule
($key);
1682 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1683 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1685 &disable_rule
($key);
1692 $$hash{'ACTIVE'}=$$hash{$key}[2];
1694 if($coloryellow eq 'on'){
1695 print"<tr bgcolor='$color{'color14'}' >";
1697 }elsif($coloryellow eq ''){
1699 print"<tr bgcolor='$color{'color22'}' >";
1702 print"<tr bgcolor='$color{'color20'}' >";
1706 <td align='right'>$key</td>
1708 if ($$hash{$key}[0] eq 'ACCEPT'){
1711 $rulecolor=$color{'color17'};
1712 }elsif($$hash{$key}[0] eq 'DROP'){
1715 $rulecolor=$color{'color25'};
1716 }elsif($$hash{$key}[0] eq 'REJECT'){
1719 $rulecolor=$color{'color16'};
1721 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1722 print"<td align='center'>";
1723 if ($$hash{$key}[3] eq 'std_net_src'){
1724 print &get_name
($$hash{$key}[4]);
1726 print $$hash{$key}[4];
1728 &getsrcport
(\
%$hash,$key);
1729 if ($$hash{$key}[17] eq 'ON'){
1730 $log="/images/on.gif";
1732 $log="/images/off.gif";
1736 <form method='post'>
1737 <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 ;'/>
1738 <input type='hidden' name='key' value='$key' />
1739 <input type='hidden' name='config' value='$config' />
1740 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1745 <td align='center' nowrap='nowrap'>
1747 if ($$hash{$key}[5] eq 'std_net_tgt'){
1748 print &get_name
($$hash{$key}[6]);
1750 print $$hash{$key}[6];
1752 &gettgtport
(\
%$hash,$key);
1753 ################################################################################
1754 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1756 if($$hash{$key}[2] eq 'ON'){
1757 $gif="/images/on.gif"
1760 $gif="/images/off.gif"
1763 <form method='post'>
1764 <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;' />
1765 <input type='hidden' name='key' value='$key' />
1766 <input type='hidden' name='config' value='$config' />
1767 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1769 <form method='post'>
1770 <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;' />
1771 <input type='hidden' name='key' value='$key' />
1772 <input type='hidden' name='config' value='$config' />
1773 <input type='hidden' name='ACTION' value='editrule' />
1775 <form method='post'>
1776 <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;' />
1777 <input type='hidden' name='key' value='$key' />
1778 <input type='hidden' name='config' value='$config' />
1779 <input type='hidden' name='ACTION' value='copyrule' />
1781 <form method='post'>
1782 <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;' />
1783 <input type='hidden' name='key' value='$key' />
1784 <input type='hidden' name='config' value='$config' />
1785 <input type='hidden' name='ACTION' value='deleterule' />
1788 if (exists $$hash{$key-1}){
1790 <form method='post'>
1791 <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;' />
1792 <input type='hidden' name='key' value='$key' />
1793 <input type='hidden' name='config' value='$config' />
1794 <input type='hidden' name='ACTION' value='moveup' />
1800 if (exists $$hash{$key+1}){
1802 <form method='post'>
1803 <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;' />
1804 <input type='hidden' name='key' value='$key' />
1805 <input type='hidden' name='config' value='$config' />
1806 <input type='hidden' name='ACTION' value='movedown' />
1807 </td></form></td></tr>
1810 print"<td></td></tr>";
1812 #if timeframe set, print new line in table
1813 if ($$hash{$key}[18] eq 'ON'){
1815 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1816 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1817 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1818 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1819 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1820 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1821 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1822 my $weekdays=join(",",@days);
1824 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1826 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1831 &Header
::closebox
();
1837 open( FILE
, "< $p2pfile" ) or die "Unable to read $p2pfile";
1840 &Header
::openbox
('100%', 'center', 'P2P-Block');
1842 <table width='40%' border='0'>
1843 <tr bgcolor='$color{'color22'}'><td align=center colspan='2' width='30%'><b>$Lang::tr{'protocol'}</b><td width='10%' align=center><b>$Lang::tr{'status'}</b>
1845 foreach my $p2pentry (sort @p2ps)
1847 my @p2pline = split( /\;/, $p2pentry );
1848 if($p2pline[2] eq 'on'){
1849 $gif="/images/on.gif"
1851 $gif="/images/off.gif"
1854 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
1855 <tr bgcolor='$color{'color20'}'>
1856 <td width='66%' align='center' colspan='2'>$p2pline[0]:</td><td width='33%' 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>
1859 print"<tr><td width='10%'><input type='image' img src='/images/on.gif'></td><td>$Lang::tr{'outgoing firewall p2p deny'}</td><td></td></tr>";
1860 print"<tr><td width='10%'><input type='image' img src='/images/off.gif'></td><td>$Lang::tr{'outgoing firewall p2p allow'}</td><td></td></tr></table>";
1861 &Header
::closebox
();
1865 my %hash=%{(shift)};
1868 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1869 if($hash{$key}[0] eq $val){
1870 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1872 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1878 if (!-f
"${General::swroot}/forward/reread"){
1879 system("touch ${General::swroot}/forward/reread");
1884 system("/usr/local/bin/forwardfwctrl");
1885 system("rm ${General::swroot}/forward/reread");
1887 &Header
::closebigbox
();
1888 &Header
::closepage
();