use strict;
# enable only the following on debugging purpose
-use warnings;
+#use warnings;
+
use Sort::Naturally;
use CGI::Carp 'fatalsToBrowser';
no warnings 'uninitialized';
my %fwinp=();
my %fwout=();
my %ovpnsettings=();
-
+my %netsettings=();
my $errormessage;
my $hint;
&General::readhash("$configovpn", \%ovpnsettings);
&General::readhasharray("$configipsec", \%ipsecconf);
&General::readhash("$configipsecrw", \%ipsecsettings);
-
+&General::readhash("/var/ipfire/ethernet/settings", \%netsettings);
&Header::getcgihash(\%fwhostsettings);
&Header::showhttpheaders();
-&Header::openpage($Lang::tr{'fwhost hosts'}, 1, '');
+&Header::openpage($Lang::tr{'fwhost menu'}, 1, '');
&Header::openbigbox('100%', 'center');
#### JAVA SCRIPT ####
foreach my $key (sort keys %customservicegrp){
if($customservicegrp{$key}[2] eq $fwhostsettings{'oldsrvname'}){
$customservicegrp{$key}[2] = $fwhostsettings{'SRV_NAME'};
+ &checkrulereload($customservicegrp{$key}[0]);
}
}
&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';
- }
- if($count gt 0 && $fwhostsettings{'oldsrvicmp'} ne $fwhostsettings{'ICMP'} ){
- $needrules='on';
}
+ &checkrulereload($fwhostsettings{'SRV_NAME'});
$fwhostsettings{'SRV_NAME'} = '';
$fwhostsettings{'SRV_PORT'} = '';
$fwhostsettings{'PROT'} = '';
$fwhostsettings{'ICMP'} = $fwhostsettings{'oldsrvicmp'};
$fwhostsettings{'updatesrv'}= 'on';
}
- if($needrules eq 'on'){
- &General::firewall_config_changed();
- }
&addservice;
}
# save
{
my $prot;
my $port;
- my $count=0;
my $tcpcounter=0;
my $udpcounter=0;
&General::readhasharray("$configsrvgrp", \%customservicegrp );
}
#on update, we have to delete the dummy entry
foreach my $key (keys %customservicegrp){
- if ($customservicegrp{$key}[2] eq 'none'){
+ if ($customservicegrp{$key}[2] eq 'none' && $customservicegrp{$key}[0] eq $fwhostsettings{'SRVGRP_NAME'}){
delete $customservicegrp{$key};
last;
}
&General::writehasharray("$configsrvgrp", \%customservicegrp );
$fwhostsettings{'updatesrvgrp'}='on';
}
- if ($count gt 0){
- &General::firewall_config_changed();
- }
+ &checkrulereload($fwhostsettings{'SRVGRP_NAME'});
&addservicegrp;
&viewtableservicegrp;
}
&General::readhasharray("$configgrp", \%customgrp);
foreach my $key (keys %customgrp){
if($customgrp{$key}[0].",".$customgrp{$key}[1].",".$customgrp{$key}[2].",".$customgrp{$key}[3] eq $fwhostsettings{'delhost'}){
- #decrease count from source host/net
- if ($customgrp{$key}[3] eq 'Custom Network'){
- &General::readhasharray("$confignet", \%customnetwork);
- foreach my $key1 (keys %customnetwork){
- if ($customnetwork{$key1}[0] eq $customgrp{$key}[2]){
- $customnetwork{$key1}[4] = $customnetwork{$key1}[4]-1;
- last;
- }
- }
- &General::writehasharray("$confignet", \%customnetwork);
- }
- if ($customgrp{$key}[3] eq 'Custom Host'){
- &General::readhasharray("$confighost", \%customhost);
- foreach my $key1 (keys %customhost){
- if ($customhost{$key1}[0] eq $customgrp{$key}[2]){
- $customhost{$key1}[4] = $customhost{$key1}[4]-1;
- last;
- }
- }
- &General::writehasharray("$confighost", \%customhost);
- }
$grpname=$customgrp{$key}[0];
$grpremark=$customgrp{$key}[1];
- delete $customgrp{$key};
+ #check if we delete the last entry, then generate dummy
+ if ($fwhostsettings{'last'} eq 'on'){
+ $customgrp{$key}[1] = '';
+ $customgrp{$key}[2] = 'none';
+ $customgrp{$key}[3] = '';
+ $fwhostsettings{'last'}='';
+ last;
+ }else{
+ delete $customgrp{$key};
+ }
}
}
&General::writehasharray("$configgrp", \%customgrp);
+ &General::firewall_config_changed();
if ($fwhostsettings{'grpcnt'} > 0){
&General::firewall_config_changed();
}
my $grpname;
my $grpremark;
&General::readhasharray("$configsrvgrp", \%customservicegrp);
- &General::readhasharray("$configsrv", \%customservice);
foreach my $key (keys %customservicegrp){
if($customservicegrp{$key}[0].",".$customservicegrp{$key}[1].",".$customservicegrp{$key}[2] eq $fwhostsettings{'delsrvfromgrp'})
{
- #decrease count from source service
- foreach my $key1 (sort keys %customservice){
- if($customservice{$key1}[0] eq $customservicegrp{$key}[2]){
- $customservice{$key1}[4]--;
- last;
- }
- }
$grpname=$customservicegrp{$key}[0];
$grpremark=$customservicegrp{$key}[1];
- delete $customservicegrp{$key};
+ if($fwhostsettings{'last'} eq 'on'){
+ $customservicegrp{$key}[2] = 'none';
+ $fwhostsettings{'last'} = '';
+ last;
+ }else{
+ delete $customservicegrp{$key};
+ }
}
}
- &General::writehasharray("$configsrv", \%customservice);
&General::writehasharray("$configsrvgrp", \%customservicegrp);
&General::firewall_config_changed();
if ($fwhostsettings{'updatesrvgrp'} eq 'on'){
}
&addservicegrp;
&viewtableservicegrp;
-
}
if ($fwhostsettings{'ACTION'} eq $Lang::tr{'fwhost newnet'})
{
}
### FUNCTIONS ###
sub showmenu {
- &Header::openbox('100%', 'left',$Lang::tr{'fwhost menu'});
+ &Header::openbox('100%', 'left',);
print "$Lang::tr{'fwhost welcome'}";
print<<END;
<br><br><table border='0' width='100%'>
<tr><td><form method='post'><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'}' ></form></td>
<td align='right'><form method='post'><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservice'}' ><input type='submit' name='ACTION' value='$Lang::tr{'fwhost newservicegrp'}' ></form></td></tr>
- <tr><td colspan='6'><hr></td></tr></table>
+ <tr><td colspan='6'></td></tr></table>
END
&Header::closebox();
$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
$fwhostsettings{'orgnetremark'}=$fwhostsettings{'NETREMARK'};
print<<END;
- <table border='0' width='100%'>
+ <table border='0' width='100%' >
<tr><td width='15%'>$Lang::tr{'name'}:</td><td><form method='post'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
<tr><td>$Lang::tr{'fwhost netaddress'}:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
<tr><td>$Lang::tr{'netmask'}:</td><td><input type='TEXT' name='SUBNET' value='$fwhostsettings{'SUBNET'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='15'></td></tr>
<tr><td>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='NETREMARK' value='$fwhostsettings{'NETREMARK'}' style='width: 98.5%;'></td></tr>
- <tr><td colspan='6'><br><hr></td></tr><tr>
+ <tr><td colspan='6'><br></td></tr><tr>
END
if ($fwhostsettings{'ACTION'} eq 'editnet' || $fwhostsettings{'error'} eq 'on')
{
- print "<td colspan='6' align='right' ><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='updatenet'><input type='hidden' name='orgnetremark' value='$fwhostsettings{'orgnetremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'></td>";
+ print "<td colspan='6' align='right'><input type='submit' value='$Lang::tr{'update'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='updatenet'><input type='hidden' name='orgnetremark' value='$fwhostsettings{'orgnetremark'}' ><input type='hidden' name='orgname' value='$fwhostsettings{'orgname'}' ><input type='hidden' name='update' value='on'><input type='hidden' name='newnet' value='$fwhostsettings{'newnet'}'>";
}else{
- print "<td colspan='6' align='right'><input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'/><input type='hidden' name='ACTION' value='savenet'><input type='hidden' name='newnet' value='on'>";
- }
+ print "<td colspan='6' align='right'><input type='submit' value='$Lang::tr{'save'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='savenet'><input type='hidden' name='newnet' value='on'>";
+ }
print "</form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;' ><input type='hidden' name='ACTION' value='resetnet'></form></td></tr></table>";
&Header::closebox();
}
$fwhostsettings{'orgname'}=$fwhostsettings{'HOSTNAME'};
$fwhostsettings{'orgremark'}=$fwhostsettings{'HOSTREMARK'};
print<<END;
- <table border='0' width='100%'>
+ <table width='100%'>
<tr><td>$Lang::tr{'name'}:</td><td><form method='post' style='display:inline;'><input type='TEXT' name='HOSTNAME' id='textbox1' value='$fwhostsettings{'HOSTNAME'}' $fwhostsettings{'BLK_HOST'} size='20'><script>document.getElementById('textbox1').focus()</script></td></tr>
<tr><td>IP/MAC:</td><td><input type='TEXT' name='IP' value='$fwhostsettings{'IP'}' $fwhostsettings{'BLK_IP'} size='20' maxlength='17'></td></tr>
<tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='TEXT' name='HOSTREMARK' value='$fwhostsettings{'HOSTREMARK'}' style='width:98%;'></td></tr>
- <tr><td colspan='5'><hr></td></tr><tr>
+ <tr><td colspan='5'><br></td></tr><tr>
END
if ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'} eq 'on')
my $rem=$fwhostsettings{'remark'};
if ($fwhostsettings{'update'} eq ''){
print<<END;
- <table width='100%' border='0'>
- <tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='20'></td></tr>
- <tr><td width='10%'>$Lang::tr{'remark'}:</td><td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 98%;'></td></tr>
- <tr><td colspan='2'><br><hr></td></tr></table>
+ <table width='100%' border='0'>
+ <tr>
+ <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
+ <td><form method='post'><input type='TEXT' name='grp_name' value='$fwhostsettings{'grp_name'}' size='30'></td>
+ </tr>
+ <tr>
+ <td>$Lang::tr{'remark'}:</td>
+ <td ><input type='TEXT' name='remark' value='$fwhostsettings{'remark'}' style='width: 99%;'></td>
+ </tr>
+ <tr>
+ <td colspan='2'><br></td>
+ </tr>
+ </table>
END
}else{
print<<END;
- <table width='100%' border='0'><form method='post' style='display:inline'>
- <tr><td nowrap='nowrap' width='12%'>$Lang::tr{'fwhost addgrpname'}</td><td width='20%'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' ></td><td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'><input type='hidden' name='ACTION' value='changegrpname'></td><td></td></form></tr>
- <tr><form method='post' style='display:inline'><td>$Lang::tr{'remark'}:</td><td colspan='2'><input type='TEXT' name='newrem' size='45' value='$fwhostsettings{'remark'}' style='width:98%'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td></tr></table></form>
- <hr>
+ <table width='100%' border='0'><form method='post'>
+ <tr>
+ <td style='width:15%;'>$Lang::tr{'fwhost addgrpname'}</td>
+ <td style='width:30%;'><input type='TEXT' name='grp' value='$fwhostsettings{'grp_name'}' size='30'></td>
+ <td><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldgrpname' value='$fwhostsettings{'oldgrpname'}'><input type='hidden' name='ACTION' value='changegrpname'></td>
+ <td></td></form>
+ </tr>
+ <tr><form method='post' style='display:inline'>
+ <td>$Lang::tr{'remark'}:</td>
+ <td colspan='2' style='width:98%;'><input type='TEXT' name='newrem' value='$fwhostsettings{'remark'}' style='width:98%;'></td>
+ <td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='grp' value='$fwhostsettings{'grp_name'}'><input type='hidden' name='oldrem' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='ACTION' value='changegrpremark' ></td>
+ </tr>
+ </table></form>
+ <br><br>
END
}
if ($fwhostsettings{'update'} eq 'on'){
<form method='post'><input type='hidden' name='remark' value='$rem'><input type='hidden' name='grp_name' value='$grp'>
<table width='100%' border='0'>
<tr><td width=50% valign='top'>
- <table width='100%' border='0'>
- <tr><td width='1%'><input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost stdnet'}</td><td><select name='DEFAULT_SRC_ADR' style='min-width:185px;'>
+ <table width='90%' border='0'>
+ <tr>
+ <td style='width:15em;'>
+ <label>
+ <input type='radio' name='grp2' value='std_net' id='DEFAULT_SRC_ADR' checked>
+ $Lang::tr{'fwhost stdnet'}
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='DEFAULT_SRC_ADR' style='width:16em;'>
END
foreach my $network (sort keys %defaultNetworks)
{
}
print"</select></td></tr>";
if (! -z $confignet){
- print"<tr><td><input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}></td><td>$Lang::tr{'fwhost cust net'}</td><td><select name='CUST_SRC_NET' style='min-width:185px;'>";
+ print<<END;
+ <tr>
+ <td>
+ <label>
+ <input type='radio' name='grp2' id='CUST_SRC_NET' value='cust_net' $checked{'grp2'}{'cust_net'}>
+ $Lang::tr{'fwhost cust net'}:
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='CUST_SRC_NET' style='width:16em;'>";
+END
foreach my $key (sort { ncmp($customnetwork{$a}[0],$customnetwork{$b}[0]) } keys %customnetwork) {
print"<option>$customnetwork{$key}[0]</option>";
}
print"</select></td></tr>";
}
if (! -z $confighost){
- print"<tr><td valign='top'><input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}></td><td valign='top'>$Lang::tr{'fwhost cust addr'}</td><td><select name='CUST_SRC_HOST' style='min-width:185px;'>";
+ print<<END;
+ <tr>
+ <td valign='top'>
+ <label>
+ <input type='radio' name='grp2' id='CUST_SRC_HOST' value='cust_host' $checked{'grp2'}{'cust_host'}>
+ $Lang::tr{'fwhost cust addr'}:
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='CUST_SRC_HOST' style='width:16em;'>";
+END
foreach my $key (sort { ncmp($customhost{$a}[0],$customhost{$b}[0]) } keys %customhost) {
print"<option>$customhost{$key}[0]</option>";
}
}
print"</table>";
#Inner table right
- print"</td><td valign='top'><table width='100%' border='0'>";
+ print"</td><td align='right' style='vertical-align:top;'><table width='90%' border='0'>";
#OVPN networks
if (! -z $configccdnet){
- print"<td width='1%'><input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdnet'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_NET' style='min-width:185px;'>";
+ print<<END;
+ <td style='width:15em;'>
+ <label>
+ <input type='radio' name='grp2' id='OVPN_CCD_NET' value='ovpn_net' $checked{'grp2'}{'ovpn_net'}>
+ $Lang::tr{'fwhost ccdnet'}
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='OVPN_CCD_NET' style='width:16em;'>";
+END
foreach my $key (sort { ncmp($ccdnet{$a}[0],$ccdnet{$b}[0]) } keys %ccdnet)
{
print"<option value='$ccdnet{$key}[0]'>$ccdnet{$key}[0]</option>";
print"</select></td></tr>";
}
#OVPN clients
+ my @ovpn_clients=();
foreach my $key (sort { ncmp($ccdhost{$a}[0],$ccdhost{$b}[0]) } keys %ccdhost)
{
if ($ccdhost{$key}[33] ne ''){
- print"<td width='1%'><input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}></td><td nowrap='nowrap' width='16%'>$Lang::tr{'fwhost ccdhost'}</td><td nowrap='nowrap' width='1%'><select name='OVPN_CCD_HOST' style='min-width:185px;'>" if ($show eq '');
$show='1';
- print"<option value='$ccdhost{$key}[1]'>$ccdhost{$key}[1]</option>";
+ push (@ovpn_clients,$ccdhost{$key}[1]);
}
}
- if ($show eq '1'){$show='';print"</select></td></tr>";}
+ if ($show eq '1'){
+ $show='';
+ print<<END;
+ <td style='width:15em;'>
+ <label>
+ <input type='radio' name='grp2' value='ovpn_host' $checked{'grp2'}{'ovpn_host'}>
+ $Lang::tr{'fwhost ccdhost'}
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='OVPN_CCD_HOST' style='width:16em;'>" if ($show eq '');
+END
+ foreach(@ovpn_clients){
+ print"<option value='$_'>$_</option>";
+ }
+ print"</select></td></tr>";
+ }
#OVPN n2n networks
+ my @OVPN_N2N=();
foreach my $key (sort { ncmp($ccdhost{$a}[1],$ccdhost{$b}[1]) } keys %ccdhost) {
if($ccdhost{$key}[3] eq 'net'){
- print"<td width='1%'><input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}></td><td valign='top'>$Lang::tr{'fwhost ovpn_n2n'}</td><td colspan='3'><select name='OVPN_N2N' style='min-width:185px;'>" if ($show eq '');
$show='1';
- print"<option>$ccdhost{$key}[1]</option>";
+ push (@OVPN_N2N,$ccdhost{$key}[1]);
+ }
+ }
+ if ($show eq '1'){
+ $show='';
+ print<<END;
+ <td style='width:15em;'>
+ <label>
+ <input type='radio' name='grp2' id='OVPN_N2N' value='ovpn_n2n' $checked{'grp2'}{'ovpn_n2n'}>
+ $Lang::tr{'fwhost ovpn_n2n'}:
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='OVPN_N2N' style='width:16em;'>"
+END
+ foreach(@OVPN_N2N){
+ print"<option>$_</option>";
}
+ print"</select></td></tr>";
}
- if ($show eq '1'){$show='';print"</select></td></tr>";}
#IPsec networks
+ my @IPSEC_N2N=();
foreach my $key (sort { ncmp($ipsecconf{$a}[0],$ipsecconf{$b}[0]) } keys %ipsecconf) {
if ($ipsecconf{$key}[3] eq 'net'){
- print"<td valign='top'><input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}></td><td valign='top'>$Lang::tr{'fwhost ipsec net'}</td><td><select name='IPSEC_NET' style='min-width:185px;'>" if ($show eq '');
$show='1';
- print"<option value='$ipsecconf{$key}[1]'>$ipsecconf{$key}[1]</option>";
+ push (@IPSEC_N2N,$ipsecconf{$key}[1]);
}
}
- if ($show eq '1'){$show='';print"</select></td></tr>";}
+ if ($show eq '1'){
+ $show='';
+ print<<END;
+ <td style='width:15em;'>
+ <label>
+ <input type='radio' name='grp2' id='IPSEC_NET' value='ipsec_net' $checked{'grp2'}{'ipsec_net'}>
+ $Lang::tr{'fwhost ipsec net'}
+ </label>
+ </td>
+ <td style='text-align:right;'>
+ <select name='IPSEC_NET' style='width:16em;'>"
+END
+ foreach(@IPSEC_N2N){
+ print"<option value='$_'>$_</option>";
+ }
+ }
+ print"</select></td></tr>";
print"</table>";
print"</td></tr></table>";
- print"<br><br><hr>";
+ print"<br><br>";
}
- print"<table border='0' width='100%'>";
- print"<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=\"$fwhostsettings{'update'}\"><input type='hidden' name='ACTION' value='savegrp' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='resetgrp'></form></td></table>";
+ print"<table width='100%'>";
+ print"<tr><td style='text-align:right;'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='oldremark' value='$fwhostsettings{'oldremark'}'><input type='hidden' name='update' value=\"$fwhostsettings{'update'}\"><input type='hidden' name='ACTION' value='savegrp' ></form><form method='post' style='display:inline'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'><input type='hidden' name='ACTION' value='resetgrp'></form></td></table>";
&Header::closebox();
}
sub addservice
print<<END;
</select></td></tr></table></div>
<div id='PORT' class='noscript'><table width='100%' border='0'><tr><td width='10%'>$Lang::tr{'fwhost port'}:</td><td><input type='text' name='SRV_PORT' value='$fwhostsettings{'SRV_PORT'}' maxlength='11' size='24'></td></tr></table></div>
- <table width='100%' border='0'><tr><td colspan='6'><br><hr></td></tr>
+ <table width='100%' border='0'><tr><td colspan='6'><br></td></tr>
<tr><td colspan='6' align='right'>
END
if ($fwhostsettings{'updatesrv'} eq 'on')
<table width='100%' border='0'><form method='post'>
<tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td><input type='text' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}' size='24'></td></tr>
<tr><td width='10%'>$Lang::tr{'remark'}:</td><td><input type='text' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width: 98%;'></td></tr>
- <tr><td colspan='2'><br><hr></tr>
+ <tr><td colspan='2'><br></tr>
</table>
END
}else{
print<<END;
- <table width='100%' border='0'><form method='post' style='display:inline'>
+ <table width='100%'><form method='post' style='display:inline'>
<tr><td width='10%'>$Lang::tr{'fwhost addgrpname'}</td><td width='20%'><input type='text' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}' size='14'></td><td align='left'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvgrpname' value='$fwhostsettings{'oldsrvgrpname'}'><input type='hidden' name='ACTION' value='changesrvgrpname'></td><td width='3%'></td></form></tr>
- <tr><form method='post'><td width='10%'>$Lang::tr{'remark'}:</td><td colspan='2'><input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'></td><td align='right'><input type='submit' value='$Lang::tr{'fwhost change'}'><input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='changesrvgrpremark' ></td></tr>
- <tr><td colspan='4'><br><hr></td></td></tr>
- </table></form>
+ <tr>
+ <form method='post'>
+ <td width='10%'>
+ $Lang::tr{'remark'}:
+ </td>
+ <td colspan='2'>
+ <input type='text' name='newsrvrem' value='$fwhostsettings{'SRVGRP_REMARK'}' style='width:98%;'>
+ </td>
+ <td align='right'>
+ <input type='submit' value='$Lang::tr{'fwhost change'}'>
+ <input type='hidden' name='oldsrvrem' value='$fwhostsettings{'oldsrvgrpremark'}'>
+ <input type='hidden' name='srvgrp' value='$fwhostsettings{'SRVGRP_NAME'}'>
+ <input type='hidden' name='ACTION' value='changesrvgrpremark' >
+ </td>
+ </tr>
+ <tr>
+ <td colspan='4'>
+ <br>
+ </td>
+ </tr>
+ </table>
+ </form>
END
}
if($fwhostsettings{'updatesrvgrp'} eq 'on'){
print<<END;
<form method='post'><input type='hidden' name='SRVGRP_REMARK' value='$fwhostsettings{'SRVGRP_REMARK'}'><input type='hidden' name='SRVGRP_NAME' value='$fwhostsettings{'SRVGRP_NAME'}'><table border='0' width='100%'>
- <tr><td width='1%' nowrap='nowrap'>$Lang::tr{'add'}</td><td><select name='CUST_SRV' style='min-width:185px;'>
+ <tr><td width='10%' nowrap='nowrap'>$Lang::tr{'add'}: </td><td><select name='CUST_SRV' style='min-width:185px;'>
END
&General::readhasharray("$configsrv", \%customservice);
#Protocols for use in servicegroups
print<<END;
</select></td></tr>
<tr><td colspan='4'><br><br></td></tr>
- <tr><td colspan='4'><hr></td></tr>
+ <tr><td colspan='4'></td></tr>
</table>
END
}
print<<END;
- <table width='100%' border='0'>
+ <table width='100%'>
<tr><td align='right'><input type='submit' value='$Lang::tr{'add'}' style='min-width:100px;' /><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'><input type='hidden' name='oldsrvgrpremark' value='$fwhostsettings{'oldsrvgrpremark'}'><input type='hidden' name='ACTION' value='saveservicegrp' ></form><form style='display:inline;' method='post'><input type='submit' value='$Lang::tr{'fwhost back'}' style='min-width:100px;'></td></tr>
</table></form>
END
&General::readhasharray("$fwconfigfwd", \%fwfwd);
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
+
if (!keys %customnetwork)
{
print "<center><b>$Lang::tr{'fwhost empty'}</b>";
}else{
print<<END;
- <table border='0' width='100%' cellspacing='0'>
- <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost netaddress'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
+ <table width='100%' cellspacing='0' class='tbl'>
+ <tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost netaddress'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
END
}
my $count=0;
+ my $col='';
foreach my $key (sort {ncmp($a,$b)} keys %customnetwork) {
if ($fwhostsettings{'ACTION'} eq 'editnet' && $fwhostsettings{'HOSTNAME'} eq $customnetwork{$key}[0]) {
- print" <tr bgcolor='${Header::colouryellow}'>";
+ print" <tr>";
+ $col="bgcolor='${Header::colouryellow}'";
}elsif ($count % 2)
{
- print" <tr bgcolor='$color{'color22'}'>";
+ $col="bgcolor='$color{'color20'}'";
+ print" <tr>";
}else
{
- print" <tr bgcolor='$color{'color20'}'>";
+ $col="bgcolor='$color{'color22'}'";
+ print" <tr>";
}
my $colnet="$customnetwork{$key}[1]/".&General::subtocidr($customnetwork{$key}[2]);
my $netcount=&getnetcount($customnetwork{$key}[0]);
- print"<td width='20%'><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center'>".&Header::colorize($colnet)."</td><td width='40%'>$customnetwork{$key}[3]</td><td align='center'>$netcount x</td>";
+ print"<td width='20%' $col><form method='post'>$customnetwork{$key}[0]</td><td width='15%' align='center' $col>".&getcolor($colnet)."</td><td width='40%' $col>$customnetwork{$key}[3]</td><td align='center' $col>$netcount x</td>";
print<<END;
- <td width='1%'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
+ <td width='1%' $col><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='ACTION' value='editnet'>
<input type='hidden' name='HOSTNAME' value='$customnetwork{$key}[0]' />
<input type='hidden' name='IP' value='$customnetwork{$key}[1]' />
END
if($netcount == '0')
{
- print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
+ print"<td width='1%' $col><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' /><input type='hidden' name='ACTION' value='delnet' /><input type='hidden' name='key' value='$customnetwork{$key}[0]' /></td></form></tr>";
}else{
- print"<td></td></tr>";
+ print"<td $col></td></tr>";
}
$count++;
}
sub getcolor
{
my $c=shift;
+ my $sip;
+ my $scidr;
+ #Check if MAC
+ if (&General::validmac($c)){ return $c;}
+
+ #Check if we got a full IP with subnet then split it
+ if($c =~ /^(.*?)\/(.*?)$/){
+ ($sip,$scidr) = split ("/",$c);
+ }else{
+ $sip=$c;
+ }
+
+ #Now check if IP is part of ORANGE,BLUE or GREEN
+ if ( &General::IpInSubnet($sip,$netsettings{'ORANGE_ADDRESS'},$netsettings{'ORANGE_NETMASK'})){
+ $tdcolor="<font style='color: $Header::colourorange;'>$c</font>";
+ return $tdcolor;
+ }
+ if ( &General::IpInSubnet($sip,$netsettings{'GREEN_ADDRESS'},$netsettings{'GREEN_NETMASK'})){
+ $tdcolor="<font style='color: $Header::colourgreen;'>$c</font>";
+ return $tdcolor;
+ }
+ if ( &General::IpInSubnet($sip,$netsettings{'BLUE_ADDRESS'},$netsettings{'BLUE_NETMASK'})){
+ $tdcolor="<font style='color: $Header::colourblue;'>$c</font>";
+ return $tdcolor;
+ }
+
#Check if IP is part of OpenVPN N2N subnet
foreach my $key (sort keys %ccdhost){
if ($ccdhost{$key}[3] eq 'net'){
my ($a,$b) = split("/",$ccdhost{$key}[11]);
- if (&General::IpInSubnet($c,$a,$b)){
- $tdcolor="style='color:$Header::colourovpn ;'";
+ if (&General::IpInSubnet($sip,$a,$b)){
+ $tdcolor="<font style='color:$Header::colourovpn ;'>$c</font>";
return $tdcolor;
}
}
}
+
#Check if IP is part of OpenVPN dynamic subnet
my ($a,$b) = split("/",$ovpnsettings{'DOVPN_SUBNET'});
- if (&General::IpInSubnet($c,$a,$b)){
- $tdcolor="style='color: $Header::colourovpn;'";
+ if (&General::IpInSubnet($sip,$a,$b)){
+ $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
return $tdcolor;
}
+
#Check if IP is part of OpenVPN static subnet
foreach my $key (sort keys %ccdnet){
my ($a,$b) = split("/",$ccdnet{$key}[1]);
$b =&General::iporsubtodec($b);
- if (&General::IpInSubnet($c,$a,$b)){
- $tdcolor="style='color: $Header::colourovpn;'";
+ if (&General::IpInSubnet($sip,$a,$b)){
+ $tdcolor="<font style='color: $Header::colourovpn;'>$c</font>";
return $tdcolor;
}
}
+
#Check if IP is part of IPsec RW network
if ($ipsecsettings{'RW_NET'} ne ''){
my ($a,$b) = split("/",$ipsecsettings{'RW_NET'});
$b=&General::iporsubtodec($b);
- if (&General::IpInSubnet($c,$a,$b)){
- $tdcolor="style='color: $Header::colourvpn;'";
+ if (&General::IpInSubnet($sip,$a,$b)){
+ $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
return $tdcolor;
}
}
+
#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($c,$a,$b)){
- $tdcolor="style='color: $Header::colourvpn;'";
+ if (&General::IpInSubnet($sip,$a,$b)){
+ $tdcolor="<font style='color: $Header::colourvpn;'>$c</font>";
return $tdcolor;
}
}
- $tdcolor='';
- return $tdcolor;
+ return "$c";
}
sub viewtablehost
{
print "<center><b>$Lang::tr{'fwhost empty'}</b>";
}else{
print<<END;
- <table border='0' width='100%' cellspacing='0'>
- <tr><td align='center'><b>$Lang::tr{'name'}</b></td><td align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></td><td align='center'><b>$Lang::tr{'remark'}</b></td><td align='center'><b>$Lang::tr{'used'}</b></td><td></td><td width='3%'></td></tr>
+ <table width='100%' cellspacing='0' class='tbl'>
+ <tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center'><b>$Lang::tr{'remark'}</b></th><th align='center'><b>$Lang::tr{'used'}</b></th><th></th><th width='3%'></th></tr>
END
}
my $count=0;
+ my $col='';
foreach my $key (sort { ncmp ($customhost{$a}[0],$customhost{$b}[0])} keys %customhost) {
if ( ($fwhostsettings{'ACTION'} eq 'edithost' || $fwhostsettings{'error'}) && $fwhostsettings{'HOSTNAME'} eq $customhost{$key}[0]) {
- print" <tr bgcolor='${Header::colouryellow}'>";
- }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}
- else{ print" <tr bgcolor='$color{'color20'}'>";}
+ print" <tr>";
+ $col="bgcolor='${Header::colouryellow}'";
+ }elsif ($count % 2){
+ print" <tr>";
+ $col="bgcolor='$color{'color20'}'";
+ }else{
+ $col="bgcolor='$color{'color22'}'";
+ print" <tr>";
+ }
my ($ip,$sub)=split(/\//,$customhost{$key}[2]);
$customhost{$key}[4]=~s/\s+//g;
my $hostcount=0;
$hostcount=&gethostcount($customhost{$key}[0]);
- print"<td width='20%'>$customhost{$key}[0]</td><td width='20%' align='center' ".&getcolor($ip).">".&Header::colorize($ip)."</td><td width='50%' align='left'>$customhost{$key}[3]</td><td align='center'>$hostcount x</td>";
+ print"<td width='20%' $col>$customhost{$key}[0]</td><td width='20%' align='center' $col >".&getcolor($ip)."</td><td width='50%' align='left' $col>$customhost{$key}[3]</td><td align='center' $col>$hostcount x</td>";
print<<END;
- <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} />
+ <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' />
<input type='hidden' name='ACTION' value='edithost' />
<input type='hidden' name='HOSTNAME' value='$customhost{$key}[0]' />
<input type='hidden' name='IP' value='$ip' />
END
if($hostcount == '0')
{
- print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delhost' /><input type='hidden' name='key' value='$customhost{$key}[0]' /></td></form></tr>";
+ print"<td width='1%' $col><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' /><input type='hidden' name='ACTION' value='delhost' /><input type='hidden' name='key' value='$customhost{$key}[0]' /></td></form></tr>";
}else{
- print"<td width='1%'></td></tr>";
+ print"<td width='1%' $col></td></tr>";
}
$count++;
}
my $remark;
my $number;
my $delflag;
+ my @counter;
+ my %hash;
if (!keys %customgrp)
{
print "<center><b>$Lang::tr{'fwhost err emptytable'}</b>";
}else{
+ #get all groups in a hash
+ foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
+ push (@counter,$customgrp{$key}[0]);
+ }
+ foreach my $key1 (@counter) {
+ $hash{$key1}++ ;
+ }
foreach my $key (sort { ncmp($customgrp{$a}[0],$customgrp{$b}[0]) } sort { ncmp($customgrp{$a}[2],$customgrp{$b}[2]) } keys %customgrp){
$count++;
if ($helper ne $customgrp{$key}[0]){
if ($customgrp{$key}[2] eq "none"){$customgrp{$key}[2]=$Lang::tr{'fwhost err emptytable'};}
$grpname=$customgrp{$key}[0];
$remark="$customgrp{$key}[1]";
- if($count gt 1){ print"</table>";}
+ if($count gt 1){ print"</table>";$count=1;}
print "<br><b><u>$grpname</u></b> ";
print " <b>$Lang::tr{'remark'}:</b>  $remark   " if ($remark ne '');
my $netgrpcount=&getnetcount($grpname);
print "<b>$Lang::tr{'used'}:</b> $netgrpcount x";
if($netgrpcount == '0')
{
- print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='ACTION' value='delgrp'></form>";
+ print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='ACTION' value='delgrp'></form>";
}
- print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='remark' value='$remark' ><input type='hidden' name='ACTION' value='editgrp'></form>";
- print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'ip address'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost type'}</td><td></td></tr>";
+ print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' align='right' /><input type='hidden' name='grp_name' value='$grpname' ><input type='hidden' name='remark' value='$remark' ><input type='hidden' name='ACTION' value='editgrp'></form>";
+ print"<table width='100%' cellspacing='0' class='tbl'><tr><th align='center'><b>$Lang::tr{'name'}</b></th><th align='center'><b>$Lang::tr{'fwhost ip_mac'}</b></th><th align='center' width='25%'><b>$Lang::tr{'fwhost type'}</th><th></th></tr>";
}
-
+ my $col='';
if ( ($fwhostsettings{'ACTION'} eq 'editgrp' || $fwhostsettings{'update'} ne '') && $fwhostsettings{'grp_name'} eq $customgrp{$key}[0]) {
- print" <tr bgcolor='${Header::colouryellow}'>";
+ print" <tr>";
+ $col="bgcolor='${Header::colouryellow}'";
}elsif ($count %2 == 0){
- print"<tr bgcolor='$color{'color22'}'>";
+ print"<tr>";
+ $col="bgcolor='$color{'color20'}'";
}else{
- print"<tr bgcolor='$color{'color20'}'>";
+ print"<tr>";
+ $col="bgcolor='$color{'color22'}'";
}
my $ip=&getipforgroup($customgrp{$key}[2],$customgrp{$key}[3]);
- if ($ip eq ''){print"<tr bgcolor='${Header::colouryellow}'>";}
- print "<td width='39%' align='left'>";
+ if ($ip eq ''){
+ print"<tr>";
+ $col="bgcolor='${Header::colouryellow}'";
+ }
+ print "<td width='39%' align='left' $col>";
if($customgrp{$key}[3] eq 'Standard Network'){
print &get_name($customgrp{$key}[2])."</td>";
}else{
print "$customgrp{$key}[2]</td>";
}
if ($ip eq '' && $customgrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){
- print "<td align='center'>$Lang::tr{'fwhost deleted'}</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
+ 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'>";
}else{
my ($colip,$colsub) = split("/",$ip);
$ip="$colip/".&General::subtocidr($colsub) if ($colsub);
- print"<td align='center' ".&getcolor($colip).">".&Header::colorize($ip)."</td><td align='center'>$customgrp{$key}[3]</td><td width='1%'><form method='post'>";
- }
- if ($delflag > 1 && $ip ne ''){
- print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
+ print"<td align='center' $col>".&getcolor($ip)."</td><td align='center' $col>$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'}' />";
+ #check if this group has only one entry
+ foreach my $key2 (keys %hash) {
+ if ($hash{$key2}<2 && $key2 eq $customgrp{$key}[0]){
+ print "<input type='hidden' name='last' value='on'>" ;
+ }
+ }
}
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>";
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
print<<END;
- <table width='100%' border='0' cellspacing='0'>
- <tr><td align='center'><b>$Lang::tr{'fwhost srv_name'}</b></td><td align='center'><b>$Lang::tr{'fwhost prot'}</b></td><td align='center'><b>$Lang::tr{'fwhost port'}</b></td><td align='center'><b>ICMP</b></td><td align='center'><b>$Lang::tr{'fwhost used'}</b></td><td></td><td width='3%'></td></tr>
+ <table width='100%' cellspacing='0' class='tbl'>
+ <tr><th align='center'><b>$Lang::tr{'fwhost srv_name'}</b></th><th align='center'><b>$Lang::tr{'fwhost prot'}</b></th><th align='center'><b>$Lang::tr{'fwhost port'}</b></th><th align='center'><b>ICMP</b></th><th align='center'><b>$Lang::tr{'fwhost used'}</b></th><th></th><th width='3%'></th></tr>
END
+ my $col='';
foreach my $key (sort { ncmp($customservice{$a}[0],$customservice{$b}[0])} keys %customservice)
{
$count++;
if ( ($fwhostsettings{'updatesrv'} eq 'on' || $fwhostsettings{'error'}) && $fwhostsettings{'SRV_NAME'} eq $customservice{$key}[0]) {
- print" <tr bgcolor='${Header::colouryellow}'>";
- }elsif ($count % 2){ print" <tr bgcolor='$color{'color22'}'>";}else{ print" <tr bgcolor='$color{'color20'}'>";}
+ print" <tr>";
+ $col="bgcolor='${Header::colouryellow}'";
+ }elsif ($count % 2){
+ print" <tr>";
+ $col="bgcolor='$color{'color22'}'";
+ }else{
+ print" <tr>";
+ $col="bgcolor='$color{'color20'}'";
+ }
print<<END;
- <td>$customservice{$key}[0]</td><td align='center'>$customservice{$key}[2]</td><td align='center'>$customservice{$key}[1]</td><td align='center'>
+ <td $col>$customservice{$key}[0]</td><td align='center' $col>$customservice{$key}[2]</td><td align='center' $col>$customservice{$key}[1]</td><td align='center' $col>
END
#Neuer count
$srvcount=&getsrvcount($customservice{$key}[0]);
if($customservice{$key}[3] eq 'All ICMP-Types'){print $Lang::tr{'fwdfw all icmp'};}
elsif($customservice{$key}[3] ne 'BLANK'){print $customservice{$key}[3];}
print<<END;
- </td><td align='center'>$srvcount x</td>
- <td width='1%'><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} /><input type='hidden' name='ACTION' value='editservice' />
+ </td><td align='center' $col>$srvcount x</td>
+ <td width='1%' $col><form method='post'><input type='image' src='/images/edit.gif' align='middle' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' /><input type='hidden' name='ACTION' value='editservice' />
<input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]' />
<input type='hidden' name='SRV_PORT' value='$customservice{$key}[1]' />
<input type='hidden' name='PROT' value='$customservice{$key}[2]' />
END
if ($srvcount eq '0')
{
- print"<td width='1%'><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} /><input type='hidden' name='ACTION' value='delservice' /><input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]'></td></tr></form>";
+ print"<td width='1%' $col><form method='post'><input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' /><input type='hidden' name='ACTION' value='delservice' /><input type='hidden' name='SRV_NAME' value='$customservice{$key}[0]'></td></tr></form>";
}else{
- print"<td></td></tr>";
+ print"<td $col></td></tr>";
}
}
print"</table>";
my $grpname;
my $remark;
my $helper;
+ my $helper1;
my $port;
my $protocol;
my $delflag;
my $grpcount=0;
+ my $col='';
+ my $lastentry=0;
+ my @counter;
+ my %hash;
if (! -z $configsrvgrp){
&Header::openbox('100%', 'left', $Lang::tr{'fwhost cust srvgrp'});
&General::readhasharray("$configsrvgrp", \%customservicegrp);
&General::readhasharray("$fwconfiginp", \%fwinp);
&General::readhasharray("$fwconfigout", \%fwout);
my $number= keys %customservicegrp;
+ foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
+ push (@counter,$customservicegrp{$key}[0]);
+ }
+ foreach my $key1 (@counter) {
+ $hash{$key1}++ ;
+ }
foreach my $key (sort { ncmp($customservicegrp{$a}[0],$customservicegrp{$b}[0]) } sort { ncmp($customservicegrp{$a}[2],$customservicegrp{$b}[2]) }keys %customservicegrp){
$count++;
if ($helper ne $customservicegrp{$key}[0]){
}
$grpname=$customservicegrp{$key}[0];
if ($customservicegrp{$key}[2] eq "none"){
- $customservicegrp{$key}[2]=$Lang::tr{'fwhost empty'};
+ $customservicegrp{$key}[2]=$Lang::tr{'fwhost err emptytable'};
$port='';
$protocol='';
}
$remark="$customservicegrp{$key}[1]";
- if($count >=2){print"</table>";}
+ if($count >0){print"</table>";$count=1;}
print "<br><b><u>$grpname</u></b> ";
print "<b>$Lang::tr{'remark'}:</b> $remark " if ($remark ne '');
print " <b>$Lang::tr{'used'}:</b> $grpcount x";
if($grpcount == '0')
{
- print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='ACTION' value='delservicegrp'></form>";
+ print"<form method='post' style='display:inline'><input type='image' src='/images/delete.gif' alt='$Lang::tr{'delete'}' title='$Lang::tr{'delete'}' align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='ACTION' value='delservicegrp'></form>";
}
- print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt=$Lang::tr{'edit'} title=$Lang::tr{'edit'} align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='SRVGRP_REMARK' value='$remark' ><input type='hidden' name='ACTION' value='editservicegrp'></form>";
- print"<table width='100%' style='border: 1px solid #CCCCCC;' rules='none' cellspacing='0'><tr><td align='center'><b>Name</b></td><td align='center'><b>$Lang::tr{'port'}</b></td><td align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</td><td></td></tr>";
+ print"<form method='post' style='display:inline'><input type='image' src='/images/edit.gif' alt='$Lang::tr{'edit'}' title='$Lang::tr{'edit'}' align='right' /><input type='hidden' name='SRVGRP_NAME' value='$grpname' ><input type='hidden' name='SRVGRP_REMARK' value='$remark' ><input type='hidden' name='ACTION' value='editservicegrp'></form>";
+ print"<table width='100%' cellspacing='0' class='tbl'><tr><th align='center'><b>Name</b></th><th align='center'><b>$Lang::tr{'port'}</b></th><th align='center' width='25%'><b>$Lang::tr{'fwhost prot'}</th><th></th></tr>";
}
if( $fwhostsettings{'SRVGRP_NAME'} eq $customservicegrp{$key}[0]) {
- print" <tr bgcolor='${Header::colouryellow}'>";
+ print"<tr>";
+ $col="bgcolor='${Header::colouryellow}'";
}elsif ($count %2 == 0){
- print"<tr bgcolor='$color{'color22'}'>";
+ print"<tr>";
+ $col="bgcolor='$color{'color20'}'";
}else{
- print"<tr bgcolor='$color{'color20'}'>";
+ print"<tr>";
+ $col="bgcolor='$color{'color22'}'";
+ }
+ #make lines yellow if it is a dummy entry
+ if ($customservicegrp{$key}[2] eq $Lang::tr{'fwhost err emptytable'}){
+ print"<tr>";
+ $col="bgcolor='${Header::colouryellow}'";
}
#Set fields if we use protocols in servicegroups
if ($customservicegrp{$key}[2] ne 'TCP' || $customservicegrp{$key}[2] ne 'UDP' || $customservicegrp{$key}[2] ne 'ICMP'){
if ($customservicegrp{$key}[2] eq 'IGMP'){$protocol='IGMP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IGMP";}
if ($customservicegrp{$key}[2] eq 'IPIP'){$protocol='IPIP';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPIP";}
if ($customservicegrp{$key}[2] eq 'IPV6'){$protocol='IPV6';$customservicegrp{$key}[2]="$Lang::tr{'protocol'} IPv6 encapsulation";}
- print "<td width='39%'>$customservicegrp{$key}[2]</td>";
+ print "<td width='39%' $col>$customservicegrp{$key}[2]</td>";
foreach my $srv (sort keys %customservice){
if ($customservicegrp{$key}[2] eq $customservice{$srv}[0]){
$protocol=$customservice{$srv}[2];
last;
}
}
- print"<td align='center'>$port</td><td align='center'>$protocol</td><td width='1%'><form method='post'>";
- if ($delflag gt '1'){
- print"<input type='image' src='/images/delete.gif' align='middle' alt=$Lang::tr{'delete'} title=$Lang::tr{'delete'} />";
+ print"<td align='center' $col>$port</td><td align='center' $col>$protocol</td><td width='1%' $col><form method='post'>";
+ if ($delflag gt '0'){
+ if ($customservicegrp{$key}[2] ne $Lang::tr{'fwhost err emptytable'}){
+ print"<input type='image' src='/images/delete.gif' align='middle' alt='$Lang::tr{'delete'}' title=$Lang::tr{'delete'} />";
+ }
+ #check if this group has only one entry
+ foreach my $key2 (keys %hash) {
+ if ($hash{$key2}<2 && $key2 eq $customservicegrp{$key}[0]){
+ print "<input type='hidden' name='last' value='on'>" ;
+ }
+ }
}
print"<input type='hidden' name='ACTION' value='delgrpservice'><input type='hidden' name='updatesrvgrp' value='$fwhostsettings{'updatesrvgrp'}'>";
if($protocol eq 'TCP' || $protocol eq 'UDP' || $protocol eq 'ICMP'){
}
sub checkgroup
{
- &General::readhasharray("$configsrvgrp", \%customservicegrp );
+ &General::readhasharray("$configgrp", \%customgrp );
my $name=shift;
foreach my $key (keys %customservicegrp) {
if($customservicegrp{$key}[0] eq $name){
}
return $errormessage;
}
+sub checkrulereload
+{
+ my $search=shift;
+ &General::readhasharray("$fwconfigfwd", \%fwfwd);
+ &General::readhasharray("$fwconfiginp", \%fwinp);
+ &General::readhasharray("$fwconfigout", \%fwout);
+
+ #check if service or servicegroup is used in rules
+ foreach my $key (keys %fwfwd){
+ if($search eq $fwfwd{$key}[15]){
+ &General::firewall_config_changed();
+ return;
+ }
+ }
+ foreach my $key (keys %fwinp){
+ if($search eq $fwinp{$key}[15]){
+ &General::firewall_config_changed();
+ return;
+ }
+ }
+ foreach my $key (keys %fwout){
+ if($search eq $fwout{$key}[15]){
+ &General::firewall_config_changed();
+ return;
+ }
+ }
+}
sub error
{
if ($errormessage) {