From aeefcc9caa329cfd1ca8b8cdafdc845aab7507b2 Mon Sep 17 00:00:00 2001 From: Alexander Marx Date: Sat, 11 Jan 2014 05:30:46 +0100 Subject: [PATCH] Firewall: modified firewall-groups so that they can be empty even if used in rules Now one can create a group, use it in a rule and then delete every entry from the group. (The firewallrule then will be displayed yellow and disabled). --- html/cgi-bin/firewall.cgi | 24 ++++++-- html/cgi-bin/fwhosts.cgi | 111 ++++++++++++++++++++++--------------- html/cgi-bin/p2p-block.cgi | 0 html/cgi-bin/shutdown.cgi | 0 html/cgi-bin/tor.cgi | 0 5 files changed, 87 insertions(+), 48 deletions(-) mode change 100755 => 100644 html/cgi-bin/firewall.cgi mode change 100755 => 100644 html/cgi-bin/p2p-block.cgi mode change 100755 => 100644 html/cgi-bin/shutdown.cgi mode change 100755 => 100644 html/cgi-bin/tor.cgi diff --git a/html/cgi-bin/firewall.cgi b/html/cgi-bin/firewall.cgi old mode 100755 new mode 100644 index ceaab566b..7ffe59c6f --- a/html/cgi-bin/firewall.cgi +++ b/html/cgi-bin/firewall.cgi @@ -1050,7 +1050,7 @@ END if (! -z $configgrp || $optionsfw{'SHOWDROPDOWN'} eq 'on'){ print"$Lang::tr{'fwhost cust grp'}"; + #check if this group has only one entry + foreach my $key2 (keys %hash) { + if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){ + print "" ; + } + } } print""; @@ -1793,11 +1793,15 @@ sub viewtableservicegrp my $grpname; my $remark; my $helper; + my $helper1; my $port; my $protocol; my $delflag; my $grpcount=0; my $col=''; + my $lastentry=0; + my @counter; + my %hash; if (! -z $configsrvgrp){ &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'}); &General::readhasharray("$configsrvgrp", \%customservicegrp); @@ -1806,6 +1810,12 @@ sub viewtableservicegrp &General::readhasharray("$fwconfiginp", \%fwinp); &General::readhasharray("$fwconfigout", \%fwout); my $number= keys %customservicegrp; + foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){ + push (@counter,$customservicegrp{$key}[0]); + } + foreach my $key1 (@counter) { + $hash{$key1}++ ; + } foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){ $count++; if ($helper ne $customservicegrp{$key}[0]){ @@ -1823,12 +1833,12 @@ sub viewtableservicegrp } $grpname=$customservicegrp{$key}[0]; if ($customservicegrp{$key}[2] eq "none"){ - $customservicegrp{$key}[2]=$Lang::tr{'fwhost empty'}; + $customservicegrp{$key}[2]=$Lang::tr{'fwhost err emptytable'}; $port=''; $protocol=''; } $remark="$customservicegrp{$key}[1]"; - if($count >=2){print"";} + if($count >0){print"";$count=1;} print "
$grpname    "; print "$Lang::tr{'remark'}:  $remark " if ($remark ne ''); print "  $Lang::tr{'used'}: $grpcount x"; @@ -1849,6 +1859,11 @@ sub viewtableservicegrp print""; $col="bgcolor='$color{'color22'}'"; } + #make lines yellow if it is a dummy entry + if ($customservicegrp{$key}[2] eq $Lang::tr{'fwhost err emptytable'}){ + print""; + $col="bgcolor='${Header::colouryellow}'"; + } #Set fields if we use protocols in servicegroups if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){ $port='-'; @@ -1868,8 +1883,16 @@ sub viewtableservicegrp } } print"$port$protocol
"; - if ($delflag gt '1'){ - print""; + if ($delflag gt '0'){ + if ($customservicegrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){ + print""; + } + #check if this group has only one entry + foreach my $key2 (keys %hash) { + if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){ + print "" ; + } + } } print""; if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){ diff --git a/html/cgi-bin/p2p-block.cgi b/html/cgi-bin/p2p-block.cgi old mode 100755 new mode 100644 diff --git a/html/cgi-bin/shutdown.cgi b/html/cgi-bin/shutdown.cgi old mode 100755 new mode 100644 diff --git a/html/cgi-bin/tor.cgi b/html/cgi-bin/tor.cgi old mode 100755 new mode 100644 -- 2.39.2