]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/fwhosts.cgi
Forward Firewall: redefined layout of customservicegroups and some layout changes
[ipfire-2.x.git] / html / cgi-bin / fwhosts.cgi
index 278d57c0a662437d954e8a206856f95ccdd5cbf8..88c32c4cc337f9bbbc4697c7965056fe8c8e6679 100755 (executable)
@@ -800,9 +800,8 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
                $customservicegrp{$key}[0] = $fwhostsettings{'SRVGRP_NAME'};
                $customservicegrp{$key}[1] = $fwhostsettings{'SRVGRP_REMARK'};
                $customservicegrp{$key}[2] = $fwhostsettings{'CUST_SRV'};
-               $customservicegrp{$key}[3] = $port;
-               $customservicegrp{$key}[4] = $prot;
-               $customservicegrp{$key}[5] = $count;
+               $customservicegrp{$key}[3] = $count;
+               
                &General::writehasharray("$configsrvgrp", \%customservicegrp );
                $fwhostsettings{'updatesrvgrp'}='on';
        }
@@ -1313,7 +1312,7 @@ END
        <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
 END
        &General::readhasharray("$configsrv", \%customservice);
-       foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) }  keys %customservice)
+       foreach my $key (sort {$a <=> $b}  keys %customservice)
        {
                print "<option>$customservice{$key}[0]</option>";
        }
@@ -1348,7 +1347,7 @@ sub viewtablenet
 END
                }
                my $count=0;
-               foreach my $key (sort { uc($customnetwork{$a}[0]) cmp uc($customnetwork{$b}[0]) } keys %customnetwork) {
+               foreach my $key (sort {$a <=> $b} keys %customnetwork) {
                        if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
                                print" <tr bgcolor='${Header::colouryellow}'>";
                        }elsif ($count % 2)
@@ -1359,7 +1358,7 @@ END
                                print" <tr bgcolor='$color{'color20'}'>";
                        }
                        print<<END;
-                       <td width='40%'><form method='post'>$customnetwork{$key}[0]</td><td width=25%'>$customnetwork{$key}[1]</td><td width='25%'>$customnetwork{$key}[2]</td><td align='center'>$customnetwork{$key}[3] x</td>
+                       <td width='40%'><form method='post'>$customnetwork{$key}[0]</td><td width=25%'>$customnetwork{$key}[1]</td><td width='25%'>$customnetwork{$key}[2]</td><td align='center'>$customnetwork{$key}[3]x</td>
                        <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
                        <input type='hidden' name='ACTION' value='editnet'>
                        <input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
@@ -1395,14 +1394,14 @@ sub viewtablehost
 END
        }
                my $count=0;
-               foreach my $key (sort { uc($customhost{$a}[0]) cmp uc($customhost{$b}[0]) } keys %customhost) {
+               foreach my $key (sort {$a <=> $b} keys %customhost) {
                        if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
                                print" <tr bgcolor='${Header::colouryellow}'>";
                        }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
                        else{            print" <tr bgcolor='$color{'color20'}'>";}
                        my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
                        print<<END;
-                       <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$customhost{$key}[2]</td><td align='center'>$customhost{$key}[3] x</td>
+                       <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$customhost{$key}[2]</td><td align='center'>$customhost{$key}[3]x</td>
                        <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
                        <input type='hidden' name='ACTION' value='edithost' />
                        <input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
@@ -1451,7 +1450,7 @@ sub viewtablegrp
                                if($count >=2){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";
+                               print "<b>$Lang::tr{'used'}:</b> $customgrp{$key}[4]x";
                                if($customgrp{$key}[4] == '0')
                                {
                                        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>";
@@ -1502,7 +1501,7 @@ sub viewtableservice
                        <table width='100%' border='0'>
                        <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</td><td align='center'><b>$Lang::tr{'fwhost prot'}</td><td align='center'><b>$Lang::tr{'fwhost port'}</td><td align='center'><b>ICMP</td><td align='center'><b>$Lang::tr{'fwhost used'}</td><td></td><td width='3%'></td></tr>
 END
-               foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0]) } keys %customservice)
+               foreach my $key (sort { uc($customservice{$a}[0]) cmp uc($customservice{$b}[0])||  $a <=> $b } keys %customservice)
                {
                        $count++;
                        if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
@@ -1537,12 +1536,14 @@ sub viewtableservicegrp
        my $grpname;
        my $remark;
        my $helper;
+       my $port;
+       my $protocol;
        if (! -z $configsrvgrp){
-       
                &Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'});
                &General::readhasharray("$configsrvgrp", \%customservicegrp);
+               &General::readhasharray("$configsrv", \%customservice);
                my $number= keys %customservicegrp;
-               foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0]) }  keys %customservicegrp){
+               foreach my $key (sort { uc($customservicegrp{$a}[0]) cmp uc($customservicegrp{$b}[0])||  $a <=> $b } keys %customservicegrp){
                        $count++;
                        if ($helper ne $customservicegrp{$key}[0]){
                                $grpname=$customservicegrp{$key}[0];
@@ -1550,8 +1551,8 @@ sub viewtableservicegrp
                                if($count >=2){print"</table>";}
                                print "<br><b><u>$grpname</u></b> &nbsp &nbsp ";
                                print "<b>$Lang::tr{'remark'}:</b>&nbsp $remark " if ($remark ne '');
-                               print "&nbsp <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[5] x";
-                               if($customservicegrp{$key}[5] == '0')
+                               print "&nbsp <b>$Lang::tr{'used'}:</b> $customservicegrp{$key}[3]x";
+                               if($customservicegrp{$key}[3] == '0')
                                {
                                        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>";
                                }
@@ -1560,14 +1561,26 @@ sub viewtableservicegrp
                        }
                        if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
                                print" <tr bgcolor='${Header::colouryellow}'>";
-                               }elsif ($count %2 == 0){print"<tr bgcolor='$color{'color22'}'>";}else{print"<tr bgcolor='$color{'color20'}'>";}
-                               print "<td width='39%'>$customservicegrp{$key}[2]</td>";
-                               print"<td align='center'>$customservicegrp{$key}[3]</td><td align='center'>$customservicegrp{$key}[4]</td><td width='1%'><form method='post'>";
-                               if ($number gt '1'){
-                                       print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
+                       }
+                       if ($count %2 == 0){
+                               print"<tr bgcolor='$color{'color22'}'>";
+                       }else{
+                               print"<tr bgcolor='$color{'color20'}'>";
+                       }
+                       print "<td width='39%'>$customservicegrp{$key}[2]</td>";
+                       foreach my $srv (sort keys %customservice){
+                               if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
+                                       $protocol=$customservice{$srv}[2];
+                                       $port=$customservice{$srv}[1];
+                                       last;
                                }
-                               print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
-                               $helper=$customservicegrp{$key}[0];
+                       }
+                       print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
+                       if ($number gt '1'){
+                               print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
+                       }
+                       print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='delsrvfromgrp' value='$grpname,$remark,$customservicegrp{$key}[2],$customservicegrp{$key}[3]'></form></td></tr>";
+                       $helper=$customservicegrp{$key}[0];
                }
                print"</table>";
                &Header::closebox();