version 1.251, 2002/07/04 15:56:17
|
version 1.257, 2002/07/30 21:20:27
|
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'}; |
|
} |
|
|
|
# --------------- Take an uploaded file and put it into the userfiles directory |
|
# input: name of form element |
|
# output: url of file in userspace |
|
|
|
sub userfileupload { |
|
my $formname=shift; |
|
my $fname=$ENV{'form.'.$formname.'.filename'}; |
|
$fname=~s/\\/\//g; |
|
$fname=~s/^.*\/([^\/]+)$/$1/; |
|
unless ($fname) { return 'error: no uploaded file'; } |
|
chop($ENV{'form.'.$formname}); |
|
my $path='/userfiles/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/'; |
|
# |
|
# FIXME: actually save file |
|
# |
|
return 'http;//'.$ENV{'SERVER_NAME'}.$path.$fname; |
|
} |
|
|
# ------------------------------------------------------------------------- Log |
# ------------------------------------------------------------------------- Log |
|
|
sub log { |
sub log { |
Line 1033 sub tmpreset {
|
Line 1060 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 1096 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 1140 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 2193 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 2395 sub EXT {
|
Line 2445 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 2444 sub EXT {
|
Line 2494 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 2631 sub symblist {
|
Line 2681 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 2659 sub symbverify {
|
Line 2709 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 2713 sub symbread {
|
Line 2763 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 2729 sub symbread {
|
Line 2779 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 2948 BEGIN {
|
Line 2998 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; } |
|
} |
} |
} |
} |
|
|