--- loncom/lontrans.pm 2002/08/02 14:45:04 1.1 +++ loncom/lontrans.pm 2002/08/08 13:45:21 1.2 @@ -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.2 2002/08/08 13:45:21 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -33,9 +33,23 @@ use Apache::Constants qw(:common :remote 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; +} + + sub handler { my $r = shift; - return DECLINED; + unless ($r->uri=~/^\/uploaded\//) { return DECLINED; } + my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri); + $ufile=~s/^[\~\.]+//; + $r->filename(&propath($udom,$uname).'/userfiles/'.$ufile); } 1;