version 1.1392, 2018/12/05 03:29:11
|
version 1.1397, 2018/12/27 18:14:50
|
Line 311 sub get_server_loncaparev {
|
Line 311 sub get_server_loncaparev {
|
$answer = &reply('serverloncaparev',$lonhost); |
$answer = &reply('serverloncaparev',$lonhost); |
if (($answer eq 'unknown_cmd') || ($answer eq 'con_lost')) { |
if (($answer eq 'unknown_cmd') || ($answer eq 'con_lost')) { |
if ($caller eq 'loncron') { |
if ($caller eq 'loncron') { |
|
my $hostname = &hostname($lonhost); |
my $protocol = $protocol{$lonhost}; |
my $protocol = $protocol{$lonhost}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
my $url = $protocol.'://'.&hostname($lonhost).'/adm/about.html'; |
my $url = $protocol.'://'.$hostname.'/adm/about.html'; |
my $request=new HTTP::Request('GET',$url); |
my $request=new HTTP::Request('GET',$url); |
my $response=&LONCAPA::LWPReq::makerequest($lonhost,$request,'',\%perlvar,4,1); |
my $response=&LONCAPA::LWPReq::makerequest($lonhost,$request,'',\%perlvar,4,1); |
unless ($response->is_error()) { |
unless ($response->is_error()) { |
Line 458 sub reply {
|
Line 459 sub reply {
|
unless (defined(&hostname($server))) { return 'no_such_host'; } |
unless (defined(&hostname($server))) { return 'no_such_host'; } |
my $answer=subreply($cmd,$server); |
my $answer=subreply($cmd,$server); |
if (($answer=~/^refused/) || ($answer=~/^rejected/)) { |
if (($answer=~/^refused/) || ($answer=~/^rejected/)) { |
&logthis("<font color=\"blue\">WARNING:". |
my $logged = $cmd; |
" $cmd to $server returned $answer</font>"); |
if ($cmd =~ /^encrypt:([^:]+):/) { |
|
my $subcmd = $1; |
|
if (($subcmd eq 'auth') || ($subcmd eq 'passwd') || |
|
($subcmd eq 'changeuserauth') || ($subcmd eq 'makeuser') || |
|
($subcmd eq 'putdom') || ($subcmd eq 'autoexportgrades')) { |
|
(undef,undef,my @rest) = split(/:/,$cmd); |
|
if (($subcmd eq 'auth') || ($subcmd eq 'putdom')) { |
|
splice(@rest,2,1,'Hidden'); |
|
} elsif ($subcmd eq 'passwd') { |
|
splice(@rest,2,2,('Hidden','Hidden')); |
|
} elsif (($subcmd eq 'changeuserauth') || ($subcmd eq 'makeuser') || |
|
($subcmd eq 'autoexportgrades')) { |
|
splice(@rest,3,1,'Hidden'); |
|
} |
|
$logged = join(':',('encrypt:'.$subcmd,@rest)); |
|
} |
|
} |
|
&logthis("<font color=\"blue\">WARNING:". |
|
" $logged to $server returned $answer</font>"); |
} |
} |
return $answer; |
return $answer; |
} |
} |
Line 711 sub check_for_valid_session {
|
Line 730 sub check_for_valid_session {
|
|
|
if (!defined($disk_env{'user.name'}) |
if (!defined($disk_env{'user.name'}) |
|| !defined($disk_env{'user.domain'})) { |
|| !defined($disk_env{'user.domain'})) { |
|
untie(%disk_env); |
return undef; |
return undef; |
} |
} |
|
|
Line 723 sub check_for_valid_session {
|
Line 743 sub check_for_valid_session {
|
$userhashref->{'ltiuri'} = $disk_env{'request.lti.uri'}; |
$userhashref->{'ltiuri'} = $disk_env{'request.lti.uri'}; |
} |
} |
} |
} |
|
untie(%disk_env); |
|
|
return $handle; |
return $handle; |
} |
} |
Line 987 sub spareserver {
|
Line 1008 sub spareserver {
|
} |
} |
|
|
if (!$want_server_name) { |
if (!$want_server_name) { |
my $protocol = 'http'; |
|
if ($protocol{$spare_server} eq 'https') { |
|
$protocol = $protocol{$spare_server}; |
|
} |
|
if (defined($spare_server)) { |
if (defined($spare_server)) { |
my $hostname = &hostname($spare_server); |
my $hostname = &hostname($spare_server); |
if (defined($hostname)) { |
if (defined($hostname)) { |
|
my $protocol = 'http'; |
|
if ($protocol{$spare_server} eq 'https') { |
|
$protocol = $protocol{$spare_server}; |
|
} |
$spare_server = $protocol.'://'.$hostname; |
$spare_server = $protocol.'://'.$hostname; |
} |
} |
} |
} |
Line 1643 sub check_balancer_result {
|
Line 1664 sub check_balancer_result {
|
$is_balancer = 1; |
$is_balancer = 1; |
$currtargets = $result->{'targets'}; |
$currtargets = $result->{'targets'}; |
$currrules = $result->{'rules'}; |
$currrules = $result->{'rules'}; |
$dom_balancers = $currbalancer; |
|
} |
} |
$dom_balancers = $currbalancer; |
$dom_balancers = $currbalancer; |
} else { |
} else { |
Line 1740 sub trusted_domains {
|
Line 1760 sub trusted_domains {
|
if (&domain($calldom) eq '') { |
if (&domain($calldom) eq '') { |
return ($trusted,$untrusted); |
return ($trusted,$untrusted); |
} |
} |
unless ($cmdtype =~ /^(content|shared|enroll|coaurem|domroles|catalog|reqcrs|msg)$/) { |
unless ($cmdtype =~ /^(content|shared|enroll|coaurem|othcoau|domroles|catalog|reqcrs|msg)$/) { |
return ($trusted,$untrusted); |
return ($trusted,$untrusted); |
} |
} |
my $callprimary = &domain($calldom,'primary'); |
my $callprimary = &domain($calldom,'primary'); |
Line 1762 sub trusted_domains {
|
Line 1782 sub trusted_domains {
|
map { $possexc{$_} = 1; } @{$trustconfig->{$cmdtype}->{'exc'}}; |
map { $possexc{$_} = 1; } @{$trustconfig->{$cmdtype}->{'exc'}}; |
} |
} |
if (ref($trustconfig->{$cmdtype}->{'inc'}) eq 'ARRAY') { |
if (ref($trustconfig->{$cmdtype}->{'inc'}) eq 'ARRAY') { |
|
$possinc{$intcalldom} = 1; |
map { $possinc{$_} = 1; } @{$trustconfig->{$cmdtype}->{'inc'}}; |
map { $possinc{$_} = 1; } @{$trustconfig->{$cmdtype}->{'inc'}}; |
} |
} |
} |
} |
Line 1796 sub trusted_domains {
|
Line 1817 sub trusted_domains {
|
} |
} |
foreach my $exc (@allexc) { |
foreach my $exc (@allexc) { |
if (ref($doms_by_intdom{$exc}) eq 'ARRAY') { |
if (ref($doms_by_intdom{$exc}) eq 'ARRAY') { |
$untrusted = $doms_by_intdom{$exc}; |
push(@{$untrusted},@{$doms_by_intdom{$exc}}); |
} |
} |
} |
} |
foreach my $inc (@allinc) { |
foreach my $inc (@allinc) { |
if (ref($doms_by_intdom{$inc}) eq 'ARRAY') { |
if (ref($doms_by_intdom{$inc}) eq 'ARRAY') { |
$trusted = $doms_by_intdom{$inc}; |
push(@{$trusted},@{$doms_by_intdom{$inc}}); |
} |
} |
} |
} |
} |
} |
Line 3356 sub remove_stale_resfile {
|
Line 3377 sub remove_stale_resfile {
|
(grep { $_ eq $homeserver } ¤t_machine_ids())) { |
(grep { $_ eq $homeserver } ¤t_machine_ids())) { |
my $fname = &filelocation('',$url); |
my $fname = &filelocation('',$url); |
if (-e $fname) { |
if (-e $fname) { |
my $protocol = $protocol{$homeserver}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
|
my $hostname = &hostname($homeserver); |
my $hostname = &hostname($homeserver); |
if ($hostname) { |
if ($hostname) { |
|
my $protocol = $protocol{$homeserver}; |
|
$protocol = 'http' if ($protocol ne 'https'); |
my $uri = &declutter($url); |
my $uri = &declutter($url); |
my $request=new HTTP::Request('HEAD',$protocol.'://'.$hostname.'/raw/'.$uri); |
my $request=new HTTP::Request('HEAD',$protocol.'://'.$hostname.'/raw/'.$uri); |
my $response = &LONCAPA::LWPReq::makerequest($homeserver,$request,'',\%perlvar,5,0,1); |
my $response = &LONCAPA::LWPReq::makerequest($homeserver,$request,'',\%perlvar,5,0,1); |
Line 5354 sub set_first_access {
|
Line 5375 sub set_first_access {
|
my $firstaccess=&get_first_access($type,$symb,$map); |
my $firstaccess=&get_first_access($type,$symb,$map); |
if ($firstaccess) { |
if ($firstaccess) { |
&logthis("First access time already set ($firstaccess) when attempting ". |
&logthis("First access time already set ($firstaccess) when attempting ". |
"to set new value (type: $type, extent: $res) for $uname:$udom ". |
"to set new value (type: $type, extent: $res) for $uname:$udom ". |
"in $courseid"); |
"in $courseid"); |
return 'already_set'; |
return 'already_set'; |
} else { |
} else { |
my $start = time; |
my $start = time; |
Line 13337 sub repcopy_userfile {
|
Line 13358 sub repcopy_userfile {
|
my $request; |
my $request; |
$uri=~s/^\///; |
$uri=~s/^\///; |
my $homeserver = &homeserver($cnum,$cdom); |
my $homeserver = &homeserver($cnum,$cdom); |
|
my $hostname = &hostname($homeserver); |
my $protocol = $protocol{$homeserver}; |
my $protocol = $protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
$request=new HTTP::Request('GET',$protocol.'://'.&hostname($homeserver).'/raw/'.$uri); |
$request=new HTTP::Request('GET',$protocol.'://'.$hostname.'/raw/'.$uri); |
my $response = &LONCAPA::LWPReq::makerequest($homeserver,$request,$transferfile,\%perlvar,'',0,1); |
my $response = &LONCAPA::LWPReq::makerequest($homeserver,$request,$transferfile,\%perlvar,'',0,1); |
# did it work? |
# did it work? |
if ($response->is_error()) { |
if ($response->is_error()) { |
Line 13363 sub tokenwrapper {
|
Line 13385 sub tokenwrapper {
|
$file=~s|(\?\.*)*$||; |
$file=~s|(\?\.*)*$||; |
&appenv({"userfile.$udom/$uname/$file" => $env{'request.course.id'}}); |
&appenv({"userfile.$udom/$uname/$file" => $env{'request.course.id'}}); |
my $homeserver = &homeserver($uname,$udom); |
my $homeserver = &homeserver($uname,$udom); |
|
my $hostname = &hostname($homeserver); |
my $protocol = $protocol{$homeserver}; |
my $protocol = $protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
return $protocol.'://'.&hostname($homeserver).'/'.$uri. |
return $protocol.'://'.$hostname.'/'.$uri. |
(($uri=~/\?/)?'&':'?').'token='.$token. |
(($uri=~/\?/)?'&':'?').'token='.$token. |
'&tokenissued='.$perlvar{'lonHostID'}; |
'&tokenissued='.$perlvar{'lonHostID'}; |
} else { |
} else { |
Line 13381 sub getuploaded {
|
Line 13404 sub getuploaded {
|
my ($reqtype,$uri,$cdom,$cnum,$info,$rtncode) = @_; |
my ($reqtype,$uri,$cdom,$cnum,$info,$rtncode) = @_; |
$uri=~s/^\///; |
$uri=~s/^\///; |
my $homeserver = &homeserver($cnum,$cdom); |
my $homeserver = &homeserver($cnum,$cdom); |
|
my $hostname = &hostname($homeserver); |
my $protocol = $protocol{$homeserver}; |
my $protocol = $protocol{$homeserver}; |
$protocol = 'http' if ($protocol ne 'https'); |
$protocol = 'http' if ($protocol ne 'https'); |
$uri = $protocol.'://'.&hostname($homeserver).'/raw/'.$uri; |
$uri = $protocol.'://'.$hostname.'/raw/'.$uri; |
my $request=new HTTP::Request($reqtype,$uri); |
my $request=new HTTP::Request($reqtype,$uri); |
my $response=&LONCAPA::LWPReq::makerequest($homeserver,$request,'',\%perlvar,'',0,1); |
my $response=&LONCAPA::LWPReq::makerequest($homeserver,$request,'',\%perlvar,'',0,1); |
$$rtncode = $response->code; |
$$rtncode = $response->code; |