]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/forwardfw.cgi
37ba41d0b2b4d390f146c28bba3ca2bbbacf3952
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'} eq 'AH'){
628 $fwdfwsettings{'SRC_PORT'}='';
629 $fwdfwsettings{'ICMP_TYPES'}='';
630 }elsif($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP'){
631 $fwdfwsettings{'ICMP_TYPES'}='';
633 $fwdfwsettings{'ICMP_TYPES'}='';
634 $fwdfwsettings{'SRC_PORT'}='';
635 $fwdfwsettings{'PROT'}='';
638 if($fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'PROT'} ne 'ICMP' && $fwdfwsettings{'SRC_PORT'} ne ''){
639 #change dashes with :
640 $fwdfwsettings{'SRC_PORT'}=~ tr/-/:/;
642 if ($fwdfwsettings{'SRC_PORT'} eq "*") {
643 $fwdfwsettings{'SRC_PORT'} = "1:65535";
645 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\D)\:(\d+)$/) {
646 $fwdfwsettings{'SRC_PORT'} = "1:$2";
648 if ($fwdfwsettings{'SRC_PORT'} =~ /^(\d+)\:(\D)$/) {
649 $fwdfwsettings{'SRC_PORT'} = "$1:65535";
652 $errormessage.=&General
::validportrange
($fwdfwsettings{'SRC_PORT'},'src');
654 return $errormessage;
660 if ($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} ne ''){
661 #check if ip with subnet
662 if ($fwdfwsettings{'tgt_addr'} =~ /^(.*?)\/(.*?
)$/) {
663 ($ip,$subnet)=split (/\//,$fwdfwsettings{'tgt_addr'});
664 $subnet = &General
::iporsubtocidr
($subnet);
667 if($fwdfwsettings{'tgt_addr'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
668 $ip=$fwdfwsettings{'tgt_addr'};
671 #check and form valid IP
672 $ip=&General
::ip2dec
($ip);
673 $ip=&General
::dec2ip
($ip);
675 #check if net or broadcast
676 my @tmp= split (/\./,$ip);
677 if (($tmp[3] eq "0") || ($tmp[3] eq "255"))
679 $errormessage=$Lang::tr
{'fwhost err hostip'}."<br>";
681 $fwdfwsettings{'tgt_addr'}="$ip/$subnet";
683 if(!&General
::validipandmask
($fwdfwsettings{'tgt_addr'})){
684 $errormessage.=$Lang::tr
{'fwdfw err tgt_addr'}."<br>";
687 }elsif($fwdfwsettings{'tgt_addr'} eq $fwdfwsettings{$fwdfwsettings{'grp2'}} && $fwdfwsettings{'tgt_addr'} eq ''){
688 $errormessage.=$Lang::tr
{'fwdfw err notgtip'};
689 return $errormessage;
693 if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq ''){ $errormessage.=$Lang::tr
{'fwdfw err notgt'}."<br>";}
696 if ($fwdfwsettings{'USESRV'} eq 'ON'){
697 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
698 $fwdfwsettings{'TGT_PROT'}='';
699 $fwdfwsettings{'ICMP_TGT'}='';
701 if ($fwdfwsettings{'grp3'} eq 'cust_srvgrp'){
702 $fwdfwsettings{'TGT_PROT'}='';
703 $fwdfwsettings{'ICMP_TGT'}='';
704 #check target service
705 if($fwdfwsettings{$fwdfwsettings{'grp3'}} eq ''){
706 $errormessage.=$Lang::tr
{'fwdfw err tgt_grp'};
709 if ($fwdfwsettings{'grp3'} eq 'TGT_PORT'){
710 if ($fwdfwsettings{'TGT_PROT'} ne 'ICMP' && $fwdfwsettings{'TGT_PROT'} ne 'GRE'){
711 if ($fwdfwsettings{'TGT_PORT'} ne ''){
712 #change dashes with :
713 $fwdfwsettings{'TGT_PORT'}=~ tr/-/:/;
714 if ($fwdfwsettings{'TGT_PORT'} eq "*") {
715 $fwdfwsettings{'TGT_PORT'} = "1:65535";
717 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\D)\:(\d+)$/) {
718 $fwdfwsettings{'TGT_PORT'} = "1:$2";
720 if ($fwdfwsettings{'TGT_PORT'} =~ /^(\d+)\:(\D)$/) {
721 $fwdfwsettings{'TGT_PORT'} = "$1:65535";
723 $errormessage .= &General
::validportrange
($fwdfwsettings{'TGT_PORT'}, 'destination');
725 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'GRE'){
726 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
727 $fwdfwsettings{'ICMP_TGT'} = '';
728 }elsif($fwdfwsettings{'TGT_PORT'} eq 'ESP'){
729 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
730 $fwdfwsettings{'ICMP_TGT'}='';
731 }elsif($fwdfwsettings{'TGT_PORT'} eq 'AH'){
732 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
733 $fwdfwsettings{'ICMP_TGT'}='';
734 }elsif ($fwdfwsettings{'TGT_PROT'} eq 'ICMP'){
735 $fwdfwsettings{$fwdfwsettings{'grp3'}} = '';
736 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
737 foreach my $key (keys %icmptypes){
739 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwdfwsettings{'ICMP_TGT'}){
740 $fwdfwsettings{'ICMP_TGT'}=$icmptypes{$key}[0];
748 if ($fwdfwsettings{'USESRV'} ne 'ON'){
749 $fwdfwsettings{'grp3'}='';
750 $fwdfwsettings{$fwdfwsettings{'grp3'}}='';
751 $fwdfwsettings{'TGT_PROT'}='';
752 $fwdfwsettings{'ICMP_TGT'}='';
755 if($fwdfwsettings{'TIME'} eq 'ON'){
756 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 ''){
757 $errormessage=$Lang::tr
{'fwdfw err time'};
760 return $errormessage;
765 if ($fwdfwsettings{'ruleremark'} ne '' && !&validremark
($fwdfwsettings{'ruleremark'})){
766 $errormessage.=$Lang::tr
{'fwdfw err remark'}."<br>";
768 #check if source and target identical
769 if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $fwdfwsettings{$fwdfwsettings{'grp2'}}){
770 $errormessage.=$Lang::tr
{'fwdfw err same'};
771 return $errormessage;
774 #get source and targetip address if possible
775 my ($sip,$scidr,$tip,$tcidr);
776 ($sip,$scidr)=&get_ip
("src","grp1");
777 ($tip,$tcidr)=&get_ip
("tgt","grp2");
779 #check same iprange in source and target
780 if ($sip ne '' && $scidr ne '' && $tip ne '' && $tcidr ne ''){
781 my $networkip1=&General
::getnetworkip
($sip,$scidr);
782 my $networkip2=&General
::getnetworkip
($tip,$tcidr);
783 if ($scidr gt $tcidr){
784 if ( &General
::IpInSubnet
($networkip1,$tip,&General
::iporsubtodec
($tcidr)) ){
785 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
787 }elsif($scidr eq $tcidr && $scidr eq '32'){
788 my ($sbyte1,$sbyte2,$sbyte3,$sbyte4)=split(/\./,$networkip1);
789 my ($tbyte1,$tbyte2,$tbyte3,$tbyte4)=split(/\./,$networkip2);
790 if ($sbyte1 eq $tbyte1 && $sbyte2 eq $tbyte2 && $sbyte3 eq $tbyte3){
791 $hint=$Lang::tr
{'fwdfw hint ip1'}."<br>";
792 $hint.=$Lang::tr
{'fwdfw hint ip2'}." Source: $networkip1/$scidr Target: $networkip2/$tcidr<br>";
795 if ( &General
::IpInSubnet
($networkip2,$sip,&General
::iporsubtodec
($scidr)) ){
796 $errormessage.=$Lang::tr
{'fwdfw err samesub'};
801 #check source and destination protocol if manual
802 if( $fwdfwsettings{'USE_SRC_PORT'} eq 'ON' && $fwdfwsettings{'USESRV'} eq 'ON'){
803 if($fwdfwsettings{'PROT'} ne $fwdfwsettings{'TGT_PROT'} && $fwdfwsettings{'grp3'} eq 'TGT_PORT'){
804 $errormessage.=$Lang::tr
{'fwdfw err prot'};
806 #check source and destination protocol if source manual and dest servicegrp
807 if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
808 &General
::readhasharray
("$configsrv", \
%customservice);
809 foreach my $key (sort keys %customservice){
810 if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
811 if ($customservice{$key}[2] ne $fwdfwsettings{'PROT'}){
812 $errormessage.=$Lang::tr
{'fwdfw err prot'};
826 &General
::readhash
("/var/ipfire/ethernet/settings", \
%netsettings);
827 if ($fwdfwsettings{$grp} ne $Lang::tr
{'fwhost any'}){
828 if ($fwdfwsettings{$grp} eq $val.'_addr'){
829 ($a,$b) = split (/\//, $fwdfwsettings{$fwdfwsettings{$grp}});
830 }elsif($fwdfwsettings{$grp} eq 'std_net_'.$val){
831 if ($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Gr/i){
832 $a=$netsettings{'GREEN_NETADDRESS'};
833 $b=&General
::iporsubtocidr
($netsettings{'GREEN_NETMASK'});
834 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Ora/i){
835 $a=$netsettings{'ORANGE_NETADDRESS'};
836 $b=&General
::iporsubtocidr
($netsettings{'ORANGE_NETMASK'});
837 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /Bl/i){
838 $a=$netsettings{'BLUE_NETADDRESS'};
839 $b=&General
::iporsubtocidr
($netsettings{'BLUE_NETMASK'});
840 }elsif($fwdfwsettings{$fwdfwsettings{$grp}} =~ /OpenVPN/i){
841 &General
::readhash
("$configovpn",\
%ovpnsettings);
842 ($a,$b) = split (/\//, $ovpnsettings{'DOVPN_SUBNET'});
843 $b=&General
::iporsubtocidr
($b);
845 }elsif($fwdfwsettings{$grp} eq 'cust_net_'.$val){
846 &General
::readhasharray
("$confignet", \
%customnetwork);
847 foreach my $key (keys %customnetwork){
848 if($customnetwork{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
849 $a=$customnetwork{$key}[1];
850 $b=&General
::iporsubtocidr
($customnetwork{$key}[2]);
853 }elsif($fwdfwsettings{$grp} eq 'cust_host_'.$val){
854 &General
::readhasharray
("$confighost", \
%customhost);
855 foreach my $key (keys %customhost){
856 if($customhost{$key}[0] eq $fwdfwsettings{$fwdfwsettings{$grp}}){
857 if ($customhost{$key}[1] eq 'ip'){
858 ($a,$b)=split (/\//,$customhost{$key}[2]);
859 $b=&General
::iporsubtocidr
($b);
862 $errormessage=$Lang::tr
{'fwdfw err tgt_mac'};
874 &General
::setup_default_networks
(\
%defaultNetworks);
875 #read all configfiles
876 &General
::readhasharray
("$configccdnet", \
%ccdnet);
877 &General
::readhasharray
("$confignet", \
%customnetwork);
878 &General
::readhasharray
("$configccdhost", \
%ccdhost);
879 &General
::readhasharray
("$confighost", \
%customhost);
880 &General
::readhasharray
("$configccdhost", \
%ccdhost);
881 &General
::readhasharray
("$configgrp", \
%customgrp);
882 &General
::readhasharray
("$configipsec", \
%ipsecconf);
883 &General
::get_aliases
(\
%aliases);
887 if($fwdfwsettings{'config'} eq ''){$fwdfwsettings{'config'}=$configfwdfw;}
888 my $config=$fwdfwsettings{'config'};
890 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
891 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
892 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
893 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
894 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
895 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
896 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
897 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
898 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
899 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
900 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
901 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
902 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
903 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
904 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
905 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
906 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
907 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
908 #check if update and get values
909 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on' && !$errormessage){
910 &General
::readhasharray
("$config", \
%hash);
911 foreach my $key (sort keys %hash){
913 if ($key eq $fwdfwsettings{'key'}){
914 $fwdfwsettings{'oldrulenumber'} = $key;
915 $fwdfwsettings{'RULE_ACTION'} = $hash{$key}[0];
916 $fwdfwsettings{'ACTIVE'} = $hash{$key}[2];
917 $fwdfwsettings{'grp1'} = $hash{$key}[3];
918 $fwdfwsettings{$fwdfwsettings{'grp1'}} = $hash{$key}[4];
919 $fwdfwsettings{'grp2'} = $hash{$key}[5];
920 $fwdfwsettings{$fwdfwsettings{'grp2'}} = $hash{$key}[6];
921 $fwdfwsettings{'USE_SRC_PORT'} = $hash{$key}[7];
922 $fwdfwsettings{'PROT'} = $hash{$key}[8];
923 $fwdfwsettings{'ICMP_TYPES'} = $hash{$key}[9];
924 $fwdfwsettings{'SRC_PORT'} = $hash{$key}[10];
925 $fwdfwsettings{'USESRV'} = $hash{$key}[11];
926 $fwdfwsettings{'TGT_PROT'} = $hash{$key}[12];
927 $fwdfwsettings{'ICMP_TGT'} = $hash{$key}[13];
928 $fwdfwsettings{'grp3'} = $hash{$key}[14];
929 $fwdfwsettings{$fwdfwsettings{'grp3'}} = $hash{$key}[15];
930 $fwdfwsettings{'ruleremark'} = $hash{$key}[16];
931 $fwdfwsettings{'LOG'} = $hash{$key}[17];
932 $fwdfwsettings{'TIME'} = $hash{$key}[18];
933 $fwdfwsettings{'TIME_MON'} = $hash{$key}[19];
934 $fwdfwsettings{'TIME_TUE'} = $hash{$key}[20];
935 $fwdfwsettings{'TIME_WED'} = $hash{$key}[21];
936 $fwdfwsettings{'TIME_THU'} = $hash{$key}[22];
937 $fwdfwsettings{'TIME_FRI'} = $hash{$key}[23];
938 $fwdfwsettings{'TIME_SAT'} = $hash{$key}[24];
939 $fwdfwsettings{'TIME_SUN'} = $hash{$key}[25];
940 $fwdfwsettings{'TIME_FROM'} = $hash{$key}[26];
941 $fwdfwsettings{'TIME_TO'} = $hash{$key}[27];
942 $checked{'grp1'}{$fwdfwsettings{'grp1'}} = 'CHECKED';
943 $checked{'grp2'}{$fwdfwsettings{'grp2'}} = 'CHECKED';
944 $checked{'grp3'}{$fwdfwsettings{'grp3'}} = 'CHECKED';
945 $checked{'USE_SRC_PORT'}{$fwdfwsettings{'USE_SRC_PORT'}} = 'CHECKED';
946 $checked{'USESRV'}{$fwdfwsettings{'USESRV'}} = 'CHECKED';
947 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
948 $checked{'LOG'}{$fwdfwsettings{'LOG'}} = 'CHECKED';
949 $checked{'TIME'}{$fwdfwsettings{'TIME'}} = 'CHECKED';
950 $checked{'TIME_MON'}{$fwdfwsettings{'TIME_MON'}} = 'CHECKED';
951 $checked{'TIME_TUE'}{$fwdfwsettings{'TIME_TUE'}} = 'CHECKED';
952 $checked{'TIME_WED'}{$fwdfwsettings{'TIME_WED'}} = 'CHECKED';
953 $checked{'TIME_THU'}{$fwdfwsettings{'TIME_THU'}} = 'CHECKED';
954 $checked{'TIME_FRI'}{$fwdfwsettings{'TIME_FRI'}} = 'CHECKED';
955 $checked{'TIME_SAT'}{$fwdfwsettings{'TIME_SAT'}} = 'CHECKED';
956 $checked{'TIME_SUN'}{$fwdfwsettings{'TIME_SUN'}} = 'CHECKED';
957 $selected{'TIME_FROM'}{$fwdfwsettings{'TIME_FROM'}} = 'selected';
958 $selected{'TIME_TO'}{$fwdfwsettings{'TIME_TO'}} = 'selected';
959 $selected{'ipfire'}{$fwdfwsettings{$fwdfwsettings{'grp2'}}} ='selected';
962 $fwdfwsettings{'oldgrp1a'}=$fwdfwsettings{'grp1'};
963 $fwdfwsettings{'oldgrp1b'}=$fwdfwsettings{$fwdfwsettings{'grp1'}};
964 $fwdfwsettings{'oldgrp2a'}=$fwdfwsettings{'grp2'};
965 $fwdfwsettings{'oldgrp2b'}=$fwdfwsettings{$fwdfwsettings{'grp2'}};
966 $fwdfwsettings{'oldgrp3a'}=$fwdfwsettings{'grp3'};
967 $fwdfwsettings{'oldgrp3b'}=$fwdfwsettings{$fwdfwsettings{'grp3'}};
968 $fwdfwsettings{'oldusesrv'}=$fwdfwsettings{'USESRV'};
969 $fwdfwsettings{'oldruleremark'}=$fwdfwsettings{'ruleremark'};
971 $fwdfwsettings{'ACTIVE'}='ON';
972 $checked{'ACTIVE'}{$fwdfwsettings{'ACTIVE'}} = 'CHECKED';
975 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw addrule'});
980 <tr><td nowrap>$Lang::tr{'fwdfw rule action'}</td><td><select name='RULE_ACTION'>
982 foreach ("ACCEPT","DROP","REJECT")
984 if($fwdfwsettings{'POLICY'} eq 'MODE2'){
985 $fwdfwsettings{'RULE_ACTION'} = 'DROP';
988 if ($_ eq $fwdfwsettings{'RULE_ACTION'})
990 print"<option selected>$_</option>";
992 print"<option>$_</option>";
995 print"</select></td></tr></table><hr>";
999 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw source'});
1002 #------SOURCE-------------------------------------------------------
1004 <table width='100%' border='0'>
1005 <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>
1006 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1007 <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;'>
1009 foreach my $network (sort keys %defaultNetworks)
1011 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1012 next if($defaultNetworks{$network}{'NAME'} eq "RED");
1013 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1014 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $defaultNetworks{$network}{'NAME'});
1015 print ">$network</option>";
1018 </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;'>
1020 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1023 <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;'>
1025 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1027 </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;'>
1029 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1031 if ($ccdhost{$key}[33] ne ''){
1033 print "<option value='$ccdhost{$key}[1]'";
1034 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1035 print ">$ccdhost{$key}[1]</option>";
1040 <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;'>
1042 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp1'}});
1044 </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;'>
1046 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1047 if($ccdhost{$key}[3] eq 'net'){
1049 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ccdhost{$key}[1]);
1050 print ">$ccdhost{$key}[1]</option>";
1056 <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;'>
1058 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1059 if($helper ne $customgrp{$key}[0]){
1061 print "selected='selected' " if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $customgrp{$key}[0]);
1062 print ">$customgrp{$key}[0]</option>";
1064 $helper=$customgrp{$key}[0];
1068 <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;'>
1070 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1071 if ($ipsecconf{$key}[3] eq 'net'){
1073 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1074 print ">$ipsecconf{$key}[1]</option>";
1082 # <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;'>
1084 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1085 # if ($ipsecconf{$key}[3] eq 'host'){
1087 # print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp1'}} eq $ipsecconf{$key}[1]);
1088 # print ">$ipsecconf{$key}[1]</option>";
1092 <tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr></table>
1093 <table width='100%' border='0'>
1094 <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>
1095 <td width='15%' nowrap='nowrap'>$Lang::tr{'fwdfw man port'}</td><td><select name='PROT'>
1097 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1099 if ($_ eq $fwdfwsettings{'PROT'})
1101 print"<option selected>$_</option>";
1103 print"<option>$_</option>";
1107 </select></td><td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='11' size='9' ></td></tr>
1108 <tr><td></td><td></td><td></td><td></td><td nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES'>
1110 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1111 print"<option>All ICMP-Types</option>";
1112 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) } keys %icmptypes){
1113 if($fwdfwsettings{'ICMP_TYPES'} eq "$icmptypes{$key}[0]"){
1114 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1116 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1120 </select></td></tr></table><hr>
1122 &Header
::closebox
();
1124 #---TARGET------------------------------------------------------
1125 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw target'});
1127 <table width='100%' border='0'>
1128 <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;'>
1130 print "<option value='Default IP' $selected{'ipfire'}{'Default IP'}>Default IP</option>";
1132 foreach my $alias (sort keys %aliases)
1134 print "<option value='$alias' $selected{'ipfire'}{$alias}>$alias</option>";
1139 <tr><td colspan='7'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></tr>
1140 <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;'>
1142 foreach my $network (sort keys %defaultNetworks)
1144 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1145 print " selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $defaultNetworks{$network}{'NAME'});
1146 print ">$network</option>";
1149 </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;'>
1151 &fillselect
(\
%ccdnet,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1154 <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;'>
1156 &fillselect
(\
%customnetwork,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1158 </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;'>
1160 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost)
1162 if ($ccdhost{$key}[33] ne ''){
1163 print "<option value='$ccdhost{$key}[1]' ";
1164 print "selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[33]);
1165 print ">$ccdhost{$key}[1]</option>";
1170 <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;'>
1172 &fillselect
(\
%customhost,$fwdfwsettings{$fwdfwsettings{'grp2'}});
1174 </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;'>
1176 foreach my $key (sort { uc($ccdhost{$a}[0]) cmp uc($ccdhost{$b}[0]) } keys %ccdhost) {
1177 if($ccdhost{$key}[3] eq 'net'){
1179 print "selected='selected'" if($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ccdhost{$key}[1]);
1180 print ">$ccdhost{$key}[1]</option>";
1185 <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;'>
1188 foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } keys %customgrp) {
1189 if($helper ne $customgrp{$key}[0]){
1191 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $customgrp{$key}[0]);
1192 print">$customgrp{$key}[0]</option>";
1194 $helper=$customgrp{$key}[0];
1198 <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;'>
1200 foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1201 if ($ipsecconf{$key}[3] eq 'net'){
1203 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1204 print">$ipsecconf{$key}[1]</option>";
1210 # <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;'>
1212 # foreach my $key (sort { uc($ipsecconf{$a}[1]) cmp uc($ipsecconf{$b}[1]) } keys %ipsecconf) {
1213 # if ($ipsecconf{$key}[3] eq 'host'){
1215 # print"selected='Selected'" if ($fwdfwsettings{$fwdfwsettings{'grp2'}} eq $ipsecconf{$key}[1]);
1216 # print">$ipsecconf{$key}[1]</option>";
1221 <b>$Lang::tr{'fwhost attention'}:</b><br>
1222 $Lang::tr{'fwhost macwarn'}<br><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '></hr><br>
1224 <table width='100%' border='0'>
1225 <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;' >
1227 &General
::readhasharray
("$configsrv", \
%customservice);
1228 foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice){
1230 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservice{$key}[0]);
1231 print"value='$customservice{$key}[0]'>$customservice{$key}[0]</option>";
1235 <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;' >
1237 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1239 foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) } keys %customservicegrp){
1240 if ($helper ne $customservicegrp{$key}[0]){
1242 print"selected='selected'" if ($fwdfwsettings{$fwdfwsettings{'grp3'}} eq $customservicegrp{$key}[0]);
1243 print">$customservicegrp{$key}[0]</option>";
1245 $helper=$customservicegrp{$key}[0];
1249 <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'>
1251 foreach ("TCP","UDP","GRE","ESP","AH","ICMP")
1253 if ($_ eq $fwdfwsettings{'TGT_PROT'})
1255 print"<option selected>$_</option>";
1257 print"<option>$_</option>";
1261 </select></td><td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='11' size='9' ></td></tr>
1262 <tr><td colspan='2'></td><td></td><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TGT'>
1264 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1265 print"<option>All ICMP-Types</option>";
1266 foreach my $key (sort { uc($icmptypes{$a}[0]) cmp uc($icmptypes{$b}[0]) }keys %icmptypes){
1267 if($fwdfwsettings{'ICMP_TGT'} eq "$icmptypes{$key}[0]"){
1268 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1270 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1275 </table><hr><br><br>
1278 #---Activate/logging/remark-------------------------------------
1279 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw additional'});
1281 <table width='100%' border='0'>
1282 <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>
1284 if($fwdfwsettings{'updatefwrule'} eq 'on' || $fwdfwsettings{'copyfwrule'} eq 'on'){
1285 print "<tr><td width='12%'>$Lang::tr{'fwdfw rulepos'}:</td><td><select name='rulepos' >";
1286 for (my $count =1; $count <= $sum; $count++){
1287 print"<option value='$count' ";
1288 print"selected='selected'" if($fwdfwsettings{'oldrulenumber'} eq $count);
1289 print">$count</option>";
1291 print"</select></td></tr>";
1295 </table><table width='100%'>
1296 <tr><td width='1%'><input type='checkbox' name='ACTIVE' value='ON' $checked{'ACTIVE'}{'ON'}></td><td>$Lang::tr{'fwdfw rule activate'}</td></tr>
1297 <tr><td width='1%'><input type='checkbox' name='LOG' value='ON' $checked{'LOG'}{'ON'} ></td><td>$Lang::tr{'fwdfw log rule'}</td></tr>
1300 &Header
::closebox
();
1301 #---ADD TIMEFRAME-----------------------------------------------
1302 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwdfw timeframe'});
1304 <table width='70%' border='0'>
1305 <tr><td width='1%'><input type='checkbox' name='TIME' value='ON' $checked{'TIME'}{'ON'}></td><td colspan='4'>$Lang::tr{'fwdfw timeframe'}</td></tr>
1306 <tr><td colspan='7'> </td></tr>
1308 <td align='left'>$Lang::tr{'time'}:</td>
1309 <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>
1310 <td width='15%' align='left'>$Lang::tr{'advproxy from'}</td>
1311 <td width='15%' align='left'>$Lang::tr{'advproxy to'}</td>
1314 <td align='right'></td>
1315 <td width='30%' align='left'>
1316 <input type='checkbox' name='TIME_MON' value='on' $checked{'TIME_MON'}{'on'} />
1317 <input type='checkbox' name='TIME_TUE' value='on' $checked{'TIME_TUE'}{'on'} />
1318 <input type='checkbox' name='TIME_WED' value='on' $checked{'TIME_WED'}{'on'} />
1319 <input type='checkbox' name='TIME_THU' value='on' $checked{'TIME_THU'}{'on'} />
1320 <input type='checkbox' name='TIME_FRI' value='on' $checked{'TIME_FRI'}{'on'} />
1321 <input type='checkbox' name='TIME_SAT' value='on' $checked{'TIME_SAT'}{'on'} />
1322 <input type='checkbox' name='TIME_SUN' value='on' $checked{'TIME_SUN'}{$Lang::tr{'fwdfw wd_sun'}} />
1324 <td><select name='TIME_FROM'>
1326 for (my $i=0;$i<=23;$i++) {
1327 $i = sprintf("%02s",$i);
1328 for (my $j=0;$j<=45;$j+=15) {
1329 $j = sprintf("%02s",$j);
1330 my $time = $i.":".$j;
1331 print "\t\t\t\t\t<option $selected{'TIME_FROM'}{$time}>$i:$j</option>\n";
1336 <td><select name='TIME_TO'>
1338 for (my $i=0;$i<=23;$i++) {
1339 $i = sprintf("%02s",$i);
1340 for (my $j=0;$j<=45;$j+=15) {
1341 $j = sprintf("%02s",$j);
1342 my $time = $i.":".$j;
1343 print "\t\t\t\t\t<option $selected{'TIME_TO'}{$time}>$i:$j</option>\n";
1350 &Header
::closebox
();
1351 #---ACTION------------------------------------------------------
1352 if($fwdfwsettings{'updatefwrule'} ne 'on'){
1354 <table border='0' width='100%'>
1355 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' />
1356 <input type='hidden' name='config' value='$config' >
1357 <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>
1362 <table border='0' width='100%'>
1363 <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'}'>
1364 <input type='hidden' name='oldgrp1a' value='$fwdfwsettings{'oldgrp1a'}' />
1365 <input type='hidden' name='oldgrp1b' value='$fwdfwsettings{'oldgrp1b'}' />
1366 <input type='hidden' name='oldgrp2a' value='$fwdfwsettings{'oldgrp2a'}' />
1367 <input type='hidden' name='oldgrp2b' value='$fwdfwsettings{'oldgrp2b'}' />
1368 <input type='hidden' name='oldgrp3a' value='$fwdfwsettings{'oldgrp3a'}' />
1369 <input type='hidden' name='oldgrp3b' value='$fwdfwsettings{'oldgrp3b'}' />
1370 <input type='hidden' name='oldusesrv' value='$fwdfwsettings{'oldusesrv'}' />
1371 <input type='hidden' name='oldrulenumber' value='$fwdfwsettings{'oldrulenumber'}' />
1372 <input type='hidden' name='rulenumber' value='$fwdfwsettings{'rulepos'}' />
1373 <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>
1377 &Header
::closebox
();
1383 &General
::readhasharray
("$config", $hash);
1384 if (!$errormessage){
1385 if ($fwdfwsettings{'updatefwrule'} ne 'on'){
1386 my $key = &General
::findhasharraykey
($hash);
1387 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1388 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1389 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1390 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1391 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1392 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1393 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1394 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1395 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1396 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1397 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1398 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1399 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1400 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1401 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1402 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1403 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1404 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1405 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1406 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1407 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1408 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1409 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1410 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1411 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1412 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1413 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1414 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1415 &General
::writehasharray
("$config", $hash);
1417 foreach my $key (sort {$a <=> $b} keys %$hash){
1418 if($key eq $fwdfwsettings{'key'}){
1419 $$hash{$key}[0] = $fwdfwsettings{'RULE_ACTION'};
1420 $$hash{$key}[1] = $fwdfwsettings{'chain'};
1421 $$hash{$key}[2] = $fwdfwsettings{'ACTIVE'};
1422 $$hash{$key}[3] = $fwdfwsettings{'grp1'};
1423 $$hash{$key}[4] = $fwdfwsettings{$fwdfwsettings{'grp1'}};
1424 $$hash{$key}[5] = $fwdfwsettings{'grp2'};
1425 $$hash{$key}[6] = $fwdfwsettings{$fwdfwsettings{'grp2'}};
1426 $$hash{$key}[7] = $fwdfwsettings{'USE_SRC_PORT'};
1427 $$hash{$key}[8] = $fwdfwsettings{'PROT'};
1428 $$hash{$key}[9] = $fwdfwsettings{'ICMP_TYPES'};
1429 $$hash{$key}[10] = $fwdfwsettings{'SRC_PORT'};
1430 $$hash{$key}[11] = $fwdfwsettings{'USESRV'};
1431 $$hash{$key}[12] = $fwdfwsettings{'TGT_PROT'};
1432 $$hash{$key}[13] = $fwdfwsettings{'ICMP_TGT'};
1433 $$hash{$key}[14] = $fwdfwsettings{'grp3'};
1434 $$hash{$key}[15] = $fwdfwsettings{$fwdfwsettings{'grp3'}};
1435 $$hash{$key}[16] = $fwdfwsettings{'ruleremark'};
1436 $$hash{$key}[17] = $fwdfwsettings{'LOG'};
1437 $$hash{$key}[18] = $fwdfwsettings{'TIME'};
1438 $$hash{$key}[19] = $fwdfwsettings{'TIME_MON'};
1439 $$hash{$key}[20] = $fwdfwsettings{'TIME_TUE'};
1440 $$hash{$key}[21] = $fwdfwsettings{'TIME_WED'};
1441 $$hash{$key}[22] = $fwdfwsettings{'TIME_THU'};
1442 $$hash{$key}[23] = $fwdfwsettings{'TIME_FRI'};
1443 $$hash{$key}[24] = $fwdfwsettings{'TIME_SAT'};
1444 $$hash{$key}[25] = $fwdfwsettings{'TIME_SUN'};
1445 $$hash{$key}[26] = $fwdfwsettings{'TIME_FROM'};
1446 $$hash{$key}[27] = $fwdfwsettings{'TIME_TO'};
1451 &General
::writehasharray
("$config", $hash);
1452 if($fwdfwsettings{'oldrulenumber'} gt $fwdfwsettings{'rulepos'}){
1454 my $val=$fwdfwsettings{'oldrulenumber'}-$fwdfwsettings{'rulepos'};
1455 for (my $z=0;$z<$val;$z++){
1456 foreach my $key (sort {$a <=> $b} keys %$hash){
1457 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1459 if (exists $$hash{$last}){
1461 foreach my $y (0 .. $#{$$hash{$last}}) {
1462 $tmp{0}[$y] = $$hash{$last}[$y];
1464 #copy active rule to last
1465 foreach my $i (0 .. $#{$$hash{$last}}) {
1466 $$hash{$last}[$i] = $$hash{$key}[$i];
1468 #copy saved rule to actual position
1469 foreach my $x (0 .. $#{$tmp{0}}) {
1470 $$hash{$key}[$x] = $tmp{0}[$x];
1475 $fwdfwsettings{'oldrulenumber'}--;
1477 &General
::writehasharray
("$config", $hash);
1479 }elsif($fwdfwsettings{'rulepos'} gt $fwdfwsettings{'oldrulenumber'}){
1481 my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
1482 for (my $z=0;$z<$val;$z++){
1483 foreach my $key (sort {$a <=> $b} keys %$hash){
1484 if ($key eq $fwdfwsettings{'oldrulenumber'}) {
1485 my $next = $key + 1;
1486 if (exists $$hash{$next}){
1488 foreach my $y (0 .. $#{$$hash{$next}}) {
1489 $tmp{0}[$y] = $$hash{$next}[$y];
1491 #copy active rule to next
1492 foreach my $i (0 .. $#{$$hash{$next}}) {
1493 $$hash{$next}[$i] = $$hash{$key}[$i];
1495 #copy saved rule to actual position
1496 foreach my $x (0 .. $#{$tmp{0}}) {
1497 $$hash{$key}[$x] = $tmp{0}[$x];
1502 $fwdfwsettings{'oldrulenumber'}++;
1504 &General
::writehasharray
("$config", $hash);
1511 if ($errormessage) {
1512 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1513 print "<class name='base'>$errormessage\n";
1514 print " </class>\n";
1515 &Header
::closebox
();
1522 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1523 print "<class name='base'>$hint\n";
1524 print " </class>\n";
1525 &Header
::closebox
();
1532 &General
::setup_default_networks
(\
%defaultNetworks);
1533 foreach my $network (sort keys %defaultNetworks)
1535 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1540 # Checks a hostname against RFC1035
1543 # Each part should be at least two characters in length
1544 # but no more than 63 characters
1545 if (length ($remark) < 1 || length ($remark) > 255) {
1547 # Only valid characters are a-z, A-Z, 0-9 and -
1548 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:_\/\s
]*$/) {
1550 # First character can only be a letter or a digit
1551 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
1553 # Last character can only be a letter or a digit
1554 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.]*$/) {
1560 my %hash=%{(shift)};
1562 if($hash{$key}[7] eq 'ON' && $hash{$key}[8] ne 'ICMP'){
1563 print" : ($hash{$key}[8]) $hash{$key}[10]";
1564 }elsif($hash{$key}[7] eq 'ON' && $hash{$key}[8] eq 'ICMP'){
1565 print" : ($hash{$key}[8]) <br> $hash{$key}[9]";
1570 my %hash=%{(shift)};
1575 if($hash{$key}[11] eq 'ON' && $hash{$key}[12] ne 'ICMP'){
1576 if($hash{$key}[14] eq 'cust_srv'){
1577 &General
::readhasharray
("$configsrv", \
%customservice);
1578 foreach my $i (sort keys %customservice){
1579 #print "HHUHU: $customservice{$i}[0] und $hash{$key}[15]<br>";
1580 if($customservice{$i}[0] eq $hash{$key}[15]){
1581 $prot = $hash{$key}[12];
1582 $service = $customservice{$i}[0];
1585 }elsif($hash{$key}[14] eq 'cust_srvgrp'){
1587 $service=$hash{$key}[15];
1588 }elsif($hash{$key}[14] eq 'TGT_PORT'){
1589 $service=$hash{$key}[15];
1590 $prot=$hash{$key}[12];
1592 }elsif($hash{$key}[11] eq 'ON' && $hash{$key}[12] eq 'ICMP'){
1593 print" : ($hash{$key}[12]) <br>$hash{$key}[13]";
1596 if ($prot ne '' || $service ne ''){
1606 &viewtablenew
(\
%configfwdfw,$configfwdfw,$Lang::tr
{'fwdfw rules'},"Forward" );
1607 &viewtablenew
(\
%configinputfw,$configinput,"",$Lang::tr
{'external access'} );
1616 if ( ! -z
"$config"){
1617 &Header
::openbox
('100%', 'left',$title);
1625 &General
::readhasharray
("$config", $hash);
1626 print"<b>$title1</b><br>";
1627 print"<table width='100%' border='0' cellspacing='1' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
1628 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>";
1629 foreach my $key (sort {$a <=> $b} keys %$hash){
1631 #check if vpn hosts/nets have been deleted
1632 if($$hash{$key}[3] =~ /ipsec/i || $$hash{$key}[3] =~ /ovpn/i){
1633 push (@tmpsrc,$$hash{$key}[4]);
1635 if($$hash{$key}[5] =~ /ipsec/i || $$hash{$key}[5] =~ /ovpn/i){
1636 push (@tmpsrc,$$hash{$key}[6]);
1638 foreach my $host (@tmpsrc){
1639 if($$hash{$key}[3] eq 'ipsec_net_src' || $$hash{$key}[5] eq 'ipsec_net_tgt'){
1640 if(&fwlib
::get_ipsec_net_ip
($host,11) eq ''){
1642 &disable_rule
($key);
1645 }elsif($$hash{$key}[3] eq 'ovpn_net_src' || $$hash{$key}[5] eq 'ovpn_net_tgt'){
1646 if(&fwlib
::get_ovpn_net_ip
($host,1) eq ''){
1648 &disable_rule
($key);
1651 }elsif($$hash{$key}[3] eq 'ovpn_n2n_src' || $$hash{$key}[5] eq 'ovpn_n2n_tgt'){
1652 if(&fwlib
::get_ovpn_n2n_ip
($host,27) eq ''){
1654 &disable_rule
($key);
1657 }elsif($$hash{$key}[3] eq 'ovpn_host_src' || $$hash{$key}[5] eq 'ovpn_host_tgt'){
1658 if(&fwlib
::get_ovpn_host_ip
($host,33) eq ''){
1660 &disable_rule
($key);
1667 $$hash{'ACTIVE'}=$$hash{$key}[2];
1669 if($coloryellow eq 'on'){
1670 print"<tr bgcolor='$color{'color14'}' >";
1672 }elsif($coloryellow eq ''){
1674 print"<tr bgcolor='$color{'color22'}' >";
1677 print"<tr bgcolor='$color{'color20'}' >";
1681 <td align='right'>$key</td>
1683 if ($$hash{$key}[0] eq 'ACCEPT'){
1686 $rulecolor=$color{'color17'};
1687 }elsif($$hash{$key}[0] eq 'DROP'){
1690 $rulecolor=$color{'color25'};
1691 }elsif($$hash{$key}[0] eq 'REJECT'){
1694 $rulecolor=$color{'color16'};
1696 print"<td bgcolor='$rulecolor' width='2%' align='center'><span title='$tooltip'><b>$ruletype</b></span></td>";
1697 print"<td align='center'>";
1698 if ($$hash{$key}[3] eq 'std_net_src'){
1699 print &get_name
($$hash{$key}[4]);
1701 print $$hash{$key}[4];
1703 &getsrcport
(\
%$hash,$key);
1704 if ($$hash{$key}[17] eq 'ON'){
1705 $log="/images/on.gif";
1707 $log="/images/off.gif";
1711 <form method='post'>
1712 <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 ;'/>
1713 <input type='hidden' name='key' value='$key' />
1714 <input type='hidden' name='config' value='$config' />
1715 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
1720 <td align='center' nowrap='nowrap'>
1722 if ($$hash{$key}[5] eq 'std_net_tgt'){
1723 print &get_name
($$hash{$key}[6]);
1725 print $$hash{$key}[6];
1727 &gettgtport
(\
%$hash,$key);
1728 ################################################################################
1729 print"</td><td width='20%'>$$hash{$key}[16]</td>";
1731 if($$hash{$key}[2] eq 'ON'){
1732 $gif="/images/on.gif"
1735 $gif="/images/off.gif"
1738 <form method='post'>
1739 <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;' />
1740 <input type='hidden' name='key' value='$key' />
1741 <input type='hidden' name='config' value='$config' />
1742 <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw toggle'}' />
1744 <form method='post'>
1745 <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;' />
1746 <input type='hidden' name='key' value='$key' />
1747 <input type='hidden' name='config' value='$config' />
1748 <input type='hidden' name='ACTION' value='editrule' />
1750 <form method='post'>
1751 <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;' />
1752 <input type='hidden' name='key' value='$key' />
1753 <input type='hidden' name='config' value='$config' />
1754 <input type='hidden' name='ACTION' value='copyrule' />
1756 <form method='post'>
1757 <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;' />
1758 <input type='hidden' name='key' value='$key' />
1759 <input type='hidden' name='config' value='$config' />
1760 <input type='hidden' name='ACTION' value='deleterule' />
1763 if (exists $$hash{$key-1}){
1765 <form method='post'>
1766 <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;' />
1767 <input type='hidden' name='key' value='$key' />
1768 <input type='hidden' name='config' value='$config' />
1769 <input type='hidden' name='ACTION' value='moveup' />
1775 if (exists $$hash{$key+1}){
1777 <form method='post'>
1778 <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;' />
1779 <input type='hidden' name='key' value='$key' />
1780 <input type='hidden' name='config' value='$config' />
1781 <input type='hidden' name='ACTION' value='movedown' />
1782 </td></form></td></tr>
1785 print"<td></td></tr>";
1787 #if timeframe set, print new line in table
1788 if ($$hash{$key}[18] eq 'ON'){
1790 if($$hash{$key}[19] ne ''){push (@days,$Lang::tr
{'fwdfw wd_mon'});}
1791 if($$hash{$key}[20] ne ''){push (@days,$Lang::tr
{'fwdfw wd_tue'});}
1792 if($$hash{$key}[21] ne ''){push (@days,$Lang::tr
{'fwdfw wd_wed'});}
1793 if($$hash{$key}[22] ne ''){push (@days,$Lang::tr
{'fwdfw wd_thu'});}
1794 if($$hash{$key}[23] ne ''){push (@days,$Lang::tr
{'fwdfw wd_fri'});}
1795 if($$hash{$key}[24] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sat'});}
1796 if($$hash{$key}[25] ne ''){push (@days,$Lang::tr
{'fwdfw wd_sun'});}
1797 my $weekdays=join(",",@days);
1799 print"<tr bgcolor='#FFE4B5'><td colspan='4'>$Lang::tr{'fwdfw time'} ";
1801 print "  $Lang::tr{'fwdfw from'} $$hash{$key}[26]   $Lang::tr{'fwdfw till'} $$hash{$key}[27]</td><td colspan='8'></d></tr>";
1806 &Header
::closebox
();
1811 my %hash=%{(shift)};
1814 foreach my $key (sort { uc($hash{$a}[0]) cmp uc($hash{$b}[0]) } keys %hash){
1815 if($hash{$key}[0] eq $val){
1816 print"<option value='$hash{$key}[0]' selected>$hash{$key}[0]</option>";
1818 print"<option value='$hash{$key}[0]'>$hash{$key}[0]</option>";
1824 if (!-f
"${General::swroot}/forward/reread"){
1825 system("touch ${General::swroot}/forward/reread");
1830 system("/usr/local/bin/forwardfwctrl");
1831 system("rm ${General::swroot}/forward/reread");
1833 &Header
::closebigbox
();
1834 &Header
::closepage
();