--- loncom/lontrans.pm 2002/09/30 20:48:24 1.4 +++ loncom/lontrans.pm 2004/03/31 17:02:51 1.7 @@ -1,7 +1,7 @@ # The LearningOnline Network # URL translation for User Files # -# $Id: lontrans.pm,v 1.4 2002/09/30 20:48:24 matthew Exp $ +# $Id: lontrans.pm,v 1.7 2004/03/31 17:02:51 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -32,24 +32,22 @@ 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; +use LONCAPA::Configuration; sub handler { my $r = shift; - if ($r->uri=~m|^/uploaded/|) { - my (undef,undef,$udom,$uname,$ufile)=split(/\//,$r->uri); - $ufile=~s/^[\~\.]+//; - $r->filename(&propath($udom,$uname).'/userfiles/'.$ufile); + my $configvars = &LONCAPA::Configuration::read_conf('loncapa.conf'); + 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); + if ($chome eq $$configvars{'lonHostID'}) { + $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 +55,7 @@ sub handler { $fn=~s|^/~(\w+)|/home/$1/public_html|; $r->filename($fn); } else { return DECLINED; } + return OK; } 1;