print<<END;
<script>
\$(document).ready(function() {
+ // Hide sourceport area when no sourceport is used
+ if (! \$("#USE_SRC_PORT").attr("checked")) {
+ toggle_elements('#srcport');
+ }
+ // Hide targetport area when no targetport is used
+ if (! \$("#USESRV").attr("checked")) {
+ toggle_elements('#targetport');
+ }
+ // When nat not used, hide it
+ if (! \$("#nat").attr("checked")) {
+ toggle_elements('#natpart');
+ }
+ // When protocol dropdown is changed, check if we selected icmp - then show icmp-types
+ \$("#prt").change(function(){
+ if ( \$("#PROT").val() === 'ICMP' ){
+ \$('#PROTOKOLL').show();
+ }
+ else{
+ \$('#PROTOKOLL').hide();
+ }
+ });
+ // When Prot not icmp, hide icmp-types
+ if ( ! \$("#PROT").val() == 'ICMP') {
+ \$('#PROTOKOLL').hide();
+ }
+
+ // Show NAT area when "use nat" checkbox is clicked
+ \$( "#nat" ).change(function() {
+ toggle_elements('#natpart');
+ });
+ // Show Sourceport area when "use sourceport" checkbox is clicked
+ \$( "#spt" ).change(function() {
+ toggle_elements('#srcport');
+ });
+ // Show Targetport area when "use Targetport" checkbox is clicked
+ \$( "#tpt" ).change(function() {
+ toggle_elements('#targetport');
+ });
// Automatically select radio buttons when corresponding
// dropdown menu changes.
\$("select").change(function() {
\$(a).attr('checked', true);
}
function toggle_elements( id ) {
- if(document.getElementById(id).style.display== "none")
+ \$(id).toggle();
+ if(! \$("targetport:visible") && \$("#PROT").val() === 'ICMP' )
{
- document.getElementById(id).style.display='block';
- }
- else{
- document.getElementById(id).style.display='none';
+ \$('#PROTOKOLL').show();
}
- return true;
-}
-function hide_elements()
-{
- var elementNames = hide_elements.arguments;
- for (var i=0; i<elementNames.length; i++)
+ if(\$("targetport:visible") && \$("#PROT").val() === 'ICMP' )
{
- var elementName = elementNames[i];
- document.getElementById(elementName).style.display='none';
- }
-}
-function getdropdown()
-{
- d = document.getElementById("PROT").value;
- if ( d == 'ICMP' )
- {
- document.getElementById('PROTOKOLL').style.display='block';
- }
- else
- {
- document.getElementById('PROTOKOLL').style.display='none';
+ \$('#PROTOKOLL').hide();
}
+ return true;
}
</script>
END
}
}
}
- #check source and destination protocol if source manual and dest single service
+ #When using source- or targetport, the protocol has to be TCP or UDP
+ if (($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON') && ($fwdfwsettings{'SRC_PORT'} ne '' || $fwdfwsettings{'TGT_PORT'} ne '') && ($fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP')){
+ $errormessage.=$Lang::tr{'fwdfw err prot_port1'};
+ return;
+ }
+ #when icmp selected, no targetport allowed
+ if (($fwdfwsettings{'PROT'} ne '' && $fwdfwsettings{'PROT'} ne 'TCP' && $fwdfwsettings{'PROT'} ne 'UDP') && ($fwdfwsettings{'USESRV'} eq 'ON' || $fwdfwsettings{'USE_SRC_PORT'} eq 'ON')){
+ $errormessage.=$Lang::tr{'fwdfw err prot_port'};
+ return;
+ }
+ #change protocol if prot not equal dest single service
if ($fwdfwsettings{'grp3'} eq 'cust_srv'){
foreach my $key (sort keys %customservice){
if($customservice{$key}[0] eq $fwdfwsettings{$fwdfwsettings{'grp3'}}){
if ($fwdfwsettings{'PROT'} eq 'ICMP'){
$fwdfwsettings{'USE_SRC_PORT'}='';
$fwdfwsettings{'SRC_PORT'}='';
- $fwdfwsettings{'USESRV'}='';
+ #$fwdfwsettings{'USESRV'}='';
$fwdfwsettings{'TGT_PORT'}='';
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
foreach my $key (keys %icmptypes){
}
}
if($tcp && $udp && $icmp){
- push (@protocols,"All");
+ push (@protocols,"TCP,UDP, <br>ICMP");
return @protocols;
}
if($tcp){
}
}
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw addrule'});
- print "<form method='post'>";
&Header::closebox();
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw source'});
#------SOURCE-------------------------------------------------------
+ print "<form method='post'>";
print<<END;
<table width='100%' border='0'>
<tr><td width='1%'><input type='radio' name='grp1' value='src_addr' checked></td><td width='60%'>$Lang::tr{'fwdfw sourceip'}<input type='TEXT' name='src_addr' value='$fwdfwsettings{'src_addr'}' size='16' maxlength='18' ></td><td width='1%'><input type='radio' name='grp1' id='ipfire_src' value='ipfire_src' $checked{'grp1'}{'ipfire_src'}></td><td><b>Firewall</b></td>
#---SNAT / DNAT ------------------------------------------------
&Header::openbox('100%', 'left', 'NAT');
print<<END;
- <table width='100%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='USE_NAT' id='USE_NAT' value='ON' $checked{'USE_NAT'}{'ON'} onclick="toggle_elements('natpart')" ></td><td width='15%'>$Lang::tr{'fwdfw use nat'}</td><td colspan='5'></td></tr></table>
+ <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>
}
print"</select></td></tr></table>";
print"</div><br><hr>";
- if ($fwdfwsettings{'USE_NAT'} ne 'ON'){
- print"<script language='JavaScript'>hide_elements('natpart');</script>";
- }
&Header::closebox();
#---TARGET------------------------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw target'});
#---PROTOCOL------------------------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwhost prot'});
print<<END;
- <table width='15%' border='0' style="float:left;">
- <tr><td><select name='PROT' id='PROT' onchange="getdropdown()">
+ <div id="prt"><table width='15%' border='0' style="float:left;">
+ <tr><td><select name='PROT' id='PROT' >
END
if ($fwdfwsettings{'PROT'} eq ''){
- print"<option selected>$Lang::tr{'all'}</option>";
+ print"<option value='' selected>$Lang::tr{'all'}</option>";
}else{
print"<option value=''>$Lang::tr{'all'}</option>";
}
print"<option>$_</option>";
}
}
- print"</select></td></tr></table>";
+ print"</select></td></tr></table></div>";
print<<END;
<div id="PROTOKOLL" class="noscript"><table width='30%' border='0' style="float:left;"><tr><td>$Lang::tr{'fwhost icmptype'}</td><td colspan='2'><select name='ICMP_TYPES' style='min-width:230px;'>
END
</select></td></tr>
</table></div><br><br><br>
END
- if ($fwdfwsettings{'PROT'} ne 'ICMP'){
- print"<script language='JavaScript'>hide_elements('PROTOKOLL');</script>";
- }
#SOURCEPORT
print<<END;
<table width='100%'><tr><td colspan='8'><hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; ' /></td></table>
- <table width='100%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'} onclick="toggle_elements('srcport')"></td>
- <td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td></tr></table>
+ <div id="spt"><table width='100%' border='0'>
+ <tr><td width='1%'><input type='checkbox' name='USE_SRC_PORT' id='USE_SRC_PORT' value='ON' $checked{'USE_SRC_PORT'}{'ON'}></td>
+ <td width='51%' colspan='3'>$Lang::tr{'fwdfw use srcport'}</td></tr></table></div>
<div id="srcport" class="noscript"><table width='100%' border='0'><tr>
<td width='70%' nowrap='nowrap' align='right'>$Lang::tr{'fwdfw man port'}</td>
END
<td align='right'><input type='text' name='SRC_PORT' value='$fwdfwsettings{'SRC_PORT'}' maxlength='20' size='18' ></td></tr>
</table></div><br>
END
- if ($fwdfwsettings{'USE_SRC_PORT'} ne 'ON'){
- print"<script language='JavaScript'>hide_elements('srcport');</script>";
- }
#TARGETPORT
print<<END;
<hr style='border:dotted #BFBFBF; border-width:1px 0 0 0 ; '><br>
- <table width='100%' border='0'>
- <tr><td width='1%'><input type='checkbox' name='USESRV' value='ON' $checked{'USESRV'}{'ON'} onclick="toggle_elements('targetport')"></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td></tr></table>
+ <div id="tpt"><table width='100%' border='0'>
+ <tr><td width='1%'><input type='checkbox' name='USESRV' id='USESRV' value='ON' $checked{'USESRV'}{'ON'}></td><td width='48%'>$Lang::tr{'fwdfw use srv'}</td></tr></table></div>
<div id="targetport" class="noscript"><table width='100%' border='0'><tr><td width='80%'></td><td width='1%'><input type='radio' name='grp3' id='cust_srv' value='cust_srv' checked></td><td nowrap='nowrap'>$Lang::tr{'fwhost cust service'}</td><td width='1%' colspan='2'><select name='cust_srv' style='min-width:230px;' >
END
&General::readhasharray("$configsrv", \%customservice);
<td align='right'><input type='text' name='TGT_PORT' value='$fwdfwsettings{'TGT_PORT'}' maxlength='20' size='18' onclick='checkradio(\"#TGT_PORT\")'></td></tr>
</table></div><br><hr>
END
- if ($fwdfwsettings{'USESRV'} ne 'ON'){
- print"<script language='JavaScript'>hide_elements('targetport');</script>";
- }
&Header::closebox;
#---Activate/logging/remark-------------------------------------
&Header::openbox('100%', 'left', $Lang::tr{'fwdfw additional'});
push (@protocols,$Lang::tr{'all'});
}
my $protz=join(",",@protocols);
- if($protz eq 'ICMP'){
+ if($protz eq 'ICMP' && $$hash{$key}[9] ne 'All ICMP-Types' && $$hash{$key}[14] ne 'cust_srvgrp'){
&General::readhasharray("${General::swroot}/fwhosts/icmp-types", \%icmptypes);
foreach my $keyicmp (sort { ncmp($icmptypes{$a}[0],$icmptypes{$b}[0]) }keys %icmptypes){
if($$hash{$key}[9] eq "$icmptypes{$keyicmp}[0]"){