Diff for /loncom/lonnet/perl/lonuploadrep.pm between versions 1.5 and 1.11

version 1.5, 2005/03/02 22:26:36 version 1.11, 2009/02/13 17:20:35
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # Uploaded File Replication Manager  # Uploaded File Replication Manager
 #  #
   # $Id$
   #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
Line 28  package Apache::lonuploadrep; Line 30  package Apache::lonuploadrep;
   
 use strict;  use strict;
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonnet();  use Apache::lonrep();
 use CGI::Cookie();  use Apache::lonnet;
   use LONCAPA();
   
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     if ($r->uri =~m|^/*uploaded/(\w+)/(\w+)/(.+)$|) {      if ($r->uri =~m{^/*uploaded/($LONCAPA::domain_re)/($LONCAPA::name_re)/(.+)$}) {
         my $chome=&Apache::lonnet::homeserver($2,$1);          my $chome=&Apache::lonnet::homeserver($2,$1);
  my @ids=&Apache::lonnet::current_machine_ids();   my @ids=&Apache::lonnet::current_machine_ids();
  foreach my $id (@ids) { if ($id eq $chome) { return OK; } }   foreach my $id (@ids) { if ($id eq $chome) { return OK; } }
Line 46  sub handler { Line 49  sub handler {
             } elsif ( ($info > 0) && ($info =~ /\d+/) )  {              } elsif ( ($info > 0) && ($info =~ /\d+/) )  {
                 my @statinfo = stat($filename);                   my @statinfo = stat($filename); 
                 if ($statinfo[9] >= $info ) {                  if ($statinfo[9] >= $info ) {
                     $r->filename($filename);                      &Apache::lonrep::update_filename($r,$filename);
                     return OK;                      return OK;
                 }                  }
             }              }
         }          }
         my $response=&Apache::lonnet::repcopy_userfile($r->uri);          my $response=&Apache::lonnet::repcopy_userfile($r->uri);
         if ($response eq 'OK') {          if ($response eq 'ok') {
             $r->filename($filename);      &Apache::lonrep::update_filename($r,$filename);
             return OK;              return OK;
         }          }
     }      }
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));      my $handle = &Apache::lonnet::check_for_valid_session($r);
     my $lonid=$cookies{'lonID'};      if ($handle) {
     if ($lonid) {          $r->log_reason('Copying failed in lonuploadrep for '.$handle);
         $r->log_reason('Copying failed in lonuploadrep for '.$lonid->value);  
         return HTTP_NOT_FOUND;          return HTTP_NOT_FOUND;
     } else {      } else {
         $r->log_reason('Copying failed in lonuploadrep for unknown user');           $r->log_reason('Copying failed in lonuploadrep for unknown user'); 

Removed from v.1.5  
changed lines
  Added in v.1.11


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