version 1.250, 2002/07/04 15:47:18
|
version 1.256, 2002/07/30 19:59:32
|
Line 708 sub ssi {
|
Line 708 sub ssi {
|
return $response->content; |
return $response->content; |
} |
} |
|
|
|
# ------- Add a token to a remote URI's query string to vouch for access rights |
|
|
|
sub tokenwrapper { |
|
my $uri=shift; |
|
my $token=&reply('tmpput:'.&escape($uri),$perlvar{'lonHostID'}); |
|
return $uri.(($uri=~/\?/)?'&':'?'). |
|
'token='.$token.'&server='.$perlvar{'lonHostID'}; |
|
} |
|
|
|
|
# ------------------------------------------------------------------------- Log |
# ------------------------------------------------------------------------- Log |
|
|
sub log { |
sub log { |
Line 1033 sub tmpreset {
|
Line 1043 sub tmpreset {
|
my %hash; |
my %hash; |
if (tie(%hash,'GDBM_File', |
if (tie(%hash,'GDBM_File', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
&GDBM_WRCREAT,0640)) { |
&GDBM_WRCREAT(),0640)) { |
foreach my $key (keys %hash) { |
foreach my $key (keys %hash) { |
if ($key=~ /:$symb/) { |
if ($key=~ /:$symb/) { |
delete($hash{$key}); |
delete($hash{$key}); |
Line 1069 sub tmpstore {
|
Line 1079 sub tmpstore {
|
my $path=$perlvar{'lonDaemons'}.'/tmp'; |
my $path=$perlvar{'lonDaemons'}.'/tmp'; |
if (tie(%hash,'GDBM_File', |
if (tie(%hash,'GDBM_File', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
&GDBM_WRCREAT,0640)) { |
&GDBM_WRCREAT(),0640)) { |
$hash{"version:$symb"}++; |
$hash{"version:$symb"}++; |
my $version=$hash{"version:$symb"}; |
my $version=$hash{"version:$symb"}; |
my $allkeys=''; |
my $allkeys=''; |
Line 1113 sub tmprestore {
|
Line 1123 sub tmprestore {
|
my $path=$perlvar{'lonDaemons'}.'/tmp'; |
my $path=$perlvar{'lonDaemons'}.'/tmp'; |
if (tie(%hash,'GDBM_File', |
if (tie(%hash,'GDBM_File', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
$path.'/tmpstore_'.$stuname.'_'.$domain.'_'.$namespace.'.db', |
&GDBM_READER,0640)) { |
&GDBM_READER(),0640)) { |
my $version=$hash{"version:$symb"}; |
my $version=$hash{"version:$symb"}; |
$returnhash{'version'}=$version; |
$returnhash{'version'}=$version; |
my $scope; |
my $scope; |
Line 2166 sub revokecustomrole {
|
Line 2176 sub revokecustomrole {
|
# ------------------------------------------------------------ Directory lister |
# ------------------------------------------------------------ Directory lister |
|
|
sub dirlist { |
sub dirlist { |
my $uri=shift; |
my ($uri,$userdomain,$username,$alternateDirectoryRoot)=@_; |
|
|
$uri=~s/^\///; |
$uri=~s/^\///; |
$uri=~s/\/$//; |
$uri=~s/\/$//; |
my ($res,$udom,$uname,@rest)=split(/\//,$uri); |
my ($udom, $uname); |
if ($udom) { |
(undef,$udom,$uname)=split(/\//,$uri); |
if ($uname) { |
if(defined($userdomain)) { |
my $listing=reply('ls:'.$perlvar{'lonDocRoot'}.'/'.$uri, |
$udom = $userdomain; |
homeserver($uname,$udom)); |
} |
return split(/:/,$listing); |
if(defined($username)) { |
} else { |
$uname = $username; |
my $tryserver; |
} |
my %allusers=(); |
|
foreach $tryserver (keys %libserv) { |
my $dirRoot = $perlvar{'lonDocRoot'}; |
if ($hostdom{$tryserver} eq $udom) { |
if(defined($alternateDirectoryRoot)) { |
my $listing=reply('ls:'.$perlvar{'lonDocRoot'}.'/res/'.$udom, |
$dirRoot = $alternateDirectoryRoot; |
$tryserver); |
$dirRoot =~ s/\/$//; |
if (($listing ne 'no_such_dir') && ($listing ne 'empty') |
} |
&& ($listing ne 'con_lost')) { |
|
foreach (split(/:/,$listing)) { |
if($udom) { |
my ($entry,@stat)=split(/&/,$_); |
if($uname) { |
$allusers{$entry}=1; |
my $listing=reply('ls:'.$dirRoot.'/'.$uri, |
|
homeserver($uname,$udom)); |
|
return split(/:/,$listing); |
|
} elsif(!defined($alternateDirectoryRoot)) { |
|
my $tryserver; |
|
my %allusers=(); |
|
foreach $tryserver (keys %libserv) { |
|
if($hostdom{$tryserver} eq $udom) { |
|
my $listing=reply('ls:'.$perlvar{'lonDocRoot'}.'/res/'. |
|
$udom, $tryserver); |
|
if (($listing ne 'no_such_dir') && ($listing ne 'empty') |
|
&& ($listing ne 'con_lost')) { |
|
foreach (split(/:/,$listing)) { |
|
my ($entry,@stat)=split(/&/,$_); |
|
$allusers{$entry}=1; |
|
} |
|
} |
} |
} |
} |
} |
} |
my $alluserstr=''; |
} |
foreach (sort keys %allusers) { |
my $alluserstr=''; |
$alluserstr.=$_.'&user:'; |
foreach (sort keys %allusers) { |
} |
$alluserstr.=$_.'&user:'; |
$alluserstr=~s/:$//; |
} |
return split(/:/,$alluserstr); |
$alluserstr=~s/:$//; |
} else { |
return split(/:/,$alluserstr); |
my @emptyResults = (); |
} |
push(@emptyResults, 'missing user name'); |
} else { |
return split(':',@emptyResults); |
my $tryserver; |
} |
my %alldom=(); |
} elsif(!defined($alternateDirectoryRoot)) { |
foreach $tryserver (keys %libserv) { |
my $tryserver; |
$alldom{$hostdom{$tryserver}}=1; |
my %alldom=(); |
} |
foreach $tryserver (keys %libserv) { |
my $alldomstr=''; |
$alldom{$hostdom{$tryserver}}=1; |
foreach (sort keys %alldom) { |
} |
$alldomstr.=$perlvar{'lonDocRoot'}.'/res/'.$_.'&domain:'; |
my $alldomstr=''; |
} |
foreach (sort keys %alldom) { |
$alldomstr=~s/:$//; |
$alldomstr.=$perlvar{'lonDocRoot'}.'/res/'.$_.'&domain:'; |
return split(/:/,$alldomstr); |
} |
} |
$alldomstr=~s/:$//; |
|
return split(/:/,$alldomstr); |
|
} else { |
|
my @emptyResults = (); |
|
push(@emptyResults, 'missing domain'); |
|
return split(':',@emptyResults); |
|
} |
} |
} |
|
|
# -------------------------------------------------------- Value of a Condition |
# -------------------------------------------------------- Value of a Condition |
Line 2278 sub courseresdata {
|
Line 2311 sub courseresdata {
|
if (time-$courseresdatacache{$hashid.'.time'}>300) { $dodump=1; } |
if (time-$courseresdatacache{$hashid.'.time'}>300) { $dodump=1; } |
} |
} |
if ($dodump) { |
if ($dodump) { |
my $coursehom=&homeserver($coursenum,$coursedomain); |
my %dumpreply=&dump('resourcedata',$coursedomain,$coursenum); |
if ($coursehom) { |
my ($tmp) = keys(%dumpreply); |
my $dumpreply=&reply('dump:'.$coursedomain.':'.$coursenum. |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
':resourcedata:.',$coursehom); |
$courseresdatacache{$hashid.'.time'}=time; |
if ($dumpreply!~/^error\:/) { |
$courseresdatacache{$hashid}=\%dumpreply; |
$courseresdatacache{$hashid.'.time'}=time; |
|
$courseresdatacache{$hashid}=$dumpreply; |
|
} |
|
} |
} |
} |
} |
my @pairs=split(/\&/,$courseresdatacache{$hashid}); |
foreach my $item (@which) { |
my %returnhash=(); |
if ($courseresdatacache{$hashid}->{$item}) { |
foreach (@pairs) { |
return $courseresdatacache{$hashid}->{$item}; |
my ($key,$value)=split(/=/,$_); |
} |
$returnhash{unescape($key)}=unescape($value); |
|
} |
|
my $item; |
|
foreach $item (@which) { |
|
if ($returnhash{$item}) { return $returnhash{$item}; } |
|
} |
} |
return ''; |
return ''; |
} |
} |
Line 2403 sub EXT {
|
Line 2428 sub EXT {
|
my $section; |
my $section; |
if (($ENV{'user.name'} eq $uname) && |
if (($ENV{'user.name'} eq $uname) && |
($ENV{'user.domain'} eq $udom)) { |
($ENV{'user.domain'} eq $udom)) { |
$section={'request.course.sec'}; |
$section=$ENV{'request.course.sec'}; |
} else { |
} else { |
$section=&usection($udom,$uname,$courseid); |
$section=&usection($udom,$uname,$courseid); |
} |
} |
Line 2452 sub EXT {
|
Line 2477 sub EXT {
|
my $thisparm=''; |
my $thisparm=''; |
if (tie(%parmhash,'GDBM_File', |
if (tie(%parmhash,'GDBM_File', |
$ENV{'request.course.fn'}.'_parms.db', |
$ENV{'request.course.fn'}.'_parms.db', |
&GDBM_READER,0640)) { |
&GDBM_READER(),0640)) { |
$thisparm=$parmhash{$symbparm}; |
$thisparm=$parmhash{$symbparm}; |
untie(%parmhash); |
untie(%parmhash); |
} |
} |
Line 2639 sub symblist {
|
Line 2664 sub symblist {
|
my %hash; |
my %hash; |
if (($ENV{'request.course.fn'}) && (%newhash)) { |
if (($ENV{'request.course.fn'}) && (%newhash)) { |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', |
if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', |
&GDBM_WRCREAT,0640)) { |
&GDBM_WRCREAT(),0640)) { |
foreach (keys %newhash) { |
foreach (keys %newhash) { |
$hash{declutter($_)}=$mapname.'___'.$newhash{$_}; |
$hash{declutter($_)}=$mapname.'___'.$newhash{$_}; |
} |
} |
Line 2667 sub symbverify {
|
Line 2692 sub symbverify {
|
my %bighash; |
my %bighash; |
my $okay=0; |
my $okay=0; |
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
&GDBM_READER,0640)) { |
&GDBM_READER(),0640)) { |
my $ids=$bighash{'ids_/res/'.$thisfn}; |
my $ids=$bighash{'ids_/res/'.$thisfn}; |
unless ($ids) { |
unless ($ids) { |
$ids=$bighash{'ids_/'.$thisfn}; |
$ids=$bighash{'ids_/'.$thisfn}; |
Line 2721 sub symbread {
|
Line 2746 sub symbread {
|
my $syval=''; |
my $syval=''; |
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)) { |
$syval=$hash{$thisfn}; |
$syval=$hash{$thisfn}; |
untie(%hash); |
untie(%hash); |
} |
} |
Line 2737 sub symbread {
|
Line 2762 sub symbread {
|
} else { |
} else { |
# ------------------------------------------------------- Was not in symb table |
# ------------------------------------------------------- Was not in symb table |
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
if (tie(%bighash,'GDBM_File',$ENV{'request.course.fn'}.'.db', |
&GDBM_READER,0640)) { |
&GDBM_READER(),0640)) { |
# ---------------------------------------------- Get ID(s) for current resource |
# ---------------------------------------------- Get ID(s) for current resource |
my $ids=$bighash{'ids_/res/'.$thisfn}; |
my $ids=$bighash{'ids_/res/'.$thisfn}; |
unless ($ids) { |
unless ($ids) { |
Line 2956 BEGIN {
|
Line 2981 BEGIN {
|
while (my $configline=<$config>) { |
while (my $configline=<$config>) { |
chomp($configline); |
chomp($configline); |
my ($id,$domain,$role,$name,$ip,$domdescr)=split(/:/,$configline); |
my ($id,$domain,$role,$name,$ip,$domdescr)=split(/:/,$configline); |
$hostname{$id}=$name; |
if ($id && $domain && $role && $name && $ip) { |
$hostdom{$id}=$domain; |
$hostname{$id}=$name; |
$hostip{$id}=$ip; |
$hostdom{$id}=$domain; |
if ($domdescr) { |
$hostip{$id}=$ip; |
$domaindescription{$domain}=$domdescr; |
if ($domdescr) { $domaindescription{$domain}=$domdescr; } |
|
if ($role eq 'library') { $libserv{$id}=$name; } |
|
} else { |
|
if ($configline) { |
|
&logthis("Skipping hosts.tab line -$configline-"); |
|
} |
} |
} |
if ($role eq 'library') { $libserv{$id}=$name; } |
|
} |
} |
} |
} |
|
|