Diff for /loncom/auth/lonracc.pm between versions 1.16 and 1.19

version 1.16, 2005/02/10 22:30:56 version 1.19, 2007/02/01 06:31:33
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;  
       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;

Removed from v.1.16  
changed lines
  Added in v.1.19


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>