File:  [LON-CAPA] / loncom / lonnet / perl / lonrep.pm
Revision 1.6: download - view: text, annotated - select for diffs
Thu Nov 29 18:55:24 2001 UTC (22 years, 6 months ago) by www
Branches: MAIN
CVS tags: version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, version_0_5_1, version_0_5, version_0_4, stable_2002_spring, stable_2002_july, stable_2002_april, conference_2003, STABLE, HEAD
GPL

    1: # The LearningOnline Network
    2: # Replication Manager
    3: #
    4: # $Id: lonrep.pm,v 1.6 2001/11/29 18:55:24 www Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # (Access Handler for File Transfers
   29: # (lonacc: Cookie Based Access Handler
   30: # 5/21/99,5/22,5/29,5/31,6/15 Gerd Kortemeyer)
   31: # 6/16,6/18 Gerd Kortemeyer)
   32: # 6/18,6/21,6/26,6/28,6/29,6/30,
   33: # 7/2,7/3,7/9,7/10,7/12,
   34: # 01/06,01/14,10/5,
   35: # 06/14/01 Gerd Kortemeyer
   36: 
   37: package Apache::lonrep;
   38: 
   39: use strict;
   40: use Apache::Constants qw(:common :http);
   41: use Apache::lonnet();
   42: use Apache::File();
   43: use CGI::Cookie();
   44: 
   45: sub handler {
   46:     my $r = shift;
   47:     if (-e $r->finfo) {
   48:       return OK;
   49:     } else {
   50:       my $filename=$r->filename.$r->path_info;
   51:       if ($filename=~/\/$/) { return OK; }
   52:       if (-e "$filename.in.transfer") {
   53: 	sleep 10;
   54:         $r->filename($filename);
   55:         if (-e $r->finfo) {
   56: 	   return OK;
   57:         } else {
   58: 	   $r->log_reason("Waiting for file transfer timed out",$filename);
   59: 	   return HTTP_SERVICE_UNAVAILABLE;
   60:         }
   61:       } else {
   62:           my $response=Apache::lonnet::repcopy($filename);
   63:           if ($response==OK) {
   64: 	      $r->filename($filename);
   65:               return OK;
   66:           }
   67:           my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
   68:           my $lonid=$cookies{'lonID'};
   69:           if ($lonid) {
   70: 	     $r->log_reason('Replication failed for '.$lonid->value);
   71:              return $response;
   72: 	  } else {
   73: 	     $r->log_reason('Replication failed for unknown user'); 
   74:              return FORBIDDEN;
   75:           } 
   76:       }
   77:     }
   78: }
   79: 
   80: 1;
   81: __END__
   82: 
   83: 
   84: 
   85: 
   86: 
   87: 
   88: 
   89: 

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