version 1.17, 2005/04/07 06:56:21
|
version 1.19, 2007/02/01 06:31:33
|
Line 36 use IO::Socket;
|
Line 36 use IO::Socket;
|
|
|
sub subscribed { |
sub subscribed { |
my ($filename,$id) = @_; |
my ($filename,$id) = @_; |
my $found=0; |
|
|
return 0 if (-e "$filename.subscription"); |
|
|
my $hostname=$Apache::lonnet::hostname{$id}; |
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 %iphost=&Apache::lonnet::get_iphost(); |
my $hostids=$iphost{$reqhost}; |
my $hostids=$iphost{$reqhost}; |
Line 64 sub handler {
|
Line 76 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; |