]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blobdiff - html/cgi-bin/forwardfw.cgi
p2p-block.cgi: Fix coding style.
[people/teissler/ipfire-2.x.git] / html / cgi-bin / forwardfw.cgi
index 31dab30ab3f3a03c5451482df5d3dc32d89cc90e..5e62dbcb99b8d2b274d87a643e4655d5a2a387b3 100755 (executable)
@@ -137,13 +137,13 @@ print<<END;
                update_protocol();
 
                // When nat not used, hide it
-               if (! \$("#nat").attr("checked")) {
-                       \$("#natpart").hide();
+               if (! \$("#USE_NAT").attr("checked")) {
+                       \$(".NAT").hide();
                }
 
                // Show NAT area when "use nat" checkbox is clicked
-               \$("#nat").change(function() {
-                       \$("#natpart").toggle();
+               \$("#USE_NAT").change(function() {
+                       \$(".NAT").toggle();
                });
 
                // Time constraints
@@ -385,7 +385,7 @@ if ($fwdfwsettings{'ACTION'} eq 'saverule')
                &newrule;
        }else{
                if($fwdfwsettings{'nosave2'} ne 'on'){
-                       &rules;
+                       &General::firewall_config_changed();
                }
                &base;
        }
@@ -404,7 +404,7 @@ if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw toggle'})
                }
        }
        &General::writehasharray($fwdfwsettings{'config'}, \%togglehash);
-       &rules;
+       &General::firewall_config_changed();
        &base;
 }
 if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw togglelog'})
@@ -417,12 +417,12 @@ if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw togglelog'})
                }
        }
        &General::writehasharray($fwdfwsettings{'config'}, \%togglehash);
-       &rules;
+       &General::firewall_config_changed();
        &base;
 }
 if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'})
 {
-       &reread_rules;
+       &General::firewall_reload();
        &base;
 }
 if ($fwdfwsettings{'ACTION'} eq 'editrule')
@@ -469,7 +469,7 @@ sub addrule
                                        <td align="right">
 END
 
-       if (-f "${General::swroot}/forward/reread") {
+       if (&General::firewall_needs_reload()) {
                print <<END;
                        <input type='submit' name='ACTION' value='$Lang::tr{'fwdfw reread'}' style='font-weight: bold; color: green;'>
 END
@@ -1012,7 +1012,7 @@ sub deleterule
        delete $delhash{$last_key};
 
        &General::writehasharray($fwdfwsettings{'config'}, \%delhash);
-       &rules;
+       &General::firewall_config_changed();
 
        if($fwdfwsettings{'nobase'} ne 'on'){
                &base;
@@ -1028,7 +1028,7 @@ sub disable_rule
                }
        }
        &General::writehasharray("$configfwdfw", \%configfwdfw);
-       &rules;
+       &General::firewall_config_changed();
 }
 sub dec_counter
 {
@@ -1656,11 +1656,18 @@ END
                #---SNAT / DNAT ------------------------------------------------
                &Header::openbox('100%', 'left', 'NAT');
                print<<END;
-               <div id="nat"><table width='100%' border='0'>
-               <tr><td width='1%'><input type='checkbox' name='USE_NAT' id='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'} ></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr></table></div>
-               <div id="natpart" class="noscript">
-               <table width='100%' border='0'><tr>
-               <tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' id='dnat' value='dnat' checked ></td><td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
+                       <label>
+                               <input type='checkbox' name='USE_NAT' id='USE_NAT' value="ON" $checked{'USE_NAT'}{'ON'}>
+                               $Lang::tr{'fwdfw use nat'}
+                       </label>
+                       <div class="NAT">
+                               <table width='100%' border='0'>
+                                       <tr>
+                                               <td colspan='2'></td>
+                                               <td width='1%'>
+                                                       <input type='radio' name='nat' id='dnat' value='dnat' checked>
+                                               </td>
+                                               <td width='50%'>$Lang::tr{'fwdfw dnat'}</td>
 END
                print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='dnat' style='width:140px;'>";
                print "<option value='ALL' $selected{'dnat'}{$Lang::tr{'all'}}>$Lang::tr{'all'}</option>";
@@ -1670,9 +1677,6 @@ END
                        print "<option value='$alias' $selected{'dnat'}{$alias}>$alias</option>";
                }
                print"</select></td></tr>";
