--- loncom/lontrans.pm 2002/08/02 14:45:04 1.1 +++ loncom/lontrans.pm 2011/10/21 16:03:06 1.14 @@ -1,7 +1,7 @@ # The LearningOnline Network # URL translation for User Files # -# $Id: lontrans.pm,v 1.1 2002/08/02 14:45:04 www Exp $ +# $Id: lontrans.pm,v 1.14 2011/10/21 16:03:06 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,10 +32,28 @@ use strict; use Apache::Constants qw(:common :remotehost); use Apache::lonnet(); use Apache::File(); +use LONCAPA; + sub handler { my $r = shift; - return DECLINED; + # FIXME line remove when mod_perl fixes BUG#4948 + $r->notes->set('error-notes' => ''); + if ($r->uri=~m|^(/raw)?/uploaded/|) { + my $fn = $r->uri(); + $fn=~s/^\/raw//; + my (undef,undef,$udom,$uname,@ufile)=split(/\//,$fn); + if (@ufile) { $ufile[-1]=~s/^[\~\.]+//; } + my $chome=&Apache::lonnet::homeserver($uname,$udom); + my $allowed=0; + my @ids=&Apache::lonnet::current_machine_ids(); + foreach my $id (@ids) { if ($id eq $chome) { $allowed=1; } } + if ($allowed) { + $r->filename(&propath($udom,$uname). + '/userfiles/'.(join('/',@ufile))); + } + } else { return DECLINED; } + return OK; } 1;