p2p-block.cgi: Fix coding style.

This commit is contained in:
Michael Tremer
2013-10-22 19:08:35 +02:00
parent 2d5447bb1b
commit 4a75efa5a7
3 changed files with 71 additions and 35 deletions

View File

@@ -31,36 +31,34 @@ require '/var/ipfire/general-functions.pl';
require "${General::swroot}/lang.pl"; require "${General::swroot}/lang.pl";
require "${General::swroot}/header.pl"; require "${General::swroot}/header.pl";
my $errormessage=''; my $errormessage = '';
my $p2pfile = "${General::swroot}/forward/p2protocols"; my $p2pfile = "${General::swroot}/forward/p2protocols";
my @p2ps = (); my @p2ps = ();
my %fwdfwsettings=(); my %fwdfwsettings = ();
my %color=(); my %color = ();
my %mainsettings=(); my %mainsettings = ();
&General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings);
&General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("${General::swroot}/main/settings", \%mainsettings);
&General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color);
&Header::showhttpheaders(); &Header::showhttpheaders();
&Header::getcgihash(\%fwdfwsettings); &Header::getcgihash(\%fwdfwsettings);
&Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); &Header::openpage($Lang::tr{'p2p block'}, 1, '');
&Header::openbigbox('100%', 'center', $errormessage); &Header::openbigbox('100%', 'center', $errormessage);
if ($fwdfwsettings{'ACTION'} eq 'togglep2p') { if ($fwdfwsettings{'ACTION'} eq 'togglep2p') {
open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; open( FILE, "<$p2pfile") or die "Unable to read $p2pfile";
@p2ps = <FILE>; @p2ps = <FILE>;
close FILE; close FILE;
open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile"; open( FILE, ">$p2pfile") or die "Unable to write $p2pfile";
foreach my $p2pentry (sort @p2ps) foreach my $p2pentry (sort @p2ps) {
{ my @p2pline = split( /\;/, $p2pentry);
my @p2pline = split( /\;/, $p2pentry );
if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) { if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) {
if($p2pline[2] eq 'on'){ if ($p2pline[2] eq 'on') {
$p2pline[2]='off'; $p2pline[2] = 'off';
}else{ } else {
$p2pline[2]='on'; $p2pline[2] = 'on';
} }
} }
print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n";
@@ -73,34 +71,70 @@ if ($fwdfwsettings{'ACTION'} eq 'togglep2p') {
&p2pblock(); &p2pblock();
} }
sub p2pblock sub p2pblock {
{
my $gif; my $gif;
open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile";
open(FILE, "<$p2pfile") or die "Unable to read $p2pfile";
@p2ps = <FILE>; @p2ps = <FILE>;
close FILE; close FILE;
&Header::openbox('100%', 'center', 'P2P-Block');
&Header::openbox('100%', 'center', $Lang::tr{'p2p block'});
print <<END; print <<END;
<table width='35%' border='0'> <table width='35%' border='0'>
<tr bgcolor='$color{'color22'}'><td align=center colspan='2' ><b>$Lang::tr{'protocol'}</b></td><td align='center'><b>$Lang::tr{'status'}</b></td></tr> <tr bgcolor='$color{'color22'}'>
<td align=center colspan='2' >
<b>$Lang::tr{'protocol'}</b>
</td>
<td align='center'>
<b>$Lang::tr{'status'}</b>
</td>
</tr>
END END
foreach my $p2pentry (sort @p2ps)
{ foreach my $p2pentry (sort @p2ps) {
my @p2pline = split( /\;/, $p2pentry ); my @p2pline = split( /\;/, $p2pentry);
if($p2pline[2] eq 'on'){ if ($p2pline[2] eq 'on') {
$gif="/images/on.gif" $gif = "/images/on.gif"
}else{ } else {
$gif="/images/off.gif" $gif = "/images/off.gif"
} }
print <<END; print <<END;
<form method='post' action='$ENV{'SCRIPT_NAME'}'> <tr bgcolor='$color{'color20'}'>
<tr bgcolor='$color{'color20'}'> <td align='center' colspan='2'>
<td align='center' colspan='2' >$p2pline[0]:</td><td align='center'><input type='hidden' name='P2PROT' value='$p2pline[1]' /><input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;' ><input type='hidden' name='ACTION' value='togglep2p'></td></tr></form> $p2pline[0]:
</td>
<td align='center'>
<form method='post' action='$ENV{'SCRIPT_NAME'}'>
<input type='hidden' name='P2PROT' value='$p2pline[1]'>
<input type='image' img src='$gif' alt='$Lang::tr{'click to disable'}' title='$Lang::tr{'fwdfw toggle'}' style='padding-top: 0px; padding-left: 0px; padding-bottom: 0px ;padding-right: 0px ;display: block;'>
<input type='hidden' name='ACTION' value='togglep2p'>
</form>
</td>
</tr>
END END
} }
print"<tr><td><img src='/images/on.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p allow'}</td></tr>";
print"<tr><td><img src='/images/off.gif'></td><td align='left'>$Lang::tr{'outgoing firewall p2p deny'}</td></tr></table>"; print <<END;
print"<br><br><br><table width='100%'><tr><td align='left'>$Lang::tr{'fwdfw p2p txt'}</td></tr></table>"; <tr>
<td>
<img src='/images/on.gif'>
</td>
<td>
$Lang::tr{'outgoing firewall p2p allow'}
</td>
</tr>
<tr>
<td>
<img src='/images/off.gif'>
</td>
<td>
$Lang::tr{'outgoing firewall p2p deny'}
</td>
</tr>
</table>
END
&Header::closebox(); &Header::closebox();
} }

View File

@@ -1606,6 +1606,7 @@
'ovpn_processprioVH' => 'Sehr Hoch', 'ovpn_processprioVH' => 'Sehr Hoch',
'ovpnstatus log' => 'OVPN-Status-Log', 'ovpnstatus log' => 'OVPN-Status-Log',
'ovpnsys log' => 'OVPN-System-Log', 'ovpnsys log' => 'OVPN-System-Log',
'p2p block' => 'P2P-Block',
'package failed to install' => 'Programmpaket konnte nicht installiert werden.', 'package failed to install' => 'Programmpaket konnte nicht installiert werden.',
'pagerefresh' => 'Seite wird aktualisiert. Bitte warten.', 'pagerefresh' => 'Seite wird aktualisiert. Bitte warten.',
'pakfire accept all' => 'Möchten Sie der Installation aller Pakete zustimmen?', 'pakfire accept all' => 'Möchten Sie der Installation aller Pakete zustimmen?',

View File

@@ -1635,6 +1635,7 @@
'ovpn_processprioVH' => 'Very high', 'ovpn_processprioVH' => 'Very high',
'ovpnstatus log' => 'OVPN-Status-Log', 'ovpnstatus log' => 'OVPN-Status-Log',
'ovpnsys log' => 'OVPN-System-Log', 'ovpnsys log' => 'OVPN-System-Log',
'p2p block' => 'P2P block',
'package failed to install' => 'Package failed to install.', 'package failed to install' => 'Package failed to install.',
'pagerefresh' => 'Page is beeing refreshed, please wait.', 'pagerefresh' => 'Page is beeing refreshed, please wait.',
'pakfire accept all' => 'Do you want to install all packages?', 'pakfire accept all' => 'Do you want to install all packages?',