]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/fwhosts.cgi
Forward Firewall: added "apply" button to groupmanagement. Now the user can make...
[people/teissler/ipfire-2.x.git] / html / cgi-bin / fwhosts.cgi
index 6ce7ac8df2e635e4e60cdfa6212c18b1b94ae8ba..636cf65e43b02c7878de1bdb9e585c6c03d60639 100755 (executable)
@@ -80,6 +80,11 @@ unless (-e $configsrvgrp) { system("touch $configsrvgrp"); }
 &Header::openbigbox('100%', 'center');
 
 ## ACTION ####
+if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'})
+{
+       &reread_rules;
+       &showmenu;
+}
 # Update
 if ($fwhostsettings{'ACTION'} eq 'updatenet' )
 {
@@ -108,7 +113,6 @@ if ($fwhostsettings{'ACTION'} eq 'updatehost')
        {
                if($customhost{$key}[0] eq $fwhostsettings{'orgname'})
                {
-                       $fwhostsettings{'orgname'} = $customhost{$key}[0];
                        if ($customhost{$key}[1] eq 'ip'){
                                ($ip,$subnet) = split (/\//,$customhost{$key}[2]);
                        }else{
@@ -117,11 +121,15 @@ if ($fwhostsettings{'ACTION'} eq 'updatehost')
                        $fwhostsettings{'orgip'} = $ip;
                        $fwhostsettings{'count'} = $customhost{$key}[3];
                        delete $customhost{$key};
+                       &General::writehasharray("$confighost", \%customhost);
                }
        }
-       &General::writehasharray("$confighost", \%customhost);
        $fwhostsettings{'actualize'} = 'on';
+       if($fwhostsettings{'orgip'}){
        $fwhostsettings{'ACTION'} = 'savehost';
+       }else{
+               $fwhostsettings{'ACTION'} = $Lang::tr{'fwhost newhost'};
+       }
 }
 if ($fwhostsettings{'ACTION'} eq 'updateservice')
 {
@@ -179,18 +187,14 @@ if ($fwhostsettings{'ACTION'} eq 'updateservice')
                                }
                        }
                        &General::writehasharray("$configsrvgrp", \%customservicegrp);
-                       
                        $needrules='on';
                }
-               
-               
                if($count gt 0 && $fwhostsettings{'oldsrvport'} ne $fwhostsettings{'SRV_PORT'} ){
                        $needrules='on';
                }
                if($count gt 0 && $fwhostsettings{'oldsrvprot'} ne $fwhostsettings{'PROT'} ){
                        $needrules='on';
                }
-               
                $fwhostsettings{'SRV_NAME'}     = '';
                $fwhostsettings{'SRV_PORT'}     = '';
                $fwhostsettings{'PROT'}         = '';
@@ -747,7 +751,7 @@ if ($fwhostsettings{'ACTION'} eq 'saveservicegrp')
                {
                        if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'})
                        {
-                               $count=$customservicegrp{$key}[5];
+                               $count=$customservicegrp{$key}[3];
                                last;
                        }
                }
@@ -1004,9 +1008,15 @@ sub showmenu
        <table border='0' width='100%'><form method='post'>
        <tr><td><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newnet'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newhost'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newgrp'}' /></td>
        <td align='right'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' /><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' /></td></tr>
-       <tr><td colspan='6'><hr></hr></td></tr></table></form>
+       <tr><td colspan='6'><hr></hr></td>
 END
        
+               
+       if (-f "${General::swroot}/fwhosts/reread"){
+               print "</tr><tr><td colspan='6'><input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}'>$Lang::tr{'fwhost reread'}</td>";
+       }
+               print"</tr></table></form>";    
+
        &Header::closebox();
        
 }
@@ -1364,6 +1374,7 @@ END
                        }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
                        else{            print" <tr bgcolor='$color{'color20'}'>";}
                        my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
+                       $customhost{$key}[3]=~s/\s+//g;
                        print<<END;
                        <td width='40%'><form method='post'>$customhost{$key}[0]</td><td width='50%'>$ip</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'} />
@@ -1397,18 +1408,18 @@ sub viewtablegrp
        &General::readhasharray("$confignet", \%customnetwork);
        my @grp=();
        my $helper='';
-       my $count=0;
+       my $count=1;
        my $grpname;
        my $remark;
-       my $number=keys %customgrp;
+       my $number;
        if (!keys %customgrp) 
        { 
                print "<center><b>$Lang::tr{'fwhost empty'}</b>"; 
        }else{
                foreach my $key (sort { uc($customgrp{$a}[0]) cmp uc($customgrp{$b}[0]) } sort { uc($customgrp{$a}[2]) cmp uc($customgrp{$b}[2]) } keys %customgrp){
-                       
                        $count++;
                        if ($helper ne $customgrp{$key}[0]){
+                               $number=1;
                                $grpname=$customgrp{$key}[0];
                                $remark=$customgrp{$key}[1];
                                if($count >=2){print"</table>";}
@@ -1440,12 +1451,13 @@ sub viewtablegrp
                        }else{
                                print"<td>$ip</td><td>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
                        }
-                       if ($number gt '1' && $ip ne ''){
+                       if ($number > 1 && $ip ne ''){
                                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='deletegrphost'><input type='hidden' name='delhost' value='$grpname,$remark,$customgrp{$key}[2],$customgrp{$key}[3]'></form></td></tr>";
                        
                        $helper=$customgrp{$key}[0];
+                       $number++;
                }
                print"</table>";
                
@@ -1608,7 +1620,6 @@ sub checkservicegroup
        {
                $errormessage.=$Lang::tr{'fwhost err groupempty'}."<br>";
        }
-       
        #check if name already exists
        if ($fwhostsettings{'updatesrvgrp'} ne 'on'){
                foreach my $key (keys %customservicegrp) {
@@ -1620,14 +1631,10 @@ sub checkservicegroup
        }
        #check if service already exists in group
        foreach my $key (keys %customservicegrp) {
-                       if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
-                               $errormessage.=$Lang::tr{'fwhost err srvexist'}."<br>";
-                       
-                       }
+               if($customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'} && $customservicegrp{$key}[2] eq $fwhostsettings{'CUST_SRV'} ){
+                       $errormessage.=$Lang::tr{'fwhost err srvexist'}."<br>";
                }
-       
-       
-       
+       }
        return $errormessage;
 }
 sub error
@@ -1880,10 +1887,20 @@ sub getipforgroup
        }
 }
 sub rules
+{
+       if (!-f "${General::swroot}/fwhosts/reread"){
+               system("touch ${General::swroot}/fwhosts/reread");
+       }
+}
+sub reread_rules
 {
        system ("/usr/local/bin/forwardfwctrl");
-       system("rm ${General::swroot}/forward/reread");
+       if ( -f "${General::swroot}/fwhosts/reread"){
+               system("rm ${General::swroot}/fwhosts/reread");
+       }
+       
 }
+
 sub decrease
 {
        my $grp=$_[0];