version 1.258, 2002/07/31 13:50:38
|
version 1.262, 2002/08/07 20:40:57
|
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 |
Line 1556 sub allowed {
|
Line 1580 sub allowed {
|
return ''; |
return ''; |
} |
} |
} |
} |
|
if ($ENV{'request.role'}=~ /li\.\//) { |
|
# Library role, so allow browsing of resources in this domain. |
|
return 'F'; |
|
} |
} |
} |
|
|
my $thisallowed=''; |
my $thisallowed=''; |
Line 2679 sub metadata {
|
Line 2707 sub metadata {
|
# the next is the end of "start tag" |
# the next is the end of "start tag" |
} |
} |
} |
} |
|
&metadata_generate_part0(\%metathesekeys,\%metacache,$uri); |
$metacache{$uri.':keys'}=join(',',keys %metathesekeys); |
$metacache{$uri.':keys'}=join(',',keys %metathesekeys); |
$metacache{$uri.':cachedtimestamp'}=time; |
$metacache{$uri.':cachedtimestamp'}=time; |
# this is the end of "was not already recently cached |
# this is the end of "was not already recently cached |
Line 2686 sub metadata {
|
Line 2715 sub metadata {
|
return $metacache{$uri.':'.$what}; |
return $metacache{$uri.':'.$what}; |
} |
} |
|
|
|
sub metadata_generate_part0 { |
|
my ($metadata,$metacache,$uri) = @_; |
|
my %allnames; |
|
foreach my $metakey (sort keys %$metadata) { |
|
if ($metakey=~/^parameter\_(.*)/) { |
|
my $part=$$metacache{$uri.':'.$metakey.'.part'}; |
|
my $name=$$metacache{$uri.':'.$metakey.'.name'}; |
|
if (! exists($$metadata{'parameter_0_'.$name})) { |
|
$allnames{$name}=$part; |
|
} |
|
} |
|
} |
|
foreach my $name (keys(%allnames)) { |
|
$$metadata{"parameter_0_$name"}=1; |
|
my $key="$uri:parameter_0_$name"; |
|
$$metacache{"$key.part"}='0'; |
|
$$metacache{"$key.name"}=$name; |
|
$$metacache{"$key.type"}=$$metacache{$uri.':parameter_'. |
|
$allnames{$name}.'_'.$name. |
|
'.type'}; |
|
my $olddis=$$metacache{$uri.':parameter_'.$allnames{$name}.'_'.$name. |
|
'.display'}; |
|
my $expr='\\[Part: '.$allnames{$name}.'\\]'; |
|
$olddis=~s/$expr/\[Part: 0\]/; |
|
$$metacache{"$key.display"}=$olddis; |
|
} |
|
} |
|
|
# ------------------------------------------------- Update symbolic store links |
# ------------------------------------------------- Update symbolic store links |
|
|
sub symblist { |
sub symblist { |
Line 2894 sub ireceipt {
|
Line 2951 sub ireceipt {
|
} |
} |
|
|
sub receipt { |
sub receipt { |
return &ireceipt($ENV{'user.name'},$ENV{'user.domain'}, |
my ($symb,$courseid,$domain,$name) = &Apache::lonxml::whichuser(); |
$ENV{'request.course.id'},&symbread()); |
return &ireceipt($name,$domain,$courseid,$symb); |
} |
} |
|
|
# ------------------------------------------------------------ Serves up a file |
# ------------------------------------------------------------ Serves up a file |
# returns either the contents of the file or a -1 |
# returns either the contents of the file or a -1 |
sub getfile { |
sub getfile { |