version 1.244, 2002/06/24 20:25:44
|
version 1.255, 2002/07/30 19:57:40
|
Line 80 use vars
|
Line 80 use vars
|
qw(%perlvar %hostname %homecache %badServerCache %hostip %spareid %hostdom |
qw(%perlvar %hostname %homecache %badServerCache %hostip %spareid %hostdom |
%libserv %pr %prp %metacache %packagetab |
%libserv %pr %prp %metacache %packagetab |
%courselogs %accesshash $processmarker $dumpcount |
%courselogs %accesshash $processmarker $dumpcount |
%coursedombuf %coursehombuf %courseresdatacache); |
%coursedombuf %coursehombuf %courseresdatacache %domaindescription); |
use IO::Socket; |
use IO::Socket; |
use GDBM_File; |
use GDBM_File; |
use Apache::Constants qw(:common :http); |
use Apache::Constants qw(:common :http); |
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 1737 sub allowed {
|
Line 1747 sub allowed {
|
} |
} |
} |
} |
|
|
# Restricted by state? |
# Restricted by state or randomout? |
|
|
if ($thisallowed=~/X/) { |
if ($thisallowed=~/X/) { |
|
if ($ENV{'acc.randomout'}) { |
|
my $symb=&symbread($uri,1); |
|
if (($symb) && ($ENV{'acc.randomout'}=~/\&$symb\&/)) { |
|
return ''; |
|
} |
|
} |
if (&condval($statecond)) { |
if (&condval($statecond)) { |
return '2'; |
return '2'; |
} else { |
} else { |
Line 2160 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 2265 sub courseresdata {
|
Line 2304 sub courseresdata {
|
my ($coursenum,$coursedomain,@which)=@_; |
my ($coursenum,$coursedomain,@which)=@_; |
my $coursehom=&homeserver($coursenum,$coursedomain); |
my $coursehom=&homeserver($coursenum,$coursedomain); |
my $hashid=$coursenum.':'.$coursedomain; |
my $hashid=$coursenum.':'.$coursedomain; |
unless (defined($courseresdatacache{$hashid.'.time'})) { |
my $dodump=0; |
unless (time-$courseresdatacache{$hashid.'.time'}<300) { |
if (!defined($courseresdatacache{$hashid.'.time'})) { |
my $coursehom=&homeserver($coursenum,$coursedomain); |
$dodump=1; |
if ($coursehom) { |
} else { |
my $dumpreply=&reply('dump:'.$coursedomain.':'.$coursenum. |
if (time-$courseresdatacache{$hashid.'.time'}>300) { $dodump=1; } |
':resourcedata:.',$coursehom); |
|
unless ($dumpreply=~/^error\:/) { |
|
$courseresdatacache{$hashid.'.time'}=time; |
|
$courseresdatacache{$hashid}=$dumpreply; |
|
} |
|
} |
|
} |
|
} |
} |
my @pairs=split(/\&/,$courseresdatacache{$hashid}); |
if ($dodump) { |
my %returnhash=(); |
my %dumpreply=&dump('resourcedata',$coursedomain,$coursenum); |
foreach (@pairs) { |
my ($tmp) = keys(%dumpreply); |
my ($key,$value)=split(/=/,$_); |
if ($tmp !~ /^(con_lost|error|no_such_host)/i) { |
$returnhash{unescape($key)}=unescape($value); |
$courseresdatacache{$hashid.'.time'}=time; |
} |
$courseresdatacache{$hashid}=\%dumpreply; |
my $item; |
} |
foreach $item (@which) { |
} |
if ($returnhash{$item}) { return $returnhash{$item}; } |
foreach my $item (@which) { |
} |
if ($courseresdatacache{$hashid}->{$item}) { |
return ''; |
return $courseresdatacache{$hashid}->{$item}; |
|
} |
|
} |
|
return ''; |
} |
} |
|
|
# --------------------------------------------------------- Value of a Variable |
# --------------------------------------------------------- Value of a Variable |
Line 2393 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 2695 sub symbclean {
|
Line 2730 sub symbclean {
|
# ------------------------------------------------------ Return symb list entry |
# ------------------------------------------------------ Return symb list entry |
|
|
sub symbread { |
sub symbread { |
my $thisfn=shift; |
my ($thisfn,$donotrecurse)=@_; |
# no filename provided? try from environment |
# no filename provided? try from environment |
unless ($thisfn) { |
unless ($thisfn) { |
if ($ENV{'request.symb'}) { return &symbclean($ENV{'request.symb'}); } |
if ($ENV{'request.symb'}) { return &symbclean($ENV{'request.symb'}); } |
Line 2744 sub symbread {
|
Line 2779 sub symbread {
|
# ----------------------------------------------- There is only one possibility |
# ----------------------------------------------- There is only one possibility |
my ($mapid,$resid)=split(/\./,$ids); |
my ($mapid,$resid)=split(/\./,$ids); |
$syval=declutter($bighash{'map_id_'.$mapid}).'___'.$resid; |
$syval=declutter($bighash{'map_id_'.$mapid}).'___'.$resid; |
} else { |
} elsif (!$donotrecurse) { |
# ------------------------------------------ There is more than one possibility |
# ------------------------------------------ There is more than one possibility |
my $realpossible=0; |
my $realpossible=0; |
foreach (@possibilities) { |
foreach (@possibilities) { |
Line 2759 sub symbread {
|
Line 2794 sub symbread {
|
} |
} |
} |
} |
if ($realpossible!=1) { $syval=''; } |
if ($realpossible!=1) { $syval=''; } |
|
} else { |
|
$syval=''; |
} |
} |
} |
} |
untie(%bighash) |
untie(%bighash) |
Line 2943 BEGIN {
|
Line 2980 BEGIN {
|
|
|
while (my $configline=<$config>) { |
while (my $configline=<$config>) { |
chomp($configline); |
chomp($configline); |
my ($id,$domain,$role,$name,$ip)=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 ($role eq 'library') { $libserv{$id}=$name; } |
$hostip{$id}=$ip; |
|
if ($domdescr) { $domaindescription{$domain}=$domdescr; } |
|
if ($role eq 'library') { $libserv{$id}=$name; } |
|
} else { |
|
if ($configline) { |
|
&logthis("Skipping hosts.tab line -$configline-"); |
|
} |
|
} |
} |
} |
} |
} |
|
|