version 1.35.2.6.2.8, 2024/10/09 15:49:17
|
version 1.65, 2023/06/02 01:20:26
|
Line 31 package Apache::switchserver;
|
Line 31 package Apache::switchserver;
|
use strict; |
use strict; |
use Apache::Constants qw(:common :remotehost); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon; |
|
use Apache::lonmenu; |
|
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
use CGI::Cookie(); |
use CGI::Cookie(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
Line 65 sub do_redirect {
|
Line 63 sub do_redirect {
|
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Switching Server ...',undef, |
&Apache::loncommon::start_page('Switching Server ...',undef, |
{'redirect' => [$delay,$url,'',$write_to_opener,1], |
{'redirect' => [$delay,$url,'',$write_to_opener,1], |
'only_body' => $only_body, |
'only_body' => $only_body,}); |
'switchserver' => 1, |
|
'links_disabled' => 1, |
|
'no_inline_link' => 1,}); |
|
my $end_page = &Apache::loncommon::end_page(); |
my $end_page = &Apache::loncommon::end_page(); |
$r->print($start_page.$extra_text.$end_page); |
$r->print($start_page.$extra_text.$end_page); |
unless ($env{'user.name'} eq 'public' && ($env{'user.domain'} eq 'public')) { |
unless ($env{'user.name'} eq 'public' && ($env{'user.domain'} eq 'public')) { |
Line 160 sub handler {
|
Line 155 sub handler {
|
$skip_canhost_check = 1; |
$skip_canhost_check = 1; |
} |
} |
} elsif ($env{'form.role'} =~ m{^[ac]a\./($match_domain)/($match_username)$}) { |
} elsif ($env{'form.role'} =~ m{^[ac]a\./($match_domain)/($match_username)$}) { |
if (&Apache::lonnet::homeserver($2,$1) eq $env{'form.otherserver'}) { |
my ($audom,$auname) = ($1,$2); |
$skip_canhost_check = 1; |
if (&Apache::lonnet::homeserver($auname,$audom) eq $env{'form.otherserver'}) { |
|
if ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) { |
|
$skip_canhost_check = 1; |
|
} |
} |
} |
} |
} |
} |
} |
Line 189 sub handler {
|
Line 188 sub handler {
|
if (exists($env{$rolekey})) { |
if (exists($env{$rolekey})) { |
my ($start,$end) = split(/\./,$env{$rolekey}); |
my ($start,$end) = split(/\./,$env{$rolekey}); |
unless (($start && $start > $now) || ($end && $end < $now)) { |
unless (($start && $start > $now) || ($end && $end < $now)) { |
$hasrole = $rolekey; |
if ($rolekey eq "user.role.au./$audom/") { |
|
$hasrole = $rolekey; |
|
} elsif ((&Apache::lonnet::will_trust('othcoau',$env{'user.domain'},$audom)) && |
|
(&Apache::lonnet::will_trust('coaurem',$audom,$env{'user.domain'}))) { |
|
$hasrole = $rolekey; |
|
} |
} |
} |
if ($hasrole) { |
if ($hasrole) { |
$hasrole =~ s/^\Quser.role.\E//; |
$hasrole =~ s/^\Quser.role.\E//; |
Line 276 sub handler {
|
Line 280 sub handler {
|
} |
} |
# -------------------------------------------------------- Menu script and info |
# -------------------------------------------------------- Menu script and info |
|
|
my $windowinfo = &Apache::lonmenu::close(); |
|
|
|
# ---------------------------------------------------------------- Get handover |
# ---------------------------------------------------------------- Get handover |
|
|
my ($is_balancer,$setcookie,$newcookieid,$otherbalcookie); |
my ($is_balancer,$setcookie,$newcookieid,$otherbalcookie,$offloadto,$dom_balancers); |
my $only_body = 0; |
my $only_body = 0; |
($is_balancer,undef,$setcookie) = |
($is_balancer,undef,$setcookie,$offloadto,$dom_balancers) = |
&Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'},'switchserver'); |
&Apache::lonnet::check_loadbalancing($env{'user.name'},$env{'user.domain'},'switchserver'); |
if ($is_balancer && $setcookie && $env{'form.otherserver'}) { |
if ($is_balancer && $setcookie && $env{'form.otherserver'}) { |
|
|
Line 302 sub handler {
|
Line 304 sub handler {
|
$otherbalcookie = $env{'request.balancercookie'}; |
$otherbalcookie = $env{'request.balancercookie'}; |
} |
} |
|
|
my %info=('ip' => $ip, |
my %info=('ip' => $ip, |
'domain' => $env{'user.domain'}, |
'domain' => $env{'user.domain'}, |
'username' => $env{'user.name'}, |
'username' => $env{'user.name'}, |
'role' => $env{'form.role'}, |
'home' => $env{'user.home'}, |
'server' => $r->dir_config('lonHostID'), |
'role' => $env{'form.role'}, |
'balancer' => $is_balancer); |
'server' => $r->dir_config('lonHostID'), |
|
'balancer' => $is_balancer, |
|
'dom_balancers' => $dom_balancers, |
|
'offloadto' => ''); |
|
if (ref($offloadto) eq 'HASH') { |
|
foreach my $key (keys(%{$offloadto})) { |
|
if (ref($offloadto->{$key}) eq 'ARRAY') { |
|
$info{'offloadto'} .= $key.'='.join(',',@{$offloadto->{$key}}).'&'; |
|
} |
|
} |
|
$info{'offloadto'} =~ s/\&$//; |
|
} elsif (ref($offloadto) eq 'ARRAY') { |
|
$info{'offloadto'} = join(',',@{$offloadto}); |
|
} |
if ($newcookieid) { |
if ($newcookieid) { |
$info{'balcookie'} = $newcookieid; |
$info{'balcookie'} = $newcookieid; |
} elsif ($otherbalcookie) { |
} elsif ($otherbalcookie) { |
Line 332 sub handler {
|
Line 347 sub handler {
|
if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
$ssologoutscript .= join('',<$fh>); |
$ssologoutscript .= join('',<$fh>); |
close($fh); |
close($fh); |
} |
} |
} |
} |
if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) { |
if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) { |
Line 403 sub handler {
|
Line 418 sub handler {
|
$url .= join('&',@args); |
$url .= join('&',@args); |
} |
} |
# --------------------------------------------------------------- Screen Output |
# --------------------------------------------------------------- Screen Output |
return &do_redirect($r, $url, $only_body, $windowinfo.$ssologoutscript, |
return &do_redirect($r, $url, $only_body, $ssologoutscript, $env{'form.lcssowin'}); |
$env{'form.lcssowin'}); |
|
} |
} |
|
|
1; |
1; |