--- loncom/lonnet/perl/lonnet.pm 2021/01/04 13:41:25 1.1172.2.118.2.14 +++ loncom/lonnet/perl/lonnet.pm 2020/05/04 15:07:10 1.1172.2.123 @@ -1,7 +1,7 @@ # The LearningOnline Network # TCP networking package # -# $Id: lonnet.pm,v 1.1172.2.118.2.14 2021/01/04 13:41:25 raeburn Exp $ +# $Id: lonnet.pm,v 1.1172.2.123 2020/05/04 15:07:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,13 +125,12 @@ our @EXPORT = qw(%env); $logid ++; my $now = time(); my $id=$now.'00000'.$$.'00000'.$logid; - my $ip = &get_requestor_ip(); my $logentry = { $id => { 'exe_uname' => $env{'user.name'}, 'exe_udom' => $env{'user.domain'}, 'exe_time' => $now, - 'exe_ip' => $ip, + 'exe_ip' => $ENV{'REMOTE_ADDR'}, 'delflag' => $delflag, 'logentry' => $storehash, 'uname' => $uname, @@ -1083,21 +1082,6 @@ sub check_for_balancer_cookie { return ($otherserver,$cookie); } -sub updatebalcookie { - my ($cookie,$balancer,$lastentry)=@_; - if ($cookie =~ /^($match_domain)\_($match_username)\_[a-f0-9]{32}$/) { - my ($udom,$uname) = ($1,$2); - my $uprimary_id = &domain($udom,'primary'); - my $uintdom = &internet_dom($uprimary_id); - my $intdom = &internet_dom($balancer); - my $serverhomedom = &host_domain($balancer); - if (($uintdom ne '') && ($uintdom eq $intdom)) { - return &reply('updatebalcookie:'.&escape($cookie).':'.&escape($lastentry),$balancer); - } - } - return; -} - sub delbalcookie { my ($cookie,$balancer) =@_; if ($cookie =~ /^($match_domain)\_($match_username)\_[a-f0-9]{32}$/) { @@ -1107,7 +1091,7 @@ sub delbalcookie { my $intdom = &internet_dom($balancer); my $serverhomedom = &host_domain($balancer); if (($uintdom ne '') && ($uintdom eq $intdom)) { - return &reply('delbalcookie:'.&escape($cookie),$balancer); + return &reply("delbalcookie:$cookie",$balancer); } } } @@ -1594,7 +1578,7 @@ sub check_loadbalancing { if ($domneedscache) { &do_cache_new('loadbalancing',$domneedscache,$is_balancer,$cachetime); } - if (($is_balancer) && ($caller ne 'switchserver')) { + if ($is_balancer) { my $lowest_load = 30000; if (ref($offloadto) eq 'HASH') { if (ref($offloadto->{'primary'}) eq 'ARRAY') { @@ -1634,9 +1618,9 @@ sub check_loadbalancing { } } } - } - if (($is_balancer) && (!$homeintdom)) { - undef($setcookie); + unless ($homeintdom) { + undef($setcookie); + } } return ($is_balancer,$otherserver,$setcookie); } @@ -1889,12 +1873,7 @@ sub get_dom { } } if ($udom && $uhome && ($uhome ne 'no_host')) { - my $rep; - if ($namespace =~ /^enc/) { - $rep=&reply("encrypt:egetdom:$udom:$namespace:$items",$uhome); - } else { - $rep=&reply("getdom:$udom:$namespace:$items",$uhome); - } + my $rep=&reply("getdom:$udom:$namespace:$items",$uhome); my %returnhash; if ($rep eq '' || $rep =~ /^error: 2 /) { return %returnhash; @@ -1938,11 +1917,7 @@ sub put_dom { $items.=&escape($item).'='.&freeze_escape($$storehash{$item}).'&'; } $items=~s/\&$//; - if ($namespace =~ /^enc/) { - return &reply("encrypt:putdom:$udom:$namespace:$items",$uhome); - } else { - return &reply("putdom:$udom:$namespace:$items",$uhome); - } + return &reply("putdom:$udom:$namespace:$items",$uhome); } else { &logthis("put_dom failed - no homeserver and/or domain"); } @@ -2559,22 +2534,6 @@ sub get_passwdconf { return %passwdconf; } -sub course_portal_url { - my ($cnum,$cdom) = @_; - my $chome = &homeserver($cnum,$cdom); - my $hostname = &hostname($chome); - my $protocol = $protocol{$chome}; - $protocol = 'http' if ($protocol ne 'https'); - my %domdefaults = &get_domain_defaults($cdom); - my $firsturl; - if ($domdefaults{'portal_def'}) { - $firsturl = $domdefaults{'portal_def'}; - } else { - $firsturl = $protocol.'://'.$hostname; - } - return $firsturl; -} - # --------------------------------------------------- Assign a key to a student sub assign_access_key { @@ -3110,27 +3069,6 @@ sub repcopy { } } -# ------------------------------------------------- Unsubscribe from a resource - -sub unsubscribe { - my ($fname) = @_; - my $answer; - if ($fname=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) { return $answer; } - $fname=~s/[\n\r]//g; - my $author=$fname; - $author=~s/\/home\/httpd\/html\/res\/([^\/]*)\/([^\/]*).*/$1\/$2/; - my ($udom,$uname)=split(/\//,$author); - my $home=homeserver($uname,$udom); - if ($home eq 'no_host') { - $answer = 'no_host'; - } elsif (grep { $_ eq $home } ¤t_machine_ids()) { - $answer = 'home'; - } else { - $answer = reply("unsub:$fname",$home); - } - return $answer; -} - # ------------------------------------------------ Get server side include body sub ssi_body { my ($filelink,%form)=@_; @@ -3289,18 +3227,12 @@ sub remove_stale_resfile { $stale = 1; } if ($stale) { - if (unlink($fname)) { - if ($uri!~/\.meta$/) { - if (-e $fname.'.meta') { - unlink($fname.'.meta'); - } - } - my $unsubresult = &unsubscribe($fname); - unless ($unsubresult eq 'ok') { - &logthis("no unsub of $fname from $homeserver, reason: $unsubresult"); - } - $removed = 1; + unlink($fname); + if ($uri!~/\.meta$/) { + unlink($fname.'.meta'); } + &reply("unsub:$fname",$homeserver); + $removed = 1; } } } @@ -3462,14 +3394,6 @@ sub can_edit_resource { $cfile = '/adm/wrapper'.$resurl; } } - } elsif ($resurl =~ m{^/adm/wrapper/adm/$cdom/$cnum/\d+/ext\.tool$}) { - $incourse = 1; - if ($env{'form.forceedit'}) { - $forceview = 1; - } else { - $forceedit = 1; - } - $cfile = $resurl; } elsif ($resurl =~ m{^/?adm/viewclasslist$}) { $incourse = 1; if ($env{'form.forceedit'}) { @@ -3494,14 +3418,6 @@ sub can_edit_resource { $forceedit = 1; } $cfile = $resurl; - } elsif (($resurl =~ m{^/adm/wrapper/adm/$cdom/$cnum/\d+/ext\.tool$}) && ($env{'form.folderpath'} =~ /^supplemental/)) { - $incourse = 1; - if ($env{'form.forceedit'}) { - $forceview = 1; - } else { - $forceedit = 1; - } - $cfile = $resurl; } elsif (($resurl eq '/adm/extresedit') && ($symb || $env{'form.folderpath'})) { $incourse = 1; $forceview = 1; @@ -3511,13 +3427,8 @@ sub can_edit_resource { $cfile = &clutter($res); } else { $cfile = $env{'form.suppurl'}; - my $escfile = &unescape($cfile); - if ($escfile =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) { - $cfile = '/adm/wrapper'.$escfile; - } else { - $escfile =~ s{^http://}{}; - $cfile = &escape("/adm/wrapper/ext/$escfile"); - } + $cfile =~ s{^http://}{}; + $cfile = '/adm/wrapper/ext/'.$cfile; } } elsif ($resurl =~ m{^/?adm/viewclasslist$}) { if ($env{'form.forceedit'}) { @@ -4734,11 +4645,7 @@ sub courseacclog { if ($formitem =~ /^HWFILE(?:SIZE|TOOBIG)/) { $what.=':'.$formitem.'='.$env{$key}; } elsif ($formitem !~ /^HWFILE(?:[^.]+)$/) { - if ($formitem eq 'proctorpassword') { - $what.=':'.$formitem.'=' . '*' x length($env{$key}); - } else { - $what.=':'.$formitem.'='.$env{$key}; - } + $what.=':'.$formitem.'='.$env{$key}; } } } @@ -5494,10 +5401,9 @@ my %cachedtimes=(); my $cachedtime=''; sub load_all_first_access { - my ($uname,$udom,$ignorecache)=@_; + my ($uname,$udom)=@_; if (($cachedkey eq $uname.':'.$udom) && - (abs($cachedtime-time)<5) && (!$env{'form.markaccess'}) && - (!$ignorecache)) { + (abs($cachedtime-time)<5) && (!$env{'form.markaccess'})) { return; } $cachedtime=time; @@ -5506,7 +5412,7 @@ sub load_all_first_access { } sub get_first_access { - my ($type,$argsymb,$argmap,$ignorecache)=@_; + my ($type,$argsymb,$argmap)=@_; my ($symb,$courseid,$udom,$uname)=&whichuser(); if ($argsymb) { $symb=$argsymb; } my ($map,$id,$res)=&decode_symb($symb); @@ -5518,7 +5424,7 @@ sub get_first_access { } else { $res=$symb; } - &load_all_first_access($uname,$udom,$ignorecache); + &load_all_first_access($uname,$udom); return $cachedtimes{"$courseid\0$res"}; } @@ -5570,14 +5476,13 @@ sub checkout { my ($symb,$tuname,$tudom,$tcrsid)=@_; my $now=time; my $lonhost=$perlvar{'lonHostID'}; - my $ip = &get_requestor_ip(); my $infostr=&escape( 'CHECKOUTTOKEN&'. $tuname.'&'. $tudom.'&'. $tcrsid.'&'. $symb.'&'. - $now.'&'.$ip); + $now.'&'.$ENV{'REMOTE_ADDR'}); my $token=&reply('tmpput:'.$infostr,$lonhost); if ($token=~/^error\:/) { &logthis("WARNING: ". @@ -5591,7 +5496,7 @@ sub checkout { my %infohash=('resource.0.outtoken' => $token, 'resource.0.checkouttime' => $now, - 'resource.0.outremote' => $ip); + 'resource.0.outremote' => $ENV{'REMOTE_ADDR'}); unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { return ''; @@ -5622,7 +5527,6 @@ sub checkin { $lonhost=~tr/A-Z/a-z/; my $dtoken=$ta.'_'.&hostname($lonhost).'_'.$tb; $dtoken=~s/\W/\_/g; - my $ip = &get_requestor_ip(); my ($dummy,$tuname,$tudom,$tcrsid,$symb,$chtim,$rmaddr)= split(/\&/,&unescape(&reply('tmpget:'.$dtoken,$lonhost))); @@ -5639,7 +5543,7 @@ sub checkin { my %infohash=('resource.0.intoken' => $token, 'resource.0.checkintime' => $now, - 'resource.0.inremote' => $ip); + 'resource.0.inremote' => $ENV{'REMOTE_ADDR'}); unless (&cstore(\%infohash,$symb,$tcrsid,$tudom,$tuname) eq 'ok') { return ''; @@ -6937,7 +6841,7 @@ sub currentdump { # my %returnhash=(); # - if ($rep eq 'unknown_cmd') { + if ($rep eq "unknown_cmd") { # an old lond will not know currentdump # Do a dump and make it look like a currentdump my @tmp = &dumpstore($courseid,$sdom,$sname,'.'); @@ -7072,8 +6976,7 @@ sub putstore { foreach my $key (keys(%{$storehash})) { $namevalue.=&escape($key).'='.&freeze_escape($storehash->{$key}).'&'; } - my $ip = &get_requestor_ip(); - $namevalue .= 'ip='.&escape($ip). + $namevalue .= 'ip='.&escape($ENV{'REMOTE_ADDR'}). '&host='.&escape($perlvar{'lonHostID'}). '&version='.$esc_v. '&by='.&escape($env{'user.name'}.':'.$env{'user.domain'}); @@ -7854,7 +7757,7 @@ sub customaccess { # ------------------------------------------------- Check for a user privilege sub allowed { - my ($priv,$uri,$symb,$role,$clientip,$noblockcheck,$ignorecache)=@_; + my ($priv,$uri,$symb,$role,$clientip,$noblockcheck)=@_; my $ver_orguri=$uri; $uri=&deversion($uri); my $orguri=$uri; @@ -7871,7 +7774,7 @@ sub allowed { if (defined($env{'allowed.'.$priv})) { return $env{'allowed.'.$priv}; } # Free bre access to adm and meta resources - if (((($uri=~/^adm\//) && ($uri !~ m{/(?:smppg|bulletinboard|viewclasslist|aboutme|ext\.tool)$})) + if (((($uri=~/^adm\//) && ($uri !~ m{/(?:smppg|bulletinboard)$})) || (($uri=~/\.meta$/) && ($uri!~m|^uploaded/|) )) && ($priv eq 'bre')) { return 'F'; @@ -8079,7 +7982,7 @@ sub allowed { if ($noblockcheck) { $thisallowed.=$value; } else { - my @blockers = &has_comm_blocking($priv,$symb,$uri,$ignorecache); + my @blockers = &has_comm_blocking($priv,$symb,$uri); if (@blockers > 0) { $thisallowed = 'B'; } else { @@ -8099,7 +8002,7 @@ sub allowed { if ($noblockcheck) { $thisallowed='F'; } else { - my @blockers = &has_comm_blocking($priv,'',$refuri,'',1); + my @blockers = &has_comm_blocking($priv,$symb,$refuri); if (@blockers > 0) { $thisallowed = 'B'; } else { @@ -8118,7 +8021,7 @@ sub allowed { && &is_portfolio_url($uri)) { $thisallowed = &portfolio_access($uri,$clientip); } - + # Full access at system, domain or course-wide level? Exit. if ($thisallowed=~/F/) { return 'F'; @@ -8172,7 +8075,7 @@ sub allowed { if ($noblockcheck) { $thisallowed.=$value; } else { - my @blockers = &has_comm_blocking($priv,$symb,$uri,$ignorecache); + my @blockers = &has_comm_blocking($priv,$symb,$uri); if (@blockers > 0) { $thisallowed = 'B'; } else { @@ -8185,7 +8088,7 @@ sub allowed { $checkreferer=0; } } - + if ($checkreferer) { my $refuri=$env{'httpref.'.$orguri}; unless ($refuri) { @@ -8214,7 +8117,7 @@ sub allowed { if ($noblockcheck) { $thisallowed.=$value; } else { - my @blockers = &has_comm_blocking($priv,'',$refuri,'',1); + my @blockers = &has_comm_blocking($priv,$symb,$refuri); if (@blockers > 0) { $thisallowed = 'B'; } else { @@ -8300,7 +8203,7 @@ sub allowed { } } } - + # # Rest of the restrictions depend on selected course # @@ -8458,27 +8361,22 @@ sub constructaccess { # # User for whom data are being temporarily cached. my $cacheduser=''; -# Course for which data are being temporarily cached. -my $cachedcid=''; # Cached blockers for this user (a hash of blocking items). my %cachedblockers=(); # When the data were last cached. my $cachedlast=''; sub load_all_blockers { - my ($uname,$udom)=@_; + my ($uname,$udom,$blocks)=@_; if (($uname ne '') && ($udom ne '')) { if (($cacheduser eq $uname.':'.$udom) && - ($cachedcid eq $env{'request.course.id'}) && (abs($cachedlast-time)<5)) { return; } } $cachedlast=time; $cacheduser=$uname.':'.$udom; - $cachedcid=$env{'request.course.id'}; - %cachedblockers = &get_commblock_resources(); - return; + %cachedblockers = &get_commblock_resources($blocks); } sub get_comm_blocks { @@ -8558,23 +8456,14 @@ sub get_commblock_resources { if ($mapsymb) { if (ref($navmap)) { my $mapres = $navmap->getBySymb($mapsymb); - if (ref($mapres)) { - my $first = $mapres->map_start(); - my $finish = $mapres->map_finish(); - my $it = $navmap->getIterator($first,$finish,undef,0,0); - if (ref($it)) { - my $res; - while ($res = $it->next(undef,1)) { - next unless (ref($res)); - my $symb = $res->symb(); - next if (($symb eq $mapsymb) || ($symb eq '')); - @interval=&EXT("resource.0.interval",$symb); - if ($interval[1] eq 'map') { - if ($res->answerable()) { - push(@to_test,$res); - last; - } - } + @to_test = $mapres->retrieveResources($mapres,undef,0,0,0,1); + foreach my $res (@to_test) { + my $symb = $res->symb(); + next if ($symb eq $mapsymb); + if ($symb ne '') { + @interval=&EXT("resource.0.interval",$symb); + if ($interval[1] eq 'map') { + last; } } } @@ -8582,8 +8471,7 @@ sub get_commblock_resources { } } } - if ($interval[0] =~ /^(\d+)/) { - my $timelimit = $1; + if ($interval[0] =~ /^\d+$/) { my $first_access; if ($type eq 'resource') { $first_access=&get_first_access($interval[1],$item); @@ -8593,7 +8481,7 @@ sub get_commblock_resources { $first_access=&get_first_access($interval[1]); } if ($first_access) { - my $timesup = $first_access+$timelimit; + my $timesup = $first_access+$interval[0]; if ($timesup > $now) { my $activeblock; foreach my $res (@to_test) { @@ -8625,23 +8513,17 @@ sub get_commblock_resources { } sub has_comm_blocking { - my ($priv,$symb,$uri,$ignoresymbdb,$noenccheck,$blocked,$blocks) = @_; + my ($priv,$symb,$uri,$blocks) = @_; my @blockers; return unless ($env{'request.course.id'}); return unless ($priv eq 'bre'); return if ($env{'user.priv.'.$env{'request.role'}} =~/evb\&([^\:]*)/); return if ($env{'request.state'} eq 'construct'); - my %blockinfo; - if (ref($blocks) eq 'HASH') { - %blockinfo = &get_commblock_resources($blocks); - } else { - &load_all_blockers($env{'user.name'},$env{'user.domain'}); - %blockinfo = %cachedblockers; - } - return unless (keys(%blockinfo) > 0); + &load_all_blockers($env{'user.name'},$env{'user.domain'},$blocks); + return unless (keys(%cachedblockers) > 0); my (%possibles,@symbs); if (!$symb) { - $symb = &symbread($uri,1,1,1,\%possibles,$ignoresymbdb,$noenccheck); + $symb = &symbread($uri,1,1,1,\%possibles); } if ($symb) { @symbs = ($symb); @@ -8652,38 +8534,34 @@ sub has_comm_blocking { foreach my $symb (@symbs) { last if ($noblock); my ($map,$resid,$resurl)=&decode_symb($symb); - foreach my $block (keys(%blockinfo)) { + foreach my $block (keys(%cachedblockers)) { if ($block =~ /^firstaccess____(.+)$/) { my $item = $1; - unless ($blocked) { - if (($item eq $map) || ($item eq $symb)) { - $noblock = 1; - last; - } + if (($item eq $map) || ($item eq $symb)) { + $noblock = 1; + last; } } - if (ref($blockinfo{$block}) eq 'HASH') { - if (ref($blockinfo{$block}{'resources'}) eq 'HASH') { - if ($blockinfo{$block}{'resources'}{$symb}) { + if (ref($cachedblockers{$block}) eq 'HASH') { + if (ref($cachedblockers{$block}{'resources'}) eq 'HASH') { + if ($cachedblockers{$block}{'resources'}{$symb}) { unless (grep(/^\Q$block\E$/,@blockers)) { push(@blockers,$block); } } } - if (ref($blockinfo{$block}{'maps'}) eq 'HASH') { - if ($blockinfo{$block}{'maps'}{$map}) { - unless (grep(/^\Q$block\E$/,@blockers)) { - push(@blockers,$block); - } + } + if (ref($cachedblockers{$block}{'maps'}) eq 'HASH') { + if ($cachedblockers{$block}{'maps'}{$map}) { + unless (grep(/^\Q$block\E$/,@blockers)) { + push(@blockers,$block); } } } } } - unless ($noblock) { - return @blockers; - } - return; + return if ($noblock); + return @blockers; } } @@ -9998,14 +9876,13 @@ sub modifyuserauth { ' in domain '.$env{'request.role.domain'}); my $reply=&reply('encrypt:changeuserauth:'.$udom.':'.$uname.':'.$umode.':'. &escape($upass),$uhome); - my $ip = &get_requestor_ip(); &log($env{'user.domain'},$env{'user.name'},$env{'user.home'}, 'Authentication changed for '.$udom.', '.$uname.', '.$umode. - '(Remote '.$ip.'): '.$reply); + '(Remote '.$ENV{'REMOTE_ADDR'}.'): '.$reply); &log($udom,,$uname,$uhome, 'Authentication changed by '.$env{'user.domain'}.', '. $env{'user.name'}.', '.$umode. - '(Remote '.$ip.'): '.$reply); + '(Remote '.$ENV{'REMOTE_ADDR'}.'): '.$reply); unless ($reply eq 'ok') { &logthis('Authentication mode error: '.$reply); return 'error: '.$reply; @@ -10330,19 +10207,14 @@ sub writecoursepref { sub createcourse { my ($udom,$description,$url,$course_server,$nonstandard,$inst_code, - $course_owner,$crstype,$cnum,$context,$category,$callercontext)=@_; + $course_owner,$crstype,$cnum,$context,$category)=@_; $url=&declutter($url); my $cid=''; if ($context eq 'requestcourses') { my $can_create = 0; my ($ownername,$ownerdom) = split(':',$course_owner); if ($udom eq $ownerdom) { - my $reload; - if (($callercontext eq 'auto') && - ($ownerdom eq $env{'user.domain'}) && ($ownername eq $env{'user.name'})) { - $reload = 'reload'; - } - if (&usertools_access($ownername,$ownerdom,$category,$reload, + if (&usertools_access($ownername,$ownerdom,$category,undef, $context)) { $can_create = 1; } @@ -10526,7 +10398,7 @@ sub store_userdata { if (($uhome eq '') || ($uhome eq 'no_host')) { $result = 'error: no_host'; } else { - $storehash->{'ip'} = &get_requestor_ip(); + $storehash->{'ip'} = $ENV{'REMOTE_ADDR'}; $storehash->{'host'} = $perlvar{'lonHostID'}; my $namevalue=''; @@ -11351,7 +11223,7 @@ sub get_userresdata { # Parameters: # $name - Course/user name. # $domain - Name of the domain the user/course is registered on. -# $type - Type of thing $name is (must be 'course' or 'user') +# $type - Type of thing $name is (must be 'course' or 'user' # @which - Array of names of resources desired. # Returns: # The value of the first reasource in @which that is found in the @@ -11372,47 +11244,11 @@ sub resdata { foreach my $item (@which) { if (defined($result->{$item->[0]})) { return [$result->{$item->[0]},$item->[1]]; - } + } } return undef; } -sub get_domain_lti { - my ($cdom,$context) = @_; - my ($name,%lti); - if ($context eq 'consumer') { - $name = 'ltitools'; - } elsif ($context eq 'provider') { - $name = 'lti'; - } else { - return %lti; - } - my ($result,$cached)=&is_cached_new($name,$cdom); - if (defined($cached)) { - if (ref($result) eq 'HASH') { - %lti = %{$result}; - } - } else { - my %domconfig = &get_dom('configuration',[$name],$cdom); - if (ref($domconfig{$name}) eq 'HASH') { - %lti = %{$domconfig{$name}}; - my %encdomconfig = &get_dom('encconfig',[$name],$cdom); - if (ref($encdomconfig{$name}) eq 'HASH') { - foreach my $id (keys(%lti)) { - if (ref($encdomconfig{$name}{$id}) eq 'HASH') { - foreach my $item ('key','secret') { - $lti{$id}{$item} = $encdomconfig{$name}{$id}{$item}; - } - } - } - } - } - my $cachetime = 24*60*60; - &do_cache_new($name,$cdom,\%lti,$cachetime); - } - return %lti; -} - sub get_numsuppfiles { my ($cnum,$cdom,$ignorecache)=@_; my $hashid=$cnum.':'.$cdom; @@ -11868,7 +11704,7 @@ sub metadata { # if it is a non metadata possible uri return quickly if (($uri eq '') || (($uri =~ m|^/*adm/|) && - ($uri !~ m|^adm/includes|) && ($uri !~ m{/(smppg|bulletinboard|ext\.tool)$})) || + ($uri !~ m|^adm/includes|) && ($uri !~ m{/(smppg|bulletinboard)$})) || ($uri =~ m|/$|) || ($uri =~ m|/.meta$|) || ($uri =~ m{^/*uploaded/.+\.sequence$})) { return undef; } @@ -12564,16 +12400,13 @@ sub deversion { # ------------------------------------------------------ Return symb list entry sub symbread { - my ($thisfn,$donotrecurse,$ignorecachednull,$checkforblock,$possibles, - $ignoresymbdb,$noenccheck)=@_; + my ($thisfn,$donotrecurse,$ignorecachednull,$checkforblock,$possibles)=@_; my $cache_str='request.symbread.cached.'.$thisfn; if (defined($env{$cache_str})) { - unless (ref($possibles) eq 'HASH') { - if ($ignorecachednull) { - return $env{$cache_str} unless ($env{$cache_str} eq ''); - } else { - return $env{$cache_str}; - } + if ($ignorecachednull) { + return $env{$cache_str} unless ($env{$cache_str} eq ''); + } else { + return $env{$cache_str}; } } # no filename provided? try from environment @@ -12602,18 +12435,10 @@ sub symbread { if ($targetfn =~ m|^adm/wrapper/(ext/.*)|) { $targetfn=$1; } - unless ($ignoresymbdb) { - if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', - &GDBM_READER(),0640)) { - $syval=$hash{$targetfn}; - untie(%hash); - } - if ($syval && $checkforblock) { - my @blockers = &has_comm_blocking('bre',$syval,$thisfn,$ignoresymbdb,$noenccheck); - if (@blockers) { - $syval=''; - } - } + if (tie(%hash,'GDBM_File',$env{'request.course.fn'}.'_symb.db', + &GDBM_READER(),0640)) { + $syval=$hash{$targetfn}; + untie(%hash); } # ---------------------------------------------------------- There was an entry if ($syval) { @@ -12646,18 +12471,13 @@ sub symbread { $syval=&encode_symb($bighash{'map_id_'.$mapid}, $resid,$thisfn); if (ref($possibles) eq 'HASH') { - unless ($bighash{'randomout_'.$ids} || $env{'request.role.adv'}) { - $possibles->{$syval} = 1; - } + $possibles->{$syval} = 1; } if ($checkforblock) { - unless ($bighash{'randomout_'.$ids} || $env{'request.role.adv'}) { - my @blockers = &has_comm_blocking('bre',$syval,$bighash{'src_'.$ids},'',$noenccheck); - if (@blockers) { - $syval = ''; - untie(%bighash); - return $env{$cache_str}=''; - } + my @blockers = &has_comm_blocking('bre',$syval,$bighash{'src_'.$ids}); + if (@blockers) { + $syval = ''; + return; } } } elsif ((!$donotrecurse) || ($checkforblock) || (ref($possibles) eq 'HASH')) { @@ -12676,13 +12496,12 @@ sub symbread { if ($bighash{'map_type_'.$mapid} ne 'page') { my $poss_syval=&encode_symb($bighash{'map_id_'.$mapid}, $resid,$thisfn); - next if ($bighash{'randomout_'.$id} && !$env{'request.role.adv'}); - next unless (($noenccheck) || ($bighash{'encrypted_'.$id} eq $env{'request.enc'})); + if (ref($possibles) eq 'HASH') { + $possibles->{$syval} = 1; + } if ($checkforblock) { - my @blockers = &has_comm_blocking('bre',$poss_syval,$file,'',$noenccheck); - if (@blockers > 0) { - $syval = ''; - } else { + my @blockers = &has_comm_blocking('bre',$poss_syval,$file); + unless (@blockers > 0) { $syval = $poss_syval; $realpossible++; } @@ -12690,11 +12509,6 @@ sub symbread { $syval = $poss_syval; $realpossible++; } - if ($syval) { - if (ref($possibles) eq 'HASH') { - $possibles->{$syval} = 1; - } - } } } } @@ -13495,17 +13309,6 @@ sub uses_sts { return; } -sub get_requestor_ip { - my ($r,$nolookup,$noproxy) = @_; - my $from_ip; - if (ref($r)) { - $from_ip = $r->get_remote_host($nolookup); - } else { - $from_ip = $ENV{'REMOTE_ADDR'}; - } - return $from_ip; -} - # ------------------------------------------------------------- Declutters URLs sub declutter { @@ -13556,8 +13359,6 @@ sub clutter { # &logthis("Got a blank emb style"); } } - } elsif ($thisfn =~ m{^/adm/$match_domain/$match_courseid/\d+/ext\.tool$}) { - $thisfn='/adm/wrapper'.$thisfn; } return $thisfn; }