END
;
foreach (@groups) {
if ($is_supervisor)
{
print" ";
} else {
print"\n";
print"\n";
}
print <
END
;
} else {
print " \n";
print " \n";
print " $tr{'advproxy no cre groups'}\n";
print " | \n";
print " \n";
}
} else {
print " \n";
print " \n";
print " $tr{'advproxy cre disabled'}\n";
print " | \n";
print " \n";
}
print <
Advanced Proxy running on
IPFire
|
END
;
# -------------------------------------------------------------------
sub readhash
{
my $filename = $_[0];
my $hash = $_[1];
my ($var, $val);
if (-e $filename)
{
open(FILE, $filename) or die "Unable to read file $filename";
while ()
{
chop;
($var, $val) = split /=/, $_, 2;
if ($var)
{
$val =~ s/^\'//g;
$val =~ s/\'$//g;
# Untaint variables read from hash
$var =~ /([A-Za-z0-9_-]*)/; $var = $1;
$val =~ /([\w\W]*)/; $val = $1;
$hash->{$var} = $val;
}
}
close FILE;
}
}
# -------------------------------------------------------------------
sub getcgihash
{
my ($hash, $params) = @_;
my $cgi = CGI->new ();
return if ($ENV{'REQUEST_METHOD'} ne 'POST');
if (!$params->{'wantfile'}) {
$CGI::DISABLE_UPLOADS = 1;
$CGI::POST_MAX = 512 * 1024;
} else {
$CGI::POST_MAX = 10 * 1024 * 1024;
}
$cgi->referer() =~ m/^https?\:\/\/([^\/]+)/;
my $referer = $1;
$cgi->url() =~ m/^https?\:\/\/([^\/]+)/;
my $servername = $1;
return if ($referer ne $servername);
### Modified for getting multi-vars, split by |
%temp = $cgi->Vars();
foreach my $key (keys %temp) {
$hash->{$key} = $temp{$key};
$hash->{$key} =~ s/\0/|/g;
$hash->{$key} =~ s/^\s*(.*?)\s*$/$1/;
}
if (($params->{'wantfile'})&&($params->{'filevar'})) {
$hash->{$params->{'filevar'}} = $cgi->upload
($params->{'filevar'});
}
return;
}
# -------------------------------------------------------------------
sub read_acl_groups
{
undef(%acl);
open (FILE,"$acl_src_noaccess_ips");
my @aclgroups = ;
close (FILE);
foreach (@aclgroups)
{
chomp;
if (/^\#/)
{
s/^\# //;
$acl{$_}='on';
}
}
}
# -------------------------------------------------------------------
sub read_all_groups
{
my $grpstr;
open (FILE,"$group_def_file");
@group_defs = ;
close (FILE);
undef(@groups);
foreach (@group_defs)
{
chomp;
if (/^\s*\[.*\]\s*$/)
{
$grpstr=$_;
$grpstr =~ s/^\s*\[\s*//;
$grpstr =~ s/\s*\]\s*$//;
push(@groups,$grpstr);
}
}
}
# -------------------------------------------------------------------
sub write_acl
{
my $is_blocked=0;
open (FILE_IPS,">$acl_src_noaccess_ips");
open (FILE_MAC,">$acl_src_noaccess_mac");
flock (FILE_IPS, 2);
flock (FILE_MAC, 2);
foreach (@group_defs)
{
if (/^\s*\[.*\]\s*$/)
{
s/^\s*\[\s*//;
s/\s*\]\s*$//;
if ((defined($acl{$_})) && ($acl{$_} eq 'on'))
{
print FILE_IPS "# $_\n";
print FILE_MAC "# $_\n";
$is_blocked=1;
} else { $is_blocked=0; }
} elsif (($is_blocked) && ($_))
{
s/^\s+//g; s/\s+$//g;
/^[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}$/i ? print FILE_MAC "$_\n" : print FILE_IPS "$_\n";
}
}
close (FILE_IPS);
close (FILE_MAC);
}
# -------------------------------------------------------------------
|