Annotation of loncom/lonnet/perl/lonrep.pm, revision 1.8
1.1 albertel 1: # The LearningOnline Network
2: # Replication Manager
1.6 www 3: #
1.8 ! raeburn 4: # $Id: lonrep.pm,v 1.7 2005/03/02 22:26:36 raeburn Exp $
1.6 www 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: #
1.1 albertel 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,
1.2 www 33: # 7/2,7/3,7/9,7/10,7/12,
1.5 www 34: # 01/06,01/14,10/5,
35: # 06/14/01 Gerd Kortemeyer
1.1 albertel 36:
37: package Apache::lonrep;
38:
39: use strict;
40: use Apache::Constants qw(:common :http);
41: use Apache::lonnet();
42: use Apache::File();
1.4 www 43: use CGI::Cookie();
1.1 albertel 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;
1.5 www 51: if ($filename=~/\/$/) { return OK; }
1.2 www 52: if (-e "$filename.in.transfer") {
1.1 albertel 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 {
1.3 www 62: my $response=Apache::lonnet::repcopy($filename);
1.8 ! raeburn 63: if ($response eq 'ok') {
1.3 www 64: $r->filename($filename);
1.4 www 65: return OK;
1.3 www 66: }
1.4 www 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: }
1.1 albertel 76: }
1.2 www 77: }
1.1 albertel 78: }
79:
80: 1;
81: __END__
82:
83:
84:
85:
86:
87:
88:
89:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>