version 1.16, 2005/02/10 22:30:56
|
version 1.22, 2007/03/02 23:43:29
|
Line 30 package Apache::lonracc;
|
Line 30 package Apache::lonracc;
|
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet(); |
use Apache::lonnet; |
use Apache::File(); |
use Apache::File(); |
use IO::Socket; |
use IO::Socket; |
|
|
sub subscribed { |
sub subscribed { |
my ($filename,$id) = @_; |
my ($filename,$id) = @_; |
my $found=0; |
|
my $hostname=$Apache::lonnet::hostname{$id}; |
return 0 if (!-e "$filename.subscription"); |
|
|
|
my $hostname=&Apache::lonnet::hostname($id); |
my (undef,undef,undef,undef,$ip) = gethostbyname($hostname); |
my (undef,undef,undef,undef,$ip) = gethostbyname($hostname); |
|
|
|
return 0 if (length($ip) != 4); |
|
|
$ip=inet_ntoa($ip); |
$ip=inet_ntoa($ip); |
my $expr='^'.$id.':'.$ip.':'; |
|
$expr =~ s/\./\\\./g; |
my $expr='^'.quotemeta($id).':'.quotemeta($ip).':'; |
my $sh; |
|
if ($sh=Apache::File->new("$filename.subscription")) { |
my $found=0; |
|
if (my $sh=Apache::File->new("$filename.subscription")) { |
while (my $subline=<$sh>) { if ($subline =~ /$expr/) { $found=1; } } |
while (my $subline=<$sh>) { if ($subline =~ /$expr/) { $found=1; } } |
$sh->close(); |
$sh->close(); |
} |
} |
Line 52 sub subscribed {
|
Line 58 sub subscribed {
|
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
|
my $filename=$r->filename; |
|
if (!-e $filename) { |
|
return NOT_FOUND; |
|
} |
|
|
my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP); |
my $reqhost = $r->get_remote_host(REMOTE_NOLOOKUP); |
my %iphost=&Apache::lonnet::get_iphost(); |
my @hostids= &Apache::lonnet::get_hosts_from_ip($reqhost); |
my $hostids=$iphost{$reqhost}; |
if (!@hostids && $reqhost ne '127.0.0.1' ) { |
if (!$hostids && $reqhost ne '127.0.0.1' ) { |
|
$r->log_reason("Unable to find a host for ". |
$r->log_reason("Unable to find a host for ". |
$r->get_remote_host(REMOTE_NOLOOKUP)); |
$r->get_remote_host(REMOTE_NOLOOKUP)); |
return FORBIDDEN; |
return FORBIDDEN; |
Line 64 sub handler {
|
Line 75 sub handler {
|
return OK; |
return OK; |
} |
} |
my $return; |
my $return; |
my @ids=(); |
my @ids; |
my $id; |
|
|
|
foreach $id (@{$hostids}) { |
foreach my $id (@hostids) { |
my $filename=$r->filename; |
|
my $uri =$r->uri; |
my $uri =$r->uri; |
if ((-e "$filename.$id") || |
if (($filename=~/\.meta$/) || |
&subscribed($filename,$id) || |
($uri=~m|^/raw/uploaded|) || |
($filename=~/\.meta$/) || |
(-e "$filename.$id") || |
($uri=~m|^/raw/uploaded|)) { |
&subscribed($filename,$id) ) { |
return OK; |
return OK; |
} else { |
} else { |
$return=FORBIDDEN; |
$return=FORBIDDEN; |