version 1.2, 2002/08/08 13:45:21
|
version 1.10, 2006/01/16 19:27:09
|
Line 32 use strict;
|
Line 32 use strict;
|
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet(); |
use Apache::lonnet(); |
use Apache::File(); |
use Apache::File(); |
|
use Apache::loncommon; |
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 { |
sub handler { |
my $r = shift; |
my $r = shift; |
unless ($r->uri=~/^\/uploaded\//) { return DECLINED; } |
if ($r->uri=~m|^(/raw)?/uploaded/|) { |
my ($dum1,$dum2,$udom,$uname,$ufile)=split(/\//,$r->uri); |
my $fn = $r->uri(); |
$ufile=~s/^[\~\.]+//; |
$fn=~s/^\/raw//; |
$r->filename(&propath($udom,$uname).'/userfiles/'.$ufile); |
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(&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 |
|
# through SCRIPT_FILENAME |
|
$fn=~s|^/~(\w+)|/home/$1/public_html|; |
|
$r->filename($fn); |
|
} else { return DECLINED; } |
|
return OK; |
} |
} |
|
|
1; |
1; |