--- loncom/lonnet/perl/lonnet.pm 2000/10/09 20:26:17 1.40 +++ loncom/lonnet/perl/lonnet.pm 2000/10/12 02:11:16 1.45 @@ -42,7 +42,7 @@ # varval(name) : value of a variable # refreshstate() : refresh the state information string # symblist(map,hash) : Updates symbolic storage links -# symbread(filename) : returns the data handle +# symbread([filename]) : returns the data handle (filename optional) # rndseed() : returns a random seed # getfile(filename) : returns the contents of filename, or a -1 if it can't # be found, replicates and subscribes to the file @@ -62,7 +62,7 @@ # 08/22,08/28,08/31,09/01,09/02,09/04,09/05,09/25,09/28,09/30 Gerd Kortemeyer # 10/04 Gerd Kortemeyer # 10/04 Guy Albertelli -# 10/06,10/09 Gerd Kortemeyer +# 10/06,10/09,10/10,10/11 Gerd Kortemeyer package Apache::lonnet; @@ -431,7 +431,7 @@ sub log { sub store { my %storehash=@_; my $symb; - unless ($symb=escape(&symbread($ENV{'request.filename'}))) { return ''; } + unless ($symb=escape(&symbread())) { return ''; } my $namespace; unless ($namespace=$ENV{'request.course.id'}) { return ''; } my $namevalue=''; @@ -448,7 +448,7 @@ sub store { sub restore { my $symb; - unless ($symb=escape(&symbread($ENV{'request.filename'}))) { return ''; } + unless ($symb=escape(&symbread())) { return ''; } my $namespace; unless ($namespace=$ENV{'request.course.id'}) { return ''; } my $answer=reply( @@ -596,10 +596,11 @@ sub get { $ENV{'user.home'}); my @pairs=split(/\&/,$rep); my %returnhash=(); + my $i=0; map { - my ($key,$value)=split(/=/,$_); - $returnhash{unescape($key)}=unescape($value); - } @pairs; + $returnhash{$_}=unescape($pairs[$i]); + $i++; + } @storearr; return %returnhash; } @@ -657,10 +658,11 @@ sub eget { $ENV{'user.home'}); my @pairs=split(/\&/,$rep); my %returnhash=(); + my $i=0; map { - my ($key,$value)=split(/=/,$_); - $returnhash{unescape($key)}=unescape($value); - } @pairs; + $returnhash{$_}=unescape($pairs[$i]); + $i++; + } @storearr; return %returnhash; } @@ -759,7 +761,7 @@ sub allowed { # Restricted by state? if ($thisallowed=~/X/) { - if (&condval($uricond)>1) { + if (&condval($uricond)) { return '2'; } else { return ''; @@ -1027,11 +1029,15 @@ sub symblist { # ------------------------------------------------------ Return symb list entry sub symbread { - my $thisfn=declutter(shift); + my $thisfn=shift; + unless ($thisfn) { + $thisfn=$ENV{'request.filename'}; + } + $thisfn=declutter($thisfn); my %hash; my %bighash; my $syval=''; - if (($ENV{'request.course.fn'}) && ($ENV{'request.filename'})) { + if (($ENV{'request.course.fn'}) && ($thisfn)) { if (tie(%hash,'GDBM_File',$ENV{'request.course.fn'}.'_symb.db', &GDBM_READER,0640)) { $syval=$hash{$thisfn}; @@ -1041,6 +1047,7 @@ sub symbread { if ($syval) { unless ($syval=~/\_\d+$/) { unless ($ENV{'form.request.prefix'}=~/\.(\d+)\_$/) { + &appenv('request.ambiguous' => $thisfn); return ''; } $syval.=$1; @@ -1080,6 +1087,7 @@ sub symbread { } if ($syval) { return $syval.'___'.$thisfn; } } + &appenv('request.ambiguous' => $thisfn); return ''; } @@ -1099,7 +1107,7 @@ sub numval { sub rndseed { my $symb; - unless ($symb=&symbread($ENV{'request.filename'})) { return ''; } + unless ($symb=&symbread()) { return time; } my $symbchck=unpack("%32C*",$symb); my $symbseed=numval($symb)%$symbchck; my $namechck=unpack("%32C*",$ENV{'user.name'});