]> git.ipfire.org Git - ipfire-2.x.git/blobdiff - html/cgi-bin/fwhosts.cgi
Merge remote-tracking branch 'origin/master' into kernel-test
[ipfire-2.x.git] / html / cgi-bin / fwhosts.cgi
index 042fdde0c5339b1f39c7e20450d442e393ef362f..1f96336a6b4d9b964b80572504aeacf5089c5cf3 100644 (file)
@@ -66,7 +66,6 @@ my $fwconfigfwd               = "${General::swroot}/firewall/config";
 my $fwconfiginp                = "${General::swroot}/firewall/input";
 my $fwconfigout                = "${General::swroot}/firewall/outgoing";
 my $configovpn         = "${General::swroot}/ovpn/settings";
-my $tdcolor='';
 my $configipsecrw      = "${General::swroot}/vpn/settings";
 
 unless (-e $confignet)    { system("touch $confignet"); }
@@ -293,25 +292,25 @@ if ($fwhostsettings{'ACTION'} eq 'savenet' )
                }
                if($fwhostsettings{'error'} ne 'on'){
                        #check if we use one of ipfire's networks (green,orange,blue)
-                       if (($ownnet{'GREEN_NETADDRESS'}        ne '' && $ownnet{'GREEN_NETADDRESS'}    ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'GREEN_NETADDRESS'},$ownnet{'GREEN_NETMASK'}))
+                       if (($ownnet{'GREEN_NETADDRESS'}        ne '' && $ownnet{'GREEN_NETADDRESS'}    ne '0.0.0.0') && ($fwhostsettings{'IP'} eq $ownnet{'GREEN_NETADDRESS'} && $fwhostsettings{'SUBNET'} eq $ownnet{'GREEN_NETMASK'}))
                        { 
                                $errormessage=$errormessage.$Lang::tr{'ccd err green'}."<br>";
                                $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
                                if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
                        }
-                       if (($ownnet{'ORANGE_NETADDRESS'}       ne '' && $ownnet{'ORANGE_NETADDRESS'}   ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'ORANGE_NETADDRESS'},$ownnet{'ORANGE_NETMASK'}))
+                       if (($ownnet{'ORANGE_NETADDRESS'}       ne '' && $ownnet{'ORANGE_NETADDRESS'}   ne '0.0.0.0') && ($fwhostsettings{'IP'} eq $ownnet{'ORANGE_NETADDRESS'} && $fwhostsettings{'SUBNET'} eq $ownnet{'ORANGE_NETMASK'}))
                        { 
                                $errormessage=$errormessage.$Lang::tr{'ccd err orange'}."<br>";
                                $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
                                if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
                        }
-                       if (($ownnet{'BLUE_NETADDRESS'}         ne '' && $ownnet{'BLUE_NETADDRESS'}     ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'BLUE_NETADDRESS'},$ownnet{'BLUE_NETMASK'}))
+                       if (($ownnet{'BLUE_NETADDRESS'}         ne '' && $ownnet{'BLUE_NETADDRESS'}     ne '0.0.0.0') && ($fwhostsettings{'IP'} eq $ownnet{'BLUE_NETADDRESS'} && $fwhostsettings{'SUBNET'} eq $ownnet{'BLUE_NETMASK'}))
                        { 
                                $errormessage=$errormessage.$Lang::tr{'ccd err blue'}."<br>";
                                $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
                                if ($fwhostsettings{'update'} eq 'on'){$fwhostsettings{'ACTION'}='editnet';}
                        }
