X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=html%2Fcgi-bin%2Ffwhosts.cgi;h=67e8dc8271dc9f546665ad879e06e85f22339885;hb=501e7b8654263f6758e273162f09183661d40303;hp=3b46677b8c30625e6c57b9aaba47fd2e3cf1b628;hpb=4ed7ef4620637d6047edc4fd713e753d3a7f254e;p=people%2Fteissler%2Fipfire-2.x.git diff --git a/html/cgi-bin/fwhosts.cgi b/html/cgi-bin/fwhosts.cgi old mode 100755 new mode 100644 index 3b46677b8..67e8dc827 --- a/html/cgi-bin/fwhosts.cgi +++ b/html/cgi-bin/fwhosts.cgi @@ -84,7 +84,7 @@ unless (-e $configsrvgrp) { system("touch $configsrvgrp"); } &Header::getcgihash(\%fwhostsettings); &Header::showhttpheaders(); -&Header::openpage($Lang::tr{'fwhost hosts'}, 1, ''); +&Header::openpage($Lang::tr{'fwhost menu'}, 1, ''); &Header::openbigbox('100%', 'center'); #### JAVA SCRIPT #### @@ -780,7 +780,7 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp') } #on update, we have to delete the dummy entry foreach my $key (keys %customservicegrp){ - if ($customservicegrp{$key}[2] eq 'none'){ + if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){ delete $customservicegrp{$key}; last; } @@ -893,33 +893,22 @@ if ($fwhostsettings{'ACTION'} eq 'deletegrphost') &General::readhasharray("$configgrp", \%customgrp); foreach my $key (keys %customgrp){ if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){ - #decrease count from source host/net - if ($customgrp{$key}[3] eq 'Custom Network'){ - &General::readhasharray("$confignet", \%customnetwork); - foreach my $key1 (keys %customnetwork){ - if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){ - $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1; - last; - } - } - &General::writehasharray("$confignet", \%customnetwork); - } - if ($customgrp{$key}[3] eq 'Custom Host'){ - &General::readhasharray("$confighost", \%customhost); - foreach my $key1 (keys %customhost){ - if ($customhost{$key1}[0] eq $customgrp{$key}[2]){ - $customhost{$key1}[4] = $customhost{$key1}[4]-1; - last; - } - } - &General::writehasharray("$confighost", \%customhost); - } $grpname=$customgrp{$key}[0]; $grpremark=$customgrp{$key}[1]; - delete $customgrp{$key}; + #check if we delete the last entry, then generate dummy + if ($fwhostsettings{'last'} eq 'on'){ + $customgrp{$key}[1] = ''; + $customgrp{$key}[2] = 'none'; + $customgrp{$key}[3] = ''; + $fwhostsettings{'last'}=''; + last; + }else{ + delete $customgrp{$key}; + } } } &General::writehasharray("$configgrp", \%customgrp); + &General::firewall_config_changed(); if ($fwhostsettings{'grpcnt'} > 0){ &General::firewall_config_changed(); } @@ -982,23 +971,20 @@ if ($fwhostsettings{'ACTION'} eq 'delgrpservice') my $grpname; my $grpremark; &General::readhasharray("$configsrvgrp", \%customservicegrp); - &General::readhasharray("$configsrv", \%customservice); foreach my $key (keys %customservicegrp){ if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'}) { - #decrease count from source service - foreach my $key1 (sort keys %customservice){ - if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){ - $customservice{$key1}[4]--; - last; - } - } $grpname=$customservicegrp{$key}[0]; $grpremark=$customservicegrp{$key}[1]; - delete $customservicegrp{$key}; + if($fwhostsettings{'last'} eq 'on'){ + $customservicegrp{$key}[2] = 'none'; + $fwhostsettings{'last'} = ''; + last; + }else{ + delete $customservicegrp{$key}; + } } } - &General::writehasharray("$configsrv", \%customservice); &General::writehasharray("$configsrvgrp", \%customservicegrp); &General::firewall_config_changed(); if ($fwhostsettings{'updatesrvgrp'} eq 'on'){ @@ -1007,7 +993,6 @@ if ($fwhostsettings{'ACTION'} eq 'delgrpservice') } &addservicegrp; &viewtableservicegrp; - } if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newnet'}) { @@ -1139,13 +1124,13 @@ if($fwhostsettings{'ACTION'} eq '') } ### FUNCTIONS ### sub showmenu { - &Header::openbox('100%', 'left',$Lang::tr{'fwhost menu'}); + &Header::openbox('100%', 'left',); print "$Lang::tr{'fwhost welcome'}"; print<
-

+ END &Header::closebox(); @@ -1164,7 +1149,7 @@ sub addnet $Lang::tr{'fwhost netaddress'}: $Lang::tr{'netmask'}: $Lang::tr{'remark'}: -

