--- loncom/lontrans.pm 2002/09/30 20:32:45 1.3 +++ loncom/lontrans.pm 2004/07/02 07:58:01 1.9 @@ -1,7 +1,7 @@ # The LearningOnline Network # URL translation for User Files # -# $Id: lontrans.pm,v 1.3 2002/09/30 20:32:45 albertel Exp $ +# $Id: lontrans.pm,v 1.9 2004/07/02 07:58:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,24 +32,23 @@ use strict; use Apache::Constants qw(:common :remotehost); use Apache::lonnet(); use Apache::File(); - -sub propath { - my ($udom,$uname)=@_; - $udom=~s/\W//g; - $uname=~s/\W//g; - my $subdir=$uname.'__'; - $subdir =~ s/(.)(.)(.).*/$1\/$2\/$3/; - my $proname="$Apache::lonnet::perlvar{'lonUsersDir'}/$udom/$subdir/$uname"; - return $proname; -} - +use Apache::loncommon; sub handler { my $r = shift; - if ($r->uri=~m|^/uploaded/|) { - my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri); - $ufile=~s/^[\~\.]+//; - $r->filename(&propath($udom,$uname).'/userfiles/'.$ufile); + if ($r->uri=~m|^(/raw)?/uploaded/|) { + my $fn = $r->uri(); + $fn=~s/^\/raw//; + my (undef,undef,$udom,$uname,@ufile)=split(/\//,$fn); + $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(&Apache::loncommon::propath($udom,$uname). + '/userfiles/'.(join('/',@ufile))); + } } elsif ($r->uri=~m|^/~|) { #internal authentication, needs fixup. my $fn = $r->uri(); # non users do not get the full path request @@ -57,6 +56,7 @@ sub handler { $fn=~s|^/~(\w+)|/home/$1/public_html|; $r->filename($fn); } else { return DECLINED; } + return OK; } 1; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.