]>
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=();
72 my $confignet = "${General::swroot}/fwhosts/customnetworks";
73 my $confighost = "${General::swroot}/fwhosts/customhosts";
74 my $configgrp = "${General::swroot}/fwhosts/customgroups";
75 my $configsrv = "${General::swroot}/fwhosts/customservices";
76 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
77 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
78 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
79 my $configipsec = "${General::swroot}/vpn/config";
80 my $configipsecrw = "${General::swroot}/vpn/settings";
81 my $configfwdfw = "${General::swroot}/forward/config";
82 my $configinput = "${General::swroot}/forward/input";
83 my $configovpn = "${General::swroot}/ovpn/settings";
87 my $ipgrp="${General::swroot}/outgoing/groups";
90 &General
::readhash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
91 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
92 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
94 &Header
::showhttpheaders
();
95 &Header
::getcgihash
(\
%fwdfwsettings);
96 &Header
::openpage
($Lang::tr
{'fwdfw menu'}, 1, '');
97 &Header
::openbigbox
('100%', 'center',$errormessage);
100 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'save'})
102 my $MODE = $fwdfwsettings{'POLICY'};
104 $fwdfwsettings{'POLICY'} = "$MODE";
105 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
108 if ($fwdfwsettings{'ACTION'} eq 'saverule')
110 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
111 &General
::readhasharray
("$configinput", \
%configinputfw);
112 $errormessage=&checksource
;
113 if(!$errormessage){&checktarget
;}
114 if(!$errormessage){&checkrule
;}
115 #check if we change an forward rule to an external access
116 if( $fwdfwsettings{'grp2'} eq 'ipfire' && $fwdfwsettings{'oldgrp2a'} ne 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
117 $fwdfwsettings{'updatefwrule'}='';
118 $fwdfwsettings{'config'}=$configfwdfw;
119 $fwdfwsettings{'nobase'}='on';
121 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
122 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
124 #check if we change an external access rule to an forward
125 if( $fwdfwsettings{'grp2'} ne 'ipfire' && $fwdfwsettings{'oldgrp2a'} eq 'ipfire' && $fwdfwsettings{'updatefwrule'} eq 'on'){
126 $fwdfwsettings{'updatefwrule'}='';
127 $fwdfwsettings{'config'}=$configinput;
128 $fwdfwsettings{'nobase'}='on';
130 &checkcounter
(0,0,$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
131 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
134 if($fwdfwsettings{'grp2'} eq 'ipfire'){
135 $fwdfwsettings{'chain'} = 'INPUTFW';
136 #check if we have an identical rule already
137 if($fwdfwsettings{'oldrulenumer'} eq $fwdfwsettings{'rulepos'}){
138 foreach my $key (sort keys %configinputfw){
139 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'}"
140 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]"){
141 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
142 $fwdfwsettings{'nosave'} = 'on';
146 #check if we just close a rule
147 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'} ) {
148 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
150 $fwdfwsettings{'nosave2'} = 'on';
153 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
154 if ($fwdfwsettings{'nobase'} ne 'on'){
155 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
157 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
158 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
159 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
160 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
161 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
162 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
164 if($fwdfwsettings{'nosave2'} ne 'on'){
165 &saverule
(\
%configinputfw,$configinput);
167 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
168 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
169 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
170 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
171 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
172 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
173 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
174 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
175 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
176 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
177 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
178 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
179 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
180 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
181 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
182 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
184 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
185 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
186 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
187 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
189 $fwdfwsettings{'chain'} = 'FORWARDFW';
190 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
191 #check if we have an identical rule already
192 foreach my $key (sort keys %configfwdfw){
193 if ("$fwdfwsettings{'RULE_ACTION'},$fwdfwsettings{'ACTIVE'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}},$fwdfwsettings{'USE_SRC_PORT'},$fwdfwsettings{'PROT'},$fwdfwsettings{'ICMP_TYPES'},$fwdfwsettings{'SRC_PORT'},$fwdfwsettings{'USESRV'},$fwdfwsettings{'TGT_PROT'},$fwdfwsettings{'ICMP_TGT'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}},$fwdfwsettings{'LOG'},$fwdfwsettings{'TIME'},$fwdfwsettings{'TIME_MON'},$fwdfwsettings{'TIME_TUE'},$fwdfwsettings{'TIME_WED'},$fwdfwsettings{'TIME_THU'},$fwdfwsettings{'TIME_FRI'},$fwdfwsettings{'TIME_SAT'},$fwdfwsettings{'TIME_SUN'},$fwdfwsettings{'TIME_FROM'},$fwdfwsettings{'TIME_TO'}"
194 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]"){
195 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
196 $fwdfwsettings{'nosave'} = 'on';
200 #check if we just close a rule
201 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'} ) {
202 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
203 $fwdfwsettings{'nosave2'} = 'on';
208 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
209 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
210 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
211 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
212 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
213 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
214 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
215 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
217 if ($fwdfwsettings{'nobase'} eq 'on'){
218 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
220 if ($fwdfwsettings{'nosave2'} ne 'on'){
221 &saverule
(\
%configfwdfw,$configfwdfw);
223 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
224 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
225 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
226 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
227 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
228 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
229 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
230 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
231 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
232 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
233 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
234 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
235 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
236 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
237 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
238 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
240 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
241 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
242 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
243 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
248 if($fwdfwsettings{'nosave2'} ne 'on'){
254 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
256 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
257 foreach my $key (sort keys %configfwdfw){
258 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
259 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
260 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
262 &General
::readhasharray
("$configinput", \
%configinputfw);
263 foreach my $key (sort keys %configinputfw){
264 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
265 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
266 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
268 $fwdfwsettings{'POLICY'}='MODE0';
269 system("rm ${General::swroot}/forward/config");
270 system("rm ${General::swroot}/forward/input");
271 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
272 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
273 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
278 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
282 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
285 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
286 foreach my $key (sort keys %togglehash){
287 if ($key eq $fwdfwsettings{'key'}){
288 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
291 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
295 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
298 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
299 foreach my $key (sort keys %togglehash){
300 if ($key eq $fwdfwsettings{'key'}){
301 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
304 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
308 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
313 if ($fwdfwsettings{'ACTION'} eq 'editrule')
315 $fwdfwsettings{'updatefwrule'}='on';
318 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
322 if ($fwdfwsettings{'ACTION'} eq 'moveup')
327 if ($fwdfwsettings{'ACTION'} eq 'movedown')
332 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
334 $fwdfwsettings{'copyfwrule'}='on';
335 #$fwdfwsettings{'updatefwrule'}='on';
338 if ($fwdfwsettings{'ACTION'} eq '')
347 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
348 foreach my $key (sort keys %uphash){
349 if ($key eq $fwdfwsettings{'key'}) {
351 if (exists $uphash{$last}){
353 foreach my $y (0 .. $#{$uphash{$last}}) {
354 $tmp{0}[$y] = $uphash{$last}[$y];
356 #copy active rule to last
357 foreach my $i (0 .. $#{$uphash{$last}}) {
358 $uphash{$last}[$i] = $uphash{$key}[$i];
360 #copy saved rule to actual position
361 foreach my $x (0 .. $#{$tmp{0}}) {
362 $uphash{$key}[$x] = $tmp{0}[$x];
367 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
374 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
375 foreach my $key (sort keys %downhash){
376 if ($key eq $fwdfwsettings{'key'}) {
378 if (exists $downhash{$next}){
380 foreach my $y (0 .. $#{$downhash{$next}}) {
381 $tmp{0}[$y] = $downhash{$next}[$y];
383 #copy active rule to next
384 foreach my $i (0 .. $#{$downhash{$next}}) {
385 $downhash{$next}[$i] = $downhash{$key}[$i];
387 #copy saved rule to actual position
388 foreach my $x (0 .. $#{$tmp{0}}) {
389 $downhash{$key}[$x] = $tmp{0}[$x];
394 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
399 my ($base1,$val1,$base2,$val2) = @_;
401 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
402 &dec_counter
($confignet,\
%customnetwork,$val1);
403 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
404 &dec_counter
($confighost,\
%customhost,$val1);
405 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
406 &dec_counter
($configgrp,\
%customgrp,$val1);
407 }elsif($base1 eq 'cust_srv'){
408 &dec_counter
($configsrv,\
%customservice,$val1);
409 }elsif($base1 eq 'cust_srvgrp'){
410 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
413 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
414 &inc_counter
($confignet,\
%customnetwork,$val2);
415 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
416 &inc_counter
($confighost,\
%customhost,$val2);
417 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
418 &inc_counter
($configgrp,\
%customgrp,$val2);
419 }elsif($base2 eq 'cust_srv'){
420 &inc_counter
($configsrv,\
%customservice,$val2);
421 }elsif($base2 eq 'cust_srvgrp'){
422 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
432 &General
::readhasharray
($config, \
%hash);
433 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
434 if($hash{$key}[0] eq $val){
435 $pos=$#{$hash{$key}};
436 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
439 &General
::writehasharray
($config, \
%hash);
447 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
448 &General
::readhasharray
($config, \
%hash);
449 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
450 if($hash{$key}[0] eq $val){
451 $pos=$#{$hash{$key}};
452 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
455 &General
::writehasharray
($config, \
%hash);
459 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
460 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
461 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
464 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
468 #print"<table width='100' border='1'><tr>";
471 #print"<td bgcolor='$color{$i}'>$_</td>";
473 #print"</tr></table>";
474 &Header
::openbox
('100%', 'center', 'Policy');
476 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
478 <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>
479 <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>
480 <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>
481 <tr><td colspan='3'><hr /></td></tr>
482 <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>
483 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
484 <td width='45%' align='left'>
486 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
487 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
489 print "</table></form>";
495 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
497 print "<form method='post'>";
498 print "<table border='0'>";
499 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
500 if (-f
"${General::swroot}/forward/reread"){
501 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
503 print"</tr></table></form><hr>";
511 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
512 foreach my $key (sort {$a <=> $b} keys %delhash){
513 if ($key == $fwdfwsettings{'key'}){
514 #check hosts/net and groups
515 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
516 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
517 #check services and groups
518 if ($delhash{$key}[11] eq 'ON'){
519 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
522 if ($key >= $fwdfwsettings{'key'}) {
524 if (exists $delhash{$next}) {
525 foreach my $i (0 .. $#{$delhash{$next}}) {
526 $delhash{$key}[$i] = $delhash{$next}[$i];
531 # Remove the very last entry.
532 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
533 delete $delhash{$last_key};
535 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
538 if($fwdfwsettings{'nobase'} ne 'on'){
545 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
546 foreach my $key (sort keys %configfwdfw){
548 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
551 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
558 #check ip-address if manual
559 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
560 #check if ip with subnet
561 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
562 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
563 $subnet = &General
::iporsubtocidr
($subnet);
564 $fwdfwsettings{'isip'}='on';
567 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
568 $ip=$fwdfwsettings{'src_addr'};
570 $fwdfwsettings{'isip'}='on';
573 if ($fwdfwsettings{'isip'} ne 'on'){
574 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
576 if ($fwdfwsettings{'isip'} eq 'on'){
577 #check and form valid IP
578 $ip=&General
::ip2dec
($ip);
579 $ip=&General
::dec2ip
($ip);
580 #check if net or broadcast
581 my @tmp= split (/\./,$ip);
582 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
584 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
586 $fwdfwsettings{'src_addr'}="$ip/$subnet";
588 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
589 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
592 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
593 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
595 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
596 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
597 return $errormessage;
601 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
603 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
604 $fwdfwsettings{'SRC_PORT'}='';
605 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
606 foreach my $key (keys %icmptypes){
607 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
608 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
611 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
612 $fwdfwsettings{'SRC_PORT'}='';
613 $fwdfwsettings{'ICMP_TYPES'}='';
614 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
615 $fwdfwsettings{'SRC_PORT'}='';
616 $fwdfwsettings{'ICMP_TYPES'}='';
617 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
618 $fwdfwsettings{'ICMP_TYPES'}='';
620 $fwdfwsettings{'ICMP_TYPES'}='';
621 $fwdfwsettings{'SRC_PORT'}='';
622 $fwdfwsettings{'PROT'}='';
625 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
626 #change dashes with :
627 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
629 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
630 $fwdfwsettings{'SRC_PORT'} = "1:65535";
632 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
633 $fwdfwsettings{'SRC_PORT'} = "1:$2";
635 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
636 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
639 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
641 return $errormessage;
647 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
648 #check if ip with subnet
649 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
650 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
651 $subnet = &General
::iporsubtocidr
($subnet);
654 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
655 $ip=$fwdfwsettings{'tgt_addr'};
658 #check and form valid IP
659 $ip=&General
::ip2dec
($ip);
660 $ip=&General
::dec2ip
($ip);
662 #check if net or broadcast
663 my @tmp= split (/\./,$ip);
664 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
666 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
668 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
670 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
671 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
674 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
675 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
676 return $errormessage;
680 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
683 if ($fwdfwsettings{'USESRV'} eq 'ON'){
684 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
685 $fwdfwsettings{'TGT_PROT'}='';
686 $fwdfwsettings{'ICMP_TGT'}='';
688 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
689 $fwdfwsettings{'TGT_PROT'}='';
690 $fwdfwsettings{'ICMP_TGT'}='';
691 #check target service
692 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
693 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
696 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
697 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){
698 if ($fwdfwsettings{'TGT_PORT'} ne ''){
699 #change dashes with :
700 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
701 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
702 $fwdfwsettings{'TGT_PORT'} = "1:65535";
704 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
705 $fwdfwsettings{'TGT_PORT'} = "1:$2";
707 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
708 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
710 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
712 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
713 $fwdfwsettings{'TGT_PORT'} = '';
714 $fwdfwsettings{'ICMP_TGT'} = '';
715 }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){
716 $fwdfwsettings{'TGT_PORT'}='';
717 $fwdfwsettings{'ICMP_TGT'}='';
718 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
719 $fwdfwsettings{'TGT_PORT'} = '';
720 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
721 foreach my $key (keys %icmptypes){
723 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
724 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
732 if ($fwdfwsettings{'USESRV'} ne 'ON'){
733 $fwdfwsettings{'grp3'}='';
734 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
735 $fwdfwsettings{'TGT_PROT'}='';
736 $fwdfwsettings{'ICMP_TGT'}='';
739 if($fwdfwsettings{'TIME'} eq 'ON'){
740 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 ''){
741 $errormessage=$Lang::tr
{'fwdfw err time'};
744 return $errormessage;
749 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
750 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
752 #check if source and target identical
753 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
754 $errormessage.=$Lang::tr
{'fwdfw err same'};
755 return $errormessage;
758 #get source and targetip address if possible
759 my ($sip,$scidr,$tip,$tcidr);
760 ($sip,$scidr)=&get_ip
("src","grp1");
761 ($tip,$tcidr)=&get_ip
("tgt","grp2");
763 #check same iprange in source and target
764 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
765 my $networkip1=&General
::getnetworkip
($sip,$scidr);
766 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
767 if ($scidr gt $tcidr){
768 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
769 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
771 }elsif($scidr eq $tcidr && $scidr eq '32'){
772 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
773 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
774 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
775 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
776 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
779 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
780 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
785 #check source and destination protocol if manual
786 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
787 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
788 $errormessage.=$Lang::tr
{'fwdfw err prot'};
790 #check source and destination protocol if source manual and dest servicegrp
791 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
792 &General
::readhasharray
("$configsrv", \
%customservice);
793 foreach my $key (sort keys %customservice){
794 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
795 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
796 $errormessage.=$Lang::tr
{'fwdfw err prot'};
810 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
811 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
812 if ($fwdfwsettings{$grp} eq $val.'_addr'){
813 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
814 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
815 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
816 $a=$netsettings{'GREEN_NETADDRESS'};
817 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
818 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
819 $a=$netsettings{'ORANGE_NETADDRESS'};
820 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
821 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
822 $a=$netsettings{'BLUE_NETADDRESS'};
823 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
824 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
825 &General
::readhash
("$configovpn",\
%ovpnsettings);
826 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
827 $b=&General
::iporsubtocidr
($b);
829 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
830 &General
::readhasharray
("$confignet", \
%customnetwork);
831 foreach my $key (keys %customnetwork){
832 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
833 $a=$customnetwork{$key}[1];
834 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
837 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
838 &General
::readhasharray
("$confighost", \
%customhost);
839 foreach my $key (keys %customhost){
840 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
841 if ($customhost{$key}[1] eq 'ip'){
842 ($a,$b)=split (/\//,$customhost{$key}[2]);
843 $b=&General
::iporsubtocidr
($b);
846 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
858 &General
::setup_default_networks
(\
%defaultNetworks);
859 #read all configfiles
860 &General
::readhasharray
("$configccdnet", \
%ccdnet);
861 &General
::readhasharray
("$confignet", \
%customnetwork);
862 &General
::readhasharray
("$configccdhost", \
%ccdhost);
863 &General
::readhasharray
("$confighost", \
%customhost);
864 &General
::readhasharray
("$configccdhost", \
%ccdhost);
865 &General
::readhasharray
("$configgrp", \
%customgrp);
866 &General
::readhasharray
("$configipsec", \
%ipsecconf);
867 &General
::get_aliases
(\
%aliases);
871 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
872 my $config=$fwdfwsettings{'config'};
874 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
875 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
876 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
877 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
878 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
879 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
880 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
881 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
882 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
883 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
884 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
885 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
886 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
887 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
888 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
889 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
890 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
891 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
892 #check if update and get values
893 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
894 &General
::readhasharray
("$config", \
%hash);
895 foreach my $key (sort keys %hash){
897 if ($key eq $fwdfwsettings{'key'}){
898 $fwdfwsettings{'oldrulenumber'} = $key;
899 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
900 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
901 $fwdfwsettings{'grp1'} = $hash{$key}[3];
902 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
903 $fwdfwsettings{'grp2'} = $hash{$key}[5];
904 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
905 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
906 $fwdfwsettings{'PROT'} = $hash{$key}[8];
907 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
908 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
909 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
910 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
911 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
912 $fwdfwsettings{'grp3'} = $hash{$key}[14];
913 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
914 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
915 $fwdfwsettings{'LOG'} = $hash{$key}[17];
916 $fwdfwsettings{'TIME'} = $hash{$key}[18];
917 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
918 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
919 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
920 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
921 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
922 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
923 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
924 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
925 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
926 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
927 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
928 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
929 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
930 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
931 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
932 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
933 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
934 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
935 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
936 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
937 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
938 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
939 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
940 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
941 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
942 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
943 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
946 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
947 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
948 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
949 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
950 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
951 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
952 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
954 $fwdfwsettings{'ACTIVE'}='ON';
955 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
958 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
963 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
965 foreach ("ACCEPT","DROP","REJECT")
967 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
968 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
971 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
973 print"<option selected>$_</option>";
975 print"<option>$_</option>";
978 print"</select></td></tr></table><hr>";
982 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
985 #------SOURCE-------------------------------------------------------
987 <table width='100%' border='0'>
988 <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>
989 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
990 <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;'>
992 foreach my $network (sort keys %defaultNetworks)
994 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
995 next if($defaultNetworks{$network}{'NAME'} eq "RED");
996 print "<option value='$defaultNetworks{$network}{'NAME'}'";
997 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
998 print ">$network</option>";
1001 </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;'>
1003 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1006 <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;'>
1008 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1010 </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;'>
1012 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1014 if ($ccdhost{$key}[33] ne ''){
1016 print "<option value='$ccdhost{$key}[1]'";
1017 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1018 print ">$ccdhost{$key}[1]</option>";
1023 <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;'>
1025 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1027 </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;'>
1029 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1030 if($ccdhost{$key}[3] eq 'net'){
1032 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1033 print ">$ccdhost{$key}[1]</option>";
1039 <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;'>
1041 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1042 if($helper ne $customgrp{$key}[0]){
1044 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1045 print ">$customgrp{$key}[0]</option>";
1047 $helper=$customgrp{$key}[0];
1051 <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;'>
1053 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1054 if ($ipsecconf{$key}[3] eq 'net'){
1056 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1057 print ">$ipsecconf{$key}[1]</option>";
1065 # <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;'>
1067 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1068 # if ($ipsecconf{$key}[3] eq 'host'){
1070 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1071 # print ">$ipsecconf{$key}[1]</option>";
1075 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1076 <table width='100%' border='0'>
1077 <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>
1078 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1080 foreach ("TCP","UDP","GRE","ESP","ICMP")
1082 if ($_ eq $fwdfwsettings{'PROT'})
1084 print"<option selected>$_</option>";
1086 print"<option>$_</option>";
1090 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1091 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1093 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1094 print"<option>All ICMP-Types</option>";
1095 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1096 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1097 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1099 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1103 </select></td></tr></table><hr>
1105 &Header
::closebox
();
1107 #---TARGET------------------------------------------------------
1108 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1110 <table width='100%' border='0'>
1111 <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;'>
1113 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1115 foreach my $alias (sort keys %aliases)
1117 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1122 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1123 <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;'>
1125 foreach my $network (sort keys %defaultNetworks)
1127 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1128 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1129 print ">$network</option>";
1132 </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;'>
1134 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1137 <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;'>
1139 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1141 </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;'>
1143 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1145 if ($ccdhost{$key}[33] ne ''){
1146 print "<option value='$ccdhost{$key}[1]' ";
1147 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1148 print ">$ccdhost{$key}[1]</option>";
1153 <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;'>
1155 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1157 </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;'>
1159 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1160 if($ccdhost{$key}[3] eq 'net'){
1162 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1163 print ">$ccdhost{$key}[1]</option>";
1168 <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;'>
1171 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1172 if($helper ne $customgrp{$key}[0]){
1174 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1175 print">$customgrp{$key}[0]</option>";
1177 $helper=$customgrp{$key}[0];
1181 <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;'>
1183 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1184 if ($ipsecconf{$key}[3] eq 'net'){
1186 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1187 print">$ipsecconf{$key}[1]</option>";
1193 # <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;'>
1195 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1196 # if ($ipsecconf{$key}[3] eq 'host'){
1198 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1199 # print">$ipsecconf{$key}[1]</option>";
1204 <b>$Lang::tr{'fwhost attention'}:</b><br>
1205 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1207 <table width='100%' border='0'>
1208 <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;' >
1210 &General
::readhasharray
("$configsrv", \
%customservice);
1211 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1213 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1214 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1218 <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;' >
1220 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1222 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1223 if ($helper ne $customservicegrp{$key}[0]){
1225 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1226 print">$customservicegrp{$key}[0]</option>";
1228 $helper=$customservicegrp{$key}[0];
1232 <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'>
1234 foreach ("TCP","UDP","GRE","ESP","ICMP")
1236 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1238 print"<option selected>$_</option>";
1240 print"<option>$_</option>";
1244 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1245 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1247 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1248 print"<option>All ICMP-Types</option>";
1249 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1250 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1251 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1253 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1258 </table><hr><br><br>
1261 #---Activate/logging/remark-------------------------------------
1262 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1264 <table width='100%' border='0'>
1265 <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>
1267 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1268 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1269 for (my $count =1; $count <= $sum; $count++){
1270 print"<option value='$count' ";
1271 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1272 print">$count</option>";
1274 print"</select></td></tr>";
1278 </table><table width='100%'>
1279 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1280 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1283 &Header
::closebox
();
1284 #---ADD TIMEFRAME-----------------------------------------------
1285 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1287 <table width='70%' border='0'>
1288 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1289 <tr><td colspan='7'> </td></tr>
1291 <td align='left'>$Lang::tr{'time'}:</td>
1292 <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>
1293 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1294 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1297 <td align='right'></td>
1298 <td width='30%' align='left'>
1299 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1300 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1301 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1302 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1303 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1304 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1305 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1307 <td><select name='TIME_FROM'>
1309 for (my $i=0;$i<=23;$i++) {
1310 $i = sprintf("%02s",$i);
1311 for (my $j=0;$j<=45;$j+=15) {
1312 $j = sprintf("%02s",$j);
1313 my $time = $i.":".$j;
1314 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1319 <td><select name='TIME_TO'>
1321 for (my $i=0;$i<=23;$i++) {
1322 $i = sprintf("%02s",$i);
1323 for (my $j=0;$j<=45;$j+=15) {
1324 $j = sprintf("%02s",$j);
1325 my $time = $i.":".$j;
1326 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1333 &Header
::closebox
();
1334 #---ACTION------------------------------------------------------
1335 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1337 <table border='0' width='100%'>
1338 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1339 <input type='hidden' name='config' value='$config' >
1340 <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>
1345 <table border='0' width='100%'>
1346 <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'}'>
1347 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1348 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1349 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1350 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1351 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1352 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1353 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1354 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1355 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1356 <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>
1360 &Header
::closebox
();
1366 &General
::readhasharray
("$config", $hash);
1367 if (!$errormessage){
1368 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1369 my $key = &General
::findhasharraykey
($hash);
1370 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1371 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1372 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1373 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1374 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1375 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1376 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1377 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1378 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1379 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1380 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1381 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1382 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1383 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1384 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1385 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1386 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1387 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1388 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1389 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1390 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1391 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1392 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1393 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1394 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1395 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1396 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1397 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1398 &General
::writehasharray
("$config", $hash);
1401 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1403 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1404 for ($a=0;$a<$val;$a++){
1405 $fwdfwsettings{'oldrulenumber'}=$fwdfwsettings{'oldrulenumber'}-$a;
1406 foreach my $key (sort {$a <=> $b} keys %$hash){
1407 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1409 if (exists $$hash{$last}){
1411 foreach my $y (0 .. $#{$$hash{$last}}) {
1412 $tmp{0}[$y] = $$hash{$last}[$y];
1414 #copy active rule to last
1415 foreach my $i (0 .. $#{$$hash{$last}}) {
1416 $$hash{$last}[$i] = $$hash{$key}[$i];
1418 #copy saved rule to actual position
1419 foreach my $x (0 .. $#{$tmp{0}}) {
1420 $$hash{$key}[$x] = $tmp{0}[$x];
1426 &General
::writehasharray
("$config", $hash);
1428 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1430 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1431 for ($a=0;$a<$val;$a++){
1432 $fwdfwsettings{'oldrulenumber'}=$fwdfwsettings{'oldrulenumber'}+$a;
1433 foreach my $key (sort {$a <=> $b} keys %$hash){
1434 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1435 my $next = $key + 1;
1436 if (exists $$hash{$next}){
1438 foreach my $y (0 .. $#{$$hash{$next}}) {
1439 $tmp{0}[$y] = $$hash{$next}[$y];
1441 #copy active rule to next
1442 foreach my $i (0 .. $#{$$hash{$next}}) {
1443 $$hash{$next}[$i] = $$hash{$key}[$i];
1445 #copy saved rule to actual position
1446 foreach my $x (0 .. $#{$tmp{0}}) {
1447 $$hash{$key}[$x] = $tmp{0}[$x];
1453 &General
::writehasharray
("$config", $hash);
1456 foreach my $key (sort {$a <=> $b} keys %$hash){
1457 if($key eq $fwdfwsettings{'key'}){
1458 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1459 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1460 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1461 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1462 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1463 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1464 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1465 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1466 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1467 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1468 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1469 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1470 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1471 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1472 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1473 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1474 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1475 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1476 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1477 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1478 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1479 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1480 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1481 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1482 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1483 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1484 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1485 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1490 &General
::writehasharray
("$config", $hash);
1496 if ($errormessage) {
1497 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1498 print "<class name='base'>$errormessage\n";
1499 print " </class>\n";
1500 &Header
::closebox
();
1507 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1508 print "<class name='base'>$hint\n";
1509 print " </class>\n";
1510 &Header
::closebox
();
1517 &General
::setup_default_networks
(\
%defaultNetworks);
1518 foreach my $network (sort keys %defaultNetworks)
1520 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1525 # Checks a hostname against RFC1035
1528 # Each part should be at least two characters in length
1529 # but no more than 63 characters
1530 if (length ($remark) < 1 || length ($remark) > 255) {
1532 # Only valid characters are a-z, A-Z, 0-9 and -
1533 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1535 # First character can only be a letter or a digit
1536 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1538 # Last character can only be a letter or a digit
1539 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1545 my %hash=%{(shift)};
1547 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1548 print" : ($hash{$key}[8]) $hash{$key}[10]";
1549 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1550 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1555 my %hash=%{(shift)};
1560 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1561 if($hash{$key}[14] eq 'cust_srv'){
1562 &General
::readhasharray
("$configsrv", \
%customservice);
1563 foreach my $i (sort keys %customservice){
1564 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1565 if($customservice{$i}[0] eq $hash{$key}[15]){
1566 $prot = $hash{$key}[12];
1567 $service = $customservice{$i}[0];
1570 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1572 $service=$hash{$key}[15];
1573 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1574 $service=$hash{$key}[15];
1575 $prot=$hash{$key}[12];
1577 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1578 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1581 if ($prot ne '' || $service ne ''){
1591 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1592 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1601 if ( ! -z
"$config"){
1602 &Header
::openbox
('100%', 'left',$title);
1610 &General
::readhasharray
("$config", $hash);
1611 print"<b>$title1</b><br>";
1612 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1613 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>";
1614 foreach my $key (sort {$a <=> $b} keys %$hash){
1616 #check if vpn hosts/nets have been deleted
1617 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1618 push (@tmpsrc,$$hash{$key}[4]);
1620 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1621 push (@tmpsrc,$$hash{$key}[6]);
1623 foreach my $host (@tmpsrc){
1624 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1625 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1627 &disable_rule
($key);
1630 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1631 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1633 &disable_rule
($key);
1636 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1637 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1639 &disable_rule
($key);
1642 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1643 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1645 &disable_rule
($key);
1652 $$hash{'ACTIVE'}=$$hash{$key}[2];
1654 if($coloryellow eq 'on'){
1655 print"<tr bgcolor='$color{'color14'}' >";
1657 }elsif($coloryellow eq ''){
1659 print"<tr bgcolor='$color{'color22'}' >";
1662 print"<tr bgcolor='$color{'color20'}' >";
1666 <td align='right'>$key</td>
1668 if ($$hash{$key}[0] eq 'ACCEPT'){
1671 $rulecolor=$color{'color17'};
1672 }elsif($$hash{$key}[0] eq 'DROP'){
1675 $rulecolor=$color{'color25'};
1676 }elsif($$hash{$key}[0] eq 'REJECT'){
1679 $rulecolor=$color{'color16'};
1681 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1682 print"<td align='center'>";
1683 if ($$hash{$key}[3] eq 'std_net_src'){
1684 print &get_name
($$hash{$key}[4]);
1686 print $$hash{$key}[4];
1688 &getsrcport
(\
%$hash,$key);
1689 if ($$hash{$key}[17] eq 'ON'){
1690 $log="/images/on.gif";
1692 $log="/images/off.gif";
1696 <form method='post'>
1697 <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 ;'/>
1698 <input type='hidden' name='key' value='$key' />
1699 <input type='hidden' name='config' value='$config' />
1700 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1705 <td align='center' nowrap='nowrap'>
1707 if ($$hash{$key}[5] eq 'std_net_tgt'){
1708 print &get_name
($$hash{$key}[6]);
1710 print $$hash{$key}[6];
1712 &gettgtport
(\
%$hash,$key);
1713 ################################################################################
1714 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1716 if($$hash{$key}[2] eq 'ON'){
1717 $gif="/images/on.gif"
1720 $gif="/images/off.gif"
1723 <form method='post'>
1724 <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;' />
1725 <input type='hidden' name='key' value='$key' />
1726 <input type='hidden' name='config' value='$config' />
1727 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1729 <form method='post'>
1730 <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;' />
1731 <input type='hidden' name='key' value='$key' />
1732 <input type='hidden' name='config' value='$config' />
1733 <input type='hidden' name='ACTION' value='editrule' />
1735 <form method='post'>
1736 <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;' />
1737 <input type='hidden' name='key' value='$key' />
1738 <input type='hidden' name='config' value='$config' />
1739 <input type='hidden' name='ACTION' value='copyrule' />
1741 <form method='post'>
1742 <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;' />
1743 <input type='hidden' name='key' value='$key' />
1744 <input type='hidden' name='config' value='$config' />
1745 <input type='hidden' name='ACTION' value='deleterule' />
1748 if (exists $$hash{$key-1}){
1750 <form method='post'>
1751 <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;' />
1752 <input type='hidden' name='key' value='$key' />
1753 <input type='hidden' name='config' value='$config' />
1754 <input type='hidden' name='ACTION' value='moveup' />
1760 if (exists $$hash{$key+1}){
1762 <form method='post'>
1763 <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;' />
1764 <input type='hidden' name='key' value='$key' />
1765 <input type='hidden' name='config' value='$config' />
1766 <input type='hidden' name='ACTION' value='movedown' />
1767 </td></form></td></tr>
1770 print"<td></td></tr>";
1772 #if timeframe set, print new line in table
1773 if ($$hash{$key}[18] eq 'ON'){
1775 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1776 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1777 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1778 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1779 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1780 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1781 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1782 my $weekdays=join(",",@days);
1784 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1786 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1791 &Header
::closebox
();
1796 my %hash=%{(shift)};
1799 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1800 if($hash{$key}[0] eq $val){
1801 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1803 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1809 if (!-f
"${General::swroot}/forward/reread"){
1810 system("touch ${General::swroot}/forward/reread");
1815 system("/usr/local/bin/forwardfwctrl");
1816 system("rm ${General::swroot}/forward/reread");
1818 &Header
::closebigbox
();
1819 &Header
::closepage
();