]>
git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - html/cgi-bin/fwhosts.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 ###############################################################################
21 # Author: Alexander Marx (amarx@ipfire.org) #
22 ###############################################################################
25 # enable only the following on debugging purpose
28 use CGI
::Carp
'fatalsToBrowser';
29 no warnings
'uninitialized';
30 require '/var/ipfire/general-functions.pl';
31 require "${General::swroot}/lang.pl";
32 require "${General::swroot}/header.pl";
34 my %fwhostsettings=();
39 my %customservicegrp=();
45 my %defaultNetworks=();
55 my $confignet = "${General::swroot}/fwhosts/customnetworks";
56 my $confighost = "${General::swroot}/fwhosts/customhosts";
57 my $configgrp = "${General::swroot}/fwhosts/customgroups";
58 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
59 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
60 my $configipsec = "${General::swroot}/vpn/config";
61 my $configsrv = "${General::swroot}/fwhosts/customservices";
62 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
63 my $fwconfigfwd = "${General::swroot}/forward/config";
64 my $fwconfiginp = "${General::swroot}/forward/input";
66 unless (-e
$confignet) { system("touch $confignet"); }
67 unless (-e
$confighost) { system("touch $confighost"); }
68 unless (-e
$configgrp) { system("touch $configgrp"); }
69 unless (-e
$configsrv) { system("touch $configsrv"); }
70 unless (-e
$configsrvgrp) { system("touch $configsrvgrp"); }
72 &General
::readhash
("${General::swroot}/main/settings", \
%mainsettings);
73 &General
::readhash
("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \
%color);
74 &General
::readhash
("${General::swroot}/ethernet/settings", \
%ownnet);
75 &Header
::getcgihash
(\
%fwhostsettings);
77 &Header
::showhttpheaders
();
78 &Header
::openpage
($Lang::tr
{'fwhost hosts'}, 1, '');
79 &Header
::openbigbox
('100%', 'center');
84 \$(document).ready(function() {
85 // Automatically select radio buttons when corresponding
86 // dropdown menu changes.
87 \$("select").change(function() {
88 var id = \$(this).attr("name");
89 //When using SNAT or DNAT, check "USE NAT" Checkbox
90 if ( id === 'snat' || id === 'dnat') {
91 \$('#USE_NAT').prop('checked', true);
93 \$('#' + id).prop("checked", true);
100 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwdfw reread'})
106 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
108 &General
::readhasharray
("$confignet", \
%customnetwork);
109 foreach my $key (keys %customnetwork)
111 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
113 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
114 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
115 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
116 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
117 $fwhostsettings{'count'} = $customnetwork{$key}[4];
118 delete $customnetwork{$key};
122 &General
::writehasharray
("$confignet", \
%customnetwork);
123 $fwhostsettings{'actualize'} = 'on';
124 $fwhostsettings{'ACTION'} = 'savenet';
126 if ($fwhostsettings{'ACTION'} eq 'updatehost')
129 &General
::readhasharray
("$confighost", \
%customhost);
130 foreach my $key (keys %customhost)
132 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
134 if ($customhost{$key}[1] eq 'ip'){
135 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
137 $ip = $customhost{$key}[2];
139 $fwhostsettings{'orgip'} = $ip;
140 $fwhostsettings{'count'} = $customhost{$key}[4];
141 delete $customhost{$key};
142 &General
::writehasharray
("$confighost", \
%customhost);
145 $fwhostsettings{'actualize'} = 'on';
146 if($fwhostsettings{'orgip'}){
147 $fwhostsettings{'ACTION'} = 'savehost';
149 $fwhostsettings{'ACTION'} = $Lang::tr
{'fwhost newhost'};
152 if ($fwhostsettings{'ACTION'} eq 'updateservice')
156 $errormessage=&checkports
(\
%customservice);
158 &General
::readhasharray
("$configsrv", \
%customservice);
159 foreach my $key (keys %customservice)
161 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
163 $count=$customservice{$key}[4];
164 delete $customservice{$key};
165 &General
::writehasharray
("$configsrv", \
%customservice);
169 if ($fwhostsettings{'PROT'} ne 'ICMP'){
170 $fwhostsettings{'ICMP_TYPES'}='BLANK';
172 my $key1 = &General
::findhasharraykey
(\
%customservice);
173 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
174 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
175 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
176 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
177 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
178 $customservice{$key1}[4] = $count;
179 &General
::writehasharray
("$configsrv", \
%customservice);
180 #check if we need to update firewallrules
181 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
182 if ( ! -z
$fwconfigfwd ){
183 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
184 foreach my $key (sort keys %fwfwd){
185 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
186 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
189 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
191 if ( ! -z
$fwconfiginp ){
192 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
193 foreach my $line (sort keys %fwinp){
194 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
195 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
198 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
200 #check if we need to update groups
201 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
202 foreach my $key (sort keys %customservicegrp){
203 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
204 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
207 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
210 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
213 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
216 $fwhostsettings{'SRV_NAME'} = '';
217 $fwhostsettings{'SRV_PORT'} = '';
218 $fwhostsettings{'PROT'} = '';
220 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
221 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
222 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
223 $fwhostsettings{'updatesrv'}= 'on';
225 if($needrules eq 'on'){
231 if ($fwhostsettings{'ACTION'} eq 'savenet' )
235 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
236 #check if all fields are set
237 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
239 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
244 if (!&General
::validipandmask
($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
246 $errormessage=$errormessage.$Lang::tr
{'fwhost err addr'};
247 $fwhostsettings{'BLK_HOST'} ='readonly';
248 $fwhostsettings{'NOCHECK'} ='false';
249 $fwhostsettings{'error'} ='on';
252 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark
($fwhostsettings{'NETREMARK'})){
253 $errormessage=$Lang::tr
{'fwhost err remark'};
254 $fwhostsettings{'error'} ='on';
256 #check if subnet is sigle host
257 if(&General
::iporsubtocidr
($fwhostsettings{'SUBNET'}) eq '32')
259 $errormessage=$errormessage.$Lang::tr
{'fwhost err sub32'};
261 if($fwhostsettings{'error'} ne 'on'){
262 #check if we use one of ipfire's networks (green,orange,blue)
263 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
265 $errormessage=$errormessage.$Lang::tr
{'ccd err green'}."<br>";
266 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
267 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
269 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
271 $errormessage=$errormessage.$Lang::tr
{'ccd err orange'}."<br>";
272 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
273 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
275 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
277 $errormessage=$errormessage.$Lang::tr
{'ccd err blue'}."<br>";
278 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
279 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
281 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General
::IpInSubnet
($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
283 $errormessage=$errormessage.$Lang::tr
{'ccd err red'}."<br>";
284 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
285 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
288 #only check plausi when no error till now
290 &plausicheck
("editnet");
292 #check if network ip is part of an already used one
293 if(&checksubnet
(\
%customnetwork))
295 $errormessage=$errormessage.$Lang::tr
{'fwhost err partofnet'};
296 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
298 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
300 $fwhostsettings{'actualize'} = '';
301 my $key = &General
::findhasharraykey
(\
%customnetwork);
302 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
303 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
304 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
305 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
306 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
307 $customnetwork{$key}[4] = $fwhostsettings{'count'};
308 &General
::writehasharray
("$confignet", \
%customnetwork);
309 undef %customnetwork;
313 &General
::readhasharray
("$confignet", \
%customnetwork);
314 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
315 if ($fwhostsettings{'update'} == '0'){
316 foreach my $key (keys %customnetwork) {
317 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
318 $count=$customnetwork{$key}[4];
319 delete $customnetwork{$key};
325 #get count if actualize is 'on'
326 if($fwhostsettings{'actualize'} eq 'on'){
327 $fwhostsettings{'actualize'} = '';
328 $count=$fwhostsettings{'count'};
329 #check if we need to reload rules
330 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0'){
333 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
334 #check if we need to update groups
335 &General
::readhasharray
("$configgrp", \
%customgrp);
336 foreach my $key (sort keys %customgrp){
337 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
338 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
342 &General
::writehasharray
("$configgrp", \
%customgrp);
343 #check if we need to update firewallrules
344 if ( ! -z
$fwconfigfwd ){
345 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
346 foreach my $line (sort keys %fwfwd){
347 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
348 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
350 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
351 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
354 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
356 if ( ! -z
$fwconfiginp ){
357 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
358 foreach my $line (sort keys %fwinp){
359 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
360 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
363 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
367 my $key = &General
::findhasharraykey
(\
%customnetwork);
368 foreach my $i (0 .. 4) { $customnetwork{$key}[$i] = "";}
369 $fwhostsettings{'SUBNET'} = &General
::iporsubtocidr
($fwhostsettings{'SUBNET'});
370 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
371 #convert ip when leading '0' in byte
372 $fwhostsettings{'IP'} =&General
::ip2dec
($fwhostsettings{'IP'});
373 $fwhostsettings{'IP'} =&General
::dec2ip
($fwhostsettings{'IP'});
374 $customnetwork{$key}[1] = &General
::getnetworkip
($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
375 $customnetwork{$key}[2] = &General
::iporsubtodec
($fwhostsettings{'SUBNET'}) ;
376 if($fwhostsettings{'newnet'} eq 'on'){$count=0;}
377 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
378 $customnetwork{$key}[4] = $count;
379 &General
::writehasharray
("$confignet", \
%customnetwork);
380 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
381 undef %customnetwork;
382 $fwhostsettings{'HOSTNAME'}='';
383 $fwhostsettings{'IP'}='';
384 $fwhostsettings{'SUBNET'}='';
385 $fwhostsettings{'NETREMARK'}='';
386 #check if an edited net affected groups and need to reload rules
387 if ($needrules eq 'on'){
398 if ($fwhostsettings{'ACTION'} eq 'savehost')
402 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
403 $fwhostsettings{'SUBNET'}='32';
404 #check if all fields are set
405 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
407 $errormessage=$errormessage.$Lang::tr
{'fwhost err empty'};
408 $fwhostsettings{'ACTION'} = 'edithost';
410 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
411 $fwhostsettings{'type'} = 'mac';
412 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
413 $fwhostsettings{'type'} = 'ip';
415 $fwhostsettings{'type'} = '';
416 $errormessage=$Lang::tr
{'fwhost err ipmac'};
419 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark
($fwhostsettings{'HOSTREMARK'})){
420 $errormessage=$Lang::tr
{'fwhost err remark'};
423 if ($fwhostsettings{'type'} eq 'ip'){
425 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
426 if($fwhostsettings{'type'} eq 'ip' && !&General
::validipandmask
($fwhostsettings{'IP'}."/32"))
428 $errormessage.=$errormessage.$Lang::tr
{'fwhost err ip'};
429 $fwhostsettings{'error'}='on';
431 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
432 $errormessage=$errormessage.$Lang::tr
{'fwhost err ipwithsub'};
433 $fwhostsettings{'error'}='on';
435 #check if net or broadcast
436 my @tmp= split (/\./,$fwhostsettings{'IP'});
437 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
438 $errormessage=$Lang::tr
{'fwhost err hostip'};
441 #only check plausi when no error till now
443 &plausicheck
("edithost");
445 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
446 $fwhostsettings{'actualize'} = '';
447 my $key = &General
::findhasharraykey
(\
%customhost);
448 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
449 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
450 $customhost{$key}[1] = $fwhostsettings{'type'} ;
451 if($customhost{$key}[1] eq 'ip'){
452 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
454 $customhost{$key}[2] = $fwhostsettings{'orgip'};
456 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
457 $customhost{$key}[4] = $fwhostsettings{'count'};
458 &General
::writehasharray
("$confighost", \
%customhost);
462 #get count if host was edited
463 if($fwhostsettings{'actualize'} eq 'on'){
464 $count=$fwhostsettings{'count'};
465 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'} && $count gt '0' ){
468 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
469 #check if we need to update groups
470 &General
::readhasharray
("$configgrp", \
%customgrp);
471 foreach my $key (sort keys %customgrp){
472 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
473 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
476 &General
::writehasharray
("$configgrp", \
%customgrp);
477 #check if we need to update firewallrules
478 if ( ! -z
$fwconfigfwd ){
479 &General
::readhasharray
("$fwconfigfwd", \
%fwfwd);
480 foreach my $line (sort keys %fwfwd){
481 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
482 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
484 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
485 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
488 &General
::writehasharray
("$fwconfigfwd", \
%fwfwd);
490 if ( ! -z
$fwconfiginp ){
491 &General
::readhasharray
("$fwconfiginp", \
%fwinp);
492 foreach my $line (sort keys %fwinp){
493 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
494 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
497 &General
::writehasharray
("$fwconfiginp", \
%fwinp);
501 my $key = &General
::findhasharraykey
(\
%customhost);
502 foreach my $i (0 .. 4) { $customhost{$key}[$i] = "";}
503 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
504 $customhost{$key}[1] = $fwhostsettings{'type'} ;
505 if ($fwhostsettings{'type'} eq 'ip'){
506 #convert ip when leading '0' in byte
507 $fwhostsettings{'IP'}=&General
::ip2dec
($fwhostsettings{'IP'});
508 $fwhostsettings{'IP'}=&General
::dec2ip
($fwhostsettings{'IP'});
509 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'});
511 $customhost{$key}[2] = $fwhostsettings{'IP'};
513 if($fwhostsettings{'newhost'} eq 'on'){$count=0;}
514 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
515 $customhost{$key}[4] =$count;
516 &General
::writehasharray
("$confighost", \
%customhost);
518 $fwhostsettings{'HOSTNAME'}='';
519 $fwhostsettings{'IP'}='';
520 $fwhostsettings{'type'}='';
521 $fwhostsettings{'HOSTREMARK'}='';
522 #check if we need to update rules while host was edited
523 if($needrules eq 'on'){
534 if ($fwhostsettings{'ACTION'} eq 'savegrp')
536 my $grp=$fwhostsettings{'grp_name'};;
537 my $rem=$fwhostsettings{'remark'};
540 my $updcounter='off';
543 &General
::readhasharray
("$configgrp", \
%customgrp);
544 &General
::readhasharray
("$confignet", \
%customnetwork);
545 &General
::readhasharray
("$confighost", \
%customhost);
547 if (!&validhostname
($grp)){$errormessage.=$Lang::tr
{'fwhost err name'};}
549 if ($rem ne '' && !&validremark
($rem) && $fwhostsettings{'update'} ne 'on'){
550 $errormessage.=$Lang::tr
{'fwhost err remark'};
552 if ($fwhostsettings{'update'} eq 'on'){
553 #check standard networks
554 if ($fwhostsettings{'grp2'} eq 'std_net'){
555 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
556 $type='Standard Network';
558 #check custom networks
559 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
560 @target=$fwhostsettings{'CUST_SRC_NET'};
562 $type='Custom Network';
563 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
564 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
565 $fwhostsettings{'grp_name'}='';
566 $fwhostsettings{'remark'}='';
568 #check custom addresses
569 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
570 @target=$fwhostsettings{'CUST_SRC_HOST'};
573 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
574 $errormessage=$Lang::tr
{'fwhost err groupempty'}."<br>";
575 $fwhostsettings{'grp_name'}='';
576 $fwhostsettings{'remark'}='';
578 #get address from ovpn ccd static net
579 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
580 @target=$fwhostsettings{'OVPN_CCD_NET'};
581 $type='OpenVPN static network';
582 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
583 $errormessage=$Lang::tr
{'fwhost err groupempty'};
584 $fwhostsettings{'grp_name'}='';
585 $fwhostsettings{'remark'}='';
587 #get address from ovpn ccd static host
588 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
589 @target=$fwhostsettings{'OVPN_CCD_HOST'};
590 $type='OpenVPN static host';
591 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
592 $errormessage=$Lang::tr
{'fwhost err groupempty'};
594 #get address from ovpn ccd Net-2-Net
595 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
596 @target=$fwhostsettings{'OVPN_N2N'};
597 $type='OpenVPN N-2-N';
598 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
599 $errormessage=$Lang::tr
{'fwhost err groupempty'};
600 $fwhostsettings{'grp_name'}='';
601 $fwhostsettings{'remark'}='';
603 #get address from IPSEC HOST
604 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
605 @target=$fwhostsettings{'IPSEC_HOST'};
607 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
608 $errormessage=$Lang::tr
{'fwhost err groupempty'};
609 $fwhostsettings{'grp_name'}='';
610 $fwhostsettings{'remark'}='';
612 #get address from IPSEC NETWORK
613 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
614 @target=$fwhostsettings{'IPSEC_NET'};
615 $type='IpSec Network';
616 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
617 $errormessage=$Lang::tr
{'fwhost err groupempty'};
618 $fwhostsettings{'grp_name'}='';
619 $fwhostsettings{'remark'}='';
621 #check if host/net exists in grp
623 my $test="$grp,$fwhostsettings{'oldremark'},@target";
624 foreach my $key (keys %customgrp) {
625 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
626 if ($test1 eq $test){
627 $errormessage=$Lang::tr
{'fwhost err isingrp'};
628 $fwhostsettings{'update'} = 'on';
634 #on first save, we have an empty @target, so fill it with nothing
635 my $targetvalues=@target;
636 if ($targetvalues == '0'){
639 #on update, we have to delete the dummy entry
640 foreach my $key (keys %customgrp){
641 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
642 delete $customgrp{$key};
646 &General
::writehasharray
("$configgrp", \
%customgrp);
647 &General
::readhasharray
("$configgrp", \
%customgrp);
649 foreach my $key (keys %customgrp)
651 if($customgrp{$key}[0] eq $grp)
653 $count=$customgrp{$key}[4];
657 if ($count eq '' ){$count='0';}
659 #create array with new lines
660 foreach my $line (@target){
661 push (@newgrp,"$grp,$rem,$line");
664 my $key = &General
::findhasharraykey
(\
%customgrp);
665 foreach my $line (@newgrp){
666 foreach my $i (0 .. 4) { $customgrp{$key}[$i] = "";}
667 my ($a,$b,$c,$d) = split (",",$line);
668 $customgrp{$key}[0] = $a;
669 $customgrp{$key}[1] = $b;
670 $customgrp{$key}[2] = $c;
671 $customgrp{$key}[3] = $type;
672 $customgrp{$key}[4] = $count;
674 &General
::writehasharray
("$configgrp", \
%customgrp);
675 #update counter in Host/Net
676 if($updcounter eq 'net'){
677 foreach my $key (keys %customnetwork) {
678 if($customnetwork{$key}[0] eq $fwhostsettings{'CUST_SRC_NET'}){
679 $customnetwork{$key}[4] = $customnetwork{$key}[4]+1;
683 &General
::writehasharray
("$confignet", \
%customnetwork);
684 }elsif($updcounter eq 'host'){
685 foreach my $key (keys %customhost) {
686 if ($customhost{$key}[0] eq $fwhostsettings{'CUST_SRC_HOST'}){
687 $customhost{$key}[4]=$customhost{$key}[4]+1;
690 &General
::writehasharray
("$confighost", \
%customhost);
692 $fwhostsettings{'update'}='on';
694 #check if ruleupdate is needed
702 if ($fwhostsettings{'ACTION'} eq 'saveservice')
705 &General
::readhasharray
("$configsrv", \
%customservice );
706 $errormessage=&checkports
(\
%customservice);
707 if ($fwhostsettings{'PROT'} eq 'ICMP'){
708 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
709 foreach my $key (keys %icmptypes){
710 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
711 $ICMP=$icmptypes{$key}[0];
715 if($ICMP eq ''){$ICMP='BLANK';}
717 my $key = &General
::findhasharraykey
(\
%customservice);
718 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
719 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
720 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
721 $customservice{$key}[2] = $fwhostsettings{'PROT'};
722 $customservice{$key}[3] = $ICMP;
723 $customservice{$key}[4] = 0;
724 &General
::writehasharray
("$configsrv", \
%customservice );
726 $fwhostsettings{'SRV_NAME'}='';
727 $fwhostsettings{'SRV_PORT'}='';
728 $fwhostsettings{'PROT'}='';
729 $fwhostsettings{'ICMP_TYPES'}='';
733 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
738 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
739 &General
::readhasharray
("$configsrv", \
%customservice );
740 $errormessage=&checkservicegroup
;
742 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark
($fwhostsettings{'SRVGRP_REMARK'})){
743 $errormessage=$Lang::tr
{'fwhost err remark'};
746 #on first save, we have to enter a dummy value
747 if ($fwhostsettings{'CUST_SRV'} eq ''){
748 $fwhostsettings{'CUST_SRV'}='none';
750 #on update, we have to delete the dummy entry
751 foreach my $key (keys %customservicegrp){
752 if ($customservicegrp{$key}[2] eq 'none'){
753 delete $customservicegrp{$key};
757 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
758 #check if remark has also changed
759 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
761 foreach my $key (keys %customservicegrp)
763 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
765 $customservicegrp{$key}[1]='';
766 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
771 foreach my $key (keys %customservicegrp)
773 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
775 $count=$customservicegrp{$key}[3];
779 if ($count eq '' ){$count='0';}
781 foreach my $key (sort keys %customservice){
782 if($customservice{$key}[0] eq $fwhostsettings{'CUST_SRV'}){
783 $port=$customservice{$key}[1];
784 $prot=$customservice{$key}[2];
785 $customservice{$key}[4]++;
788 &General
::writehasharray
("$configsrv", \
%customservice );
789 my $key = &General
::findhasharraykey
(\
%customservicegrp);
790 foreach my $i (0 .. 3) { $customservice{$key}[$i] = "";}
791 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
792 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
793 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
794 $customservicegrp{$key}[3] = $count;
795 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp );
796 $fwhostsettings{'updatesrvgrp'}='on';
802 &viewtableservicegrp
;
805 if ($fwhostsettings{'ACTION'} eq 'editnet')
810 if ($fwhostsettings{'ACTION'} eq 'edithost')
815 if ($fwhostsettings{'ACTION'} eq 'editgrp')
817 $fwhostsettings{'update'}='on';
821 if ($fwhostsettings{'ACTION'} eq 'editservice')
823 $fwhostsettings{'updatesrv'}='on';
826 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
828 $fwhostsettings{'updatesrvgrp'} = 'on';
830 &viewtableservicegrp
;
833 if ($fwhostsettings{'ACTION'} eq 'resetnet')
835 $fwhostsettings{'HOSTNAME'} ="";
836 $fwhostsettings{'IP'} ="";
837 $fwhostsettings{'SUBNET'} ="";
840 if ($fwhostsettings{'ACTION'} eq 'resethost')
842 $fwhostsettings{'HOSTNAME'} ="";
843 $fwhostsettings{'IP'} ="";
844 $fwhostsettings{'type'} ="";
847 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
849 $fwhostsettings{'grp_name'} ="";
850 $fwhostsettings{'remark'} ="";
854 if ($fwhostsettings{'ACTION'} eq 'delnet')
856 &General
::readhasharray
("$confignet", \
%customnetwork);
857 foreach my $key (keys %customnetwork) {
858 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
859 delete $customnetwork{$key};
860 &General
::writehasharray
("$confignet", \
%customnetwork);
867 if ($fwhostsettings{'ACTION'} eq 'delhost')
869 &General
::readhasharray
("$confighost", \
%customhost);
870 foreach my $key (keys %customhost) {
871 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
872 delete $customhost{$key};
873 &General
::writehasharray
("$confighost", \
%customhost);
880 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
884 &General
::readhasharray
("$configgrp", \
%customgrp);
885 foreach my $key (keys %customgrp){
886 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
887 #decrease count from source host/net
888 if ($customgrp{$key}[3] eq 'Custom Network'){
889 &General
::readhasharray
("$confignet", \
%customnetwork);
890 foreach my $key1 (keys %customnetwork){
891 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
892 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
896 &General
::writehasharray
("$confignet", \
%customnetwork);
898 if ($customgrp{$key}[3] eq 'Custom Host'){
899 &General
::readhasharray
("$confighost", \
%customhost);
900 foreach my $key1 (keys %customhost){
901 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
902 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
906 &General
::writehasharray
("$confighost", \
%customhost);
908 $grpname=$customgrp{$key}[0];
909 $grpremark=$customgrp{$key}[1];
910 delete $customgrp{$key};
913 &General
::writehasharray
("$configgrp", \
%customgrp);
914 if ($fwhostsettings{'grpcnt'} > 0){&rules
;}
915 if ($fwhostsettings{'update'} eq 'on'){
916 $fwhostsettings{'remark'}= $grpremark;
917 $fwhostsettings{'grp_name'}=$grpname;
922 if ($fwhostsettings{'ACTION'} eq 'delgrp')
924 &General
::readhasharray
("$configgrp", \
%customgrp);
925 &decrease
($fwhostsettings{'grp_name'});
926 foreach my $key (sort keys %customgrp)
928 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
930 delete $customgrp{$key};
933 &General
::writehasharray
("$configgrp", \
%customgrp);
934 $fwhostsettings{'grp_name'}='';
938 if ($fwhostsettings{'ACTION'} eq 'delservice')
940 &General
::readhasharray
("$configsrv", \
%customservice);
941 foreach my $key (keys %customservice) {
942 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
943 #&deletefromgrp($customhost{$key}[0],$configgrp);
944 delete $customservice{$key};
945 &General
::writehasharray
("$configsrv", \
%customservice);
949 $fwhostsettings{'SRV_NAME'}='';
950 $fwhostsettings{'SRV_PORT'}='';
951 $fwhostsettings{'PROT'}='';
954 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
956 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
957 &decreaseservice
($fwhostsettings{'SRVGRP_NAME'});
958 foreach my $key (sort keys %customservicegrp)
960 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
962 delete $customservicegrp{$key};
965 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
966 $fwhostsettings{'SRVGRP_NAME'}='';
968 &viewtableservicegrp
;
970 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
974 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
975 &General
::readhasharray
("$configsrv", \
%customservice);
976 foreach my $key (keys %customservicegrp){
977 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2].",".$customservicegrp{$key}[3] eq $fwhostsettings{'delsrvfromgrp'})
979 #decrease count from source service
980 foreach my $key1 (sort keys %customservice){
981 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
982 $customservice{$key1}[4]--;
986 &General
::writehasharray
("$configsrv", \
%customservice);
987 $grpname=$customservicegrp{$key}[0];
988 $grpremark=$customservicegrp{$key}[1];
989 delete $customservicegrp{$key};
992 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
994 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
995 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
996 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
999 &viewtableservicegrp
;
1002 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newnet'})
1007 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newhost'})
1012 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newgrp'})
1017 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservice'})
1021 if ($fwhostsettings{'ACTION'} eq $Lang::tr
{'fwhost newservicegrp'})
1024 &viewtableservicegrp
;
1026 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1028 &General
::readhasharray
("$configgrp", \
%customgrp);
1029 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark
($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1030 foreach my $key (sort keys %customgrp)
1032 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1034 $customgrp{$key}[1]='';
1035 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1038 &General
::writehasharray
("$configgrp", \
%customgrp);
1039 $fwhostsettings{'update'}='on';
1040 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1042 $errormessage=$Lang::tr
{'fwhost err remark'};
1043 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1044 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1045 $fwhostsettings{'update'} = 'on';
1047 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1051 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1053 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp );
1054 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark
($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1055 foreach my $key (sort keys %customservicegrp)
1057 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1059 $customservicegrp{$key}[1]='';
1060 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1063 &General
::writehasharray
("$configsrvgrp", \
%customservicegrp);
1064 $fwhostsettings{'updatesrvgrp'}='on';
1065 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1067 $errormessage=$Lang::tr
{'fwhost err remark'};
1068 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1069 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1070 $fwhostsettings{'updatesrvgrp'} = 'on';
1072 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1074 &viewtableservicegrp
;
1077 if($fwhostsettings{'ACTION'} eq '')
1084 if (-f
"${General::swroot}/forward/reread"){
1085 print "<table border='1' rules='groups' bgcolor='lightgreen' width='100%'><form method='post'><td><div style='font-size:11pt; font-weight: bold;vertical-align: middle; '><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-face: Comic Sans MS; color: green; font-weight: bold; font-size: 14pt;'>    $Lang::tr{'fwhost reread'}</td></tr></table></form><br>";
1087 &Header
::openbox
('100%', 'left',$Lang::tr
{'fwhost menu'});
1088 print "$Lang::tr{'fwhost welcome'}";
1090 <br><br><table border='0' width='100%'>
1091 <tr><td><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newnet'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newhost'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newgrp'}' ></form></td>
1092 <td align='right'><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' ></form></td></tr>
1093 <tr><td colspan='6'><hr></td></tr></table>
1095 &Header
::closebox
();
1103 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addnet'});
1104 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1105 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1107 <table border='0' width='100%'>
1108 <tr><td width='15%'>$Lang::tr{'name'}:</td><td><form method='post'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1109 <tr><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1110 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1111 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1112 <tr><td colspan='6'><br><hr></td></tr><tr>
1114 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1116 print "<td colspan='6' align='right' ><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='updatenet'><input type='hidden' name='orgnetremark' value='$fwhostsettings{'orgnetremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'></td>";
1118 print "<td colspan='6' align='right'><input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='savenet'><input type='hidden' name='newnet' value='on'>";
1120 print "</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='resetnet'></form></td></tr></table>";
1121 &Header
::closebox
();
1127 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addhost'});
1128 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1129 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1131 <table border='0' width='100%'>
1132 <tr><td>$Lang::tr{'name'}:</td><td><form method='post' style='display:inline;'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
1133 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1134 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1135 <tr><td colspan='5'><hr></td></tr><tr>
1138 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1141 print " <td colspan='4' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='updatehost'><input type='hidden' name='orgremark' value='$fwhostsettings{'orgremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newhost' value='$fwhostsettings{'newhost'}'></form>";
1143 print " <td colspan='4' align='right'><input type='submit' name='savehost' value='$Lang::tr{'save'}' style='min-width:100px;' /><input type='hidden' name='ACTION' value='savehost' /><input type='hidden' name='newhost' value='on'>";
1145 print " </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='resethost'></form></td></tr></table>";
1146 &Header
::closebox
();
1153 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addgrp'});
1154 &General
::setup_default_networks
(\
%defaultNetworks);
1155 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1156 &General
::readhasharray
("$confignet", \
%customnetwork);
1157 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1158 &General
::readhasharray
("$confighost", \
%customhost);
1159 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1163 $checked{'check1'}{'off'} = '';
1164 $checked{'check1'}{'on'} = '';
1165 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1166 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1167 my $grp=$fwhostsettings{'grp_name'};
1168 my $rem=$fwhostsettings{'remark'};
1169 if ($fwhostsettings{'update'} eq ''){
1171 <table width='100%' border='0'>
1172 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='20'></td></tr>
1173 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1174 <tr><td colspan='2'><br><hr></td></tr></table>
1178 <table width='100%' border='0'><form method='post' style='display:inline'>
1179 <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' readonly ></td><td></td></tr>
1180 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='newrem' size='45' value='$fwhostsettings{'remark'}' style='width:98%'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td></tr></table></form>
1184 if ($fwhostsettings{'update'} eq 'on'){
1186 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1187 <table width='100%' border='0'>
1188 <tr><td width=50% valign='top'>
1189 <table width='100%' border='0'>
1190 <tr><td width='1%'><input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
1192 foreach my $network (sort keys %defaultNetworks)
1194 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1195 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1196 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1197 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1198 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1199 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1200 my $defsub1=&General
::subtocidr
($ownnet{$defsub});
1201 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1202 if ($ownnet{$defnet}){
1203 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1205 print ">$network</option>";
1208 print"</select></td></tr>";
1209 if (! -z
$confignet){
1210 print"<tr><td><input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='CUST_SRC_NET' style='min-width:185px;'>";
1211 foreach my $key (sort { ncmp
($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1212 print"<option>$customnetwork{$key}[0]</option>";
1214 print"</select></td></tr>";
1216 if (! -z
$confighost){
1217 print"<tr><td valign='top'><input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}></td><td valign='top'>$Lang::tr{'fwhost cust addr'}</td><td><select name='CUST_SRC_HOST' style='min-width:185px;'>";
1218 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1219 print"<option>$customhost{$key}[0]</option>";
1221 print"</select></td></tr>";
1225 print"</td><td valign='top'><table width='100%' border='0'>";
1227 if (! -z
$configccdnet){
1228 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_NET' style='min-width:185px;'>";
1229 foreach my $key (sort { ncmp
($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1231 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1233 print"</select></td></tr>";
1236 foreach my $key (sort { ncmp
($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1238 if ($ccdhost{$key}[33] ne ''){
1239 print"<td width='1%'><input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_HOST' style='min-width:185px;'>" if ($show eq '');
1241 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1244 if ($show eq '1'){$show='';print"</select></td></tr>";}
1246 foreach my $key (sort { ncmp
($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1247 if($ccdhost{$key}[3] eq 'net'){
1248 print"<td width='1%'><input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}></td><td valign='top'>$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='OVPN_N2N' style='min-width:185px;'>" if ($show eq '');
1250 print"<option>$ccdhost{$key}[1]</option>";
1253 if ($show eq '1'){$show='';print"</select></td></tr>";}
1255 foreach my $key (sort { ncmp
($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1256 if ($ipsecconf{$key}[3] eq 'net'){
1257 print"<td valign='top'><input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}></td><td valign='top'>$Lang::tr{'fwhost ipsec net'}</td><td><select name='IPSEC_NET' style='min-width:185px;'>" if ($show eq '');
1259 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1262 if ($show eq '1'){$show='';print"</select></td></tr>";}
1264 print"</td></tr></table>";
1265 print"<br><br><hr>";
1267 print"<table border='0' width='100%'>";
1268 print"<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=\"$fwhostsettings{'update'}\"><input type='hidden' name='ACTION' value='savegrp' ></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='resetgrp'></form></td></table>";
1269 &Header
::closebox
();
1275 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservice'});
1276 if ($fwhostsettings{'updatesrv'} eq 'on')
1278 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1279 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1280 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1283 <table width='100%' border='0'><form method='post'>
1284 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost srv_name'}:</td><td><input type='text' name='SRV_NAME' id='textbox1' value='$fwhostsettings{'SRV_NAME'}' size='24'><script>document.getElementById('textbox1').focus()</script></td></tr>
1285 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT'>
1287 foreach ("TCP","UDP","ICMP")
1289 if ($_ eq $fwhostsettings{'PROT'})
1291 print"<option selected>$_</option>";
1293 print"<option>$_</option>";
1298 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1300 &General
::readhasharray
("${General::swroot}/fwhosts/icmp-types", \
%icmptypes);
1301 print"<option>All ICMP-Types</option>";
1302 foreach my $key (sort { ncmp
($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1303 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1308 <tr><td width='10%'>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='24'></td></tr>
1309 <tr><td colspan='6'><br><hr></td></tr>
1310 <tr><td colspan='6' align='right'>
1312 if ($fwhostsettings{'updatesrv'} eq 'on')
1315 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1316 <input type='hidden' name='ACTION' value='updateservice'>
1317 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1318 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1319 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'></form>
1323 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1326 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1331 &Header
::closebox
();
1339 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost addservicegrp'});
1340 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1341 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1343 <table width='100%' border='0'><form method='post'>
1344 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1345 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1346 <tr><td colspan='2'><br><hr></tr>
1351 <table width='100%' border='0'><form method='post' style='display:inline'>
1352 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' readonly size='14'></td><td width='3%'></td></tr>
1353 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='changesrvgrpremark' ></td></tr>
1354 <tr><td colspan='3'><br><hr></td></td></tr>
1358 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1360 <form method='post'><input type='hidden' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}'><input type='hidden' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'><table border='0' width='100%'>
1361 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1363 &General
::readhasharray
("$configsrv", \
%customservice);
1364 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1366 print "<option>$customservice{$key}[0]</option>";
1370 <tr><td colspan='4'><br><br></td></tr>
1371 <tr><td colspan='4'><hr></td></tr>
1376 <table width='100%' border='0'>
1377 <tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='oldsrvgrpremark' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='saveservicegrp' ></form><form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></td></tr>
1380 &Header
::closebox
();
1385 if(! -z
$confignet){
1386 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust net'});
1387 &General
::readhasharray
("$confignet", \
%customnetwork);
1388 if (!keys %customnetwork)
1390 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1393 <table border='0' width='100%' cellspacing='0'>
1394 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1398 foreach my $key (sort {ncmp
($a,$b)} keys %customnetwork) {
1399 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1400 print" <tr bgcolor='${Header::colouryellow}'>";
1403 print" <tr bgcolor='$color{'color22'}'>";
1406 print" <tr bgcolor='$color{'color20'}'>";
1408 my $colnet="$customnetwork{$key}[1]/".&General
::subtocidr
($customnetwork{$key}[2]);
1409 print"<td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center'>".&Header
::colorize
($colnet)."</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$customnetwork{$key}[4]x</td>";
1411 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1412 <input type='hidden' name='ACTION' value='editnet'>
1413 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1414 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1415 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1416 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1419 if($customnetwork{$key}[4] == '0')
1421 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
1423 print"<td></td></tr>";
1428 &Header
::closebox
();
1434 if (! -z
$confighost){
1435 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust addr'});
1436 &General
::readhasharray
("$confighost", \
%customhost);
1437 if (!keys %customhost)
1439 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1442 <table border='0' width='100%' cellspacing='0'>
1443 <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
1447 foreach my $key (sort { ncmp
($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1448 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1449 print" <tr bgcolor='${Header::colouryellow}'>";
1450 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1451 else{ print" <tr bgcolor='$color{'color20'}'>";}
1452 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1453 $customhost{$key}[4]=~s/\s+//g;
1454 print"<td width='20%'>$customhost{$key}[0]</td><td width='20%' align='center'>".&Header
::colorize
($ip)."</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$customhost{$key}[4]x</td>";
1456 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1457 <input type='hidden' name='ACTION' value='edithost' />
1458 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1459 <input type='hidden' name='IP' value='$ip' />
1460 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1461 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1464 if($customhost{$key}[4] == '0')
1466 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delhost' /><input type='hidden' name='key' value='$customhost{$key}[0]' /></td></form></tr>";
1468 print"<td width='1%'></td></tr>";
1473 &Header
::closebox
();
1478 if(! -z
"$configgrp"){
1479 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust grp'});
1480 &General
::readhasharray
("$configgrp", \
%customgrp);
1481 &General
::readhasharray
("$configipsec", \
%ipsecconf);
1482 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1483 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1484 &General
::readhasharray
("$confighost", \
%customhost);
1485 &General
::readhasharray
("$confignet", \
%customnetwork);
1493 if (!keys %customgrp)
1495 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1497 foreach my $key (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1499 if ($helper ne $customgrp{$key}[0]){
1501 foreach my $key1 (sort { ncmp
($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp
($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1502 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1511 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr
{'fwhost empty'};}
1512 $grpname=$customgrp{$key}[0];
1513 $remark="$customgrp{$key}[1]";
1514 if($count gt 2){ print"</table>";}
1515 print "<br><b><u>$grpname</u></b> ";
1516 print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
1517 print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
1518 if($customgrp{$key}[4] == '0')
1520 print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='ACTION' value='delgrp'></form>";
1522 print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='remark' value='$remark' ><input type='hidden' name='ACTION' value='editgrp'></form>";
1523 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'ip address'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost type'}</td><td></td></tr>";
1526 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1527 print" <tr bgcolor='${Header::colouryellow}'>";
1528 }elsif ($count %2 == 0){
1529 print"<tr bgcolor='$color{'color22'}'>";
1531 print"<tr bgcolor='$color{'color20'}'>";
1533 my $ip=&getipforgroup
($customgrp{$key}[2],$customgrp{$key}[3]);
1534 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1535 print "<td width='39%' align='left'>";
1536 if($customgrp{$key}[3] eq 'Standard Network'){
1537 print &get_name
($customgrp{$key}[2])."</td>";
1539 print "$customgrp{$key}[2]</td>";
1541 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr
{'fwhost empty'}){
1542 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1544 my ($colip,$colsub) = split("/",$ip);
1545 $ip="$colip/".&General
::subtocidr
($colsub) if ($colsub);
1546 print"<td align='center'>".&Header
::colorize
($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1548 if ($delflag > '1' && $ip ne ''){
1549 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1551 print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='grpcnt' value='$customgrp{$key}[4]'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
1553 $helper=$customgrp{$key}[0];
1559 &Header
::closebox
();
1563 sub viewtableservice
1566 if(! -z
"$configsrv")
1568 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost services'});
1569 &General
::readhasharray
("$configsrv", \
%customservice);
1571 <table width='100%' border='0' cellspacing='0'>
1572 <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</b></td><td align='center'><b>$Lang::tr{'fwhost prot'}</b></td><td align='center'><b>$Lang::tr{'fwhost port'}</b></td><td align='center'><b>ICMP</b></td><td align='center'><b>$Lang::tr{'fwhost used'}</b></td><td></td><td width='3%'></td></tr>
1574 foreach my $key (sort { ncmp
($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1577 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1578 print" <tr bgcolor='${Header::colouryellow}'>";
1579 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1581 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1583 if($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1586 </td><td align='center'>$customservice{$key}[4]x</td>
1587 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} /><input type='hidden' name='ACTION' value='editservice' />
1588 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1589 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1590 <input type='hidden' name='PROT' value='$customservice{$key}[2]' /></form></td>
1592 if ($customservice{$key}[4] eq '0')
1594 print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delservice' /><input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]'></td></tr></form>";
1596 print"<td></td></tr>";
1600 &Header
::closebox
();
1603 sub viewtableservicegrp
1612 if (! -z
$configsrvgrp){
1613 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost cust srvgrp'});
1614 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1615 &General
::readhasharray
("$configsrv", \
%customservice);
1616 my $number= keys %customservicegrp;
1617 foreach my $key (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } keys %customservicegrp){
1619 if ($helper ne $customservicegrp{$key}[0]){
1621 foreach my $key1 (sort { ncmp
($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp
($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1622 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1630 $grpname=$customservicegrp{$key}[0];
1631 if ($customservicegrp{$key}[2] eq "none"){
1632 $customservicegrp{$key}[2]=$Lang::tr
{'fwhost empty'};
1636 $remark="$customservicegrp{$key}[1]";
1637 if($count >=2){print"</table>";}
1638 print "<br><b><u>$grpname</u></b> ";
1639 print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
1640 print " <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
1641 if($customservicegrp{$key}[3] == '0')
1643 print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='ACTION' value='delservicegrp'></form>";
1645 print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='SRVGRP_REMARK' value='$remark' ><input type='hidden' name='ACTION' value='editservicegrp'></form>";
1646 print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'port'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</td><td></td></tr>";
1648 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1649 print" <tr bgcolor='${Header::colouryellow}'>";
1650 }elsif ($count %2 == 0){
1651 print"<tr bgcolor='$color{'color22'}'>";
1653 print"<tr bgcolor='$color{'color20'}'>";
1655 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1656 foreach my $srv (sort keys %customservice){
1657 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1658 $protocol=$customservice{$srv}[2];
1659 $port=$customservice{$srv}[1];
1663 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1664 if ($number gt '1'){
1665 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1667 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
1668 $helper=$customservicegrp{$key}[0];
1671 &Header
::closebox
();
1677 my %hash=%{(shift)};
1678 foreach my $key (keys %hash) {
1679 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1689 my %hash=%{(shift)};
1691 foreach my $key (keys %hash) {
1692 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General
::iporsubtodec
($fwhostsettings{'SUBNET'})){
1700 my %hash=%{(shift)};
1701 &General
::readhasharray
("$confignet", \
%hash);
1702 foreach my $key (keys %hash) {
1703 if(&General
::IpInSubnet
($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1710 sub checkservicegroup
1712 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
1716 if ( ! &validhostname
($fwhostsettings{'SRVGRP_NAME'}))
1718 $errormessage.=$Lang::tr
{'fwhost err name'}."<br>";
1719 return $errormessage;
1721 #check empty selectbox
1722 if (keys %customservice lt 1)
1724 $errormessage.=$Lang::tr
{'fwhost err groupempty'}."<br>";
1726 #check if name already exists
1727 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1728 foreach my $key (keys %customservicegrp) {
1729 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1730 $errormessage.=$Lang::tr
{'fwhost err grpexist'}."<br>";
1735 #check if service already exists in group
1736 foreach my $key (keys %customservicegrp) {
1737 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1738 $errormessage.=$Lang::tr
{'fwhost err srvexist'}."<br>";
1741 return $errormessage;
1745 if ($errormessage) {
1746 &Header
::openbox
('100%', 'left', $Lang::tr
{'error messages'});
1747 print "<class name='base'>$errormessage\n";
1748 print " </class>\n";
1749 &Header
::closebox
();
1755 &Header
::openbox
('100%', 'left', $Lang::tr
{'fwhost hint'});
1756 print "<class name='base'>$hint\n";
1757 print " </class>\n";
1758 &Header
::closebox
();
1764 &General
::setup_default_networks
(\
%defaultNetworks);
1765 foreach my $network (sort keys %defaultNetworks)
1767 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1775 &General
::readhasharray
("$config",\
%hash);
1776 foreach my $key (keys %hash) {
1777 $errormessage.="lese $hash{$key}[2] und $target<br>";
1778 if($hash{$key}[2] eq $target){
1781 $errormessage.="Habe $target aus Gruppe gelöscht!<br>";
1784 &General
::writehasharray
("$config",\
%hash);
1791 if (!&validhostname
($fwhostsettings{'HOSTNAME'}))
1793 $errormessage=$errormessage.$Lang::tr
{'fwhost err name'};
1794 $fwhostsettings{'BLK_IP'}='readonly';
1795 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1796 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1798 #check if name collides with CCD Netname
1799 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1800 foreach my $key (keys %ccdnet) {
1801 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1802 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdnet'};;
1803 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1804 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1808 #check if IP collides with CCD NetIP
1809 if ($fwhostsettings{'type'} ne 'mac'){
1810 &General
::readhasharray
("$configccdnet", \
%ccdnet);
1811 foreach my $key (keys %ccdnet) {
1812 my $test=(&General
::getnetworkip
($fwhostsettings{'IP'},&General
::iporsubtocidr
($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
1813 if($ccdnet{$key}[1] eq $test){
1814 $errormessage=$errormessage.$Lang::tr
{'fwhost err isccdipnet'};
1815 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
1816 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
1817 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1822 #check if name collides with CCD Hostname
1823 &General
::readhasharray
("$configccdhost", \
%ccdhost);
1824 foreach my $key (keys %ccdhost) {
1825 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
1826 if($ip eq $fwhostsettings{'IP'}){
1827 $errormessage=$Lang::tr
{'fwhost err isccdiphost'};
1828 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1832 #check if IP collides with CCD HostIP (only hosts)
1833 if ($edit eq 'edithost')
1835 foreach my $key (keys %ccdhost) {
1836 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
1837 $errormessage=$Lang::tr
{'fwhost err isccdhost'};
1838 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
1839 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1844 #check if network with this name already exists
1845 &General
::readhasharray
("$confignet", \
%customnetwork);
1846 if (!&checkname
(\
%customnetwork))
1848 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err netexist'};
1849 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1850 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1852 #check if network ip already exists
1853 if (!&checkip
(\
%customnetwork,1))
1855 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err net'};
1856 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1858 #check if host with this name already exists
1859 &General
::readhasharray
("$confighost", \
%customhost);
1860 if (!&checkname
(\
%customhost))
1862 $errormessage.="<br>".$Lang::tr
{'fwhost err hostexist'};
1863 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
1864 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
1866 #check if host with this ip already exists
1867 if (!&checkip
(\
%customhost,2))
1869 $errormessage=$errormessage."<br>".$Lang::tr
{'fwhost err ipcheck'};
1879 #get address from IPSEC NETWORK
1880 if ($type eq 'IpSec Network'){
1881 foreach my $key (keys %ipsecconf) {
1882 if ($ipsecconf{$key}[1] eq $name){
1883 return $ipsecconf{$key}[11];
1886 &deletefromgrp
($name,$configgrp);
1889 #get address from IPSEC HOST
1890 if ($type eq 'IpSec Host'){
1891 foreach my $key (keys %ipsecconf) {
1892 if ($ipsecconf{$key}[1] eq $name){
1893 return $ipsecconf{$key}[10];
1896 &deletefromgrp
($name,$configgrp);
1899 #get address from ovpn ccd Net-2-Net
1900 if ($type eq 'OpenVPN N-2-N'){
1901 foreach my $key (keys %ccdhost) {
1902 if($ccdhost{$key}[1] eq $name){
1903 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
1904 $b=&General
::iporsubtodec
($b);
1908 &deletefromgrp
($name,$configgrp);
1911 #get address from ovpn ccd static host
1912 if ($type eq 'OpenVPN static host'){
1913 foreach my $key (keys %ccdhost) {
1914 if($ccdhost{$key}[1] eq $name){
1915 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
1916 $b=&General
::iporsubtodec
($b);
1920 &deletefromgrp
($name,$configgrp);
1923 #get address from ovpn ccd static net
1924 if ($type eq 'OpenVPN static network'){
1925 foreach my $key (keys %ccdnet) {
1926 if ($ccdnet{$key}[0] eq $name){
1927 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
1928 $b=&General
::iporsubtodec
($b);
1934 #check custom addresses
1935 if ($type eq 'Custom Host'){
1936 foreach my $key (keys %customhost) {
1937 if ($customhost{$key}[0] eq $name){
1938 my ($ip,$sub) = split("/",$customhost{$key}[2]);
1944 ##check custom networks
1945 if ($type eq 'Custom Network'){
1946 foreach my $key (keys %customnetwork) {
1947 if($customnetwork{$key}[0] eq $name){
1948 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
1953 #check standard networks
1954 if ($type eq 'Standard Network'){
1955 if ($name =~ /OpenVPN/i){
1957 &General
::readhash
("${General::swroot}/ovpn/settings",\
%ovpn);
1958 return $ovpn{'DOVPN_SUBNET'};
1960 if ($name eq 'GREEN'){
1962 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1963 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
1965 if ($name eq 'BLUE'){
1967 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1968 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
1970 if ($name eq 'ORANGE'){
1972 &General
::readhash
("${General::swroot}/ethernet/settings",\
%hash);
1973 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
1975 if ($name eq 'ALL'){
1976 return "0.0.0.0/0.0.0.0";
1978 if ($name =~ /IPsec/i){
1980 &General
::readhash
("${General::swroot}/vpn/settings",\
%hash);
1981 return $hash{'RW_NET'};
1987 if (!-f
"${General::swroot}/fwhosts/reread"){
1988 system("touch ${General::swroot}/fwhosts/reread");
1989 system("touch ${General::swroot}/forward/reread");
1994 system ("/usr/local/bin/forwardfwctrl");
1995 if ( -f
"${General::swroot}/fwhosts/reread"){
1996 system("rm ${General::swroot}/fwhosts/reread");
1997 system("rm ${General::swroot}/forward/reread");
2004 &General
::readhasharray
("$confignet", \
%customnetwork);
2005 &General
::readhasharray
("$confighost", \
%customhost);
2006 foreach my $key (sort keys %customgrp ){
2007 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2008 foreach my $key1 (sort keys %customnetwork){
2009 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2010 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2016 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2017 foreach my $key2 (sort keys %customhost){
2018 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2019 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2026 &General
::writehasharray
("$confignet", \
%customnetwork);
2027 &General
::writehasharray
("$confighost", \
%customhost);
2032 &General
::readhasharray
("$configsrv", \
%customservice);
2033 &General
::readhasharray
("$configsrvgrp", \
%customservicegrp);
2035 foreach my $key (sort keys %customservicegrp){
2036 if ($customservicegrp{$key}[0] eq $grp ){
2037 foreach my $key2 (sort keys %customservice){
2038 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2039 $customservice{$key2}[4]--;
2044 &General
::writehasharray
("$configsrv", \
%customservice);
2050 my %hash=%{(shift)};
2052 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2053 $errormessage=$Lang::tr
{'fwhost err name1'};
2055 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2056 $errormessage=$Lang::tr
{'fwhost err port'};
2059 if (! &validhostname
($fwhostsettings{'SRV_NAME'})){
2060 $errormessage="<br>".$Lang::tr
{'fwhost err name'};
2062 #change dashes with :
2063 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2065 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2066 $fwhostsettings{'SRV_PORT'} = "1:65535";
2068 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2069 $fwhostsettings{'SRV_PORT'} = "1:$2";
2071 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2072 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2074 if($fwhostsettings{'PROT'} ne 'ICMP'){
2075 $errormessage = $errormessage.&General
::validportrange
($fwhostsettings{'SRV_PORT'}, 'src');
2077 # a new service has to have a different name
2078 foreach my $key (keys %hash){
2079 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2080 $errormessage = "<br>".$Lang::tr
{'fwhost err srv exists'};
2084 return $errormessage;
2088 # Checks a hostname against RFC1035
2089 my $hostname = $_[0];
2091 # Each part should be at least two characters in length
2092 # but no more than 63 characters
2093 if (length ($hostname) < 1 || length ($hostname) > 63) {
2095 # Only valid characters are a-z, A-Z, 0-9 and -
2096 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s
]*$/) {
2098 # First character can only be a letter or a digit
2099 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2101 # Last character can only be a letter or a digit
2102 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2108 # Checks a hostname against RFC1035
2110 # Each part should be at least two characters in length
2111 # but no more than 63 characters
2112 if (length ($remark) < 1 || length ($remark) > 255) {
2114 # Only valid characters are a-z, A-Z, 0-9 and -
2115 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s
]*$/) {
2117 # First character can only be a letter or a digit
2118 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2120 # Last character can only be a letter or a digit
2121 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2125 &Header
::closebigbox
();
2126 &Header
::closepage
();