]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/fwhosts.cgi
Forward Firewall: BUGFIX: when having more than 10 hosts/networks in a firewall-group...
[people/teissler/ipfire-2.x.git] / html / cgi-bin / fwhosts.cgi
index fffa9353ebfde82eb1d846b330bb1c9b0cc31918..482ccabf5ba94a57d53a7e3076eea2438124d57b 100755 (executable)
@@ -2,7 +2,7 @@
 ###############################################################################
 #                                                                             #
 # IPFire.org - A linux based firewall                                         #
-# Copyright (C) 2013                                                          #
+# Copyright (C) 2013 Alexander Marx <amarx@ipfire.org>                        #
 #                                                                             #
 # 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        #
@@ -18,8 +18,6 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
 #                                                                             #
 ###############################################################################
-# Author: Alexander Marx  (amarx@ipfire.org)                                  #
-###############################################################################
 use strict;
 
 # enable only the following on debugging purpose
@@ -545,6 +543,8 @@ if ($fwhostsettings{'ACTION'} eq 'savegrp')
        &General::readhasharray("$confighost", \%customhost);
        #check name
        if (!&validhostname($grp)){$errormessage.=$Lang::tr{'fwhost err name'};}
+       #check existing name
+       if (!checkgroup(\%customgrp,$grp) && $fwhostsettings{'update'} ne 'on'){$errormessage.=$Lang::tr{'fwhost err grpexist'};}
        #check remark
        if ($rem ne '' && !&validremark($rem) && $fwhostsettings{'update'} ne 'on'){
                $errormessage.=$Lang::tr{'fwhost err remark'};
@@ -1492,9 +1492,9 @@ sub viewtablegrp
        my $delflag;
        if (!keys %customgrp) 
        { 
-               print "<center><b>$Lang::tr{'fwhost empty'}</b>"; 
+               print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
        }else{
-               foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp ($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
+               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]){
                                $delflag='0';
@@ -1508,10 +1508,10 @@ sub viewtablegrp
                                        }
                                }
                                $number=1;
-                               if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr{'fwhost empty'};}
+                               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 2){ print"</table>";}
+                               if($count gt 1){ print"</table>";}
                                print "<br><b><u>$grpname</u></b>&nbsp; &nbsp;";
                                print " <b>$Lang::tr{'remark'}:</b>&nbsp $remark &nbsp " if ($remark ne '');
                                print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
@@ -1538,7 +1538,7 @@ sub viewtablegrp
                        }else{
                                print "$customgrp{$key}[2]</td>";
                        }
-                       if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost empty'}){
+                       if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){
                                print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";   
                        }else{
                                my ($colip,$colsub) = split("/",$ip);
@@ -1554,7 +1554,6 @@ sub viewtablegrp
                        $number++;
                }
                print"</table>";
-               
        }
        &Header::closebox();
 }
@@ -1683,6 +1682,17 @@ sub checkname
        return 1;
        
 }
+sub checkgroup
+{
+       my %hash=%{(shift)};
+       my $name=shift;
+       foreach my $key (keys %hash) {
+               if($hash{$key}[0] eq $name){
+                       return 0;
+               }
+       }
+       return 1;
+}
 sub checkip
 {