+
END if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on') { @@ -1183,11 +1168,11 @@ sub addhost $fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'}; $fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'}; print< + - + END if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on') @@ -1224,17 +1209,36 @@ sub addgrp my $rem=$fwhostsettings{'remark'}; if ($fwhostsettings{'update'} eq ''){ print< - - -
$Lang::tr{'name'}:
IP/MAC:
$Lang::tr{'remark'}:


$Lang::tr{'fwhost addgrpname'}
$Lang::tr{'remark'}:


+ + + + + + + + + + + + +
$Lang::tr{'fwhost addgrpname'}
$Lang::tr{'remark'}:

END }else{ print< - $Lang::tr{'fwhost addgrpname'} -
$Lang::tr{'remark'}:
-
+ + $Lang::tr{'fwhost addgrpname'} + + + + +
+ $Lang::tr{'remark'}: + + + +
+

END } if ($fwhostsettings{'update'} eq 'on'){ @@ -1263,14 +1267,14 @@ END } print""; if (! -z $confignet){ - print"$Lang::tr{'fwhost cust net'}$Lang::tr{'fwhost cust net'}:"; } if (! -z $confighost){ - print"$Lang::tr{'fwhost cust addr'}$Lang::tr{'fwhost cust addr'}:$Lang::tr{'fwhost ovpn_n2n'}$Lang::tr{'fwhost ovpn_n2n'}:";} print""; print""; - print"


"; + print"

"; } - print""; + print"
"; print"
"; &Header::closebox(); } @@ -1366,7 +1370,7 @@ END print<
$Lang::tr{'fwhost port'}:
- +


";# bgcolor='$color{'color20'}'>"; + print" "; }else { $col="bgcolor='$color{'color22'}'"; - print" ";# bgcolor='$color{'color22'}'>"; + print" "; } my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]); my $netcount=&getnetcount($customnetwork{$key}[0]); @@ -1636,10 +1640,19 @@ sub viewtablegrp my $remark; my $number; my $delflag; + my @counter; + my %hash; if (!keys %customgrp) { print "
$Lang::tr{'fwhost err emptytable'}"; }else{ + #get all groups in a hash + foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){ + push (@counter,$customgrp{$key}[0]); + } + foreach my $key1 (@counter) { + $hash{$key1}++ ; + } foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){ $count++; if ($helper ne $customgrp{$key}[0]){ @@ -1657,7 +1670,7 @@ sub viewtablegrp if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr{'fwhost err emptytable'};} $grpname=$customgrp{$key}[0]; $remark="$customgrp{$key}[1]"; - if($count gt 1){ print"

END if ($fwhostsettings{'updatesrv'} eq 'on') @@ -1403,22 +1407,22 @@ sub addservicegrp - +
$Lang::tr{'fwhost addgrpname'}
$Lang::tr{'remark'}:



END }else{ print< + - +
$Lang::tr{'fwhost addgrpname'}
$Lang::tr{'remark'}:



END } if($fwhostsettings{'updatesrvgrp'} eq 'on'){ print< - - +
$Lang::tr{'add'}
$Lang::tr{'add'}:



END } print< +
END @@ -1478,11 +1482,11 @@ END }elsif ($count % 2) { $col="bgcolor='$color{'color20'}'"; - print"
";} + if($count gt 1){ print"";$count=1;} print "
$grpname   "; print " $Lang::tr{'remark'}:  $remark   " if ($remark ne ''); my $netgrpcount=&getnetcount($grpname); @@ -1667,7 +1680,7 @@ sub viewtablegrp print"
"; } print"
"; - print""; + print"
Name$Lang::tr{'ip address'}$Lang::tr{'fwhost type'}
"; } my $col=''; if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) { @@ -1675,10 +1688,10 @@ sub viewtablegrp $col="bgcolor='${Header::colouryellow}'"; }elsif ($count %2 == 0){ print""; - $col="bgcolor='$color{'color22'}'"; + $col="bgcolor='$color{'color20'}'"; }else{ print""; - $col="bgcolor='$color{'color20'}'"; + $col="bgcolor='$color{'color22'}'"; } my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]); if ($ip eq ''){ @@ -1698,8 +1711,14 @@ sub viewtablegrp $ip="$colip/".&General::subtocidr($colsub) if ($colsub); print""; @@ -1774,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); @@ -1787,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]){ @@ -1804,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"
$Lang::tr{'name'}$Lang::tr{'fwhost ip_mac'}$Lang::tr{'fwhost type'}
".&Header::colorize($ip)."$customgrp{$key}[3]
"; } - if ($delflag > 1 && $ip ne ''){ + if ($delflag > 0 && $ip ne ''){ print""; + #check if this group has only one entry + foreach my $key2 (keys %hash) { + if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){ + print "" ; + } + } } print"
";} + if($count >0){print"";$count=1;} print "
$grpname    "; print "$Lang::tr{'remark'}:  $remark " if ($remark ne ''); print "  $Lang::tr{'used'}: $grpcount x"; @@ -1830,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='-'; @@ -1849,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'){