#!/usr/bin/perl ############################################################################### # # # IPFire.org - A linux based firewall # # Copyright (C) 2013 Alexander Marx # # Copyright (C) 2024 BPFire # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # # the Free Software Foundation, either version 3 of the License, or # # (at your option) any later version. # # # # This program is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License # # along with this program. If not, see . # # # ############################################################################### use strict; # enable only the following on debugging purpose #use warnings; use Sort::Naturally; use CGI::Carp 'fatalsToBrowser'; no warnings 'uninitialized'; require '/var/ipfire/general-functions.pl'; require '/var/ipfire/network-functions.pl'; require "/var/ipfire/location-functions.pl"; require "/usr/lib/firewall/firewall-lib.pl"; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %fwhostsettings=(); my %customnetwork=(); my %customhost=(); my %icmptypes=(); my %color=(); my %defaultNetworks=(); my %mainsettings=(); my %ownnet=(); my %fwfwd=(); my %fwinp=(); my %fwout=(); my %netsettings=(); my %optionsfw=(); my $errormessage; my $hint; my $update=0; my $confignet = "${General::swroot}/fwhosts/customnetworks"; my $confighost = "${General::swroot}/fwhosts/customhosts"; my $fwoptions = "${General::swroot}/optionsfw/settings"; unless (-e $confignet) { &General::system("touch", "$confignet"); } unless (-e $confighost) { &General::system("touch", "$confighost"); } &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/ipfire/include/colors.txt", \%color); &General::readhash("${General::swroot}/ethernet/settings", \%ownnet); &General::readhash("/var/ipfire/ethernet/settings", \%netsettings); &General::readhash($fwoptions, \%optionsfw); &Header::getcgihash(\%fwhostsettings); &Header::showhttpheaders(); &Header::openpage($Lang::tr{'fwhost menu'}, 1, ''); &Header::openbigbox('100%', 'center'); #### JAVA SCRIPT #### print< var PROTOCOLS_WITH_PORTS = ["TCP", "UDP"]; var update_protocol = function() { var protocol = \$("#protocol").val(); if (protocol === undefined) return; // Check if we are dealing with a protocol, that knows ports. if (\$.inArray(protocol, PROTOCOLS_WITH_PORTS) >= 0) { \$("#PORT").show(); \$("#PROTOKOLL").hide(); } else { \$("#PORT").hide(); \$("#PROTOKOLL").show(); } }; \$(document).ready(function() { var protocol = \$("#protocol").val(); \$("#protocol").change(update_protocol); update_protocol(); // Automatically select radio buttons when corresponding // dropdown menu changes. \$("select").change(function() { var id = \$(this).attr("name"); \$('#' + id).prop("checked", true); }); }); END ## ACTION #### # Update if ($fwhostsettings{'ACTION'} eq 'updatenet' ) { &General::readhasharray("$confignet", \%customnetwork); foreach my $key (keys %customnetwork) { if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}) { $fwhostsettings{'orgname'} = $customnetwork{$key}[0]; $fwhostsettings{'orgip'} = $customnetwork{$key}[1]; $fwhostsettings{'orgsub'} = $customnetwork{$key}[2]; $fwhostsettings{'netremark'} = $customnetwork{$key}[3]; $fwhostsettings{'count'} = $customnetwork{$key}[4]; delete $customnetwork{$key}; } } &General::writehasharray("$confignet", \%customnetwork); $fwhostsettings{'actualize'} = 'on'; $fwhostsettings{'ACTION'} = 'savenet'; } if ($fwhostsettings{'ACTION'} eq 'updatehost') { my ($ip,$subnet); &General::readhasharray("$confighost", \%customhost); foreach my $key (keys %customhost) { if($customhost{$key}[0] eq $fwhostsettings{'orgname'}) { if ($customhost{$key}[1] eq 'ip'){ ($ip,$subnet) = split (/\//,$customhost{$key}[2]); }else{ $ip = $customhost{$key}[2]; } $fwhostsettings{'orgip'} = $ip; $fwhostsettings{'count'} = $customhost{$key}[4]; delete $customhost{$key}; &General::writehasharray("$confighost", \%customhost); } } $fwhostsettings{'actualize'} = 'on'; if($fwhostsettings{'orgip'}){ $fwhostsettings{'ACTION'} = 'savehost'; }else{ $fwhostsettings{'ACTION'} = $Lang::tr{'fwhost newhost'}; } } # save if ($fwhostsettings{'ACTION'} eq 'savenet' ) { my $needrules=0; if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};} #check if all fields are set if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '') { $errormessage=$errormessage.$Lang::tr{'fwhost err empty'}; &addnet; &viewtablenet; }else{ #convert ip if leading '0' exists $fwhostsettings{'IP'} = &Network::ip_remove_zero($fwhostsettings{'IP'}); #check valid ip if (!&General::validipandmask($fwhostsettings{'IP'}."/".$fwhostsettings{'SUBNET'})) { $errormessage=$errormessage.$Lang::tr{'fwhost err addr'}; $fwhostsettings{'BLK_HOST'} ='readonly'; $fwhostsettings{'NOCHECK'} ='false'; $fwhostsettings{'error'} ='on'; } #check remark if ($fwhostsettings{'NETREMARK'} ne '' && !&validremark($fwhostsettings{'NETREMARK'})){ $errormessage=$Lang::tr{'fwhost err remark'}; $fwhostsettings{'error'} ='on'; } #check if subnet is sigle host if(&General::iporsubtocidr($fwhostsettings{'SUBNET'}) eq '32') { $errormessage=$errormessage.$Lang::tr{'fwhost err sub32'}; } if($fwhostsettings{'error'} ne 'on'){ my $fullip="$fwhostsettings{'IP'}/".&General::iporsubtocidr($fwhostsettings{'SUBNET'}); $errormessage=$errormessage.&General::checksubnets($fwhostsettings{'HOSTNAME'},$fullip,"","exact"); } #only check plausi when no error till now if (!$errormessage){ &plausicheck("editnet"); } if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newnet'} ne 'on' && $errormessage) { $fwhostsettings{'actualize'} = ''; my $key = &General::findhasharraykey (\%customnetwork); foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";} $customnetwork{$key}[0] = $fwhostsettings{'orgname'} ; $customnetwork{$key}[1] = $fwhostsettings{'orgip'} ; $customnetwork{$key}[2] = $fwhostsettings{'orgsub'}; $customnetwork{$key}[3] = $fwhostsettings{'orgnetremark'}; &General::writehasharray("$confignet", \%customnetwork); undef %customnetwork; } if (!$errormessage){ &General::readhasharray("$confignet", \%customnetwork); if ($fwhostsettings{'ACTION'} eq 'updatenet'){ if ($fwhostsettings{'update'} == '0'){ foreach my $key (keys %customnetwork) { if($customnetwork{$key}[0] eq $fwhostsettings{'orgname'}){ delete $customnetwork{$key}; last; } } } } #get count if actualize is 'on' if($fwhostsettings{'actualize'} eq 'on'){ $fwhostsettings{'actualize'} = ''; #check if we need to reload rules if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){ $needrules='on'; } if ($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){ } } my $key = &General::findhasharraykey (\%customnetwork); foreach my $i (0 .. 3) { $customnetwork{$key}[$i] = "";} $fwhostsettings{'SUBNET'} = &General::iporsubtocidr($fwhostsettings{'SUBNET'}); $customnetwork{$key}[0] = $fwhostsettings{'HOSTNAME'}; $customnetwork{$key}[1] = &General::getnetworkip($fwhostsettings{'IP'},$fwhostsettings{'SUBNET'}) ; $customnetwork{$key}[2] = &General::iporsubtodec($fwhostsettings{'SUBNET'}) ; $customnetwork{$key}[3] = $fwhostsettings{'NETREMARK'}; &General::writehasharray("$confignet", \%customnetwork); $fwhostsettings{'IP'}=$fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'}); undef %customnetwork; $fwhostsettings{'HOSTNAME'}=''; $fwhostsettings{'IP'}=''; $fwhostsettings{'SUBNET'}=''; $fwhostsettings{'NETREMARK'}=''; #check if an edited net affected groups and need to reload rules if ($needrules eq 'on'){ &General::firewall_config_changed(); } &addnet; &viewtablenet; }else{ $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'}; &addnet; &viewtablenet; } } } if ($fwhostsettings{'ACTION'} eq 'savehost') { my $needrules=0; if ($fwhostsettings{'orgname'} eq ''){$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};} $fwhostsettings{'SUBNET'}='32'; #check if all fields are set if ($fwhostsettings{'HOSTNAME'} eq '' || $fwhostsettings{'IP'} eq '' || $fwhostsettings{'SUBNET'} eq '') { $errormessage=$errormessage.$Lang::tr{'fwhost err empty'}; $fwhostsettings{'ACTION'} = 'edithost'; }else{ if($fwhostsettings{'IP'}=~/^([0-9a-fA-F]{1,2}:){5}[0-9a-fA-F]{1,2}$/){ $fwhostsettings{'type'} = 'mac'; }elsif($fwhostsettings{'IP'}=~/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/){ $fwhostsettings{'type'} = 'ip'; }else{ $fwhostsettings{'type'} = ''; $errormessage=$Lang::tr{'fwhost err ipmac'}; } #check remark if ($fwhostsettings{'HOSTREMARK'} ne '' && !&validremark($fwhostsettings{'HOSTREMARK'})){ $errormessage=$Lang::tr{'fwhost err remark'}; } #CHECK IP-PART if ($fwhostsettings{'type'} eq 'ip'){ #convert ip if leading '0' exists $fwhostsettings{'IP'} = &Network::ip_remove_zero($fwhostsettings{'IP'}); #check for subnet if (rindex($fwhostsettings{'IP'},'/') eq '-1' ){ if($fwhostsettings{'type'} eq 'ip' && !&General::validipandmask($fwhostsettings{'IP'}."/32")) { $errormessage.=$errormessage.$Lang::tr{'fwhost err ip'}; $fwhostsettings{'error'}='on'; } }elsif(rindex($fwhostsettings{'IP'},'/') ne '-1' ){ $errormessage=$errormessage.$Lang::tr{'fwhost err ipwithsub'}; $fwhostsettings{'error'}='on'; } #check if net or broadcast my @tmp= split (/\./,$fwhostsettings{'IP'}); if (($tmp[3] eq "0") || ($tmp[3] eq "255")){ $errormessage=$Lang::tr{'fwhost err hostip'}; } } #only check plausi when no error till now if (!$errormessage){ &plausicheck("edithost"); } if($fwhostsettings{'actualize'} eq 'on' && $fwhostsettings{'newhost'} ne 'on' && $errormessage){ $fwhostsettings{'actualize'} = ''; my $key = &General::findhasharraykey (\%customhost); foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";} $customhost{$key}[0] = $fwhostsettings{'orgname'} ; $customhost{$key}[1] = $fwhostsettings{'type'} ; if($customhost{$key}[1] eq 'ip'){ $customhost{$key}[2] = $fwhostsettings{'orgip'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'}); }else{ $customhost{$key}[2] = $fwhostsettings{'orgip'}; } $customhost{$key}[3] = $fwhostsettings{'orgremark'}; &General::writehasharray("$confighost", \%customhost); undef %customhost; } if (!$errormessage){ #get count if host was edited if($fwhostsettings{'actualize'} eq 'on'){ if($fwhostsettings{'orgip'} ne $fwhostsettings{'IP'}){ $needrules='on'; } if($fwhostsettings{'orgname'} ne $fwhostsettings{'HOSTNAME'}){ #check if we need to update firewallrules } } my $key = &General::findhasharraykey (\%customhost); foreach my $i (0 .. 3) { $customhost{$key}[$i] = "";} $customhost{$key}[0] = $fwhostsettings{'HOSTNAME'} ; $customhost{$key}[1] = $fwhostsettings{'type'} ; if ($fwhostsettings{'type'} eq 'ip'){ $customhost{$key}[2] = $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'}); }else{ $customhost{$key}[2] = $fwhostsettings{'IP'}; } $customhost{$key}[3] = $fwhostsettings{'HOSTREMARK'}; &General::writehasharray("$confighost", \%customhost); undef %customhost; $fwhostsettings{'HOSTNAME'}=''; $fwhostsettings{'IP'}=''; $fwhostsettings{'type'}=''; $fwhostsettings{'HOSTREMARK'}=''; #check if we need to update rules while host was edited if($needrules eq 'on'){ &General::firewall_config_changed(); } &addhost; &viewtablehost; }else{ &addhost; &viewtablehost; } } } # edit if ($fwhostsettings{'ACTION'} eq 'editnet') { &addnet; &viewtablenet; } if ($fwhostsettings{'ACTION'} eq 'edithost') { &addhost; &viewtablehost; } # reset if ($fwhostsettings{'ACTION'} eq 'resetnet') { $fwhostsettings{'HOSTNAME'} =""; $fwhostsettings{'IP'} =""; $fwhostsettings{'SUBNET'} =""; &showmenu; } if ($fwhostsettings{'ACTION'} eq 'resethost') { $fwhostsettings{'HOSTNAME'} =""; $fwhostsettings{'IP'} =""; $fwhostsettings{'type'} =""; &showmenu; } # delete if ($fwhostsettings{'ACTION'} eq 'delnet') { &General::readhasharray("$confignet", \%customnetwork); foreach my $key (keys %customnetwork) { if($fwhostsettings{'key'} eq $customnetwork{$key}[0]){ delete $customnetwork{$key}; &General::writehasharray("$confignet", \%customnetwork); last; } } &addnet; &viewtablenet; } if ($fwhostsettings{'ACTION'} eq 'delhost') { &General::readhasharray("$confighost", \%customhost); foreach my $key (keys %customhost) { if($fwhostsettings{'key'} eq $customhost{$key}[0]){ delete $customhost{$key}; &General::writehasharray("$confighost", \%customhost); last; } } &addhost; &viewtablehost; } if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newnet'}) { &addnet; &viewtablenet; } if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newhost'}) { &addhost; &viewtablehost; } ### VIEW ### if($fwhostsettings{'ACTION'} eq '') { &showmenu; } ### FUNCTIONS ### sub showmenu { &Header::openbox('100%', 'left',); print "$Lang::tr{'fwhost welcome'}"; print<
END &Header::closebox(); } # Add sub addnet { &error; &showmenu; &Header::openbox('100%', 'left', $Lang::tr{'fwhost addnet'}); $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'}; print< $Lang::tr{'name'}:
$Lang::tr{'fwhost netaddress'}: $Lang::tr{'netmask'}: $Lang::tr{'remark'}:
END if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on') { print ""; }else{ print ""; } print "
"; &Header::closebox(); } sub addhost { &error; &showmenu; &Header::openbox('100%', 'left', $Lang::tr{'fwhost addhost'}); $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'}; print< $Lang::tr{'name'}:
IP/MAC: $Lang::tr{'remark'}:
END if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on') { print "
"; }else{ print " "; } print "
"; &Header::closebox(); } # View sub viewtablenet { if(! -z $confignet){ &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust net'}); &General::readhasharray("$confignet", \%customnetwork); if (!keys %customnetwork) { print "
$Lang::tr{'fwhost empty'}"; }else{ print< $Lang::tr{'name'}$Lang::tr{'fwhost netaddress'}$Lang::tr{'remark'}$Lang::tr{'used'} END } my $count=0; my $col=''; foreach my $key (sort {ncmp($a,$b)} keys %customnetwork) { if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) { print" "; $col="bgcolor='${Header::colouryellow}'"; }elsif ($count % 2) { $col="bgcolor='$color{'color20'}'"; print" "; }else { $col="bgcolor='$color{'color22'}'"; print" "; } my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]); my $netcount=&getnetcount($customnetwork{$key}[0]); print"
$customnetwork{$key}[0]".&getcolor($colnet)."$customnetwork{$key}[3]$netcount x"; print< END if($netcount == '0') { print"
"; }else{ print""; } $count++; print""; &Header::closebox(); } } sub getcolor { my $c=shift; my $sip; my $scidr; my $tdcolor=''; #Check if MAC if (&General::validmac($c)){ return $c;} #Check if we got a full IP with subnet then split it if($c =~ /^(.*?)\/(.*?)$/){ ($sip,$scidr) = split ("/",$c); }else{ $sip=$c; } #Now check if IP is part of ORANGE,BLUE or GREEN if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){ $tdcolor="$c"; return $tdcolor; } if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){ $tdcolor="$c"; return $tdcolor; } if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){ $tdcolor="$c"; return $tdcolor; } if ("$sip/$scidr" eq "0.0.0.0/0"){ $tdcolor="$c"; return $tdcolor; } return "$c"; } sub viewtablehost { if (!-z $confighost) { &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust addr'}); &General::readhasharray("$confighost", \%customhost); if (!keys %customhost) { print "
$Lang::tr{'fwhost empty'}"; } else { print < $Lang::tr{'name'} $Lang::tr{'fwhost ip_mac'} $Lang::tr{'remark'} $Lang::tr{'used'} END } my $count = 0; my $col = ''; foreach my $key (sort { ncmp($customhost{$a}[0], $customhost{$b}[0]) } keys %customhost) { if (($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) { print ""; $col = "bgcolor='${Header::colouryellow}'"; } elsif ($count % 2) { print ""; $col = "bgcolor='$color{'color20'}'"; } else { $col = "bgcolor='$color{'color22'}'"; print ""; } my ($ip, $sub) = split(/\//, $customhost{$key}[2]); $customhost{$key}[4] =~ s/\s+//g; my $hostcount = 0; $hostcount = &gethostcount($customhost{$key}[0]); print "$customhost{$key}[0]" . &getcolor($ip) . "$customhost{$key}[3]$hostcount x"; print <
END if ($hostcount == 0) { print "
"; } else { print ""; } $count++; print ""; &Header::closebox(); } } } sub checkname { my %hash=%{(shift)}; foreach my $key (keys %hash) { if($hash{$key}[0] eq $fwhostsettings{'HOSTNAME'}){ return 0; } } return 1; } sub checkip { my %hash=%{(shift)}; my $a=shift; foreach my $key (keys %hash) { if($hash{$key}[$a] eq $fwhostsettings{'IP'}."/".&General::iporsubtodec($fwhostsettings{'SUBNET'})){ return 0; } } return 1; } sub error { if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); print "$errormessage\n"; print " \n"; &Header::closebox(); } } sub hint { if ($hint) { &Header::openbox('100%', 'left', $Lang::tr{'fwhost hint'}); print "$hint\n"; print " \n"; &Header::closebox(); } } sub get_name { my $val=shift; &General::setup_default_networks(\%defaultNetworks); foreach my $network (sort keys %defaultNetworks) { return "$network" if ($val eq $defaultNetworks{$network}{'NAME'}); } } sub gethostcount { my $searchstring=shift; } sub getnetcount { my $searchstring=shift; } sub plausicheck { my $edit=shift; #check hostname if (!&validhostname($fwhostsettings{'HOSTNAME'})) { $errormessage=$errormessage.$Lang::tr{'fwhost err name'}; $fwhostsettings{'BLK_IP'}='readonly'; $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'}; if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;} } #check if network with this name already exists &General::readhasharray("$confignet", \%customnetwork); if (!&checkname(\%customnetwork)) { $errormessage=$errormessage."
".$Lang::tr{'fwhost err netexist'}; $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'}; if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;} } #check if network ip already exists if (!&checkip(\%customnetwork,1)) { $errormessage=$errormessage."
".$Lang::tr{'fwhost err net'}; if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;} } #check if host with this name already exists &General::readhasharray("$confighost", \%customhost); if (!&checkname(\%customhost)) { $errormessage.="
".$Lang::tr{'fwhost err hostexist'}; $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'}; if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}=$edit;} } #check if host with this ip already exists if (!&checkip(\%customhost,2)) { $errormessage=$errormessage."
".$Lang::tr{'fwhost err ipcheck'}; } return; } sub decrease { &General::readhasharray("$confignet", \%customnetwork); &General::readhasharray("$confighost", \%customhost); &General::writehasharray("$confignet", \%customnetwork); &General::writehasharray("$confighost", \%customhost); } sub validhostname { # Checks a hostname against RFC1035 my $hostname = $_[0]; # Each part should be at least two characters in length # but no more than 63 characters if (length ($hostname) < 1 || length ($hostname) > 63) { return 0;} # Only valid characters are a-z, A-Z, 0-9 and - if ($hostname !~ /^[a-zA-ZäöüÖÄÜ0-9-_.;()\/\s]*$/) { return 0;} # First character can only be a letter or a digit if (substr ($hostname, 0, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9]*$/) { return 0;} # Last character can only be a letter or a digit if (substr ($hostname, -1, 1) !~ /^[a-zA-ZöäüÖÄÜ0-9()]*$/) { return 0;} return 1; } sub validremark { # Checks a hostname against RFC1035 my $remark = $_[0]; # Each part should be at least two characters in length # but no more than 63 characters if (length ($remark) < 1 || length ($remark) > 255) { return 0;} # Only valid characters are a-z, A-Z, 0-9 and - if ($remark !~ /^[a-zäöüA-ZÖÄÜ0-9-.:;\|_()\/\s]*$/) { return 0;} # First character can only be a letter or a digit if (substr ($remark, 0, 1) !~ /^[a-zäöüA-ZÖÄÜ0-9]*$/) { return 0;} # Last character can only be a letter or a digit if (substr ($remark, -1, 1) !~ /^[a-zöäüA-ZÖÄÜ0-9.:;_)]*$/) { return 0;} return 1; } &Header::closebigbox(); &Header::closepage();