version 1.50, 2020/10/20 01:38:12
|
version 1.59, 2021/10/26 14:20:40
|
Line 29
|
Line 29
|
package Apache::switchserver; |
package Apache::switchserver; |
|
|
use strict; |
use strict; |
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common :remotehost); |
use Apache::lonnet; |
use Apache::lonnet; |
use Digest::MD5 qw(md5_hex); |
use Digest::MD5 qw(md5_hex); |
use CGI::Cookie(); |
use CGI::Cookie(); |
Line 57 sub do_redirect {
|
Line 57 sub do_redirect {
|
my ($r,$url,$only_body,$extra_text) = @_; |
my ($r,$url,$only_body,$extra_text) = @_; |
$r->send_http_header; |
$r->send_http_header; |
my $delay = 0.5; |
my $delay = 0.5; |
if ($only_body) { |
if ($only_body && !$extra_text) { |
$delay = 0; |
$delay = 0; |
} |
} |
my $start_page = |
my $start_page = |
Line 111 sub handler {
|
Line 111 sub handler {
|
$env{'user.name'}); |
$env{'user.name'}); |
if (! $env{'form.otherserver'}) { |
if (! $env{'form.otherserver'}) { |
$env{'form.otherserver'} = |
$env{'form.otherserver'} = |
&Apache::lonnet::spareserver(30000,undef,1); |
&Apache::lonnet::spareserver($r,30000,undef,1); |
} |
} |
$switch_to=&Apache::lonnet::hostname($env{'form.otherserver'}); |
$switch_to=&Apache::lonnet::hostname($env{'form.otherserver'}); |
} |
} |
Line 123 sub handler {
|
Line 123 sub handler {
|
if ($Apache::lonnet::protocol{$env{'form.otherserver'}} eq 'https') { |
if ($Apache::lonnet::protocol{$env{'form.otherserver'}} eq 'https') { |
$protocol = $Apache::lonnet::protocol{$env{'form.otherserver'}}; |
$protocol = $Apache::lonnet::protocol{$env{'form.otherserver'}}; |
} |
} |
|
unless ($env{'form.otherserver'} eq $r->dir_config('lonHostID')) { |
|
my $alias = &Apache::lonnet::use_proxy_alias($r,$env{'form.otherserver'}); |
|
$switch_to = $alias if ($alias ne ''); |
|
} |
} |
} |
|
|
if ($env{'user.name'} eq 'public' |
if ($env{'user.name'} eq 'public' |
Line 211 sub handler {
|
Line 215 sub handler {
|
} else { |
} else { |
$logmsg .= " (no role)"; |
$logmsg .= " (no role)"; |
} |
} |
$logmsg .= ' '.$ENV{'REMOTE_ADDR'}; |
my $ip = &Apache::lonnet::get_requestor_ip($r,REMOTE_NOLOOKUP); |
|
$logmsg .= ' '.$ip; |
&Apache::lonnet::log($env{'user.domain'},$env{'user.name'}, |
&Apache::lonnet::log($env{'user.domain'},$env{'user.name'}, |
$env{'user.home'},$logmsg); |
$env{'user.home'},$logmsg); |
|
|
Line 231 sub handler {
|
Line 236 sub handler {
|
return OK; |
return OK; |
} |
} |
# -------------------------------------------------------- Menu script and info |
# -------------------------------------------------------- Menu script and info |
|
|
# ---------------------------------------------------------------- Get handover |
# ---------------------------------------------------------------- Get handover |
|
|
my ($is_balancer,$setcookie,$newcookieid,$offloadto,$dom_balancers); |
my ($is_balancer,$setcookie,$newcookieid,$otherbalcookie,$offloadto,$dom_balancers); |
my $only_body = 0; |
my $only_body = 0; |
($is_balancer,undef,$setcookie,$offloadto,$dom_balancers) = |
($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'); |
Line 252 sub handler {
|
Line 257 sub handler {
|
$env{'user.name'},$env{'user.domain'}); |
$env{'user.name'},$env{'user.domain'}); |
} |
} |
} |
} |
|
if ((!$is_balancer) && ($env{'request.balancercookie'})) { |
|
$otherbalcookie = $env{'request.balancercookie'}; |
|
} |
|
|
my %info=('ip' => $ENV{'REMOTE_ADDR'}, |
my %info=('ip' => $ip, |
'domain' => $env{'user.domain'}, |
'domain' => $env{'user.domain'}, |
'username' => $env{'user.name'}, |
'username' => $env{'user.name'}, |
'home' => $env{'user.home'}, |
'home' => $env{'user.home'}, |
Line 274 sub handler {
|
Line 282 sub handler {
|
} |
} |
if ($newcookieid) { |
if ($newcookieid) { |
$info{'balcookie'} = $newcookieid; |
$info{'balcookie'} = $newcookieid; |
|
} elsif ($otherbalcookie) { |
|
$info{'otherbalcookie'} = $otherbalcookie; |
} |
} |
if ($env{'form.origurl'}) { |
if ($env{'form.origurl'}) { |
$info{'origurl'} = $env{'form.origurl'}; |
$info{'origurl'} = $env{'form.origurl'}; |
Line 281 sub handler {
|
Line 291 sub handler {
|
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
$info{'symb'} = $env{'form.symb'}; |
$info{'symb'} = $env{'form.symb'}; |
} |
} |
|
my $ssologoutscript = ''; |
if ($env{'request.sso.login'}) { |
if ($env{'request.sso.login'}) { |
$info{'sso.login'} = $env{'request.sso.login'}; |
$info{'sso.login'} = $env{'request.sso.login'}; |
|
if (defined($r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
|
if (open(my $fh,'<',$r->dir_config("lonSSOUserLogoutScriptFile_$info{domain}"))) { |
|
$ssologoutscript .= join('',<$fh>); |
|
close($fh); |
|
} |
|
} |
|
if (defined($r->dir_config('lonSSOUserLogoutScriptFile'))) { |
|
if (open(my $fh,'<',$r->dir_config('lonSSOUserLogoutScriptFile'))) { |
|
$ssologoutscript .= join('',<$fh>); |
|
close($fh); |
|
} |
|
} |
} |
} |
if ($env{'request.sso.reloginserver'}) { |
if ($env{'request.sso.reloginserver'}) { |
$info{'sso.reloginserver'} = $env{'request.sso.reloginserver'}; |
$info{'sso.reloginserver'} = $env{'request.sso.reloginserver'}; |
} |
} |
if ($env{'request.linkprot'}) { |
if ($env{'request.linkprot'}) { |
$info{'linkprot'} = $env{'request.linkprot'}; |
$info{'linkprot'} = $env{'request.linkprot'}; |
|
} elsif ($env{'request.linkkey'} ne '') { |
|
$info{'linkkey'} = $env{'request.linkkey'}; |
} |
} |
if ($env{'request.deeplink.login'}) { |
if ($env{'request.deeplink.login'}) { |
$info{'deeplink.login'} = $env{'request.deeplink.login'}; |
$info{'deeplink.login'} = $env{'request.deeplink.login'}; |
if ($env{'request.linkkey'}) { |
|
$info{'linkkey'} = $env{'request.linkkey'}; |
|
} |
|
} |
} |
if ($env{'request.lti.login'}) { |
if ($env{'request.lti.login'}) { |
$info{'lti.login'} = $env{'request.lti.login'}; |
$info{'lti.login'} = $env{'request.lti.login'}; |
Line 335 sub handler {
|
Line 357 sub handler {
|
'&username='.$env{'user.name'}. |
'&username='.$env{'user.name'}. |
'&token='.$token; |
'&token='.$token; |
# --------------------------------------------------------------- Screen Output |
# --------------------------------------------------------------- Screen Output |
return &do_redirect($r, $url, $only_body); |
return &do_redirect($r, $url, $only_body, $ssologoutscript); |
} |
} |
|
|
1; |
1; |