version 1.57, 2000/10/31 22:32:32
|
version 1.64, 2000/11/15 23:25:59
|
Line 42
|
Line 42
|
# directcondval(index) : reading condition value of single condition from |
# directcondval(index) : reading condition value of single condition from |
# state string |
# state string |
# condval(index) : value of condition index based on state |
# condval(index) : value of condition index based on state |
# varval(name) : value of a variable |
# EXT(name) : value of a variable |
# refreshstate() : refresh the state information string |
|
# symblist(map,hash) : Updates symbolic storage links |
# symblist(map,hash) : Updates symbolic storage links |
# symbread([filename]) : returns the data handle (filename optional) |
# symbread([filename]) : returns the data handle (filename optional) |
# rndseed() : returns a random seed |
# rndseed() : returns a random seed |
Line 68
|
Line 67
|
# 10/04 Gerd Kortemeyer |
# 10/04 Gerd Kortemeyer |
# 10/04 Guy Albertelli |
# 10/04 Guy Albertelli |
# 10/06,10/09,10/10,10/11,10/14,10/20,10/23,10/25,10/26,10/27,10/28,10/29, |
# 10/06,10/09,10/10,10/11,10/14,10/20,10/23,10/25,10/26,10/27,10/28,10/29, |
# 10/30,10/31 Gerd Kortemeyer |
# 10/30,10/31,11/2,11/14,11/15 Gerd Kortemeyer |
|
|
package Apache::lonnet; |
package Apache::lonnet; |
|
|
Line 370 sub subscribe {
|
Line 369 sub subscribe {
|
return 'not_found'; |
return 'not_found'; |
} |
} |
my $answer=reply("sub:$fname",$home); |
my $answer=reply("sub:$fname",$home); |
|
if (($answer eq 'con_lost') || ($answer eq 'rejected')) { |
|
$answer.=' by '.$home; |
|
} |
return $answer; |
return $answer; |
} |
} |
|
|
Line 381 sub repcopy {
|
Line 383 sub repcopy {
|
my $transname="$filename.in.transfer"; |
my $transname="$filename.in.transfer"; |
if ((-e $filename) || (-e $transname)) { return OK; } |
if ((-e $filename) || (-e $transname)) { return OK; } |
my $remoteurl=subscribe($filename); |
my $remoteurl=subscribe($filename); |
if ($remoteurl eq 'con_lost') { |
if ($remoteurl =~ /^con_lost by/) { |
&logthis("Subscribe returned con_lost: $filename"); |
&logthis("Subscribe returned $remoteurl: $filename"); |
return HTTP_SERVICE_UNAVAILABLE; |
return HTTP_SERVICE_UNAVAILABLE; |
} elsif ($remoteurl eq 'not_found') { |
} elsif ($remoteurl eq 'not_found') { |
&logthis("Subscribe returned not_found: $filename"); |
&logthis("Subscribe returned not_found: $filename"); |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} elsif ($remoteurl eq 'rejected') { |
} elsif ($remoteurl =~ /^rejected by/) { |
&logthis("Subscribe returned rejected: $filename"); |
&logthis("Subscribe returned $remoteurl: $filename"); |
return FORBIDDEN; |
return FORBIDDEN; |
} elsif ($remoteurl eq 'directory') { |
} elsif ($remoteurl eq 'directory') { |
return OK; |
return OK; |
Line 546 sub coursedescription {
|
Line 548 sub coursedescription {
|
$returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'. |
$returnhash{'fn'}=$perlvar{'lonDaemons'}.'/tmp/'. |
$ENV{'user.name'}.'_'.$cdomain.'_'.$cnum; |
$ENV{'user.name'}.'_'.$cdomain.'_'.$cnum; |
$envhash{'course.'.$normalid.'.last_cache'}=time; |
$envhash{'course.'.$normalid.'.last_cache'}=time; |
|
$envhash{'course.'.$normalid.'.home'}=$chome; |
|
$envhash{'course.'.$normalid.'.domain'}=$cdomain; |
|
$envhash{'course.'.$normalid.'.num'}=$cnum; |
&appenv(%envhash); |
&appenv(%envhash); |
return %returnhash; |
return %returnhash; |
} |
} |
Line 968 sub allowed {
|
Line 973 sub allowed {
|
return 'F'; |
return 'F'; |
} |
} |
|
|
# ---------------------------------------------------------- Refresh State Info |
|
|
|
sub refreshstate { |
|
} |
|
|
|
# ----------------------------------------------------------------- Define Role |
# ----------------------------------------------------------------- Define Role |
|
|
sub definerole { |
sub definerole { |
Line 1192 sub condval {
|
Line 1192 sub condval {
|
|
|
# --------------------------------------------------------- Value of a Variable |
# --------------------------------------------------------- Value of a Variable |
|
|
sub varval { |
sub EXT { |
my $varname=shift; |
my $varname=shift; |
my ($realm,$space,$qualifier,@therest)=split(/\./,$varname); |
my ($realm,$space,$qualifier,@therest)=split(/\./,$varname); |
my $rest; |
my $rest; |
Line 1256 sub varval {
|
Line 1256 sub varval {
|
return $ENV{'course.'.$ENV{'request.course.id'}.$section.'.'. |
return $ENV{'course.'.$ENV{'request.course.id'}.$section.'.'. |
$spacequalifierrest}; |
$spacequalifierrest}; |
} elsif ($realm eq 'resource') { |
} elsif ($realm eq 'resource') { |
# ----------------------------------------------------------- resource metadata |
if ($ENV{'request.course.id'}) { |
|
# ----------------------------------------------------- Cascading lookup scheme |
|
my $reslevel= |
|
$ENV{'request.course.id'}.'.'.&symbread().'.'.$spacequalifierrest; |
|
my $seclevel= |
|
$ENV{'request.course.id'}.'.'. |
|
$ENV{'request.course.sec'}.'.'.$spacequalifierrest; |
|
my $courselevel= |
|
$ENV{'request.course.id'}.'.'.$spacequalifierrest; |
|
|
|
# ----------------------------------------------------------- first, check user |
|
my %resourcedata=get('resourcedata',($reslevel,$seclevel,$courselevel)); |
|
if ($resourcedata{$reslevel}!~/^error\:/) { |
|
if ($resourcedata{$reslevel}) { return $resourcedata{$reslevel}; } |
|
if ($resourcedata{$seclevel}) { return $resourcedata{$seclevel}; } |
|
if ($resourcedata{$courselevel}) { return $resourcedata{$courselevel}; } |
|
} |
|
# -------------------------------------------------------- second, check course |
|
my $section=''; |
|
if ($ENV{'request.course.sec'}) { |
|
$section='_'.$ENV{'request.course.sec'}; |
|
} |
|
my $reply=&reply('get:'. |
|
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.domain'}.':'. |
|
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.num'}. |
|
':resourcedata:'. |
|
escape($reslevel).':'.escape($seclevel).':'.escape($courselevel), |
|
$ENV{'course.'.$ENV{'request.course.id'}.$section.'.home'}); |
|
if ($reply!~/^error\:/) { |
|
map { |
|
my ($name,$value)=split(/\=/,$_); |
|
$resourcedata{unescape($name)}=unescape($value); |
|
} split(/\&/,$reply); |
|
if ($resourcedata{$reslevel}) { return $resourcedata{$reslevel}; } |
|
if ($resourcedata{$seclevel}) { return $resourcedata{$seclevel}; } |
|
if ($resourcedata{$courselevel}) { return $resourcedata{$courselevel}; } |
|
} |
|
|
|
# ------------------------------------------------------ third, check map parms |
|
|
|
if ($ENV{'resource.parms.'.$reslevel}) { |
|
return $ENV{'resource.parms.'.$reslevel}; |
|
} |
|
} |
|
|
|
# --------------------------------------------- last, look in resource metadata |
my $uri=&declutter($ENV{'request.filename'}); |
my $uri=&declutter($ENV{'request.filename'}); |
my $filename=$perlvar{'lonDocRoot'}.'/res/'.$ENV.'.meta'; |
my $filename=$perlvar{'lonDocRoot'}.'/res/'.$ENV.'.meta'; |
if (-e $filename) { |
if (-e $filename) { |
Line 1268 sub varval {
|
Line 1313 sub varval {
|
if (join('',@content)=~ |
if (join('',@content)=~ |
/\<$space[^\>]*\>([^\<]*)\<\/$space\>/) { |
/\<$space[^\>]*\>([^\<]*)\<\/$space\>/) { |
return $1; |
return $1; |
} else { |
} |
return ''; |
} |
} |
|
} |
|
} elsif ($realm eq 'userdata') { |
|
my $uhome=&homeserver($qualifier,$space); |
|
# ----------------------------------------------- userdata.domain.name.resource |
|
# ---------------------------------------------------- Any other user namespace |
# ---------------------------------------------------- Any other user namespace |
} elsif ($realm eq 'environment') { |
} elsif ($realm eq 'environment') { |
# ----------------------------------------------------------------- environment |
# ----------------------------------------------------------------- environment |
Line 1288 sub varval {
|
Line 1328 sub varval {
|
return ''; |
return ''; |
} |
} |
|
|
|
# ---------------------------------------- Append resource parms to environment |
|
|
|
sub appendparms { |
|
my ($symb,$parms)=@_; |
|
my %storehash=(); |
|
my $prefix='resource.parms.'.$ENV{'request.course.id'}.'.'.$symb; |
|
map { |
|
my ($typename,$value)=split(/\=/,$_); |
|
my ($type,$name)=split(/\:/,$typename); |
|
$storehash{$prefix.'.'.unescape($name)}=unescape($value); |
|
$storehash{$prefix.'.'.unescape($name).'.type'}=unescape($type); |
|
} split(/\&/,$parms); |
|
&appenv(%storehash); |
|
} |
|
|
# ------------------------------------------------- Update symbolic store links |
# ------------------------------------------------- Update symbolic store links |
|
|
sub symblist { |
sub symblist { |
Line 1319 sub symbread {
|
Line 1374 sub symbread {
|
my %hash; |
my %hash; |
my %bighash; |
my %bighash; |
my $syval=''; |
my $syval=''; |
|
my $parms=''; |
if (($ENV{'request.course.fn'}) && ($thisfn)) { |
if (($ENV{'request.course.fn'}) && ($thisfn)) { |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', |
&GDBM_READER,0640)) { |
&GDBM_READER,0640)) { |
Line 1346 sub symbread {
|
Line 1402 sub symbread {
|
if ($#possibilities==0) { |
if ($#possibilities==0) { |
# ----------------------------------------------- There is only one possibility |
# ----------------------------------------------- There is only one possibility |
my ($mapid,$resid)=split(/\./,$ids); |
my ($mapid,$resid)=split(/\./,$ids); |
|
$parms=$bighash{'param_'.$ids}; |
$syval=declutter($bighash{'map_id_'.$mapid}).'___'.$resid; |
$syval=declutter($bighash{'map_id_'.$mapid}).'___'.$resid; |
} else { |
} else { |
# ------------------------------------------ There is more than one possibility |
# ------------------------------------------ There is more than one possibility |
Line 1356 sub symbread {
|
Line 1413 sub symbread {
|
my ($mapid,$resid)=split(/\./,$_); |
my ($mapid,$resid)=split(/\./,$_); |
if ($bighash{'map_type_'.$mapid} ne 'page') { |
if ($bighash{'map_type_'.$mapid} ne 'page') { |
$realpossible++; |
$realpossible++; |
|
$parms=$bighash{'param_'.$_}; |
$syval=declutter($bighash{'map_id_'.$mapid}). |
$syval=declutter($bighash{'map_id_'.$mapid}). |
'___'.$resid; |
'___'.$resid; |
} |
} |
Line 1367 sub symbread {
|
Line 1425 sub symbread {
|
untie(%bighash) |
untie(%bighash) |
} |
} |
} |
} |
if ($syval) { return $syval.'___'.$thisfn; } |
if ($syval) { |
|
if ($parms) { |
|
&appendparms($syval.'___'.$thisfn,$parms); |
|
} |
|
return $syval.'___'.$thisfn; |
|
} |
} |
} |
&appenv('request.ambiguous' => $thisfn); |
&appenv('request.ambiguous' => $thisfn); |
return ''; |
return ''; |
Line 1418 sub filelocation {
|
Line 1481 sub filelocation {
|
my ($dir,$file) = @_; |
my ($dir,$file) = @_; |
my $location; |
my $location; |
$file=~ s/^\s*(\S+)\s*$/$1/; ## strip off leading and trailing spaces |
$file=~ s/^\s*(\S+)\s*$/$1/; ## strip off leading and trailing spaces |
$file=~s/^$perlvar{'lonDocRoot'}//; |
if ($file=~m:^/~:) { # is a contruction space reference |
$file=~s:^/*res::; |
$location = $file; |
if ( !( $file =~ m:^/:) ) { |
$location =~ s:/~(.*?)/(.*):/home/$1/public_html/$2:; |
$location = $dir. '/'.$file; |
|
} else { |
} else { |
$location = '/home/httpd/html/res'.$file; |
$file=~s/^$perlvar{'lonDocRoot'}//; |
|
$file=~s:^/*res::; |
|
if ( !( $file =~ m:^/:) ) { |
|
$location = $dir. '/'.$file; |
|
} else { |
|
$location = '/home/httpd/html/res'.$file; |
|
} |
} |
} |
$location=~s://+:/:g; # remove duplicate / |
$location=~s://+:/:g; # remove duplicate / |
while ($location=~m:/\.\./:) {$location=~ s:/[^/]+/\.\./:/:g;} #remove dir/.. |
while ($location=~m:/\.\./:) {$location=~ s:/[^/]+/\.\./:/:g;} #remove dir/.. |