-               $fwdfwsettings{'dnatport'}=~ tr/|/,/;
-               print"<tr><td colspan='4'></td><td>Port: </td><td align='right'><input type='text' name='dnatport' style='width:130px;' value=\"$fwdfwsettings{'dnatport'}\"> </td></tr>";
-               print"<tr><td colspan='8'><br></td></tr>";
                #SNAT
                print"<tr><td colspan='2'></td><td width='1%'><input type='radio' name='nat' id='snat' value='snat'  $checked{'nat'}{'snat'}></td><td width='20%'>$Lang::tr{'fwdfw snat'}</td>";
                print"<td width='8%'>Firewall: </td><td width='20%' align='right'><select name='snat' style='width:140px;'>";
@@ -1690,7 +1694,7 @@ END
                        print ">$network</option>";
                }
                print"</select></td></tr></table>";
-               print"</div><br><hr>";
+               print"</div>";
                &Header::closebox();
                #---TARGET------------------------------------------------------
                &Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
@@ -1781,6 +1785,12 @@ END
 
                $fwdfwsettings{'SRC_PORT'} =~ s/\|/,/g;
                $fwdfwsettings{'TGT_PORT'} =~ s/\|/,/g;
+               $fwdfwsettings{'dnatport'} =~ tr/|/,/;
+
+               # The dnatport may be empty, if it matches TGT_PORT
+               if ($fwdfwsettings{'dnatport'} eq $fwdfwsettings{'TGT_PORT'}) {
+                       $fwdfwsettings{'dnatport'} = "";
+               }
 
                print <<END;
 
@@ -1806,6 +1816,13 @@ END
                                                <input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18'>
                                        </td>
                                </tr>
+                               <tr class="NAT">
+                                       <td colspan='3'></td>
+                                       <td>$Lang::tr{'fwdfw external port nat'}:</td>
+                                       <td>
+                                               <input type='text' name='dnatport' value=\"$fwdfwsettings{'dnatport'}\" maxlength='20' size='18'>
+                                       </td>
+                               </tr>
                        </table>
                </div>
 
@@ -1943,7 +1960,7 @@ END
                if ($fwdfwsettings{'updatefwrule'} eq 'on') {
                        print <<END;
                                <td>
-                                       <input type='checkbox' name='ACTIVE' $checked{'ACTIVE'}{'ON'}>
+                                       <input type='checkbox' name='ACTIVE' value="ON" $checked{'ACTIVE'}{'ON'}>
                                </td>
                                <td>$Lang::tr{'fwdfw rule activate'}</td>
 END
@@ -2085,7 +2102,7 @@ sub pos_up
                }
        }
        &General::writehasharray($fwdfwsettings{'config'}, \%uphash);
-       &rules;
+       &General::firewall_config_changed();
 }
 sub pos_down
 {
@@ -2112,22 +2129,7 @@ sub pos_down
                }
        }
        &General::writehasharray($fwdfwsettings{'config'}, \%downhash);
-       &rules;
-}
-sub rules
-{
-       if (!-f "${General::swroot}/forward/reread"){
-               system("touch ${General::swroot}/forward/reread");
-               system("touch ${General::swroot}/fwhosts/reread");
-       }
-}
-sub reread_rules
-{
-       system("/usr/local/bin/forwardfwctrl");
-       if ( -f "${General::swroot}/forward/reread"){
-               system("rm ${General::swroot}/forward/reread");
-               system("rm ${General::swroot}/fwhosts/reread");
-       }
+       &General::firewall_config_changed();
 }
 sub saverule
 {
@@ -2269,7 +2271,7 @@ sub saverule
                                $fwdfwsettings{'oldrulenumber'}--;
                        }
                        &General::writehasharray("$config", $hash);
-                       &rules;
+                       &General::firewall_config_changed();
                }elsif($fwdfwsettings{'rulepos'} > $fwdfwsettings{'oldrulenumber'}){
                        my %tmp=();
                        my $val=$fwdfwsettings{'rulepos'}-$fwdfwsettings{'oldrulenumber'};
@@ -2296,7 +2298,7 @@ sub saverule
                                $fwdfwsettings{'oldrulenumber'}++;
                        }
                        &General::writehasharray("$config", $hash);
-                       &rules;
+                       &General::firewall_config_changed();
                }
        }
 }