version 1.258, 2002/07/31 13:50:38
|
version 1.259, 2002/08/01 15:26:23
|
Line 712 sub ssi {
|
Line 712 sub ssi {
|
|
|
sub tokenwrapper { |
sub tokenwrapper { |
my $uri=shift; |
my $uri=shift; |
my $token=&reply('tmpput:'.&escape($uri),$perlvar{'lonHostID'}); |
$uri=~s/^http\:\/\/([^\/]+)//; |
return $uri.(($uri=~/\?/)?'&':'?'). |
$uri=~s/^\///; |
'token='.$token.'&server='.$perlvar{'lonHostID'}; |
$ENV{'user.environment'}=~/\/([^\/]+)\.id/; |
|
my $token=$1; |
|
if ($uri=~/^uploaded\/([^\/]+)\/([^\/]+)\/([^\/]+)(\?\.*)*$/) { |
|
&appenv('userfile.'.$1.'/'.$2.'/'.$3 => $ENV{'request.course.id'}); |
|
return 'http://'.$hostname{ &homeserver($2,$1)}.'/'.$uri. |
|
(($uri=~/\?/)?'&':'?').'token='.$token; |
|
} else { |
|
return '/adm/notfound.html'; |
|
} |
} |
} |
|
|
# --------------- Take an uploaded file and put it into the userfiles directory |
# --------------- Take an uploaded file and put it into the userfiles directory |
# input: name of form element |
# input: name of form element, coursedoc=1 means this is for the course |
# output: url of file in userspace |
# output: url of file in userspace |
|
|
sub userfileupload { |
sub userfileupload { |
my $formname=shift; |
my ($formname,$coursedoc)=@_; |
my $fname=$ENV{'form.'.$formname.'.filename'}; |
my $fname=$ENV{'form.'.$formname.'.filename'}; |
$fname=~s/\\/\//g; |
$fname=~s/\\/\//g; |
$fname=~s/^.*\/([^\/]+)$/$1/; |
$fname=~s/^.*\/([^\/]+)$/$1/; |
unless ($fname) { return 'error: no uploaded file'; } |
unless ($fname) { return 'error: no uploaded file'; } |
chop($ENV{'form.'.$formname}); |
chop($ENV{'form.'.$formname}); |
# Create the directory if not present |
# Create the directory if not present |
my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
my $docuname=''; |
|
my $docudom=''; |
|
my $docuhome=''; |
|
if ($coursedoc) { |
|
$docuname=$ENV{'course.'.$ENV{'request.course.id'}.'.num'}; |
|
$docudom=$ENV{'course.'.$ENV{'request.course.id'}.'.domain'}; |
|
$docuhome=$ENV{'course.'.$ENV{'request.course.id'}.'.home'}; |
|
} else { |
|
$docuname=$ENV{'user.name'}; |
|
$docudom=$ENV{'user.domain'}; |
|
$docuhome=$ENV{'user.home'}; |
|
} |
|
my $path=$docudom.'/'.$docuname.'/'; |
my $filepath=$perlvar{'lonDocRoot'}; |
my $filepath=$perlvar{'lonDocRoot'}; |
my @parts=split(/\//,$filepath.$path); |
my @parts=split(/\//,$filepath.'/userfiles/'.$path); |
my $count; |
my $count; |
for ($count=4;$count<=$#parts;$count++) { |
for ($count=4;$count<=$#parts;$count++) { |
$filepath.="/$parts[$count]"; |
$filepath.="/$parts[$count]"; |
Line 744 sub userfileupload {
|
Line 764 sub userfileupload {
|
my $fh=Apache::File->new('>'.$filepath.'/'.$fname); |
my $fh=Apache::File->new('>'.$filepath.'/'.$fname); |
print $fh $ENV{'form.'.$formname}; |
print $fh $ENV{'form.'.$formname}; |
} |
} |
|
# Notify homeserver to grep it |
|
# |
|
# FIXME - this still needs to happen |
|
# |
# Return the URL to it |
# Return the URL to it |
return 'http://'.$ENV{'SERVER_NAME'}.$path.$fname; |
return '/uploaded/'.$path.$fname; |
} |
} |
|
|
# ------------------------------------------------------------------------- Log |
# ------------------------------------------------------------------------- Log |