]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/forwardfw.cgi
Forward Firewall: removed cellspacing and black lines between rules in ruletable
[people/teissler/ipfire-2.x.git] / html / cgi-bin / forwardfw.cgi
index 195205875ed050d55868465af5cf256d7fa4999d..694409faef6682eeff0c2a328c0ef865240f83ab 100755 (executable)
@@ -342,35 +342,33 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
 }
 if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'reset'})
 {
-       &General::readhasharray("$configfwdfw", \%configfwdfw);
-       foreach my $key (sort keys %configfwdfw){
-               &checkcounter($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
-               &checkcounter($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
-               &checkcounter($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
-       }
-               &General::readhasharray("$configinput", \%configinputfw);
-       foreach my $key (sort keys %configinputfw){
-               &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
-               &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
-               &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
-       }
-       
-       system("rm ${General::swroot}/forward/config");
-       system("rm ${General::swroot}/forward/input");
-       &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
-       unless (-e "${General::swroot}/forward/config")         { system("touch ${General::swroot}/forward/config"); }
-       unless (-e "${General::swroot}/forward/input")          { system("touch ${General::swroot}/forward/input"); }
-       my $MODE1=$fwdfwsettings{'POLICY1'};
-       %fwdfwsettings = ();
-       $fwdfwsettings{'POLICY'}='MODE2';
-       $fwdfwsettings{'POLICY1'}=$MODE1;
-       &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
-       &reread_rules;
-
-}
-if ($fwdfwsettings{'ACTION'} eq 'resetoutgoing')
-{
-       &General::readhasharray("$configoutgoing", \%configoutgoingfw);
+       if($fwdfwsettings{'poltype'} eq 'forward'){
+               &General::readhasharray("$configfwdfw", \%configfwdfw);
+               foreach my $key (sort keys %configfwdfw){
+                       &checkcounter($configfwdfw{$key}[3],$configfwdfw{$key}[4],,);
+                       &checkcounter($configfwdfw{$key}[5],$configfwdfw{$key}[6],,);
+                       &checkcounter($configfwdfw{$key}[14],$configfwdfw{$key}[15],,);
+               }
+                       &General::readhasharray("$configinput", \%configinputfw);
+               foreach my $key (sort keys %configinputfw){
+                       &checkcounter($configinputfw{$key}[3],$configinputfw{$key}[4],,);
+                       &checkcounter($configinputfw{$key}[5],$configinputfw{$key}[6],,);
+                       &checkcounter($configinputfw{$key}[14],$configinputfw{$key}[15],,);
+               }
+               
+               system("rm ${General::swroot}/forward/config");
+               system("rm ${General::swroot}/forward/input");
+               &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
+               unless (-e "${General::swroot}/forward/config")         { system("touch ${General::swroot}/forward/config"); }
+               unless (-e "${General::swroot}/forward/input")          { system("touch ${General::swroot}/forward/input"); }
+               my $MODE1=$fwdfwsettings{'POLICY1'};
+               %fwdfwsettings = ();
+               $fwdfwsettings{'POLICY'}='MODE2';
+               $fwdfwsettings{'POLICY1'}=$MODE1;
+               &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
+               &reread_rules;
+       }else{
+               &General::readhasharray("$configoutgoing", \%configoutgoingfw);
        foreach my $key (sort keys %configoutgoingfw){
                &checkcounter($configoutgoingfw{$key}[3],$configoutgoingfw{$key}[4],,);
                &checkcounter($configoutgoingfw{$key}[5],$configoutgoingfw{$key}[6],,);
@@ -385,7 +383,7 @@ if ($fwdfwsettings{'ACTION'} eq 'resetoutgoing')
        $fwdfwsettings{'POLICY1'}='MODE2';
        &General::writehash("${General::swroot}/forward/settings", \%fwdfwsettings);
        &reread_rules;
-
+       }
 }
 if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw newrule'})
 {
@@ -589,8 +587,8 @@ sub base
 print <<END;
        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
        <table width='100%' border='0'>
-               <tr><td colspan='3' style='font-weight:bold;color:red;'>FORWARD </td></tr>
-               <tr><td colspan='3'>$Lang::tr{'fwdfw pol text'}</td></tr>
+               <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>FORWARD </td></tr>
+               <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text'}</td></tr>
                <tr><td colspan='3'><hr /></td></tr>
                <tr><td width='15%' align='left'>       <select name='POLICY' style="width: 100px">
                <option value='MODE1' $selected{'POLICY'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
@@ -598,22 +596,22 @@ print <<END;
            <input type='submit' name='ACTION' value=$Lang::tr{'save'} /></td><td width='45%' align='right'>
            
 END
-       print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /></td></tr>";
+       print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='forward' /></td></tr>";
        print "</table></form>";
        print"<br><br>";
        print <<END;
        <form method='post' action='$ENV{'SCRIPT_NAME'}'>
        <table width='100%' border='0'>
-               <tr><td colspan='3' style='font-weight:bold;color:red;'>OUTGOING </td></tr>
-               <tr><td colspan='3'>$Lang::tr{'fwdfw pol text1'}</td></tr>
+               <tr><td colspan='3' style='font-weight:bold;color:red;' align='left'>OUTGOING </td></tr>
+               <tr><td colspan='3' align='left'>$Lang::tr{'fwdfw pol text1'}</td></tr>
                <tr><td colspan='3'><hr /></td></tr>
                <tr><td width='15%' align='left'>       <select name='POLICY1' style="width: 100px">
                <option value='MODE1' $selected{'POLICY1'}{'MODE1'}>$Lang::tr{'fwdfw pol block'}</option>
                <option value='MODE2' $selected{'POLICY1'}{'MODE2'}>$Lang::tr{'fwdfw pol allow'}</option></select>
-           <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'></form><form method='post' >
+           <input type='submit' name='ACTION' value='$Lang::tr{'save'}' /></td><td width='45%' align='right'>
            
 END
-       print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' value='$Lang::tr{'reset'}' /><input type='hidden' name='ACTION' value='resetoutgoing' /></tr>";
+       print "$Lang::tr{'outgoing firewall reset'}: <input type='submit' name='ACTION' value='$Lang::tr{'reset'}' /><input type='hidden' name='poltype' value='outgoing' /></tr>";
        print "</table></form>";
        &Header::closebox();
 }
@@ -1834,8 +1832,10 @@ sub viewtablenew
        my $title1=shift;
        my $go='';
        &General::get_aliases(\%aliases);
+       &General::readhasharray("$confighost", \%customhost);
        &General::readhasharray("$config", $hash);
        if( ! -z $config){
+               if ($title1 eq $Lang::tr{'external access'} || $title1 eq 'Outgoing'){print"<br><br>";}
                &Header::openbox('100%', 'left',$title);
                my $count=0;
                my ($gif,$log);
@@ -1845,8 +1845,8 @@ sub viewtablenew
                my @tmpsrc=();
                my $coloryellow='';
                print"<b>$title1</b><br>";
-               print"<table width='100%' cellspacing='1'  rules='none'; padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
-               print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'remark'}</td><td align='center' colspan='6'><b>$Lang::tr{'fwdfw action'}</td></tr>";
+               print"<table width='100%' cellspacing='0' style=' padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;'>";
+               print"<tr><td align='center'><b>#</td><td ></td><td align='center'><b>$Lang::tr{'fwdfw source'}</td><td><b>Log</td><td align='center'><b>$Lang::tr{'fwdfw target'}</td><td align='center'><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'fwdfw time'}</td><td align='center' colspan='6'><b>$Lang::tr{'fwdfw action'}</td></tr>";
                foreach my $key (sort  {$a <=> $b} keys %$hash){
                        $tdcolor='';
                        @tmpsrc=();
@@ -1901,7 +1901,7 @@ sub viewtablenew
                        }
                        print"<tr bgcolor='$color' >";
                        print<<END;
-                       <td align='right' width='15'>$key</td>
+                       <td align='right' width='15'><b>$key</b></td>
 END
                        if ($$hash{$key}[0] eq 'ACCEPT'){
                                $ruletype='A';
@@ -1917,7 +1917,7 @@ END
                                $rulecolor=$color{'color16'};
                        }
                        print"<td bgcolor='$rulecolor' align='center' width='20'><span title='$tooltip'><b>$ruletype</b></span></td>";
-                       &getcolor($$hash{$key}[3],$$hash{$key}[4]);
+                       &getcolor($$hash{$key}[3],$$hash{$key}[4],\%customhost);
                        print"<td align='center' width='160' $tdcolor>";
                        if ($$hash{$key}[3] eq 'std_net_src'){
                                print &get_name($$hash{$key}[4]);
@@ -1940,7 +1940,7 @@ END
                        <input type='hidden' name='ACTION' value='$Lang::tr{'fwdfw togglelog'}' />
                        </td></form>
 END
-                       &getcolor($$hash{$key}[5],$$hash{$key}[6]);
+                       &getcolor($$hash{$key}[5],$$hash{$key}[6],\%customhost);
                        print<<END;
                        <td align='center' width='160' $tdcolor>
 END
@@ -1980,7 +1980,7 @@ END
                                        print"<td align='center' width='100'>$weekdays &nbsp $$hash{$key}[26] - $$hash{$key}[27]</td>";
                                }
                        }else{
-                                       print"<td></td>";
+                                       print"<td align='center'>24/7</td>";
                                }
                        if($$hash{$key}[2] eq 'ON'){
                                $gif="/images/on.gif"
@@ -2039,8 +2039,10 @@ END
                                print"<td width='25'><input type='image' img src='/images/down.gif' style='visibility:hidden;'></td></tr>";
                        }
                        #REMARK
-                       print"<tr bgcolor='$color'><td colspan='13' style='border-bottom: 1px solid black'>";
-                       print"<b>$Lang::tr{'remark'}:</b>&nbsp$$hash{$key}[16]</td></tr>";
+                       if ($optionsfw{'SHOWREMARK'} eq 'on'){
+                               print"<tr bgcolor='$color'><td colspan='13'>";
+                               print"<b>$Lang::tr{'remark'}:</b>&nbsp$$hash{$key}[16]</td></tr>";
+                       }
                }
                print"</table>";
                &Header::closebox();
@@ -2051,7 +2053,9 @@ sub getcolor
 {
        my $nettype=shift;
        my $val=shift;
+       my $hash=shift;
        if($optionsfw{'SHOWCOLORS'} eq 'on'){
+               #VPN networks
                if ($nettype eq 'ovpn_n2n_src' || $nettype eq 'ovpn_n2n_tgt' || $nettype eq 'ovpn_net_src' || $nettype eq 'ovpn_net_tgt'|| $nettype eq 'ovpn_host_src' || $nettype eq 'ovpn_host_tgt'){
                        $tdcolor="style='border: 2px solid $Header::colourovpn;'";
                        return;
@@ -2060,6 +2064,15 @@ sub getcolor
                        $tdcolor="style='border: 2px solid $Header::colourvpn;'";
                        return;
                }
+               #custom Hosts
+               if ($nettype eq 'cust_host_src' || $nettype eq 'cust_host_tgt'){
+                       foreach my $key (sort keys %$hash){
+                               if ($$hash{$key}[0] eq $val){
+                                       $val=$$hash{$key}[2];
+                               }
+                       }
+               }
+               #ALIASE
                foreach my $alias (sort keys %aliases)
                {
                        if ($val eq $alias){
@@ -2067,12 +2080,15 @@ sub getcolor
                                return;
                        }
                }
+               #standard networks
                if ($val eq 'GREEN'){
                        $tdcolor="style='border: 2px solid $Header::colourgreen;'";
                }elsif ($val eq 'ORANGE'){
                        $tdcolor="style='border: 2px solid $Header::colourorange;'";
                }elsif ($val eq 'BLUE'){
                        $tdcolor="style='border: 2px solid $Header::colourblue;'";
+               }elsif ($val eq 'RED'){
+                       $tdcolor="style='border: 2px solid $Header::colourred;'";
                }elsif ($val eq 'IPFire' ){
                        $tdcolor="style='border: 2px solid $Header::colourred;'";
                }elsif($val =~ /^(.*?)\/(.*?)$/){