-                       if (($ownnet{'RED_NETADDRESS'}  ne '' && $ownnet{'RED_NETADDRESS'}              ne '0.0.0.0') && &General::IpInSubnet($fwhostsettings{'IP'},$ownnet{'RED_NETADDRESS'},$ownnet{'RED_NETMASK'}))
+                       if (($ownnet{'RED_NETADDRESS'}  ne '' && $ownnet{'RED_NETADDRESS'}              ne '0.0.0.0') && ($fwhostsettings{'IP'} eq $ownnet{'RED_NETADDRESS'} && $fwhostsettings{'SUBNET'} eq $ownnet{'RED_NETMASK'}))
                        { 
                                $errormessage=$errormessage.$Lang::tr{'ccd err red'}."<br>";
                                $fwhostsettings{'HOSTNAME'} = $fwhostsettings{'orgname'};
@@ -910,9 +909,6 @@ if ($fwhostsettings{'ACTION'} eq 'deletegrphost')
        }
        &General::writehasharray("$configgrp", \%customgrp);
        &General::firewall_config_changed();
-       if ($fwhostsettings{'grpcnt'} > 0){
-               &General::firewall_config_changed();
-       }
        if ($fwhostsettings{'update'} eq 'on'){
                $fwhostsettings{'remark'}= $grpremark;
                $fwhostsettings{'grp_name'}=$grpname;
@@ -1624,6 +1620,7 @@ sub getcolor
                my $c=shift;
                my $sip;
                my $scidr;
+               my $tdcolor='';
                #Check if MAC
                if (&General::validmac($c)){ return $c;}
 
@@ -1635,7 +1632,7 @@ sub getcolor
                }
 
                #Now check if IP is part of ORANGE,BLUE or GREEN
-               if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+               if ( &Header::orange_used() && &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
                        $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
                        return $tdcolor;
                }
@@ -1643,7 +1640,7 @@ sub getcolor
                        $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
                        return $tdcolor;
                }
-               if ( &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
+               if ( &Header::blue_used() && &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
                        $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
                        return $tdcolor;
                }
@@ -1688,10 +1685,13 @@ sub getcolor
 
                #Check if IP is part of a IPsec N2N network
                foreach my $key (sort keys %ipsecconf){
-                       my ($a,$b) = split("/",$ipsecconf{$key}[11]);
-                       if (&General::IpInSubnet($sip,$a,$b)){
-                               $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
-                               return $tdcolor;
+                       if ($ipsecconf{$key}[11]){
+                               my ($a,$b) = split("/",$ipsecconf{$key}[11]);
+                               $b=&General::iporsubtodec($b);
+                               if (&General::IpInSubnet($sip,$a,$b)){
+                                       $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
+                                       return $tdcolor;
+                               }
                        }
                }
                return "$c";
@@ -1840,11 +1840,11 @@ sub viewtablegrp
                                print "$customgrp{$key}[2]</td>";
                        }
                        if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){
-                               print "<td align='center' $col>$Lang::tr{'fwhost deleted'}</td><td align='center' $col>$customgrp{$key}[3]</td><td width='1%' $col><form method='post'>";
+                               print "<td align='center' $col>$Lang::tr{'fwhost deleted'}</td><td align='center' $col>$Lang::tr{'fwhost '.$customgrp{$key}[3]}</td><td width='1%' $col><form method='post'>";
                        }else{
                                my ($colip,$colsub) = split("/",$ip);
-                               $ip="$colip/".&General::subtocidr($colsub) if ($colsub);
-                               print"<td align='center' $col>".&getcolor($ip)."</td><td align='center' $col>$customgrp{$key}[3]</td><td width='1%' $col><form method='post'>";
+                               $ip="$colip/".&General::iporsubtocidr($colsub) if ($colsub);
+                               print"<td align='center' $col>".&getcolor($ip)."</td><td align='center' $col>$Lang::tr{'fwhost '.$customgrp{$key}[3]}</td><td width='1%' $col><form method='post'>";
                        }
                        if ($delflag > 0 && $ip ne ''){
                                print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' />";
@@ -1855,8 +1855,7 @@ sub viewtablegrp
                                        }
                                }
                        }
-                       print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='grpcnt' value='$customgrp{$key}[4]'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
-                       
+                       print"<input type='hidden' name='ACTION' value='deletegrphost'><input type='hidden' name='update' value='$fwhostsettings{'update'}'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
                        $helper=$customgrp{$key}[0];
                        $number++;
                }