]> git.ipfire.org Git - ipfire-2.x.git/blob - html/cgi-bin/fwhosts.cgi
330b0f72d4f410e36385410e05cbf2fe28454774
[ipfire-2.x.git] / html / cgi-bin / fwhosts.cgi
1 #!/usr/bin/perl
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> #
6 # #
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. #
11 # #
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. #
16 # #
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/>. #
19 # #
20 ###############################################################################
21 use strict;
22
23 # enable only the following on debugging purpose
24 use warnings;
25 use Sort::Naturally;
26 use CGI::Carp 'fatalsToBrowser';
27 no warnings 'uninitialized';
28 require '/var/ipfire/general-functions.pl';
29 require "${General::swroot}/lang.pl";
30 require "${General::swroot}/header.pl";
31
32 my %fwhostsettings=();
33 my %customnetwork=();
34 my %customhost=();
35 my %customgrp=();
36 my %customservice=();
37 my %customservicegrp=();
38 my %ccdnet=();
39 my %ccdhost=();
40 my %ipsecconf=();
41 my %icmptypes=();
42 my %color=();
43 my %defaultNetworks=();
44 my %mainsettings=();
45 my %ownnet=();
46 my %ipsecsettings=();
47 my %fwfwd=();
48 my %fwinp=();
49 my %fwout=();
50 my %ovpnsettings=();
51
52
53 my $errormessage;
54 my $hint;
55 my $update=0;
56 my $confignet = "${General::swroot}/fwhosts/customnetworks";
57 my $confighost = "${General::swroot}/fwhosts/customhosts";
58 my $configgrp = "${General::swroot}/fwhosts/customgroups";
59 my $configccdnet = "${General::swroot}/ovpn/ccd.conf";
60 my $configccdhost = "${General::swroot}/ovpn/ovpnconfig";
61 my $configipsec = "${General::swroot}/vpn/config";
62 my $configsrv = "${General::swroot}/fwhosts/customservices";
63 my $configsrvgrp = "${General::swroot}/fwhosts/customservicegrp";
64 my $fwconfigfwd = "${General::swroot}/firewall/config";
65 my $fwconfiginp = "${General::swroot}/firewall/input";
66 my $fwconfigout = "${General::swroot}/firewall/outgoing";
67 my $configovpn = "${General::swroot}/ovpn/settings";
68 my $tdcolor='';
69 my $configipsecrw = "${General::swroot}/vpn/settings";
70
71 unless (-e $confignet) { system("touch $confignet"); }
72 unless (-e $confighost) { system("touch $confighost"); }
73 unless (-e $configgrp) { system("touch $configgrp"); }
74 unless (-e $configsrv) { system("touch $configsrv"); }
75 unless (-e $configsrvgrp) { system("touch $configsrvgrp"); }
76
77 &General::readhash("${General::swroot}/main/settings", \%mainsettings);
78 &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
79 &General::readhash("${General::swroot}/ethernet/settings", \%ownnet);
80 &General::readhash("$configovpn", \%ovpnsettings);
81 &General::readhasharray("$configipsec", \%ipsecconf);
82 &General::readhash("$configipsecrw", \%ipsecsettings);
83
84 &Header::getcgihash(\%fwhostsettings);
85
86 &Header::showhttpheaders();
87 &Header::openpage($Lang::tr{'fwhost hosts'}, 1, '');
88 &Header::openbigbox('100%', 'center');
89
90 #### JAVA SCRIPT ####
91 print<<END;
92 <script>
93 var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"];
94 var update_protocol = function() {
95 var protocol = \$("#protocol").val();
96
97 if (protocol === undefined)
98 return;
99
100 // Check if we are dealing with a protocol, that knows ports.
101 if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) {
102 \$("#PORT").show();
103 \$("#PROTOKOLL").hide();
104 } else {
105 \$("#PORT").hide();
106 \$("#PROTOKOLL").show();
107 }
108 };
109
110 \$(document).ready(function() {
111 var protocol = \$("#protocol").val();
112 \$("#protocol").change(update_protocol);
113 update_protocol();
114 // Automatically select radio buttons when corresponding
115 // dropdown menu changes.
116 \$("select").change(function() {
117 var id = \$(this).attr("name");
118 \$('#' + id).prop("checked", true);
119 });
120 });
121 </script>
122 END
123
124 ## ACTION ####
125 # Update
126 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
127 {
128 &General::readhasharray("$confignet", \%customnetwork);
129 foreach my $key (keys %customnetwork)
130 {
131 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'})
132 {
133 $fwhostsettings{'orgname'} = $customnetwork{$key}[0];
134 $fwhostsettings{'orgip'} = $customnetwork{$key}[1];
135 $fwhostsettings{'orgsub'} = $customnetwork{$key}[2];
136 $fwhostsettings{'netremark'} = $customnetwork{$key}[3];
137 $fwhostsettings{'count'} = $customnetwork{$key}[4];
138 delete $customnetwork{$key};
139
140 }
141 }
142 &General::writehasharray("$confignet", \%customnetwork);
143 $fwhostsettings{'actualize'} = 'on';
144 $fwhostsettings{'ACTION'} = 'savenet';
145 }
146 if ($fwhostsettings{'ACTION'} eq 'updatehost')
147 {
148 my ($ip,$subnet);
149 &General::readhasharray("$confighost", \%customhost);
150 foreach my $key (keys %customhost)
151 {
152 if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
153 {
154 if ($customhost{$key}[1] eq 'ip'){
155 ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
156 }else{
157 $ip = $customhost{$key}[2];
158 }
159 $fwhostsettings{'orgip'} = $ip;
160 $fwhostsettings{'count'} = $customhost{$key}[4];
161 delete $customhost{$key};
162 &General::writehasharray("$confighost", \%customhost);
163 }
164 }
165 $fwhostsettings{'actualize'} = 'on';
166 if($fwhostsettings{'orgip'}){
167 $fwhostsettings{'ACTION'} = 'savehost';
168 }else{
169 $fwhostsettings{'ACTION'} = $Lang::tr{'fwhost newhost'};
170 }
171 }
172 if ($fwhostsettings{'ACTION'} eq 'updateservice')
173 {
174 my $count=0;
175 my $needrules=0;
176 $errormessage=&checkports(\%customservice);
177 if ($fwhostsettings{'oldsrvname'} ne $fwhostsettings{'SRV_NAME'} && !&checkgroup($fwhostsettings{'SRV_NAME'})){
178 $errormessage=$Lang::tr{'fwhost err grpexist'};
179 }
180 if (!$errormessage){
181 &General::readhasharray("$configsrv", \%customservice);
182 foreach my $key (keys %customservice)
183 {
184 if ($customservice{$key}[0] eq $fwhostsettings{'oldsrvname'})
185 {
186 delete $customservice{$key};
187 &General::writehasharray("$configsrv", \%customservice);
188 last;
189 }
190 }
191 if ($fwhostsettings{'PROT'} ne 'ICMP'){
192 $fwhostsettings{'ICMP_TYPES'}='BLANK';
193 }
194 my $key1 = &General::findhasharraykey(\%customservice);
195 #find out short ICMP-TYPE
196 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
197 foreach my $key (keys %icmptypes){
198 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
199 $fwhostsettings{'ICMP_TYPES'}=$icmptypes{$key}[0];
200 }
201 }
202 foreach my $i (0 .. 4) { $customservice{$key1}[$i] = "";}
203 $customservice{$key1}[0] = $fwhostsettings{'SRV_NAME'};
204 $customservice{$key1}[1] = $fwhostsettings{'SRV_PORT'};
205 $customservice{$key1}[2] = $fwhostsettings{'PROT'};
206 $customservice{$key1}[3] = $fwhostsettings{'ICMP_TYPES'};
207 &General::writehasharray("$configsrv", \%customservice);
208 #check if we need to update firewallrules
209 if ($fwhostsettings{'SRV_NAME'} ne $fwhostsettings{'oldsrvname'}){
210 if ( ! -z $fwconfigfwd ){
211 &General::readhasharray("$fwconfigfwd", \%fwfwd);
212 foreach my $key (sort keys %fwfwd){
213 if ($fwfwd{$key}[15] eq $fwhostsettings{'oldsrvname'}){
214 $fwfwd{$key}[15] = $fwhostsettings{'SRV_NAME'};
215 }
216 }
217 &General::writehasharray("$fwconfigfwd", \%fwfwd);
218 }
219 if ( ! -z $fwconfiginp ){
220 &General::readhasharray("$fwconfiginp", \%fwinp);
221 foreach my $line (sort keys %fwinp){
222 if ($fwfwd{$line}[15] eq $fwhostsettings{'oldsrvname'}){
223 $fwfwd{$line}[15] = $fwhostsettings{'SRV_NAME'};
224 }
225 }
226 &General::writehasharray("$fwconfiginp", \%fwinp);
227 }
228 if ( ! -z $fwconfigout ){
229 &General::readhasharray("$fwconfigout", \%fwout);
230 foreach my $line (sort keys %fwout){
231 if ($fwout{$line}[15] eq $fwhostsettings{'oldsrvname'}){
232 $fwout{$line}[15] = $fwhostsettings{'SRV_NAME'};
233 }
234 }
235 &General::writehasharray("$fwconfigout", \%fwout);
236 }
237 #check if we need to update groups
238 &General::readhasharray("$configsrvgrp", \%customservicegrp);
239 foreach my $key (sort keys %customservicegrp){
240 if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
241 $customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
242 }
243 }
244 &General::writehasharray("$configsrvgrp", \%customservicegrp);
245 $needrules='on';
246 }
247 if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
248 $needrules='on';
249 }
250 if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
251 $needrules='on';
252 }
253 if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
254 $needrules='on';
255 }
256 $fwhostsettings{'SRV_NAME'} = '';
257 $fwhostsettings{'SRV_PORT'} = '';
258 $fwhostsettings{'PROT'} = '';
259 $fwhostsettings{'ICMP'} = '';
260 $fwhostsettings{'oldsrvicmp'} = '';
261 $fwhostsettings{'updatesrv'} = '';
262 }else{
263 $fwhostsettings{'SRV_NAME'} = $fwhostsettings{'oldsrvname'};
264 $fwhostsettings{'SRV_PORT'} = $fwhostsettings{'oldsrvport'};
265 $fwhostsettings{'PROT'} = $fwhostsettings{'oldsrvprot'};
266 $fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
267 $fwhostsettings{'updatesrv'}= 'on';
268 }
269 if($needrules eq 'on'){
270 &General::firewall_config_changed();
271 }
272 &addservice;
273 }
274 # save
275 if ($fwhostsettings{'ACTION'} eq 'savenet' )
276 {
277 my $needrules=0;
278 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
279 #check if all fields are set
280 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
281 {
282 $errormessage=$errormessage.$Lang::tr{'fwhost err empty'};
283 &addnet;
284 &viewtablenet;
285 }else{
286 #check valid ip
287 if (!&General::validipandmask($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'}))
288 {
289 $errormessage=$errormessage.$Lang::tr{'fwhost err addr'};
290 $fwhostsettings{'BLK_HOST'} ='readonly';
291 $fwhostsettings{'NOCHECK'} ='false';
292 $fwhostsettings{'error'} ='on';
293 }
294 #check remark
295 if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark($fwhostsettings{'NETREMARK'})){
296 $errormessage=$Lang::tr{'fwhost err remark'};
297 $fwhostsettings{'error'} ='on';
298 }
299 #check if subnet is sigle host
300 if(&General::iporsubtocidr($fwhostsettings{'SUBNET'}) eq '32')
301 {
302 $errormessage=$errormessage.$Lang::tr{'fwhost err sub32'};
303 }
304 if($fwhostsettings{'error'} ne 'on'){
305 #check if we use one of ipfire's networks (green,orange,blue)
306 if (($ownnet{'GREEN_NETADDRESS'} ne '' && $ownnet{'GREEN_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
307 {
308 $errormessage=$errormessage.$Lang::tr{'ccd err green'}."<br>";
309 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
310 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
311 }
312 if (($ownnet{'ORANGE_NETADDRESS'} ne '' && $ownnet{'ORANGE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
313 {
314 $errormessage=$errormessage.$Lang::tr{'ccd err orange'}."<br>";
315 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
316 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
317 }
318 if (($ownnet{'BLUE_NETADDRESS'} ne '' && $ownnet{'BLUE_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
319 {
320 $errormessage=$errormessage.$Lang::tr{'ccd err blue'}."<br>";
321 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
322 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
323 }
324 if (($ownnet{'RED_NETADDRESS'} ne '' && $ownnet{'RED_NETADDRESS'} ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
325 {
326 $errormessage=$errormessage.$Lang::tr{'ccd err red'}."<br>";
327 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
328 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
329 }
330 }
331 #only check plausi when no error till now
332 if (!$errormessage){
333 &plausicheck("editnet");
334 }
335 #check if network ip is part of an already used one
336 if(&checksubnet(\%customnetwork))
337 {
338 $errormessage=$errormessage.$Lang::tr{'fwhost err partofnet'};
339 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
340 }
341 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage)
342 {
343 $fwhostsettings{'actualize'} = '';
344 my $key = &General::findhasharraykey (\%customnetwork);
345 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
346 $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ;
347 $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ;
348 $customnetwork{$key}[2] = $fwhostsettings{'orgsub'};
349 $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'};
350 &General::writehasharray("$confignet", \%customnetwork);
351 undef %customnetwork;
352 }
353 if (!$errormessage){
354
355 &General::readhasharray("$confignet", \%customnetwork);
356 if ($fwhostsettings{'ACTION'} eq 'updatenet'){
357 if ($fwhostsettings{'update'} == '0'){
358 foreach my $key (keys %customnetwork) {
359 if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){
360 delete $customnetwork{$key};
361 last;
362 }
363 }
364 }
365 }
366 #get count if actualize is 'on'
367 if($fwhostsettings{'actualize'} eq 'on'){
368 $fwhostsettings{'actualize'} = '';
369 #check if we need to reload rules
370 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
371 $needrules='on';
372 }
373 if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
374 #check if we need to update groups
375 &General::readhasharray("$configgrp", \%customgrp);
376 foreach my $key (sort keys %customgrp){
377 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
378 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
379 last;
380 }
381 }
382 &General::writehasharray("$configgrp", \%customgrp);
383 #check if we need to update firewallrules
384 if ( ! -z $fwconfigfwd ){
385 &General::readhasharray("$fwconfigfwd", \%fwfwd);
386 foreach my $line (sort keys %fwfwd){
387 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
388 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
389 }
390 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
391 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
392 }
393 }
394 &General::writehasharray("$fwconfigfwd", \%fwfwd);
395 }
396 if ( ! -z $fwconfiginp ){
397 &General::readhasharray("$fwconfiginp", \%fwinp);
398 foreach my $line (sort keys %fwinp){
399 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
400 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
401 }
402 }
403 &General::writehasharray("$fwconfiginp", \%fwinp);
404 }
405 }
406 }
407 my $key = &General::findhasharraykey (\%customnetwork);
408 foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";}
409 $fwhostsettings{'SUBNET'} = &General::iporsubtocidr($fwhostsettings{'SUBNET'});
410 $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'};
411 #convert ip when leading '0' in byte
412 $fwhostsettings{'IP'} =&General::ip2dec($fwhostsettings{'IP'});
413 $fwhostsettings{'IP'} =&General::dec2ip($fwhostsettings{'IP'});
414 $customnetwork{$key}[1] = &General::getnetworkip($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ;
415 $customnetwork{$key}[2] = &General::iporsubtodec($fwhostsettings{'SUBNET'}) ;
416 $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'};
417 &General::writehasharray("$confignet", \%customnetwork);
418 $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
419 undef %customnetwork;
420 $fwhostsettings{'HOSTNAME'}='';
421 $fwhostsettings{'IP'}='';
422 $fwhostsettings{'SUBNET'}='';
423 $fwhostsettings{'NETREMARK'}='';
424 #check if an edited net affected groups and need to reload rules
425 if ($needrules eq 'on'){
426 &General::firewall_config_changed();
427 }
428 &addnet;
429 &viewtablenet;
430 }else {
431 &addnet;
432 &viewtablenet;
433 }
434 }
435 }
436 if ($fwhostsettings{'ACTION'} eq 'savehost')
437 {
438 my $needrules=0;
439 if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};}
440 $fwhostsettings{'SUBNET'}='32';
441 #check if all fields are set
442 if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '')
443 {
444 $errormessage=$errormessage.$Lang::tr{'fwhost err empty'};
445 $fwhostsettings{'ACTION'} = 'edithost';
446 }else{
447 if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){
448 $fwhostsettings{'type'} = 'mac';
449 }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){
450 $fwhostsettings{'type'} = 'ip';
451 }else{
452 $fwhostsettings{'type'} = '';
453 $errormessage=$Lang::tr{'fwhost err ipmac'};
454 }
455 #check remark
456 if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark($fwhostsettings{'HOSTREMARK'})){
457 $errormessage=$Lang::tr{'fwhost err remark'};
458 }
459 #CHECK IP-PART
460 if ($fwhostsettings{'type'} eq 'ip'){
461 #check for subnet
462 if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){
463 if($fwhostsettings{'type'} eq 'ip' && !&General::validipandmask($fwhostsettings{'IP'}."/32"))
464 {
465 $errormessage.=$errormessage.$Lang::tr{'fwhost err ip'};
466 $fwhostsettings{'error'}='on';
467 }
468 }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){
469 $errormessage=$errormessage.$Lang::tr{'fwhost err ipwithsub'};
470 $fwhostsettings{'error'}='on';
471 }
472 #check if net or broadcast
473 my @tmp= split (/\./,$fwhostsettings{'IP'});
474 if (($tmp[3] eq "0") || ($tmp[3] eq "255")){
475 $errormessage=$Lang::tr{'fwhost err hostip'};
476 }
477 }
478 #only check plausi when no error till now
479 if (!$errormessage){
480 &plausicheck("edithost");
481 }
482 if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){
483 $fwhostsettings{'actualize'} = '';
484 my $key = &General::findhasharraykey (\%customhost);
485 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
486 $customhost{$key}[0] = $fwhostsettings{'orgname'} ;
487 $customhost{$key}[1] = $fwhostsettings{'type'} ;
488 if($customhost{$key}[1] eq 'ip'){
489 $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
490 }else{
491 $customhost{$key}[2] = $fwhostsettings{'orgip'};
492 }
493 $customhost{$key}[3] = $fwhostsettings{'orgremark'};
494 &General::writehasharray("$confighost", \%customhost);
495 undef %customhost;
496 }
497 if (!$errormessage){
498 #get count if host was edited
499 if($fwhostsettings{'actualize'} eq 'on'){
500 if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){
501 $needrules='on';
502 }
503 if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){
504 #check if we need to update groups
505 &General::readhasharray("$configgrp", \%customgrp);
506 foreach my $key (sort keys %customgrp){
507 if($customgrp{$key}[2] eq $fwhostsettings{'orgname'}){
508 $customgrp{$key}[2]=$fwhostsettings{'HOSTNAME'};
509 }
510 }
511 &General::writehasharray("$configgrp", \%customgrp);
512 #check if we need to update firewallrules
513 if ( ! -z $fwconfigfwd ){
514 &General::readhasharray("$fwconfigfwd", \%fwfwd);
515 foreach my $line (sort keys %fwfwd){
516 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
517 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
518 }
519 if ($fwfwd{$line}[6] eq $fwhostsettings{'orgname'}){
520 $fwfwd{$line}[6] = $fwhostsettings{'HOSTNAME'};
521 }
522 }
523 &General::writehasharray("$fwconfigfwd", \%fwfwd);
524 }
525 if ( ! -z $fwconfiginp ){
526 &General::readhasharray("$fwconfiginp", \%fwinp);
527 foreach my $line (sort keys %fwinp){
528 if ($fwfwd{$line}[4] eq $fwhostsettings{'orgname'}){
529 $fwfwd{$line}[4] = $fwhostsettings{'HOSTNAME'};
530 }
531 }
532 &General::writehasharray("$fwconfiginp", \%fwinp);
533 }
534 }
535 }
536 my $key = &General::findhasharraykey (\%customhost);
537 foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";}
538 $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ;
539 $customhost{$key}[1] = $fwhostsettings{'type'} ;
540 if ($fwhostsettings{'type'} eq 'ip'){
541 #convert ip when leading '0' in byte
542 $fwhostsettings{'IP'}=&General::ip2dec($fwhostsettings{'IP'});
543 $fwhostsettings{'IP'}=&General::dec2ip($fwhostsettings{'IP'});
544 $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'});
545 }else{
546 $customhost{$key}[2] = $fwhostsettings{'IP'};
547 }
548 $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'};
549 &General::writehasharray("$confighost", \%customhost);
550 undef %customhost;
551 $fwhostsettings{'HOSTNAME'}='';
552 $fwhostsettings{'IP'}='';
553 $fwhostsettings{'type'}='';
554 $fwhostsettings{'HOSTREMARK'}='';
555 #check if we need to update rules while host was edited
556 if($needrules eq 'on'){
557 &General::firewall_config_changed();
558 }
559 &addhost;
560 &viewtablehost;
561 }else{
562 &addhost;
563 &viewtablehost;
564 }
565 }
566 }
567 if ($fwhostsettings{'ACTION'} eq 'savegrp')
568 {
569 my $grp=$fwhostsettings{'grp_name'};
570 my $rem=$fwhostsettings{'remark'};
571 my $count;
572 my $type;
573 my $updcounter='off';
574 my @target;
575 my @newgrp;
576 &General::readhasharray("$configgrp", \%customgrp);
577 &General::readhasharray("$confignet", \%customnetwork);
578 &General::readhasharray("$confighost", \%customhost);
579 &General::readhasharray("$fwconfigfwd", \%fwfwd);
580 &General::readhasharray("$fwconfiginp", \%fwinp);
581 &General::readhasharray("$fwconfigout", \%fwout);
582 #check name
583 if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};}
584 #check existing name
585 if (!&checkgroup($grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr{'fwhost err grpexist'};}
586 #check remark
587 if ($rem ne '' && !&validremark($rem) && $fwhostsettings{'update'} ne 'on'){
588 $errormessage.=$Lang::tr{'fwhost err remark'};
589 }
590 if ($fwhostsettings{'update'} eq 'on'){
591 #check standard networks
592 if ($fwhostsettings{'grp2'} eq 'std_net'){
593 @target=$fwhostsettings{'DEFAULT_SRC_ADR'};
594 $type='Standard Network';
595 }
596 #check custom networks
597 if ($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} ne ''){
598 @target=$fwhostsettings{'CUST_SRC_NET'};
599 $updcounter='net';
600 $type='Custom Network';
601 }elsif($fwhostsettings{'grp2'} eq 'cust_net' && $fwhostsettings{'CUST_SRC_NET'} eq ''){
602 $errormessage=$Lang::tr{'fwhost err groupempty'}."<br>";
603 $fwhostsettings{'grp_name'}='';
604 $fwhostsettings{'remark'}='';
605 }
606 #check custom addresses
607 if ($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} ne ''){
608 @target=$fwhostsettings{'CUST_SRC_HOST'};
609 $updcounter='host';
610 $type='Custom Host';
611 }elsif($fwhostsettings{'grp2'} eq 'cust_host' && $fwhostsettings{'CUST_SRC_HOST'} eq ''){
612 $errormessage=$Lang::tr{'fwhost err groupempty'}."<br>";
613 $fwhostsettings{'grp_name'}='';
614 $fwhostsettings{'remark'}='';
615 }
616 #get address from ovpn ccd static net
617 if ($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} ne ''){
618 @target=$fwhostsettings{'OVPN_CCD_NET'};
619 $type='OpenVPN static network';
620 }elsif($fwhostsettings{'grp2'} eq 'ovpn_net' && $fwhostsettings{'OVPN_CCD_NET'} eq ''){
621 $errormessage=$Lang::tr{'fwhost err groupempty'};
622 $fwhostsettings{'grp_name'}='';
623 $fwhostsettings{'remark'}='';
624 }
625 #get address from ovpn ccd static host
626 if ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} ne ''){
627 @target=$fwhostsettings{'OVPN_CCD_HOST'};
628 $type='OpenVPN static host';
629 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_host' && $fwhostsettings{'OVPN_CCD_HOST'} eq ''){
630 $errormessage=$Lang::tr{'fwhost err groupempty'};
631 }
632 #get address from ovpn ccd Net-2-Net
633 if ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} ne ''){
634 @target=$fwhostsettings{'OVPN_N2N'};
635 $type='OpenVPN N-2-N';
636 }elsif ($fwhostsettings{'grp2'} eq 'ovpn_n2n' && $fwhostsettings{'OVPN_N2N'} eq ''){
637 $errormessage=$Lang::tr{'fwhost err groupempty'};
638 $fwhostsettings{'grp_name'}='';
639 $fwhostsettings{'remark'}='';
640 }
641 #get address from IPSEC HOST
642 if ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} ne ''){
643 @target=$fwhostsettings{'IPSEC_HOST'};
644 $type='IpSec Host';
645 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_host' && $fwhostsettings{'IPSEC_HOST'} eq ''){
646 $errormessage=$Lang::tr{'fwhost err groupempty'};
647 $fwhostsettings{'grp_name'}='';
648 $fwhostsettings{'remark'}='';
649 }
650 #get address from IPSEC NETWORK
651 if ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} ne ''){
652 @target=$fwhostsettings{'IPSEC_NET'};
653 $type='IpSec Network';
654 }elsif ($fwhostsettings{'grp2'} eq 'ipsec_net' && $fwhostsettings{'IPSEC_NET'} eq ''){
655 $errormessage=$Lang::tr{'fwhost err groupempty'};
656 $fwhostsettings{'grp_name'}='';
657 $fwhostsettings{'remark'}='';
658 }
659 #check if host/net exists in grp
660
661 my $test="$grp,$fwhostsettings{'oldremark'},@target";
662 foreach my $key (keys %customgrp) {
663 my $test1="$customgrp{$key}[0],$customgrp{$key}[1],$customgrp{$key}[2]";
664 if ($test1 eq $test){
665 $errormessage=$Lang::tr{'fwhost err isingrp'};
666 $fwhostsettings{'update'} = 'on';
667 }
668 }
669 }
670
671 if (!$errormessage){
672 #on first save, we have an empty @target, so fill it with nothing
673 my $targetvalues=@target;
674 if ($targetvalues == '0'){
675 @target="none";
676 }
677 #on update, we have to delete the dummy entry
678 foreach my $key (keys %customgrp){
679 if ($customgrp{$key}[0] eq $grp && $customgrp{$key}[2] eq "none"){
680 delete $customgrp{$key};
681 last;
682 }
683 }
684 &General::writehasharray("$configgrp", \%customgrp);
685 &General::readhasharray("$configgrp", \%customgrp);
686 #create array with new lines
687 foreach my $line (@target){
688 push (@newgrp,"$grp,$rem,$line");
689 }
690 #append new entries
691 my $key = &General::findhasharraykey (\%customgrp);
692 foreach my $line (@newgrp){
693 foreach my $i (0 .. 3) { $customgrp{$key}[$i] = "";}
694 my ($a,$b,$c,$d) = split (",",$line);
695 $customgrp{$key}[0] = $a;
696 $customgrp{$key}[1] = $b;
697 $customgrp{$key}[2] = $c;
698 $customgrp{$key}[3] = $type;
699 }
700 &General::writehasharray("$configgrp", \%customgrp);
701 #update counter in Host/Net
702 $fwhostsettings{'update'}='on';
703 }
704 #check if ruleupdate is needed
705 my $netgrpcount=0;
706 $netgrpcount=&getnetcount($grp);
707 if($netgrpcount > 0 )
708 {
709 &General::firewall_config_changed();
710 }
711 &addgrp;
712 &viewtablegrp;
713 }
714 if ($fwhostsettings{'ACTION'} eq 'saveservice')
715 {
716 my $ICMP;
717 &General::readhasharray("$configsrv", \%customservice );
718 &General::readhasharray("$configgrp", \%customgrp);
719 $errormessage=&checkports(\%customservice);
720 if ($fwhostsettings{'PROT'} eq 'ICMP'){
721 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
722 foreach my $key (keys %icmptypes){
723 if ("$icmptypes{$key}[0] ($icmptypes{$key}[1])" eq $fwhostsettings{'ICMP_TYPES'}){
724 $ICMP=$icmptypes{$key}[0];
725 }
726 }
727 }
728 if($ICMP eq ''){$ICMP=$fwhostsettings{'ICMP_TYPES'};}
729 if ($fwhostsettings{'PROT'} ne 'ICMP'){$ICMP='BLANK';}
730 #Check if a group with the same name already exists
731 if (!&checkgroup($fwhostsettings{'SRV_NAME'})){
732 $errormessage = $Lang::tr{'fwhost err grpexist'};
733 }
734 if (!$errormessage){
735 my $key = &General::findhasharraykey (\%customservice);
736 foreach my $i (0 .. 4) { $customservice{$key}[$i] = "";}
737 $customservice{$key}[0] = $fwhostsettings{'SRV_NAME'};
738 $customservice{$key}[1] = $fwhostsettings{'SRV_PORT'};
739 $customservice{$key}[2] = $fwhostsettings{'PROT'};
740 $customservice{$key}[3] = $ICMP;
741 &General::writehasharray("$configsrv", \%customservice );
742 #reset fields
743 $fwhostsettings{'SRV_NAME'}='';
744 $fwhostsettings{'SRV_PORT'}='';
745 $fwhostsettings{'PROT'}='';
746 $fwhostsettings{'ICMP_TYPES'}='';
747 }
748 &addservice;
749 }
750 if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
751 {
752 my $prot;
753 my $port;
754 my $count=0;
755 my $tcpcounter=0;
756 my $udpcounter=0;
757 &General::readhasharray("$configsrvgrp", \%customservicegrp );
758 &General::readhasharray("$configsrv", \%customservice );
759 $errormessage=&checkservicegroup;
760 #Check if we have more than 15 services from one Protocol in the group
761 #iptables can only handle 15 ports/portranges via multiport
762 foreach my $key (keys %customservicegrp){
763 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
764 foreach my $key1 (keys %customservice){
765 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
766 $tcpcounter++ if $customservice{$key1}[2] eq 'TCP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
767 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0];
768 $udpcounter++ if $customservice{$key1}[2] eq 'UDP' && $customservicegrp{$key}[2] eq $customservice{$key1}[0] && $customservice{$key1}[1] =~m/:/i;
769 }
770 }
771 }
772 if ($tcpcounter > 15){
773 $errormessage=$Lang::tr{'fwhost err maxservicetcp'};
774 }
775 if ($udpcounter > 15){
776 $errormessage=$Lang::tr{'fwhost err maxserviceudp'};
777 }
778 $tcpcounter=0;
779 $udpcounter=0;
780 #check remark
781 if ($fwhostsettings{'SRVGRP_REMARK'} ne '' && !&validremark($fwhostsettings{'SRVGRP_REMARK'})){
782 $errormessage .= $Lang::tr{'fwhost err remark'};
783 }
784 #Check if there is already a service with the same name
785 if(!&checkservice($fwhostsettings{'SRVGRP_NAME'})){
786 $errormessage .= $Lang::tr{'fwhost err srv exists'};
787 }
788 if (!$errormessage){
789 #on first save, we have to enter a dummy value
790 if ($fwhostsettings{'CUST_SRV'} eq ''){
791 $fwhostsettings{'CUST_SRV'}='none';
792 }
793 #on update, we have to delete the dummy entry
794 foreach my $key (keys %customservicegrp){
795 if ($customservicegrp{$key}[2] eq 'none'){
796 delete $customservicegrp{$key};
797 last;
798 }
799 }
800 &General::writehasharray("$configsrvgrp", \%customservicegrp );
801 #check if remark has also changed
802 if ($fwhostsettings{'SRVGRP_REMARK'} ne $fwhostsettings{'oldsrvgrpremark'} && $fwhostsettings{'updatesrvgrp'} eq 'on')
803 {
804 foreach my $key (keys %customservicegrp)
805 {
806 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvgrpremark'})
807 {
808 $customservicegrp{$key}[1]='';
809 $customservicegrp{$key}[1]=$fwhostsettings{'SRVGRP_REMARK'};
810 }
811 }
812 }
813 my $key = &General::findhasharraykey (\%customservicegrp);
814 foreach my $i (0 .. 2) { $customservice{$key}[$i] = "";}
815 $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
816 $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
817 $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
818 &General::writehasharray("$configsrvgrp", \%customservicegrp );
819 $fwhostsettings{'updatesrvgrp'}='on';
820 }
821 if ($count gt 0){
822 &General::firewall_config_changed();
823 }
824 &addservicegrp;
825 &viewtableservicegrp;
826 }
827 # edit
828 if ($fwhostsettings{'ACTION'} eq 'editnet')
829 {
830 &addnet;
831 &viewtablenet;
832 }
833 if ($fwhostsettings{'ACTION'} eq 'edithost')
834 {
835 &addhost;
836 &viewtablehost;
837 }
838 if ($fwhostsettings{'ACTION'} eq 'editgrp')
839 {
840 $fwhostsettings{'update'}='on';
841 &addgrp;
842 &viewtablegrp;
843 }
844 if ($fwhostsettings{'ACTION'} eq 'editservice')
845 {
846 $fwhostsettings{'updatesrv'}='on';
847 &addservice;
848 }
849 if ($fwhostsettings{'ACTION'} eq 'editservicegrp')
850 {
851 $fwhostsettings{'updatesrvgrp'} = 'on';
852 &addservicegrp;
853 &viewtableservicegrp;
854 }
855 # reset
856 if ($fwhostsettings{'ACTION'} eq 'resetnet')
857 {
858 $fwhostsettings{'HOSTNAME'} ="";
859 $fwhostsettings{'IP'} ="";
860 $fwhostsettings{'SUBNET'} ="";
861 &showmenu;
862 }
863 if ($fwhostsettings{'ACTION'} eq 'resethost')
864 {
865 $fwhostsettings{'HOSTNAME'} ="";
866 $fwhostsettings{'IP'} ="";
867 $fwhostsettings{'type'} ="";
868 &showmenu;
869 }
870 if ($fwhostsettings{'ACTION'} eq 'resetgrp')
871 {
872 $fwhostsettings{'grp_name'} ="";
873 $fwhostsettings{'remark'} ="";
874 &showmenu;
875 }
876 # delete
877 if ($fwhostsettings{'ACTION'} eq 'delnet')
878 {
879 &General::readhasharray("$confignet", \%customnetwork);
880 foreach my $key (keys %customnetwork) {
881 if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){
882 delete $customnetwork{$key};
883 &General::writehasharray("$confignet", \%customnetwork);
884 last;
885 }
886 }
887 &addnet;
888 &viewtablenet;
889 }
890 if ($fwhostsettings{'ACTION'} eq 'delhost')
891 {
892 &General::readhasharray("$confighost", \%customhost);
893 foreach my $key (keys %customhost) {
894 if($fwhostsettings{'key'} eq $customhost{$key}[0]){
895 delete $customhost{$key};
896 &General::writehasharray("$confighost", \%customhost);
897 last;
898 }
899 }
900 &addhost;
901 &viewtablehost;
902 }
903 if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
904 {
905 my $grpremark;
906 my $grpname;
907 &General::readhasharray("$configgrp", \%customgrp);
908 foreach my $key (keys %customgrp){
909 if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
910 #decrease count from source host/net
911 if ($customgrp{$key}[3] eq 'Custom Network'){
912 &General::readhasharray("$confignet", \%customnetwork);
913 foreach my $key1 (keys %customnetwork){
914 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
915 $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
916 last;
917 }
918 }
919 &General::writehasharray("$confignet", \%customnetwork);
920 }
921 if ($customgrp{$key}[3] eq 'Custom Host'){
922 &General::readhasharray("$confighost", \%customhost);
923 foreach my $key1 (keys %customhost){
924 if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
925 $customhost{$key1}[4] = $customhost{$key1}[4]-1;
926 last;
927 }
928 }
929 &General::writehasharray("$confighost", \%customhost);
930 }
931 $grpname=$customgrp{$key}[0];
932 $grpremark=$customgrp{$key}[1];
933 delete $customgrp{$key};
934 }
935 }
936 &General::writehasharray("$configgrp", \%customgrp);
937 if ($fwhostsettings{'grpcnt'} > 0){
938 &General::firewall_config_changed();
939 }
940 if ($fwhostsettings{'update'} eq 'on'){
941 $fwhostsettings{'remark'}= $grpremark;
942 $fwhostsettings{'grp_name'}=$grpname;
943 }
944 &addgrp;
945 &viewtablegrp;
946 }
947 if ($fwhostsettings{'ACTION'} eq 'delgrp')
948 {
949 &General::readhasharray("$configgrp", \%customgrp);
950 &decrease($fwhostsettings{'grp_name'});
951 foreach my $key (sort keys %customgrp)
952 {
953 if($customgrp{$key}[0] eq $fwhostsettings{'grp_name'})
954 {
955 delete $customgrp{$key};
956 }
957 }
958 &General::writehasharray("$configgrp", \%customgrp);
959 $fwhostsettings{'grp_name'}='';
960 &addgrp;
961 &viewtablegrp;
962 }
963 if ($fwhostsettings{'ACTION'} eq 'delservice')
964 {
965 &General::readhasharray("$configsrv", \%customservice);
966 foreach my $key (keys %customservice) {
967 if($customservice{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
968 delete $customservice{$key};
969 &General::writehasharray("$configsrv", \%customservice);
970 last;
971 }
972 }
973 $fwhostsettings{'SRV_NAME'}='';
974 $fwhostsettings{'SRV_PORT'}='';
975 $fwhostsettings{'PROT'}='';
976 &addservice;
977 }
978 if ($fwhostsettings{'ACTION'} eq 'delservicegrp')
979 {
980 &General::readhasharray("$configsrvgrp", \%customservicegrp);
981 &decreaseservice($fwhostsettings{'SRVGRP_NAME'});
982 foreach my $key (sort keys %customservicegrp)
983 {
984 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
985 {
986 delete $customservicegrp{$key};
987 }
988 }
989 &General::writehasharray("$configsrvgrp", \%customservicegrp);
990 $fwhostsettings{'SRVGRP_NAME'}='';
991 &addservicegrp;
992 &viewtableservicegrp;
993 }
994 if ($fwhostsettings{'ACTION'} eq 'delgrpservice')
995 {
996 my $grpname;
997 my $grpremark;
998 &General::readhasharray("$configsrvgrp", \%customservicegrp);
999 &General::readhasharray("$configsrv", \%customservice);
1000 foreach my $key (keys %customservicegrp){
1001 if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
1002 {
1003 #decrease count from source service
1004 foreach my $key1 (sort keys %customservice){
1005 if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
1006 $customservice{$key1}[4]--;
1007 last;
1008 }
1009 }
1010 $grpname=$customservicegrp{$key}[0];
1011 $grpremark=$customservicegrp{$key}[1];
1012 delete $customservicegrp{$key};
1013 }
1014 }
1015 &General::writehasharray("$configsrv", \%customservice);
1016 &General::writehasharray("$configsrvgrp", \%customservicegrp);
1017 &General::firewall_config_changed();
1018 if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
1019 $fwhostsettings{'SRVGRP_NAME'}=$grpname;
1020 $fwhostsettings{'SRVGRP_REMARK'}=$grpremark;
1021 }
1022 &addservicegrp;
1023 &viewtableservicegrp;
1024
1025 }
1026 if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newnet'})
1027 {
1028 &addnet;
1029 &viewtablenet;
1030 }
1031 if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newhost'})
1032 {
1033 &addhost;
1034 &viewtablehost;
1035 }
1036 if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newgrp'})
1037 {
1038 &addgrp;
1039 &viewtablegrp;
1040 }
1041 if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newservice'})
1042 {
1043 &addservice;
1044 }
1045 if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newservicegrp'})
1046 {
1047 &addservicegrp;
1048 &viewtableservicegrp;
1049 }
1050 if ($fwhostsettings{'ACTION'} eq 'changegrpremark')
1051 {
1052 &General::readhasharray("$configgrp", \%customgrp);
1053 if ($fwhostsettings{'oldrem'} ne $fwhostsettings{'newrem'} && (&validremark($fwhostsettings{'newrem'}) || $fwhostsettings{'newrem'} eq '')){
1054 foreach my $key (sort keys %customgrp)
1055 {
1056 if($customgrp{$key}[0] eq $fwhostsettings{'grp'} && $customgrp{$key}[1] eq $fwhostsettings{'oldrem'})
1057 {
1058 $customgrp{$key}[1]='';
1059 $customgrp{$key}[1]=$fwhostsettings{'newrem'};
1060 }
1061 }
1062 &General::writehasharray("$configgrp", \%customgrp);
1063 $fwhostsettings{'update'}='on';
1064 $fwhostsettings{'remark'}=$fwhostsettings{'newrem'};
1065 }else{
1066 $errormessage=$Lang::tr{'fwhost err remark'};
1067 $fwhostsettings{'remark'}=$fwhostsettings{'oldrem'};
1068 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1069 $fwhostsettings{'update'} = 'on';
1070 }
1071 $fwhostsettings{'grp_name'}=$fwhostsettings{'grp'};
1072 &addgrp;
1073 &viewtablegrp;
1074 }
1075 if ($fwhostsettings{'ACTION'} eq 'changesrvgrpremark')
1076 {
1077 &General::readhasharray("$configsrvgrp", \%customservicegrp );
1078 if ($fwhostsettings{'oldsrvrem'} ne $fwhostsettings{'newsrvrem'} && (&validremark($fwhostsettings{'newsrvrem'}) || $fwhostsettings{'newsrvrem'} eq '')){
1079 foreach my $key (sort keys %customservicegrp)
1080 {
1081 if($customservicegrp{$key}[0] eq $fwhostsettings{'srvgrp'} && $customservicegrp{$key}[1] eq $fwhostsettings{'oldsrvrem'})
1082 {
1083 $customservicegrp{$key}[1]='';
1084 $customservicegrp{$key}[1]=$fwhostsettings{'newsrvrem'};
1085 }
1086 }
1087 &General::writehasharray("$configsrvgrp", \%customservicegrp);
1088 $fwhostsettings{'updatesrvgrp'}='on';
1089 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'newsrvrem'};
1090 }elsif($fwhostsettings{'oldsrvrem'} eq $fwhostsettings{'newsrvrem'}){
1091 &addservicegrp;
1092 &viewtableservicegrp;
1093 }else{
1094 $errormessage=$Lang::tr{'fwhost err remark'};
1095 $fwhostsettings{'SRVGRP_REMARK'}=$fwhostsettings{'oldsrvrem'};
1096 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1097 $fwhostsettings{'updatesrvgrp'} = 'on';
1098 }
1099 $fwhostsettings{'SRVGRP_NAME'}=$fwhostsettings{'srvgrp'};
1100 &addservicegrp;
1101 &viewtableservicegrp;
1102 }
1103 ### VIEW ###
1104 if($fwhostsettings{'ACTION'} eq '')
1105 {
1106 &showmenu;
1107 }
1108 ### FUNCTIONS ###
1109 sub showmenu {
1110 &Header::openbox('100%', 'left',$Lang::tr{'fwhost menu'});
1111 print "$Lang::tr{'fwhost welcome'}";
1112 print<<END;
1113 <br><br><table border='0' width='100%'>
1114 <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>
1115 <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>
1116 <tr><td colspan='6'><hr></td></tr></table>
1117 END
1118 &Header::closebox();
1119
1120 }
1121 # Add
1122 sub addnet
1123 {
1124 &error;
1125 &showmenu;
1126 &Header::openbox('100%', 'left', $Lang::tr{'fwhost addnet'});
1127 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1128 $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
1129 print<<END;
1130 <table border='0' width='100%'>
1131 <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>
1132 <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>
1133 <tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
1134 <tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
1135 <tr><td colspan='6'><br><hr></td></tr><tr>
1136 END
1137 if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
1138 {
1139 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>";
1140 }else{
1141 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'>";
1142 }
1143 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>";
1144 &Header::closebox();
1145 }
1146 sub addhost
1147 {
1148 &error;
1149 &showmenu;
1150 &Header::openbox('100%', 'left', $Lang::tr{'fwhost addhost'});
1151 $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
1152 $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
1153 print<<END;
1154 <table border='0' width='100%'>
1155 <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>
1156 <tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
1157 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
1158 <tr><td colspan='5'><hr></td></tr><tr>
1159 END
1160
1161 if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
1162 {
1163
1164 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>";
1165 }else{
1166 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'>";
1167 }
1168 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>";
1169 &Header::closebox();
1170 }
1171 sub addgrp
1172 {
1173 &hint;
1174 &error;
1175 &showmenu;
1176 &Header::openbox('100%', 'left', $Lang::tr{'fwhost addgrp'});
1177 &General::setup_default_networks(\%defaultNetworks);
1178 &General::readhasharray("$configccdnet", \%ccdnet);
1179 &General::readhasharray("$confignet", \%customnetwork);
1180 &General::readhasharray("$configccdhost", \%ccdhost);
1181 &General::readhasharray("$confighost", \%customhost);
1182 &General::readhasharray("$configipsec", \%ipsecconf);
1183
1184 my %checked=();
1185 my $show='';
1186 $checked{'check1'}{'off'} = '';
1187 $checked{'check1'}{'on'} = '';
1188 $checked{'grp2'}{$fwhostsettings{'grp2'}} = 'CHECKED';
1189 $fwhostsettings{'oldremark'}=$fwhostsettings{'remark'};
1190 my $grp=$fwhostsettings{'grp_name'};
1191 my $rem=$fwhostsettings{'remark'};
1192 if ($fwhostsettings{'update'} eq ''){
1193 print<<END;
1194 <table width='100%' border='0'>
1195 <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>
1196 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
1197 <tr><td colspan='2'><br><hr></td></tr></table>
1198 END
1199 }else{
1200 print<<END;
1201 <table width='100%' border='0'><form method='post' style='display:inline'>
1202 <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>
1203 <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>
1204 <hr>
1205 END
1206 }
1207 if ($fwhostsettings{'update'} eq 'on'){
1208 print<<END;
1209 <form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
1210 <table width='100%' border='0'>
1211 <tr><td width=50% valign='top'>
1212 <table width='100%' border='0'>
1213 <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;'>
1214 END
1215 foreach my $network (sort keys %defaultNetworks)
1216 {
1217 next if($defaultNetworks{$network}{'LOCATION'} eq "IPCOP");
1218 next if($defaultNetworks{$network}{'NAME'} eq "IPFire");
1219 print "<option value='$defaultNetworks{$network}{'NAME'}'";
1220 print " selected='selected'" if ($fwhostsettings{'DEFAULT_SRC_ADR'} eq $defaultNetworks{$network}{'NAME'});
1221 my $defnet="$defaultNetworks{$network}{'NAME'}_NETADDRESS";
1222 my $defsub="$defaultNetworks{$network}{'NAME'}_NETMASK";
1223 my $defsub1=&General::subtocidr($ownnet{$defsub});
1224 $ownnet{$defnet}='' if ($defaultNetworks{$network}{'NAME'} eq 'RED');
1225 if ($ownnet{$defnet}){
1226 print ">$network ($ownnet{$defnet}/$defsub1)</option>";
1227 }else{
1228 print ">$network</option>";
1229 }
1230 }
1231 print"</select></td></tr>";
1232 if (! -z $confignet){
1233 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;'>";
1234 foreach my $key (sort { ncmp($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
1235 print"<option>$customnetwork{$key}[0]</option>";
1236 }
1237 print"</select></td></tr>";
1238 }
1239 if (! -z $confighost){
1240 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;'>";
1241 foreach my $key (sort { ncmp($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
1242 print"<option>$customhost{$key}[0]</option>";
1243 }
1244 print"</select></td></tr>";
1245 }
1246 print"</table>";
1247 #Inner table right
1248 print"</td><td valign='top'><table width='100%' border='0'>";
1249 #OVPN networks
1250 if (! -z $configccdnet){
1251 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;'>";
1252 foreach my $key (sort { ncmp($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
1253 {
1254 print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
1255 }
1256 print"</select></td></tr>";
1257 }
1258 #OVPN clients
1259 foreach my $key (sort { ncmp($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
1260 {
1261 if ($ccdhost{$key}[33] ne ''){
1262 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 '');
1263 $show='1';
1264 print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
1265 }
1266 }
1267 if ($show eq '1'){$show='';print"</select></td></tr>";}
1268 #OVPN n2n networks
1269 foreach my $key (sort { ncmp($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
1270 if($ccdhost{$key}[3] eq 'net'){
1271 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 '');
1272 $show='1';
1273 print"<option>$ccdhost{$key}[1]</option>";
1274 }
1275 }
1276 if ($show eq '1'){$show='';print"</select></td></tr>";}
1277 #IPsec networks
1278 foreach my $key (sort { ncmp($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
1279 if ($ipsecconf{$key}[3] eq 'net'){
1280 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 '');
1281 $show='1';
1282 print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
1283 }
1284 }
1285 if ($show eq '1'){$show='';print"</select></td></tr>";}
1286 print"</table>";
1287 print"</td></tr></table>";
1288 print"<br><br><hr>";
1289 }
1290 print"<table border='0' width='100%'>";
1291 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>";
1292 &Header::closebox();
1293 }
1294 sub addservice
1295 {
1296 &error;
1297 &showmenu;
1298 &Header::openbox('100%', 'left', $Lang::tr{'fwhost addservice'});
1299 if ($fwhostsettings{'updatesrv'} eq 'on')
1300 {
1301 $fwhostsettings{'oldsrvname'} = $fwhostsettings{'SRV_NAME'};
1302 $fwhostsettings{'oldsrvport'} = $fwhostsettings{'SRV_PORT'};
1303 $fwhostsettings{'oldsrvprot'} = $fwhostsettings{'PROT'};
1304 $fwhostsettings{'oldsrvicmp'} = $fwhostsettings{'ICMP'};
1305 }
1306 print<<END;
1307 <table width='100%' border='0'><form method='post'>
1308 <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>
1309 <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost prot'}:</td><td><select name='PROT' id='protocol' >
1310 END
1311 foreach ("TCP","UDP","ICMP")
1312 {
1313 if ($_ eq $fwhostsettings{'PROT'})
1314 {
1315 print"<option selected>$_</option>";
1316 }else{
1317 print"<option>$_</option>";
1318 }
1319 }
1320 print<<END;
1321 </select></td></tr></table>
1322 <div id='PROTOKOLL' class='noscript'><table width=100%' border='0'><tr><td width='10%' nowrap='nowrap'>$Lang::tr{'fwhost icmptype'}</td><td><select name='ICMP_TYPES'>
1323 END
1324 &General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
1325 print"<option value='All ICMP-Types'>$Lang::tr{'fwdfw all icmp'}</option>";
1326 foreach my $key (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
1327 if ($icmptypes{$key}[0] eq $fwhostsettings{'oldsrvicmp'}){
1328 print"<option selected>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1329 }else{
1330 print"<option>$icmptypes{$key}[0] ($icmptypes{$key}[1])</option>";
1331 }
1332 }
1333 print<<END;
1334 </select></td></tr></table></div>
1335 <div id='PORT' class='noscript'><table width='100%' border='0'><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></table></div>
1336 <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
1337 <tr><td colspan='6' align='right'>
1338 END
1339 if ($fwhostsettings{'updatesrv'} eq 'on')
1340 {
1341 print<<END;
1342 <input type='submit' value='$Lang::tr{'update'}'style='min-width:100px;' >
1343 <input type='hidden' name='ACTION' value='updateservice'>
1344 <input type='hidden' name='oldsrvname' value='$fwhostsettings{'oldsrvname'}'>
1345 <input type='hidden' name='oldsrvport' value='$fwhostsettings{'oldsrvport'}'>
1346 <input type='hidden' name='oldsrvprot' value='$fwhostsettings{'oldsrvprot'}'>
1347 <input type='hidden' name='oldsrvicmp' value='$fwhostsettings{'oldsrvicmp'}'>
1348 </form>
1349 END
1350 }else{
1351 print"<input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='saveservice'></form>";
1352 }
1353 print<<END;
1354 <form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></form></td></tr>
1355 </table></form>
1356 END
1357 &Header::closebox();
1358 &viewtableservice;
1359 }
1360 sub addservicegrp
1361 {
1362 &hint;
1363 &error;
1364 &showmenu;
1365 &Header::openbox('100%', 'left', $Lang::tr{'fwhost addservicegrp'});
1366 $fwhostsettings{'oldsrvgrpremark'}=$fwhostsettings{'SRVGRP_REMARK'};
1367 if ($fwhostsettings{'updatesrvgrp'} eq ''){
1368 print<<END;
1369 <table width='100%' border='0'><form method='post'>
1370 <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
1371 <tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
1372 <tr><td colspan='2'><br><hr></tr>
1373 </table>
1374 END
1375 }else{
1376 print<<END;
1377 <table width='100%' border='0'><form method='post' style='display:inline'>
1378 <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>
1379 <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>
1380 <tr><td colspan='3'><br><hr></td></td></tr>
1381 </table></form>
1382 END
1383 }
1384 if($fwhostsettings{'updatesrvgrp'} eq 'on'){
1385 print<<END;
1386 <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%'>
1387 <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
1388 END
1389 &General::readhasharray("$configsrv", \%customservice);
1390 #Protocols for use in servicegroups
1391 print "<optgroup label='$Lang::tr{'fwhost cust service'}'>";
1392 foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0]) } keys %customservice)
1393 {
1394 print "<option>$customservice{$key}[0]</option>";
1395 }
1396 print "</optgroup>";
1397 print "<optgroup label='$Lang::tr{'protocol'}'>";
1398 print "<option>GRE</option>";
1399 print "<option>AH</option>";
1400 print "<option>ESP</option>";
1401 print "<option>IGMP</option>";
1402 print "<option>IPIP</option>";
1403 print "<option value='IPV6'>IPv6 encap</option>";
1404 print "</optgroup>";
1405 print<<END;
1406 </select></td></tr>
1407 <tr><td colspan='4'><br><br></td></tr>
1408 <tr><td colspan='4'><hr></td></tr>
1409 </table>
1410 END
1411 }
1412 print<<END;
1413 <table width='100%' border='0'>
1414 <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>
1415 </table></form>
1416 END
1417 &Header::closebox();
1418 }
1419 # View
1420 sub viewtablenet
1421 {
1422 if(! -z $confignet){
1423 &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust net'});
1424 &General::readhasharray("$confignet", \%customnetwork);
1425 &General::readhasharray("$configgrp", \%customgrp);
1426 &General::readhasharray("$fwconfigfwd", \%fwfwd);
1427 &General::readhasharray("$fwconfiginp", \%fwinp);
1428 &General::readhasharray("$fwconfigout", \%fwout);
1429 if (!keys %customnetwork)
1430 {
1431 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1432 }else{
1433 print<<END;
1434 <table border='0' width='100%' cellspacing='0'>
1435 <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>
1436 END
1437 }
1438 my $count=0;
1439 foreach my $key (sort {ncmp($a,$b)} keys %customnetwork) {
1440 if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
1441 print" <tr bgcolor='${Header::colouryellow}'>";
1442 }elsif ($count % 2)
1443 {
1444 print" <tr bgcolor='$color{'color22'}'>";
1445 }else
1446 {
1447 print" <tr bgcolor='$color{'color20'}'>";
1448 }
1449 my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]);
1450 my $netcount=&getnetcount($customnetwork{$key}[0]);
1451 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'>$netcount x</td>";
1452 print<<END;
1453 <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1454 <input type='hidden' name='ACTION' value='editnet'>
1455 <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
1456 <input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
1457 <input type='hidden' name='SUBNET' value='$customnetwork{$key}[2]' />
1458 <input type='hidden' name='NETREMARK' value='$customnetwork{$key}[3]' />
1459 </td></form>
1460 END
1461 if($netcount == '0')
1462 {
1463 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>";
1464 }else{
1465 print"<td></td></tr>";
1466 }
1467 $count++;
1468 }
1469 print"</table>";
1470 &Header::closebox();
1471 }
1472
1473 }
1474 sub getcolor
1475 {
1476 my $c=shift;
1477 #Check if IP is part of OpenVPN N2N subnet
1478 foreach my $key (sort keys %ccdhost){
1479 if ($ccdhost{$key}[3] eq 'net'){
1480 my ($a,$b) = split("/",$ccdhost{$key}[11]);
1481 if (&General::IpInSubnet($c,$a,$b)){
1482 $tdcolor="style='color:$Header::colourovpn ;'";
1483 return $tdcolor;
1484 }
1485 }
1486 }
1487 #Check if IP is part of OpenVPN dynamic subnet
1488 my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
1489 if (&General::IpInSubnet($c,$a,$b)){
1490 $tdcolor="style='color: $Header::colourovpn;'";
1491 return $tdcolor;
1492 }
1493 #Check if IP is part of OpenVPN static subnet
1494 foreach my $key (sort keys %ccdnet){
1495 my ($a,$b) = split("/",$ccdnet{$key}[1]);
1496 $b =&General::iporsubtodec($b);
1497 if (&General::IpInSubnet($c,$a,$b)){
1498 $tdcolor="style='color: $Header::colourovpn;'";
1499 return $tdcolor;
1500 }
1501 }
1502 #Check if IP is part of IPsec RW network
1503 if ($ipsecsettings{'RW_NET'} ne ''){
1504 my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
1505 $b=&General::iporsubtodec($b);
1506 if (&General::IpInSubnet($c,$a,$b)){
1507 $tdcolor="style='color: $Header::colourvpn;'";
1508 return $tdcolor;
1509 }
1510 }
1511 #Check if IP is part of a IPsec N2N network
1512 foreach my $key (sort keys %ipsecconf){
1513 my ($a,$b) = split("/",$ipsecconf{$key}[11]);
1514 if (&General::IpInSubnet($c,$a,$b)){
1515 $tdcolor="style='color: $Header::colourvpn;'";
1516 return $tdcolor;
1517 }
1518 }
1519 $tdcolor='';
1520 return $tdcolor;
1521 }
1522 sub viewtablehost
1523 {
1524 if (! -z $confighost){
1525 &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust addr'});
1526 &General::readhasharray("$confighost", \%customhost);
1527 &General::readhasharray("$configccdnet", \%ccdnet);
1528 &General::readhasharray("$configccdhost", \%ccdhost);
1529 &General::readhasharray("$fwconfigfwd", \%fwfwd);
1530 &General::readhasharray("$fwconfiginp", \%fwinp);
1531 &General::readhasharray("$fwconfigout", \%fwout);
1532 &General::readhasharray("$configgrp", \%customgrp);
1533 if (!keys %customhost)
1534 {
1535 print "<center><b>$Lang::tr{'fwhost empty'}</b>";
1536 }else{
1537 print<<END;
1538 <table border='0' width='100%' cellspacing='0'>
1539 <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>
1540 END
1541 }
1542 my $count=0;
1543 foreach my $key (sort { ncmp ($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
1544 if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
1545 print" <tr bgcolor='${Header::colouryellow}'>";
1546 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
1547 else{ print" <tr bgcolor='$color{'color20'}'>";}
1548 my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
1549 $customhost{$key}[4]=~s/\s+//g;
1550 my $hostcount=0;
1551 $hostcount=&gethostcount($customhost{$key}[0]);
1552 print"<td width='20%'>$customhost{$key}[0]</td><td width='20%' align='center' ".&getcolor($ip).">".&Header::colorize($ip)."</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$hostcount x</td>";
1553 print<<END;
1554 <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
1555 <input type='hidden' name='ACTION' value='edithost' />
1556 <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
1557 <input type='hidden' name='IP' value='$ip' />
1558 <input type='hidden' name='type' value='$customhost{$key}[1]' />
1559 <input type='hidden' name='HOSTREMARK' value='$customhost{$key}[3]' />
1560 </form></td>
1561 END
1562 if($hostcount == '0')
1563 {
1564 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>";
1565 }else{
1566 print"<td width='1%'></td></tr>";
1567 }
1568 $count++;
1569 }
1570 print"</table>";
1571 &Header::closebox();
1572 }
1573 }
1574 sub viewtablegrp
1575 {
1576 if(! -z "$configgrp"){
1577 &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust grp'});
1578 &General::readhasharray("$configgrp", \%customgrp);
1579 &General::readhasharray("$configipsec", \%ipsecconf);
1580 &General::readhasharray("$configccdhost", \%ccdhost);
1581 &General::readhasharray("$configccdnet", \%ccdnet);
1582 &General::readhasharray("$confighost", \%customhost);
1583 &General::readhasharray("$confignet", \%customnetwork);
1584 &General::readhasharray("$fwconfigfwd", \%fwfwd);
1585 &General::readhasharray("$fwconfiginp", \%fwinp);
1586 &General::readhasharray("$fwconfigout", \%fwout);
1587 my @grp=();
1588 my $helper='';
1589 my $count=1;
1590 my $grpname;
1591 my $remark;
1592 my $number;
1593 my $delflag;
1594 if (!keys %customgrp)
1595 {
1596 print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
1597 }else{
1598 foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1599 $count++;
1600 if ($helper ne $customgrp{$key}[0]){
1601 $delflag='0';
1602 foreach my $key1 (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
1603 if ($customgrp{$key}[0] eq $customgrp{$key1}[0])
1604 {
1605 $delflag++;
1606 }
1607 if($delflag > 1){
1608 last;
1609 }
1610 }
1611 $number=1;
1612 if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr{'fwhost err emptytable'};}
1613 $grpname=$customgrp{$key}[0];
1614 $remark="$customgrp{$key}[1]";
1615 if($count gt 1){ print"</table>";}
1616 print "<br><b><u>$grpname</u></b>&nbsp; &nbsp;";
1617 print " <b>$Lang::tr{'remark'}:</b>&nbsp $remark &nbsp " if ($remark ne '');
1618 my $netgrpcount=&getnetcount($grpname);
1619 print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
1620 if($netgrpcount == '0')
1621 {
1622 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>";
1623 }
1624 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>";
1625 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>";
1626 }
1627
1628 if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
1629 print" <tr bgcolor='${Header::colouryellow}'>";
1630 }elsif ($count %2 == 0){
1631 print"<tr bgcolor='$color{'color22'}'>";
1632 }else{
1633 print"<tr bgcolor='$color{'color20'}'>";
1634 }
1635 my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]);
1636 if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
1637 print "<td width='39%' align='left'>";
1638 if($customgrp{$key}[3] eq 'Standard Network'){
1639 print &get_name($customgrp{$key}[2])."</td>";
1640 }else{
1641 print "$customgrp{$key}[2]</td>";
1642 }
1643 if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){
1644 print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1645 }else{
1646 my ($colip,$colsub) = split("/",$ip);
1647 $ip="$colip/".&General::subtocidr($colsub) if ($colsub);
1648 print"<td align='center' ".&getcolor($colip).">".&Header::colorize($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
1649 }
1650 if ($delflag > 1 && $ip ne ''){
1651 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1652 }
1653 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>";
1654
1655 $helper=$customgrp{$key}[0];
1656 $number++;
1657 }
1658 print"</table>";
1659 }
1660 &Header::closebox();
1661 }
1662
1663 }
1664 sub viewtableservice
1665 {
1666 my $count=0;
1667 my $srvcount;
1668 if(! -z "$configsrv")
1669 {
1670 &Header::openbox('100%', 'left', $Lang::tr{'fwhost services'});
1671 &General::readhasharray("$configsrv", \%customservice);
1672 &General::readhasharray("$configsrvgrp", \%customservicegrp);
1673 &General::readhasharray("$fwconfigfwd", \%fwfwd);
1674 &General::readhasharray("$fwconfiginp", \%fwinp);
1675 &General::readhasharray("$fwconfigout", \%fwout);
1676 print<<END;
1677 <table width='100%' border='0' cellspacing='0'>
1678 <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>
1679 END
1680 foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
1681 {
1682 $count++;
1683 if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
1684 print" <tr bgcolor='${Header::colouryellow}'>";
1685 }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
1686 print<<END;
1687 <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
1688 END
1689 #Neuer count
1690 $srvcount=&getsrvcount($customservice{$key}[0]);
1691 if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr{'fwdfw all icmp'};}
1692 elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
1693 print<<END;
1694 </td><td align='center'>$srvcount x</td>
1695 <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' />
1696 <input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
1697 <input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
1698 <input type='hidden' name='PROT' value='$customservice{$key}[2]' />
1699 <input type='hidden' name='ICMP' value='$customservice{$key}[3]' /></form></td>
1700 END
1701 if ($srvcount eq '0')
1702 {
1703 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>";
1704 }else{
1705 print"<td></td></tr>";
1706 }
1707 }
1708 print"</table>";
1709 &Header::closebox();
1710 }
1711 }
1712 sub viewtableservicegrp
1713 {
1714 my $count=0;
1715 my $grpname;
1716 my $remark;
1717 my $helper;
1718 my $port;
1719 my $protocol;
1720 my $delflag;
1721 my $grpcount=0;
1722 if (! -z $configsrvgrp){
1723 &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'});
1724 &General::readhasharray("$configsrvgrp", \%customservicegrp);
1725 &General::readhasharray("$configsrv", \%customservice);
1726 &General::readhasharray("$fwconfigfwd", \%fwfwd);
1727 &General::readhasharray("$fwconfiginp", \%fwinp);
1728 &General::readhasharray("$fwconfigout", \%fwout);
1729 my $number= keys %customservicegrp;
1730 foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
1731 $count++;
1732 if ($helper ne $customservicegrp{$key}[0]){
1733 #Get used groupcounter
1734 $grpcount=&getsrvcount($customservicegrp{$key}[0]);
1735 $delflag=0;
1736 foreach my $key1 (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) } keys %customservicegrp){
1737 if ($customservicegrp{$key}[0] eq $customservicegrp{$key1}[0])
1738 {
1739 $delflag++;
1740 }
1741 if($delflag > 1){
1742 last;
1743 }
1744 }
1745 $grpname=$customservicegrp{$key}[0];
1746 if ($customservicegrp{$key}[2] eq "none"){
1747 $customservicegrp{$key}[2]=$Lang::tr{'fwhost empty'};
1748 $port='';
1749 $protocol='';
1750 }
1751 $remark="$customservicegrp{$key}[1]";
1752 if($count >=2){print"</table>";}
1753 print "<br><b><u>$grpname</u></b>&nbsp; &nbsp; ";
1754 print "<b>$Lang::tr{'remark'}:</b>&nbsp; $remark " if ($remark ne '');
1755 print "&nbsp; <b>$Lang::tr{'used'}:</b> $grpcount x";
1756 if($grpcount == '0')
1757 {
1758 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>";
1759 }
1760 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>";
1761 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>";
1762 }
1763 if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
1764 print" <tr bgcolor='${Header::colouryellow}'>";
1765 }elsif ($count %2 == 0){
1766 print"<tr bgcolor='$color{'color22'}'>";
1767 }else{
1768 print"<tr bgcolor='$color{'color20'}'>";
1769 }
1770 #Set fields if we use protocols in servicegroups
1771 if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
1772 $port='-';
1773 }
1774 if ($customservicegrp{$key}[2] eq 'GRE'){$protocol='GRE';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} GRE";}
1775 if ($customservicegrp{$key}[2] eq 'ESP'){$protocol='ESP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} ESP";}
1776 if ($customservicegrp{$key}[2] eq 'AH'){$protocol='AH';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} AH";}
1777 if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
1778 if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
1779 if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
1780 print "<td width='39%'>$customservicegrp{$key}[2]</td>";
1781 foreach my $srv (sort keys %customservice){
1782 if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
1783 $protocol=$customservice{$srv}[2];
1784 $port=$customservice{$srv}[1];
1785 last;
1786 }
1787 }
1788 print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
1789 if ($delflag gt '1'){
1790 print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
1791 }
1792 print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
1793 if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
1794 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2]'></form></td></tr>";
1795 }else{
1796 print "<input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$protocol'></form></td></tr>";
1797 }
1798 $helper=$customservicegrp{$key}[0];
1799 }
1800 print"</table>";
1801 &Header::closebox();
1802 }
1803 }
1804 # Check
1805 sub checkname
1806 {
1807 my %hash=%{(shift)};
1808 foreach my $key (keys %hash) {
1809 if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
1810 return 0;
1811 }
1812 }
1813 return 1;
1814
1815 }
1816 sub checkgroup
1817 {
1818 &General::readhasharray("$configsrvgrp", \%customservicegrp );
1819 my $name=shift;
1820 foreach my $key (keys %customservicegrp) {
1821 if($customservicegrp{$key}[0] eq $name){
1822 return 0;
1823 }
1824 }
1825 return 1;
1826 }
1827 sub checkservice
1828 {
1829 &General::readhasharray("$configsrv", \%customservice );
1830 my $name=shift;
1831 foreach my $key (keys %customservice) {
1832 if($customservice{$key}[0] eq $name){
1833 return 0;
1834 }
1835 }
1836 return 1;
1837 }
1838 sub checkip
1839 {
1840
1841 my %hash=%{(shift)};
1842 my $a=shift;
1843 foreach my $key (keys %hash) {
1844 if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'})){
1845 return 0;
1846 }
1847 }
1848 return 1;
1849 }
1850 sub checksubnet
1851 {
1852 my %hash=%{(shift)};
1853 &General::readhasharray("$confignet", \%hash);
1854 foreach my $key (keys %hash) {
1855 if(&General::IpInSubnet($fwhostsettings{'IP'},$hash{$key}[1],$hash{$key}[2]))
1856 {
1857 return 1;
1858 }
1859 }
1860 return 0;
1861 }
1862 sub checkservicegroup
1863 {
1864 &General::readhasharray("$configsrvgrp", \%customservicegrp);
1865 #check name
1866 if ( ! &validhostname($fwhostsettings{'SRVGRP_NAME'}))
1867 {
1868 $errormessage.=$Lang::tr{'fwhost err name'}."<br>";
1869 return $errormessage;
1870 }
1871 #check empty selectbox
1872 if (keys %customservice lt 1)
1873 {
1874 $errormessage.=$Lang::tr{'fwhost err groupempty'}."<br>";
1875 }
1876 #check if name already exists
1877 if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
1878 foreach my $key (keys %customservicegrp) {
1879 if( $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} ){
1880 $errormessage.=$Lang::tr{'fwhost err grpexist'}."<br>";
1881
1882 }
1883 }
1884 }
1885 #check if service already exists in group
1886 foreach my $key (keys %customservicegrp) {
1887 if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
1888 $errormessage.=$Lang::tr{'fwhost err srvexist'}."<br>";
1889 }
1890 }
1891 return $errormessage;
1892 }
1893 sub error
1894 {
1895 if ($errormessage) {
1896 &Header::openbox('100%', 'left', $Lang::tr{'error messages'});
1897 print "<class name='base'>$errormessage\n";
1898 print "&nbsp;</class>\n";
1899 &Header::closebox();
1900 }
1901 }
1902 sub hint
1903 {
1904 if ($hint) {
1905 &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'});
1906 print "<class name='base'>$hint\n";
1907 print "&nbsp;</class>\n";
1908 &Header::closebox();
1909 }
1910 }
1911 sub get_name
1912 {
1913 my $val=shift;
1914 &General::setup_default_networks(\%defaultNetworks);
1915 foreach my $network (sort keys %defaultNetworks)
1916 {
1917 return "$network" if ($val eq $defaultNetworks{$network}{'NAME'});
1918 }
1919 }
1920 sub gethostcount
1921 {
1922 my $searchstring=shift;
1923 my $srvcounter=0;
1924 #Count services used in servicegroups
1925 foreach my $key (keys %customgrp) {
1926 if($customgrp{$key}[2] eq $searchstring){
1927 $srvcounter++;
1928 }
1929 }
1930 #Count services used in firewall - config
1931 foreach my $key1 (keys %fwfwd) {
1932 if($fwfwd{$key1}[4] eq $searchstring){
1933 $srvcounter++;
1934 }
1935 if($fwfwd{$key1}[6] eq $searchstring){
1936 $srvcounter++;
1937 }
1938 }
1939 #Count services used in firewall - input
1940 foreach my $key2 (keys %fwinp) {
1941 if($fwinp{$key2}[4] eq $searchstring){
1942 $srvcounter++;
1943 }
1944 if($fwinp{$key2}[6] eq $searchstring){
1945 $srvcounter++;
1946 }
1947 }
1948 #Count services used in firewall - outgoing
1949 foreach my $key3 (keys %fwout) {
1950 if($fwout{$key3}[4] eq $searchstring){
1951 $srvcounter++;
1952 }
1953 if($fwout{$key3}[6] eq $searchstring){
1954 $srvcounter++;
1955 }
1956 }
1957 return $srvcounter;
1958 }
1959 sub getnetcount
1960 {
1961 my $searchstring=shift;
1962 my $srvcounter=0;
1963 #Count services used in servicegroups
1964 foreach my $key (keys %customgrp) {
1965 if($customgrp{$key}[2] eq $searchstring){
1966 $srvcounter++;
1967 }
1968 }
1969 #Count services used in firewall - config
1970 foreach my $key1 (keys %fwfwd) {
1971 if($fwfwd{$key1}[4] eq $searchstring){
1972 $srvcounter++;
1973 }
1974 if($fwfwd{$key1}[6] eq $searchstring){
1975 $srvcounter++;
1976 }
1977 }
1978 #Count services used in firewall - input
1979 foreach my $key2 (keys %fwinp) {
1980 if($fwinp{$key2}[4] eq $searchstring){
1981 $srvcounter++;
1982 }
1983 if($fwinp{$key2}[6] eq $searchstring){
1984 $srvcounter++;
1985 }
1986 }
1987 #Count services used in firewall - outgoing
1988 foreach my $key3 (keys %fwout) {
1989 if($fwout{$key3}[4] eq $searchstring){
1990 $srvcounter++;
1991 }
1992 if($fwout{$key3}[6] eq $searchstring){
1993 $srvcounter++;
1994 }
1995 }
1996 return $srvcounter;
1997 }
1998 sub getsrvcount
1999 {
2000 my $searchstring=shift;
2001 my $srvcounter=0;
2002 #Count services used in servicegroups
2003 foreach my $key (keys %customservicegrp) {
2004 if($customservicegrp{$key}[2] eq $searchstring){
2005 $srvcounter++;
2006 }
2007 }
2008 #Count services used in firewall - config
2009 foreach my $key1 (keys %fwfwd) {
2010 if($fwfwd{$key1}[15] eq $searchstring){
2011 $srvcounter++;
2012 }
2013 }
2014 #Count services used in firewall - input
2015 foreach my $key2 (keys %fwinp) {
2016 if($fwinp{$key2}[15] eq $searchstring){
2017 $srvcounter++;
2018 }
2019 }
2020 #Count services used in firewall - outgoing
2021 foreach my $key3 (keys %fwout) {
2022 if($fwout{$key3}[15] eq $searchstring){
2023 $srvcounter++;
2024 }
2025 }
2026 return $srvcounter;
2027 }
2028 sub deletefromgrp
2029 {
2030 my $target=shift;
2031 my $config=shift;
2032 my %hash=();
2033 &General::readhasharray("$config",\%hash);
2034 foreach my $key (keys %hash) {
2035 if($hash{$key}[2] eq $target){
2036 delete $hash{$key};
2037 }
2038 }
2039 &General::writehasharray("$config",\%hash);
2040
2041 }
2042 sub plausicheck
2043 {
2044 my $edit=shift;
2045 #check hostname
2046 if (!&validhostname($fwhostsettings{'HOSTNAME'}))
2047 {
2048 $errormessage=$errormessage.$Lang::tr{'fwhost err name'};
2049 $fwhostsettings{'BLK_IP'}='readonly';
2050 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2051 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2052 }
2053 #check if name collides with CCD Netname
2054 &General::readhasharray("$configccdnet", \%ccdnet);
2055 foreach my $key (keys %ccdnet) {
2056 if($ccdnet{$key}[0] eq $fwhostsettings{'HOSTNAME'}){
2057 $errormessage=$errormessage.$Lang::tr{'fwhost err isccdnet'};;
2058 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2059 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2060 last;
2061 }
2062 }
2063 #check if IP collides with CCD NetIP
2064 if ($fwhostsettings{'type'} ne 'mac'){
2065 &General::readhasharray("$configccdnet", \%ccdnet);
2066 foreach my $key (keys %ccdnet) {
2067 my $test=(&General::getnetworkip($fwhostsettings{'IP'},&General::iporsubtocidr($fwhostsettings{'SUBNET'})))."/".$fwhostsettings{'SUBNET'};
2068 if($ccdnet{$key}[1] eq $test){
2069 $errormessage=$errormessage.$Lang::tr{'fwhost err isccdipnet'};
2070 $fwhostsettings{'IP'} = $fwhostsettings{'orgip'};
2071 $fwhostsettings{'SUBNET'} = $fwhostsettings{'orgsubnet'};
2072 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2073 last;
2074 }
2075 }
2076 }
2077 #check if name collides with CCD Hostname
2078 &General::readhasharray("$configccdhost", \%ccdhost);
2079 foreach my $key (keys %ccdhost) {
2080 my ($ip,$sub)=split(/\//,$ccdhost{$key}[33]);
2081 if($ip eq $fwhostsettings{'IP'}){
2082 $errormessage=$Lang::tr{'fwhost err isccdiphost'};
2083 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2084 last;
2085 }
2086 }
2087 #check if IP collides with CCD HostIP (only hosts)
2088 if ($edit eq 'edithost')
2089 {
2090 foreach my $key (keys %ccdhost) {
2091 if($ccdhost{$key}[1] eq $fwhostsettings{'HOSTNAME'}){
2092 $errormessage=$Lang::tr{'fwhost err isccdhost'};
2093 $fwhostsettings{'IP'} = $fwhostsettings{'orgname'};
2094 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2095 last;
2096 }
2097 }
2098 }
2099 #check if network with this name already exists
2100 &General::readhasharray("$confignet", \%customnetwork);
2101 if (!&checkname(\%customnetwork))
2102 {
2103 $errormessage=$errormessage."<br>".$Lang::tr{'fwhost err netexist'};
2104 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2105 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2106 }
2107 #check if network ip already exists
2108 if (!&checkip(\%customnetwork,1))
2109 {
2110 $errormessage=$errormessage."<br>".$Lang::tr{'fwhost err net'};
2111 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2112 }
2113 #check if host with this name already exists
2114 &General::readhasharray("$confighost", \%customhost);
2115 if (!&checkname(\%customhost))
2116 {
2117 $errormessage.="<br>".$Lang::tr{'fwhost err hostexist'};
2118 $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
2119 if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;}
2120 }
2121 #check if host with this ip already exists
2122 if (!&checkip(\%customhost,2))
2123 {
2124 $errormessage=$errormessage."<br>".$Lang::tr{'fwhost err ipcheck'};
2125 }
2126 return;
2127 }
2128 sub getipforgroup
2129 {
2130 my $name=$_[0],
2131 my $type=$_[1];
2132 my $value;
2133
2134 #get address from IPSEC NETWORK
2135 if ($type eq 'IpSec Network'){
2136 foreach my $key (keys %ipsecconf) {
2137 if ($ipsecconf{$key}[1] eq $name){
2138 return $ipsecconf{$key}[11];
2139 }
2140 }
2141 &deletefromgrp($name,$configgrp);
2142 }
2143
2144 #get address from IPSEC HOST
2145 if ($type eq 'IpSec Host'){
2146 foreach my $key (keys %ipsecconf) {
2147 if ($ipsecconf{$key}[1] eq $name){
2148 return $ipsecconf{$key}[10];
2149 }
2150 }
2151 &deletefromgrp($name,$configgrp);
2152 }
2153
2154 #get address from ovpn ccd Net-2-Net
2155 if ($type eq 'OpenVPN N-2-N'){
2156 foreach my $key (keys %ccdhost) {
2157 if($ccdhost{$key}[1] eq $name){
2158 my ($a,$b) = split ("/",$ccdhost{$key}[11]);
2159 $b=&General::iporsubtodec($b);
2160 return "$a/$b";
2161 }
2162 }
2163 &deletefromgrp($name,$configgrp);
2164 }
2165
2166 #get address from ovpn ccd static host
2167 if ($type eq 'OpenVPN static host'){
2168 foreach my $key (keys %ccdhost) {
2169 if($ccdhost{$key}[1] eq $name){
2170 my ($a,$b) = split (/\//,$ccdhost{$key}[33]);
2171 $b=&General::iporsubtodec($b);
2172 return "$a/$b";
2173 }
2174 }
2175 &deletefromgrp($name,$configgrp);
2176 }
2177
2178 #get address from ovpn ccd static net
2179 if ($type eq 'OpenVPN static network'){
2180 foreach my $key (keys %ccdnet) {
2181 if ($ccdnet{$key}[0] eq $name){
2182 my ($a,$b) = split (/\//,$ccdnet{$key}[1]);
2183 $b=&General::iporsubtodec($b);
2184 return "$a/$b";
2185 }
2186 }
2187 }
2188
2189 #check custom addresses
2190 if ($type eq 'Custom Host'){
2191 foreach my $key (keys %customhost) {
2192 if ($customhost{$key}[0] eq $name){
2193 my ($ip,$sub) = split("/",$customhost{$key}[2]);
2194 return $ip;
2195 }
2196 }
2197 }
2198
2199 ##check custom networks
2200 if ($type eq 'Custom Network'){
2201 foreach my $key (keys %customnetwork) {
2202 if($customnetwork{$key}[0] eq $name){
2203 return $customnetwork{$key}[1]."/".$customnetwork{$key}[2];
2204 }
2205 }
2206 }
2207
2208 #check standard networks
2209 if ($type eq 'Standard Network'){
2210 if ($name =~ /OpenVPN/i){
2211 my %ovpn=();
2212 &General::readhash("${General::swroot}/ovpn/settings",\%ovpn);
2213 return $ovpn{'DOVPN_SUBNET'};
2214 }
2215 if ($name eq 'GREEN'){
2216 my %hash=();
2217 &General::readhash("${General::swroot}/ethernet/settings",\%hash);
2218 return $hash{'GREEN_NETADDRESS'}."/".$hash{'GREEN_NETMASK'};
2219 }
2220 if ($name eq 'BLUE'){
2221 my %hash=();
2222 &General::readhash("${General::swroot}/ethernet/settings",\%hash);
2223 return $hash{'BLUE_NETADDRESS'}."/".$hash{'BLUE_NETMASK'};
2224 }
2225 if ($name eq 'ORANGE'){
2226 my %hash=();
2227 &General::readhash("${General::swroot}/ethernet/settings",\%hash);
2228 return $hash{'ORANGE_NETADDRESS'}."/".$hash{'ORANGE_NETMASK'};
2229 }
2230 if ($name eq 'ALL'){
2231 return "0.0.0.0/0.0.0.0";
2232 }
2233 if ($name =~ /IPsec/i){
2234 my %hash=();
2235 &General::readhash("${General::swroot}/vpn/settings",\%hash);
2236 return $hash{'RW_NET'};
2237 }
2238 }
2239 }
2240 sub decrease
2241 {
2242 my $grp=$_[0];
2243 &General::readhasharray("$confignet", \%customnetwork);
2244 &General::readhasharray("$confighost", \%customhost);
2245 foreach my $key (sort keys %customgrp ){
2246 if ( ($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Network')){
2247 foreach my $key1 (sort keys %customnetwork){
2248 if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
2249 $customnetwork{$key1}[4]=$customnetwork{$key1}[4]-1;
2250 last;
2251 }
2252 }
2253 }
2254
2255 if (($customgrp{$key}[0] eq $grp) && ($customgrp{$key}[3] eq 'Custom Host')){
2256 foreach my $key2 (sort keys %customhost){
2257 if ($customhost{$key2}[0] eq $customgrp{$key}[2]){
2258 $customhost{$key2}[4]=$customhost{$key2}[4]-1;
2259 last;
2260 }
2261 }
2262
2263 }
2264 }
2265 &General::writehasharray("$confignet", \%customnetwork);
2266 &General::writehasharray("$confighost", \%customhost);
2267 }
2268 sub decreaseservice
2269 {
2270 my $grp=$_[0];
2271 &General::readhasharray("$configsrv", \%customservice);
2272 &General::readhasharray("$configsrvgrp", \%customservicegrp);
2273
2274 foreach my $key (sort keys %customservicegrp){
2275 if ($customservicegrp{$key}[0] eq $grp ){
2276 foreach my $key2 (sort keys %customservice){
2277 if ($customservice{$key2}[0] eq $customservicegrp{$key}[2]){
2278 $customservice{$key2}[4]--;
2279 }
2280 }
2281 }
2282 }
2283 &General::writehasharray("$configsrv", \%customservice);
2284
2285 }
2286 sub checkports
2287 {
2288
2289 my %hash=%{(shift)};
2290 #check empty fields
2291 if ($fwhostsettings{'SRV_NAME'} eq '' ){
2292 $errormessage=$Lang::tr{'fwhost err name1'};
2293 }
2294 if ($fwhostsettings{'SRV_PORT'} eq '' && $fwhostsettings{'PROT'} ne 'ICMP'){
2295 $errormessage=$Lang::tr{'fwhost err port'};
2296 }
2297 #check valid name
2298 if (! &validhostname($fwhostsettings{'SRV_NAME'})){
2299 $errormessage="<br>".$Lang::tr{'fwhost err name'};
2300 }
2301 #change dashes with :
2302 $fwhostsettings{'SRV_PORT'}=~ tr/-/:/;
2303
2304 if ($fwhostsettings{'SRV_PORT'} eq "*") {
2305 $fwhostsettings{'SRV_PORT'} = "1:65535";
2306 }
2307 if ($fwhostsettings{'SRV_PORT'} =~ /^(\D)\:(\d+)$/) {
2308 $fwhostsettings{'SRV_PORT'} = "1:$2";
2309 }
2310 if ($fwhostsettings{'SRV_PORT'} =~ /^(\d+)\:(\D)$/) {
2311 $fwhostsettings{'SRV_PORT'} = "$1:65535";
2312 }
2313 if($fwhostsettings{'PROT'} ne 'ICMP'){
2314 $errormessage = $errormessage.&General::validportrange($fwhostsettings{'SRV_PORT'}, 'src');
2315 }
2316 # a new service has to have a different name
2317 foreach my $key (keys %hash){
2318 if ($hash{$key}[0] eq $fwhostsettings{'SRV_NAME'}){
2319 $errormessage = "<br>".$Lang::tr{'fwhost err srv exists'};
2320 last;
2321 }
2322 }
2323 return $errormessage;
2324 }
2325 sub validhostname
2326 {
2327 # Checks a hostname against RFC1035
2328 my $hostname = $_[0];
2329
2330 # Each part should be at least two characters in length
2331 # but no more than 63 characters
2332 if (length ($hostname) < 1 || length ($hostname) > 63) {
2333 return 0;}
2334 # Only valid characters are a-z, A-Z, 0-9 and -
2335 if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s]*$/) {
2336 return 0;}
2337 # First character can only be a letter or a digit
2338 if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) {
2339 return 0;}
2340 # Last character can only be a letter or a digit
2341 if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) {
2342 return 0;}
2343 return 1;
2344 }
2345 sub validremark
2346 {
2347 # Checks a hostname against RFC1035
2348 my $remark = $_[0];
2349 # Each part should be at least two characters in length
2350 # but no more than 63 characters
2351 if (length ($remark) < 1 || length ($remark) > 255) {
2352 return 0;}
2353 # Only valid characters are a-z, A-Z, 0-9 and -
2354 if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s]*$/) {
2355 return 0;}
2356 # First character can only be a letter or a digit
2357 if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) {
2358 return 0;}
2359 # Last character can only be a letter or a digit
2360 if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) {
2361 return 0;}
2362 return 1;
2363 }
2364 &Header::closebigbox();
2365 &Header::closepage();