X-Git-Url: http://git.ipfire.org/?p=ipfire-2.x.git;a=blobdiff_plain;f=html%2Fcgi-bin%2Fp2p-block.cgi;h=04f13314244b5a1e5e42b9dc3aca8feecc729e7b;hp=9d248a133396d5a522968363c89cda35325ec782;hb=b98757a13970bebef354849be7704d5932a28353;hpb=debe3af56492731d6589a9005de8516e3037f88f diff --git a/html/cgi-bin/p2p-block.cgi b/html/cgi-bin/p2p-block.cgi old mode 100755 new mode 100644 index 9d248a1333..04f1331424 --- a/html/cgi-bin/p2p-block.cgi +++ b/html/cgi-bin/p2p-block.cgi @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2012 # +# Copyright (C) 2013 # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -18,16 +18,7 @@ # along with this program. If not, see . # # # ############################################################################### -# # -# Hi folks! I hope this code is useful for all. I needed something to handle # -# my VPN Connections in a comfortable way. As a prerequisite i needed # -# something that makes sure the vpn roadwarrior are able to have a fixed # -# ip-address. So i developed the ccd extension for the vpn server. # -# # -# Now that the ccd extension is ready i am able to develop the main request. # -# Any feedback is appreciated. # -# # -#Copymaster # +# Author: Alexander Marx (Amarx@ipfire.org) # ############################################################################### use strict; @@ -40,104 +31,124 @@ require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; -my $errormessage=''; -my $p2pfile = "${General::swroot}/forward/p2protocols"; +my $errormessage = ''; +my $notice; +my $p2pfile = "${General::swroot}/firewall/p2protocols"; my @p2ps = (); -my %fwdfwsettings=(); -my %color=(); -my %mainsettings=(); +my %fwdfwsettings = (); +my %color = (); +my %mainsettings = (); -&General::readhash("${General::swroot}/forward/settings", \%fwdfwsettings); &General::readhash("${General::swroot}/main/settings", \%mainsettings); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", \%color); - - &Header::showhttpheaders(); &Header::getcgihash(\%fwdfwsettings); -&Header::openpage($Lang::tr{'fwdfw menu'}, 1, ''); -&Header::openbigbox('100%', 'center',$errormessage); -if ($fwdfwsettings{'ACTION'} eq ''){ -&p2pblock; -} -if ($fwdfwsettings{'ACTION'} eq 'togglep2p') -{ - open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; +if ($fwdfwsettings{'ACTION'} eq 'togglep2p') { + open( FILE, "<$p2pfile") or die "Unable to read $p2pfile"; @p2ps = ; close FILE; - open( FILE, "> $p2pfile" ) or die "Unable to write $p2pfile"; - foreach my $p2pentry (sort @p2ps) - { - my @p2pline = split( /\;/, $p2pentry ); + open( FILE, ">$p2pfile") or die "Unable to write $p2pfile"; + foreach my $p2pentry (sort @p2ps) { + my @p2pline = split( /\;/, $p2pentry); if ($p2pline[1] eq $fwdfwsettings{'P2PROT'}) { - if($p2pline[2] eq 'on'){ - $p2pline[2]='off'; - }else{ - $p2pline[2]='on'; + if ($p2pline[2] eq 'on') { + $p2pline[2] = 'off'; + } else { + $p2pline[2] = 'on'; } } print FILE "$p2pline[0];$p2pline[1];$p2pline[2];\n"; } close FILE; - &rules; - &p2pblock; + + &General::firewall_config_changed(); + + $notice = $Lang::tr{'p2p block save notice'}; } -if ($fwdfwsettings{'ACTION'} eq $Lang::tr{'fwdfw reread'}) -{ - &reread_rules; - &p2pblock; + +&Header::openpage($Lang::tr{'p2p block'}, 1, ''); +&Header::openbigbox('100%', 'center', $errormessage); + +if ($notice) { + &Header::openbox('100%', 'left', $Lang::tr{'notice'}); + print "$notice"; + &Header::closebox(); } +my $gif; + +open(FILE, "<$p2pfile") or die "Unable to read $p2pfile"; +@p2ps = ; +close FILE; -sub p2pblock -{ - if (-f "${General::swroot}/forward/reread"){ - print "
$Lang::tr{'fwhost reread'}


"; +&Header::openbox('100%', 'center',); +print < + + + $Lang::tr{'protocol'} + + + $Lang::tr{'status'} + + +END +my $lines=0; +my $col=""; +foreach my $p2pentry (sort @p2ps) { + my @p2pline = split( /\;/, $p2pentry); + if ($p2pline[2] eq 'on') { + $gif = "/images/on.gif" + } else { + $gif = "/images/off.gif" } - my $gif; - open( FILE, "< $p2pfile" ) or die "Unable to read $p2pfile"; - @p2ps = ; - close FILE; - &Header::openbox('100%', 'center', 'P2P-Block'); + if ($lines % 2) { + print ""; + $col="bgcolor='$color{'color20'}'"; } + else { + print ""; + $col="bgcolor='$color{'color22'}'"; } print < - $Lang::tr{'protocol'}$Lang::tr{'status'} + + $p2pline[0]: + + +
+ + + +
+ + END - foreach my $p2pentry (sort @p2ps) - { - my @p2pline = split( /\;/, $p2pentry ); - if($p2pline[2] eq 'on'){ - $gif="/images/on.gif" - }else{ - $gif="/images/off.gif" - } - print < - - $p2pline[0]: -END - } - print"$Lang::tr{'outgoing firewall p2p allow'}"; - print"$Lang::tr{'outgoing firewall p2p deny'}"; - print"


$Lang::tr{'fwdfw p2p txt'}
"; - &Header::closebox(); -} -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"); - } +$lines++; } + +print < + + + + + + + + +
+ + + $Lang::tr{'outgoing firewall p2p allow'} +
+ + + $Lang::tr{'outgoing firewall p2p deny'} +
+END + +&Header::closebox(); + &Header::closebigbox(); &Header::closepage();