]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 # Hi folks! I hope this code is useful for all. I needed something to handle #
23 # my VPN Connections in a comfortable way. As a prerequisite i needed #
24 # something that makes sure the vpn roadwarrior are able to have a fixed #
25 # ip-address. So i developed the ccd extension for the vpn server. #
27 # Now that the ccd extension is ready i am able to develop the main request. #
28 # Any feedback is appreciated. #
31 ###############################################################################
34 no warnings
'uninitialized';
35 # enable only the following on debugging purpose
37 #use CGI::Carp 'fatalsToBrowser';
39 require '/var/ipfire/general-functions.pl';
40 require "${General::swroot}/lang.pl";
41 require "${General::swroot}/header.pl";
42 require "${General::swroot}/forward/bin/firewall-lib.pl";
44 unless (-d
"${General::swroot}/forward") { system("mkdir ${General::swroot}/forward"); }
45 unless (-e
"${General::swroot}/forward/settings") { system("touch ${General::swroot}/forward/settings"); }
46 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
47 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
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 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
145 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
146 $fwdfwsettings{'nosave'} = 'on';
151 #check if we just close a rule
152 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'} ) {
153 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
155 $fwdfwsettings{'nosave2'} = 'on';
158 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
159 if ($fwdfwsettings{'nobase'} ne 'on'){
160 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
162 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
163 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
164 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
165 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
166 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
167 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
169 if($fwdfwsettings{'nosave2'} ne 'on'){
170 &saverule
(\
%configinputfw,$configinput);
172 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
173 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
174 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
175 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
176 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
177 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
178 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
179 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
180 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
181 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
182 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
183 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
184 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
185 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
186 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
187 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
189 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
190 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
191 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
192 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
194 $fwdfwsettings{'chain'} = 'FORWARDFW';
195 if($fwdfwsettings{'oldrulenumber'} eq $fwdfwsettings{'rulepos'}){
196 #check if we have an identical rule already
197 foreach my $key (sort keys %configfwdfw){
198 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'}"
199 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]"){
200 $errormessage.=$Lang::tr
{'fwdfw err ruleexists'};
201 if ($fwdfwsettings{'oldruleremark'} ne $fwdfwsettings{'ruleremark'} && $fwdfwsettings{'updatefwrule'} eq 'on'){
204 if ($fwdfwsettings{'oldruleremark'} eq $fwdfwsettings{'ruleremark'}){
205 $fwdfwsettings{'nosave'} = 'on';
210 #check if we just close a rule
211 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'} ) {
212 if($fwdfwsettings{'nosave'} eq 'on' && $fwdfwsettings{'updatefwrule'} eq 'on'){
213 $fwdfwsettings{'nosave2'} = 'on';
218 &checkcounter
($fwdfwsettings{'oldgrp1a'},$fwdfwsettings{'oldgrp1b'},$fwdfwsettings{'grp1'},$fwdfwsettings{$fwdfwsettings{'grp1'}});
219 &checkcounter
($fwdfwsettings{'oldgrp2a'},$fwdfwsettings{'oldgrp2b'},$fwdfwsettings{'grp2'},$fwdfwsettings{$fwdfwsettings{'grp2'}});
220 if($fwdfwsettings{'oldusesrv'} eq '' && $fwdfwsettings{'USESRV'} eq 'ON'){
221 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
222 }elsif ($fwdfwsettings{'USESRV'} eq '' && $fwdfwsettings{'oldusesrv'} eq 'ON') {
223 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},0,0);
224 }elsif ($fwdfwsettings{'oldusesrv'} eq $fwdfwsettings{'USESRV'} && $fwdfwsettings{'oldgrp3b'} ne $fwdfwsettings{$fwdfwsettings{'grp3'}} && $fwdfwsettings{'updatefwrule'} eq 'on'){
225 &checkcounter
($fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'},$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
227 if ($fwdfwsettings{'nobase'} eq 'on'){
228 &checkcounter
(0,0,$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}});
230 if ($fwdfwsettings{'nosave2'} ne 'on'){
231 &saverule
(\
%configfwdfw,$configfwdfw);
233 #print "Source: $fwdfwsettings{'grp1'} -> $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
234 #print "Sourceport: $fwdfwsettings{'USE_SRC_PORT'}, $fwdfwsettings{'PROT'}, $fwdfwsettings{'ICMP_TYPES'}, $fwdfwsettings{'SRC_PORT'}<br>";
235 #print "Target: $fwdfwsettings{'grp2'} -> $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
236 #print "Dienst: $fwdfwsettings{'USESRV'}, $fwdfwsettings{'grp3'} -> $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
237 #print "BEMERKUNG: $fwdfwsettings{'ruleremark'}<br>";
238 #print " Regel AKTIV: $fwdfwsettings{'ACTIVE'}<br>";
239 #print " Regel LOG: $fwdfwsettings{'LOG'}<br>";
240 #print " ZEITRAHMEN: $fwdfwsettings{'TIME'}<br>";
241 #print " MO: $fwdfwsettings{'TIME_MON'}<br>";
242 #print " DI: $fwdfwsettings{'TIME_TUE'}<br>";
243 #print " MI: $fwdfwsettings{'TIME_WED'}<br>";
244 #print " DO: $fwdfwsettings{'TIME_THU'}<br>";
245 #print " FR: $fwdfwsettings{'TIME_FRI'}<br>";
246 #print " SA: $fwdfwsettings{'TIME_SAT'}<br>";
247 #print " SO: $fwdfwsettings{'TIME_SUN'}<br>";
248 #print " VON: $fwdfwsettings{'TIME_FROM'} bis $fwdfwsettings{'TIME_TO'}<br>";
250 #print"ALT: $fwdfwsettings{'oldgrp1a'} $fwdfwsettings{'oldgrp1b'} NEU: $fwdfwsettings{'grp1'} $fwdfwsettings{$fwdfwsettings{'grp1'}}<br>";
251 #print"ALT: $fwdfwsettings{'oldgrp2a'} $fwdfwsettings{'oldgrp2b'} NEU: $fwdfwsettings{'grp2'} $fwdfwsettings{$fwdfwsettings{'grp2'}}<br>";
252 #print"ALT: $fwdfwsettings{'oldgrp3a'} $fwdfwsettings{'oldgrp3b'} NEU: $fwdfwsettings{'grp3'} $fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
253 #print"DIENSTE Checkalt:$fwdfwsettings{'oldusesrv'} DIENSTE Checkneu:$fwdfwsettings{'USESRV'} DIENST ALT:$fwdfwsettings{'oldgrp3a'},$fwdfwsettings{'oldgrp3b'} DIENST NEU:$fwdfwsettings{'grp3'},$fwdfwsettings{$fwdfwsettings{'grp3'}}<br>";
258 if($fwdfwsettings{'nosave2'} ne 'on'){
264 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'reset'})
266 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
267 foreach my $key (sort keys %configfwdfw){
268 &checkcounter
($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
269 &checkcounter
($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
270 &checkcounter
($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
272 &General
::readhasharray
("$configinput", \
%configinputfw);
273 foreach my $key (sort keys %configinputfw){
274 &checkcounter
($configinputfw{$key}[3],$configinputfw{$key}[4],,);
275 &checkcounter
($configinputfw{$key}[5],$configinputfw{$key}[6],,);
276 &checkcounter
($configinputfw{$key}[14],$configinputfw{$key}[15],,);
278 $fwdfwsettings{'POLICY'}='MODE0';
279 system("rm ${General::swroot}/forward/config");
280 system("rm ${General::swroot}/forward/input");
281 &General
::writehash
("${General::swroot}/forward/settings", \
%fwdfwsettings);
282 unless (-e
"${General::swroot}/forward/config") { system("touch ${General::swroot}/forward/config"); }
283 unless (-e
"${General::swroot}/forward/input") { system("touch ${General::swroot}/forward/input"); }
288 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw newrule'})
292 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw toggle'})
295 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
296 foreach my $key (sort keys %togglehash){
297 if ($key eq $fwdfwsettings{'key'}){
298 if ($togglehash{$key}[2] eq 'ON'){$togglehash{$key}[2]='';}else{$togglehash{$key}[2]='ON';}
301 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
305 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw togglelog'})
308 &General
::readhasharray
($fwdfwsettings{'config'}, \
%togglehash);
309 foreach my $key (sort keys %togglehash){
310 if ($key eq $fwdfwsettings{'key'}){
311 if ($togglehash{$key}[17] eq 'ON'){$togglehash{$key}[17]='';}else{$togglehash{$key}[17]='ON';}
314 &General
::writehasharray
($fwdfwsettings{'config'}, \
%togglehash);
318 if ($fwdfwsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
323 if ($fwdfwsettings{'ACTION'} eq 'editrule')
325 $fwdfwsettings{'updatefwrule'}='on';
328 if ($fwdfwsettings{'ACTION'} eq 'deleterule')
332 if ($fwdfwsettings{'ACTION'} eq 'moveup')
337 if ($fwdfwsettings{'ACTION'} eq 'movedown')
342 if ($fwdfwsettings{'ACTION'} eq 'copyrule')
344 $fwdfwsettings{'copyfwrule'}='on';
345 #$fwdfwsettings{'updatefwrule'}='on';
348 if ($fwdfwsettings{'ACTION'} eq '')
357 &General
::readhasharray
($fwdfwsettings{'config'}, \
%uphash);
358 foreach my $key (sort keys %uphash){
359 if ($key eq $fwdfwsettings{'key'}) {
361 if (exists $uphash{$last}){
363 foreach my $y (0 .. $#{$uphash{$last}}) {
364 $tmp{0}[$y] = $uphash{$last}[$y];
366 #copy active rule to last
367 foreach my $i (0 .. $#{$uphash{$last}}) {
368 $uphash{$last}[$i] = $uphash{$key}[$i];
370 #copy saved rule to actual position
371 foreach my $x (0 .. $#{$tmp{0}}) {
372 $uphash{$key}[$x] = $tmp{0}[$x];
377 &General
::writehasharray
($fwdfwsettings{'config'}, \
%uphash);
384 &General
::readhasharray
($fwdfwsettings{'config'}, \
%downhash);
385 foreach my $key (sort keys %downhash){
386 if ($key eq $fwdfwsettings{'key'}) {
388 if (exists $downhash{$next}){
390 foreach my $y (0 .. $#{$downhash{$next}}) {
391 $tmp{0}[$y] = $downhash{$next}[$y];
393 #copy active rule to next
394 foreach my $i (0 .. $#{$downhash{$next}}) {
395 $downhash{$next}[$i] = $downhash{$key}[$i];
397 #copy saved rule to actual position
398 foreach my $x (0 .. $#{$tmp{0}}) {
399 $downhash{$key}[$x] = $tmp{0}[$x];
404 &General
::writehasharray
($fwdfwsettings{'config'}, \
%downhash);
409 my ($base1,$val1,$base2,$val2) = @_;
411 if($base1 eq 'cust_net_src' || $base1 eq 'cust_net_tgt'){
412 &dec_counter
($confignet,\
%customnetwork,$val1);
413 }elsif($base1 eq 'cust_host_src' || $base1 eq 'cust_host_tgt'){
414 &dec_counter
($confighost,\
%customhost,$val1);
415 }elsif($base1 eq 'cust_grp_src' || $base1 eq 'cust_grp_tgt'){
416 &dec_counter
($configgrp,\
%customgrp,$val1);
417 }elsif($base1 eq 'cust_srv'){
418 &dec_counter
($configsrv,\
%customservice,$val1);
419 }elsif($base1 eq 'cust_srvgrp'){
420 &dec_counter
($configsrvgrp,\
%customservicegrp,$val1);
423 if($base2 eq 'cust_net_src' || $base2 eq 'cust_net_tgt'){
424 &inc_counter
($confignet,\
%customnetwork,$val2);
425 }elsif($base2 eq 'cust_host_src' || $base2 eq 'cust_host_tgt'){
426 &inc_counter
($confighost,\
%customhost,$val2);
427 }elsif($base2 eq 'cust_grp_src' || $base2 eq 'cust_grp_tgt'){
428 &inc_counter
($configgrp,\
%customgrp,$val2);
429 }elsif($base2 eq 'cust_srv'){
430 &inc_counter
($configsrv,\
%customservice,$val2);
431 }elsif($base2 eq 'cust_srvgrp'){
432 &inc_counter
($configsrvgrp,\
%customservicegrp,$val2);
442 &General
::readhasharray
($config, \
%hash);
443 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
444 if($hash{$key}[0] eq $val){
445 $pos=$#{$hash{$key}};
446 $hash{$key}[$pos] = $hash{$key}[$pos]+1;
449 &General
::writehasharray
($config, \
%hash);
457 #$errormessage.="ALT:config: $config , verringert wird $val <br>";
458 &General
::readhasharray
($config, \
%hash);
459 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
460 if($hash{$key}[0] eq $val){
461 $pos=$#{$hash{$key}};
462 $hash{$key}[$pos] = $hash{$key}[$pos]-1;
465 &General
::writehasharray
($config, \
%hash);
469 if ($fwdfwsettings{'POLICY'} eq 'MODE0'){ $selected{'POLICY'}{'MODE0'} = 'selected'; } else { $selected{'POLICY'}{'MODE0'} = ''; }
470 if ($fwdfwsettings{'POLICY'} eq 'MODE1'){ $selected{'POLICY'}{'MODE1'} = 'selected'; } else { $selected{'POLICY'}{'MODE1'} = ''; }
471 if ($fwdfwsettings{'POLICY'} eq 'MODE2'){ $selected{'POLICY'}{'MODE2'} = 'selected'; } else { $selected{'POLICY'}{'MODE2'} = ''; }
474 if ($fwdfwsettings{'POLICY'} ne 'MODE0' && $fwdfwsettings{'POLICY'} ne '') {
478 #print"<table width='100' border='1'><tr>";
481 #print"<td bgcolor='$color{$i}'>$_</td>";
483 #print"</tr></table>";
484 &Header
::openbox
('100%', 'center', 'Policy');
486 <form method='post' action='$ENV{'SCRIPT_NAME'}'>
488 <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>
489 <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>
490 <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>
491 <tr><td colspan='3'><hr /></td></tr>
492 <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>
493 <td width='45%' align='left'><input type='submit' name='ACTION' value=$Lang::tr{'save'} />
494 <td width='45%' align='left'>
496 if ($fwdfwsettings{'POLICY'} ne 'MODE0'&& $fwdfwsettings{'POLICY'} ne '' ) {
497 print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' />";
499 print "</table></form>";
505 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
507 print "<form method='post'>";
508 print "<table border='0'>";
509 print "<tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw newrule'}'></td>";
510 if (-f
"${General::swroot}/forward/reread"){
511 print "<td><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'></td>";
513 print"</tr></table></form><hr>";
521 &General
::readhasharray
($fwdfwsettings{'config'}, \
%delhash);
522 foreach my $key (sort {$a <=> $b} keys %delhash){
523 if ($key == $fwdfwsettings{'key'}){
524 #check hosts/net and groups
525 &checkcounter
($delhash{$key}[3],$delhash{$key}[4],,);
526 &checkcounter
($delhash{$key}[5],$delhash{$key}[6],,);
527 #check services and groups
528 if ($delhash{$key}[11] eq 'ON'){
529 &checkcounter
($delhash{$key}[14],$delhash{$key}[15],,);
532 if ($key >= $fwdfwsettings{'key'}) {
534 if (exists $delhash{$next}) {
535 foreach my $i (0 .. $#{$delhash{$next}}) {
536 $delhash{$key}[$i] = $delhash{$next}[$i];
541 # Remove the very last entry.
542 my $last_key = (sort {$a <=> $b} keys %delhash)[-1];
543 delete $delhash{$last_key};
545 &General
::writehasharray
($fwdfwsettings{'config'}, \
%delhash);
548 if($fwdfwsettings{'nobase'} ne 'on'){
555 &General
::readhasharray
("$configfwdfw", \
%configfwdfw);
556 foreach my $key (sort keys %configfwdfw){
558 if ($configfwdfw{$key}[2] eq 'ON'){$configfwdfw{$key}[2]='';}
561 &General
::writehasharray
("$configfwdfw", \
%configfwdfw);
568 #check ip-address if manual
569 if ($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} ne ''){
570 #check if ip with subnet
571 if ($fwdfwsettings{'src_addr'} =~ /^(.*?)\/(.*?
)$/) {
572 ($ip,$subnet)=split (/\//,$fwdfwsettings{'src_addr'});
573 $subnet = &General
::iporsubtocidr
($subnet);
574 $fwdfwsettings{'isip'}='on';
577 if($fwdfwsettings{'src_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
578 $ip=$fwdfwsettings{'src_addr'};
580 $fwdfwsettings{'isip'}='on';
583 if ($fwdfwsettings{'isip'} ne 'on'){
584 if (&General
::validmac
($fwdfwsettings{'src_addr'})){$fwdfwsettings{'ismac'}='on';}
586 if ($fwdfwsettings{'isip'} eq 'on'){
587 #check and form valid IP
588 $ip=&General
::ip2dec
($ip);
589 $ip=&General
::dec2ip
($ip);
590 #check if net or broadcast
591 my @tmp= split (/\./,$ip);
592 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
594 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
596 $fwdfwsettings{'src_addr'}="$ip/$subnet";
598 if(!&General
::validipandmask
($fwdfwsettings{'src_addr'})){
599 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
602 if ($fwdfwsettings{'isip'} ne 'on' && $fwdfwsettings{'ismac'} ne 'on'){
603 $errormessage.=$Lang::tr
{'fwdfw err src_addr'}."<br>";
605 }elsif($fwdfwsettings{'src_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp1'}} && $fwdfwsettings{'src_addr'} eq ''){
606 $errormessage.=$Lang::tr
{'fwdfw err nosrcip'};
607 return $errormessage;
611 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err nosrc'}."<br>";}
613 if ($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ICMP'){
614 $fwdfwsettings{'SRC_PORT'}='';
615 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
616 foreach my $key (keys %icmptypes){
617 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0] ($icmptypes{$key}[1])"){
618 $fwdfwsettings{'ICMP_TYPES'}="$icmptypes{$key}[0]";
621 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'GRE'){
622 $fwdfwsettings{'SRC_PORT'}='';
623 $fwdfwsettings{'ICMP_TYPES'}='';
624 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} eq 'ESP'){
625 $fwdfwsettings{'SRC_PORT'}='';
626 $fwdfwsettings{'ICMP_TYPES'}='';
627 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
628 $fwdfwsettings{'ICMP_TYPES'}='';
630 $fwdfwsettings{'ICMP_TYPES'}='';
631 $fwdfwsettings{'SRC_PORT'}='';
632 $fwdfwsettings{'PROT'}='';
635 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
636 #change dashes with :
637 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
639 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
640 $fwdfwsettings{'SRC_PORT'} = "1:65535";
642 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
643 $fwdfwsettings{'SRC_PORT'} = "1:$2";
645 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
646 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
649 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
651 return $errormessage;
657 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
658 #check if ip with subnet
659 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
660 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
661 $subnet = &General
::iporsubtocidr
($subnet);
664 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
665 $ip=$fwdfwsettings{'tgt_addr'};
668 #check and form valid IP
669 $ip=&General
::ip2dec
($ip);
670 $ip=&General
::dec2ip
($ip);
672 #check if net or broadcast
673 my @tmp= split (/\./,$ip);
674 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
676 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
678 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
680 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
681 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
684 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
685 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
686 return $errormessage;
690 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
693 if ($fwdfwsettings{'USESRV'} eq 'ON'){
694 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
695 $fwdfwsettings{'TGT_PROT'}='';
696 $fwdfwsettings{'ICMP_TGT'}='';
698 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
699 $fwdfwsettings{'TGT_PROT'}='';
700 $fwdfwsettings{'ICMP_TGT'}='';
701 #check target service
702 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
703 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
706 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
707 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){
708 if ($fwdfwsettings{'TGT_PORT'} ne ''){
709 #change dashes with :
710 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
711 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
712 $fwdfwsettings{'TGT_PORT'} = "1:65535";
714 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
715 $fwdfwsettings{'TGT_PORT'} = "1:$2";
717 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
718 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
720 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
722 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
723 $fwdfwsettings{'TGT_PORT'} = '';
724 $fwdfwsettings{'ICMP_TGT'} = '';
725 }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){
726 $fwdfwsettings{'TGT_PORT'}='';
727 $fwdfwsettings{'ICMP_TGT'}='';
728 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
729 $fwdfwsettings{'TGT_PORT'} = '';
730 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
731 foreach my $key (keys %icmptypes){
733 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
734 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
742 if ($fwdfwsettings{'USESRV'} ne 'ON'){
743 $fwdfwsettings{'grp3'}='';
744 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
745 $fwdfwsettings{'TGT_PROT'}='';
746 $fwdfwsettings{'ICMP_TGT'}='';
749 if($fwdfwsettings{'TIME'} eq 'ON'){
750 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 ''){
751 $errormessage=$Lang::tr
{'fwdfw err time'};
754 return $errormessage;
759 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
760 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
762 #check if source and target identical
763 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
764 $errormessage.=$Lang::tr
{'fwdfw err same'};
765 return $errormessage;
768 #get source and targetip address if possible
769 my ($sip,$scidr,$tip,$tcidr);
770 ($sip,$scidr)=&get_ip
("src","grp1");
771 ($tip,$tcidr)=&get_ip
("tgt","grp2");
773 #check same iprange in source and target
774 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
775 my $networkip1=&General
::getnetworkip
($sip,$scidr);
776 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
777 if ($scidr gt $tcidr){
778 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
779 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
781 }elsif($scidr eq $tcidr && $scidr eq '32'){
782 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
783 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
784 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
785 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
786 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
789 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
790 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
795 #check source and destination protocol if manual
796 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
797 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
798 $errormessage.=$Lang::tr
{'fwdfw err prot'};
800 #check source and destination protocol if source manual and dest servicegrp
801 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
802 &General
::readhasharray
("$configsrv", \
%customservice);
803 foreach my $key (sort keys %customservice){
804 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
805 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
806 $errormessage.=$Lang::tr
{'fwdfw err prot'};
820 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
821 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
822 if ($fwdfwsettings{$grp} eq $val.'_addr'){
823 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
824 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
825 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
826 $a=$netsettings{'GREEN_NETADDRESS'};
827 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
828 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
829 $a=$netsettings{'ORANGE_NETADDRESS'};
830 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
831 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
832 $a=$netsettings{'BLUE_NETADDRESS'};
833 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
834 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
835 &General
::readhash
("$configovpn",\
%ovpnsettings);
836 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
837 $b=&General
::iporsubtocidr
($b);
839 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
840 &General
::readhasharray
("$confignet", \
%customnetwork);
841 foreach my $key (keys %customnetwork){
842 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
843 $a=$customnetwork{$key}[1];
844 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
847 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
848 &General
::readhasharray
("$confighost", \
%customhost);
849 foreach my $key (keys %customhost){
850 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
851 if ($customhost{$key}[1] eq 'ip'){
852 ($a,$b)=split (/\//,$customhost{$key}[2]);
853 $b=&General
::iporsubtocidr
($b);
856 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
868 &General
::setup_default_networks
(\
%defaultNetworks);
869 #read all configfiles
870 &General
::readhasharray
("$configccdnet", \
%ccdnet);
871 &General
::readhasharray
("$confignet", \
%customnetwork);
872 &General
::readhasharray
("$configccdhost", \
%ccdhost);
873 &General
::readhasharray
("$confighost", \
%customhost);
874 &General
::readhasharray
("$configccdhost", \
%ccdhost);
875 &General
::readhasharray
("$configgrp", \
%customgrp);
876 &General
::readhasharray
("$configipsec", \
%ipsecconf);
877 &General
::get_aliases
(\
%aliases);
881 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
882 my $config=$fwdfwsettings{'config'};
884 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
885 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
886 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
887 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
888 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
889 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
890 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
891 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
892 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
893 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
894 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
895 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
896 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
897 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
898 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
899 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
900 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
901 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
902 #check if update and get values
903 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
904 &General
::readhasharray
("$config", \
%hash);
905 foreach my $key (sort keys %hash){
907 if ($key eq $fwdfwsettings{'key'}){
908 $fwdfwsettings{'oldrulenumber'} = $key;
909 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
910 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
911 $fwdfwsettings{'grp1'} = $hash{$key}[3];
912 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
913 $fwdfwsettings{'grp2'} = $hash{$key}[5];
914 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
915 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
916 $fwdfwsettings{'PROT'} = $hash{$key}[8];
917 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
918 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
919 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
920 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
921 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
922 $fwdfwsettings{'grp3'} = $hash{$key}[14];
923 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
924 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
925 $fwdfwsettings{'LOG'} = $hash{$key}[17];
926 $fwdfwsettings{'TIME'} = $hash{$key}[18];
927 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
928 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
929 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
930 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
931 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
932 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
933 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
934 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
935 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
936 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
937 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
938 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
939 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
940 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
941 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
942 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
943 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
944 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
945 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
946 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
947 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
948 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
949 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
950 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
951 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
952 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
953 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
956 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
957 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
958 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
959 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
960 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
961 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
962 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
963 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
965 $fwdfwsettings{'ACTIVE'}='ON';
966 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
969 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
974 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
976 foreach ("ACCEPT","DROP","REJECT")
978 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
979 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
982 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
984 print"<option selected>$_</option>";
986 print"<option>$_</option>";
989 print"</select></td></tr></table><hr>";
993 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
996 #------SOURCE-------------------------------------------------------
998 <table width='100%' border='0'>
999 <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>
1000 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1001 <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;'>
1003 foreach my $network (sort keys %defaultNetworks)
1005 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1006 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1007 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1008 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1009 print ">$network</option>";
1012 </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;'>
1014 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1017 <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;'>
1019 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1021 </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;'>
1023 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1025 if ($ccdhost{$key}[33] ne ''){
1027 print "<option value='$ccdhost{$key}[1]'";
1028 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1029 print ">$ccdhost{$key}[1]</option>";
1034 <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;'>
1036 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1038 </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;'>
1040 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1041 if($ccdhost{$key}[3] eq 'net'){
1043 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1044 print ">$ccdhost{$key}[1]</option>";
1050 <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;'>
1052 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1053 if($helper ne $customgrp{$key}[0]){
1055 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1056 print ">$customgrp{$key}[0]</option>";
1058 $helper=$customgrp{$key}[0];
1062 <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;'>
1064 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1065 if ($ipsecconf{$key}[3] eq 'net'){
1067 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1068 print ">$ipsecconf{$key}[1]</option>";
1076 # <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;'>
1078 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1079 # if ($ipsecconf{$key}[3] eq 'host'){
1081 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1082 # print ">$ipsecconf{$key}[1]</option>";
1086 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1087 <table width='100%' border='0'>
1088 <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>
1089 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1091 foreach ("TCP","UDP","GRE","ESP","ICMP")
1093 if ($_ eq $fwdfwsettings{'PROT'})
1095 print"<option selected>$_</option>";
1097 print"<option>$_</option>";
1101 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1102 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1104 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1105 print"<option>All ICMP-Types</option>";
1106 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1107 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1108 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1110 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1114 </select></td></tr></table><hr>
1116 &Header
::closebox
();
1118 #---TARGET------------------------------------------------------
1119 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1121 <table width='100%' border='0'>
1122 <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;'>
1124 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1126 foreach my $alias (sort keys %aliases)
1128 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1133 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1134 <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;'>
1136 foreach my $network (sort keys %defaultNetworks)
1138 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1139 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1140 print ">$network</option>";
1143 </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;'>
1145 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1148 <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;'>
1150 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1152 </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;'>
1154 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1156 if ($ccdhost{$key}[33] ne ''){
1157 print "<option value='$ccdhost{$key}[1]' ";
1158 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1159 print ">$ccdhost{$key}[1]</option>";
1164 <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;'>
1166 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1168 </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;'>
1170 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1171 if($ccdhost{$key}[3] eq 'net'){
1173 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1174 print ">$ccdhost{$key}[1]</option>";
1179 <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;'>
1182 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1183 if($helper ne $customgrp{$key}[0]){
1185 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1186 print">$customgrp{$key}[0]</option>";
1188 $helper=$customgrp{$key}[0];
1192 <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;'>
1194 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1195 if ($ipsecconf{$key}[3] eq 'net'){
1197 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1198 print">$ipsecconf{$key}[1]</option>";
1204 # <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;'>
1206 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1207 # if ($ipsecconf{$key}[3] eq 'host'){
1209 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1210 # print">$ipsecconf{$key}[1]</option>";
1215 <b>$Lang::tr{'fwhost attention'}:</b><br>
1216 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1218 <table width='100%' border='0'>
1219 <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;' >
1221 &General
::readhasharray
("$configsrv", \
%customservice);
1222 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1224 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1225 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1229 <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;' >
1231 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1233 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1234 if ($helper ne $customservicegrp{$key}[0]){
1236 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1237 print">$customservicegrp{$key}[0]</option>";
1239 $helper=$customservicegrp{$key}[0];
1243 <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'>
1245 foreach ("TCP","UDP","GRE","ESP","ICMP")
1247 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1249 print"<option selected>$_</option>";
1251 print"<option>$_</option>";
1255 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1256 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1258 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1259 print"<option>All ICMP-Types</option>";
1260 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1261 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1262 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1264 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1269 </table><hr><br><br>
1272 #---Activate/logging/remark-------------------------------------
1273 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1275 <table width='100%' border='0'>
1276 <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>
1278 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1279 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1280 for (my $count =1; $count <= $sum; $count++){
1281 print"<option value='$count' ";
1282 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1283 print">$count</option>";
1285 print"</select></td></tr>";
1289 </table><table width='100%'>
1290 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1291 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1294 &Header
::closebox
();
1295 #---ADD TIMEFRAME-----------------------------------------------
1296 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1298 <table width='70%' border='0'>
1299 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1300 <tr><td colspan='7'> </td></tr>
1302 <td align='left'>$Lang::tr{'time'}:</td>
1303 <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>
1304 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1305 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1308 <td align='right'></td>
1309 <td width='30%' align='left'>
1310 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1311 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1312 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1313 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1314 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1315 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1316 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1318 <td><select name='TIME_FROM'>
1320 for (my $i=0;$i<=23;$i++) {
1321 $i = sprintf("%02s",$i);
1322 for (my $j=0;$j<=45;$j+=15) {
1323 $j = sprintf("%02s",$j);
1324 my $time = $i.":".$j;
1325 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1330 <td><select name='TIME_TO'>
1332 for (my $i=0;$i<=23;$i++) {
1333 $i = sprintf("%02s",$i);
1334 for (my $j=0;$j<=45;$j+=15) {
1335 $j = sprintf("%02s",$j);
1336 my $time = $i.":".$j;
1337 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1344 &Header
::closebox
();
1345 #---ACTION------------------------------------------------------
1346 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1348 <table border='0' width='100%'>
1349 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1350 <input type='hidden' name='config' value='$config' >
1351 <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>
1356 <table border='0' width='100%'>
1357 <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'}'>
1358 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1359 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1360 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1361 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1362 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1363 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1364 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1365 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1366 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1367 <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>
1371 &Header
::closebox
();
1377 &General
::readhasharray
("$config", $hash);
1378 if (!$errormessage){
1379 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1380 my $key = &General
::findhasharraykey
($hash);
1381 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1382 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1383 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1384 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1385 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1386 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1387 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1388 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1389 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1390 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1391 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1392 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1393 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1394 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1395 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1396 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1397 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1398 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1399 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1400 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1401 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1402 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1403 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1404 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1405 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1406 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1407 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1408 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1409 &General
::writehasharray
("$config", $hash);
1412 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1414 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1415 for (my $z=0;$z<$val;$z++){
1416 foreach my $key (sort {$a <=> $b} keys %$hash){
1417 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1419 if (exists $$hash{$last}){
1421 foreach my $y (0 .. $#{$$hash{$last}}) {
1422 $tmp{0}[$y] = $$hash{$last}[$y];
1424 #copy active rule to last
1425 foreach my $i (0 .. $#{$$hash{$last}}) {
1426 $$hash{$last}[$i] = $$hash{$key}[$i];
1428 #copy saved rule to actual position
1429 foreach my $x (0 .. $#{$tmp{0}}) {
1430 $$hash{$key}[$x] = $tmp{0}[$x];
1435 $fwdfwsettings{'oldrulenumber'}--;
1437 &General
::writehasharray
("$config", $hash);
1439 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1441 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1442 for (my $z=0;$z<$val;$z++){
1443 foreach my $key (sort {$a <=> $b} keys %$hash){
1444 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1445 my $next = $key + 1;
1446 if (exists $$hash{$next}){
1448 foreach my $y (0 .. $#{$$hash{$next}}) {
1449 $tmp{0}[$y] = $$hash{$next}[$y];
1451 #copy active rule to next
1452 foreach my $i (0 .. $#{$$hash{$next}}) {
1453 $$hash{$next}[$i] = $$hash{$key}[$i];
1455 #copy saved rule to actual position
1456 foreach my $x (0 .. $#{$tmp{0}}) {
1457 $$hash{$key}[$x] = $tmp{0}[$x];
1462 $fwdfwsettings{'oldrulenumber'}++;
1464 &General
::writehasharray
("$config", $hash);
1467 foreach my $key (sort {$a <=> $b} keys %$hash){
1468 if($key eq $fwdfwsettings{'key'}){
1469 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1470 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1471 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1472 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1473 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1474 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1475 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1476 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1477 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1478 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1479 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1480 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1481 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1482 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1483 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1484 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1485 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1486 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1487 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1488 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1489 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1490 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1491 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1492 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1493 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1494 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1495 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1496 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1501 &General
::writehasharray
("$config", $hash);
1507 if ($errormessage) {
1508 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1509 print "<class name='base'>$errormessage\n";
1510 print " </class>\n";
1511 &Header
::closebox
();
1518 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1519 print "<class name='base'>$hint\n";
1520 print " </class>\n";
1521 &Header
::closebox
();
1528 &General
::setup_default_networks
(\
%defaultNetworks);
1529 foreach my $network (sort keys %defaultNetworks)
1531 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1536 # Checks a hostname against RFC1035
1539 # Each part should be at least two characters in length
1540 # but no more than 63 characters
1541 if (length ($remark) < 1 || length ($remark) > 255) {
1543 # Only valid characters are a-z, A-Z, 0-9 and -
1544 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1546 # First character can only be a letter or a digit
1547 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1549 # Last character can only be a letter or a digit
1550 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1556 my %hash=%{(shift)};
1558 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1559 print" : ($hash{$key}[8]) $hash{$key}[10]";
1560 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1561 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1566 my %hash=%{(shift)};
1571 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1572 if($hash{$key}[14] eq 'cust_srv'){
1573 &General
::readhasharray
("$configsrv", \
%customservice);
1574 foreach my $i (sort keys %customservice){
1575 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1576 if($customservice{$i}[0] eq $hash{$key}[15]){
1577 $prot = $hash{$key}[12];
1578 $service = $customservice{$i}[0];
1581 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1583 $service=$hash{$key}[15];
1584 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1585 $service=$hash{$key}[15];
1586 $prot=$hash{$key}[12];
1588 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1589 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1592 if ($prot ne '' || $service ne ''){
1602 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1603 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1612 if ( ! -z
"$config"){
1613 &Header
::openbox
('100%', 'left',$title);
1621 &General
::readhasharray
("$config", $hash);
1622 print"<b>$title1</b><br>";
1623 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1624 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>";
1625 foreach my $key (sort {$a <=> $b} keys %$hash){
1627 #check if vpn hosts/nets have been deleted
1628 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1629 push (@tmpsrc,$$hash{$key}[4]);
1631 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1632 push (@tmpsrc,$$hash{$key}[6]);
1634 foreach my $host (@tmpsrc){
1635 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1636 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1638 &disable_rule
($key);
1641 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1642 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1644 &disable_rule
($key);
1647 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1648 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1650 &disable_rule
($key);
1653 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1654 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1656 &disable_rule
($key);
1663 $$hash{'ACTIVE'}=$$hash{$key}[2];
1665 if($coloryellow eq 'on'){
1666 print"<tr bgcolor='$color{'color14'}' >";
1668 }elsif($coloryellow eq ''){
1670 print"<tr bgcolor='$color{'color22'}' >";
1673 print"<tr bgcolor='$color{'color20'}' >";
1677 <td align='right'>$key</td>
1679 if ($$hash{$key}[0] eq 'ACCEPT'){
1682 $rulecolor=$color{'color17'};
1683 }elsif($$hash{$key}[0] eq 'DROP'){
1686 $rulecolor=$color{'color25'};
1687 }elsif($$hash{$key}[0] eq 'REJECT'){
1690 $rulecolor=$color{'color16'};
1692 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1693 print"<td align='center'>";
1694 if ($$hash{$key}[3] eq 'std_net_src'){
1695 print &get_name
($$hash{$key}[4]);
1697 print $$hash{$key}[4];
1699 &getsrcport
(\
%$hash,$key);
1700 if ($$hash{$key}[17] eq 'ON'){
1701 $log="/images/on.gif";
1703 $log="/images/off.gif";
1707 <form method='post'>
1708 <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 ;'/>
1709 <input type='hidden' name='key' value='$key' />
1710 <input type='hidden' name='config' value='$config' />
1711 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1716 <td align='center' nowrap='nowrap'>
1718 if ($$hash{$key}[5] eq 'std_net_tgt'){
1719 print &get_name
($$hash{$key}[6]);
1721 print $$hash{$key}[6];
1723 &gettgtport
(\
%$hash,$key);
1724 ################################################################################
1725 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1727 if($$hash{$key}[2] eq 'ON'){
1728 $gif="/images/on.gif"
1731 $gif="/images/off.gif"
1734 <form method='post'>
1735 <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;' />
1736 <input type='hidden' name='key' value='$key' />
1737 <input type='hidden' name='config' value='$config' />
1738 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1740 <form method='post'>
1741 <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;' />
1742 <input type='hidden' name='key' value='$key' />
1743 <input type='hidden' name='config' value='$config' />
1744 <input type='hidden' name='ACTION' value='editrule' />
1746 <form method='post'>
1747 <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;' />
1748 <input type='hidden' name='key' value='$key' />
1749 <input type='hidden' name='config' value='$config' />
1750 <input type='hidden' name='ACTION' value='copyrule' />
1752 <form method='post'>
1753 <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;' />
1754 <input type='hidden' name='key' value='$key' />
1755 <input type='hidden' name='config' value='$config' />
1756 <input type='hidden' name='ACTION' value='deleterule' />
1759 if (exists $$hash{$key-1}){
1761 <form method='post'>
1762 <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;' />
1763 <input type='hidden' name='key' value='$key' />
1764 <input type='hidden' name='config' value='$config' />
1765 <input type='hidden' name='ACTION' value='moveup' />
1771 if (exists $$hash{$key+1}){
1773 <form method='post'>
1774 <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;' />
1775 <input type='hidden' name='key' value='$key' />
1776 <input type='hidden' name='config' value='$config' />
1777 <input type='hidden' name='ACTION' value='movedown' />
1778 </td></form></td></tr>
1781 print"<td></td></tr>";
1783 #if timeframe set, print new line in table
1784 if ($$hash{$key}[18] eq 'ON'){
1786 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1787 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1788 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1789 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1790 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1791 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1792 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1793 my $weekdays=join(",",@days);
1795 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1797 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1802 &Header
::closebox
();
1807 my %hash=%{(shift)};
1810 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1811 if($hash{$key}[0] eq $val){
1812 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1814 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1820 if (!-f
"${General::swroot}/forward/reread"){
1821 system("touch ${General::swroot}/forward/reread");
1826 system("/usr/local/bin/forwardfwctrl");
1827 system("rm ${General::swroot}/forward/reread");
1829 &Header
::closebigbox
();
1830 &Header
::closepage
();