--- loncom/auth/lonlogin.pm 2019/08/01 14:21:37 1.158.2.8
+++ loncom/auth/lonlogin.pm 2021/01/04 03:49:10 1.158.2.12
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Login Screen
#
-# $Id: lonlogin.pm,v 1.158.2.8 2019/08/01 14:21:37 raeburn Exp $
+# $Id: lonlogin.pm,v 1.158.2.12 2021/01/04 03:49:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -76,15 +76,19 @@ sub handler {
&Apache::lonlocal::get_language_handle($r);
&Apache::loncommon::content_type($r,'text/html');
if ($expirepub) {
- my $c = new CGI::Cookie(-name => 'lonID',
+ my $c = new CGI::Cookie(-name => 'lonPubID',
-value => '',
-expires => '-10y',);
$r->header_out('Set-cookie' => $c);
} elsif (($handle eq '') && ($userdom ne '')) {
- my $c = new CGI::Cookie(-name => 'lonID',
- -value => '',
- -expires => '-10y',);
- $r->headers_out->add('Set-cookie' => $c);
+ my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
+ foreach my $name (keys(%cookies)) {
+ next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
+ my $c = new CGI::Cookie(-name => $name,
+ -value => '',
+ -expires => '-10y',);
+ $r->headers_out->add('Set-cookie' => $c);
+ }
}
$r->send_http_header;
return OK if $r->header_only;
@@ -324,22 +328,36 @@ sub handler {
&Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
}
my $spares='';
- my $last;
- foreach my $hostid (sort
- {
- &Apache::lonnet::hostname($a) cmp
- &Apache::lonnet::hostname($b);
- }
- keys(%Apache::lonnet::spareid)) {
+ my (@sparehosts,%spareservers);
+ my $sparesref = &Apache::lonnet::this_host_spares($defdom);
+ if (ref($sparesref) eq 'HASH') {
+ foreach my $key (keys(%{$sparesref})) {
+ if (ref($sparesref->{$key}) eq 'ARRAY') {
+ my @sorted = sort { &Apache::lonnet::hostname($a) cmp
+ &Apache::lonnet::hostname($b);
+ } @{$sparesref->{$key}};
+ if (@sorted) {
+ if ($key eq 'primary') {
+ unshift(@sparehosts,@sorted);
+ } elsif ($key eq 'default') {
+ push(@sparehosts,@sorted);
+ }
+ }
+ }
+ }
+ }
+ foreach my $hostid (@sparehosts) {
next if ($hostid eq $lonhost);
my $hostname = &Apache::lonnet::hostname($hostid);
- next if (($last eq $hostname) || ($hostname eq ''));
- $spares.='
'.
$hostname.''.
- ' '.&mt('(preferred)').''.$/;
- $last=$hostname;
+ ' '.&mt('(preferred)').''.$/;
}
if ($spares) {
$spares.= '
';
@@ -351,23 +369,26 @@ sub handler {
&Apache::lonnet::hostname($b);
}
keys(%all_hostnames)) {
- next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
+ next if ($hostid eq $lonhost);
my $hostname = &Apache::lonnet::hostname($hostid);
- next if (($last eq $hostname) || ($hostname eq ''));
- $spares.='
'.
$hostname.'';
- $last=$hostname;
}
$r->print(
- ''
- .'
'.&mt('Please attempt to login to one of the following servers:') @@ -482,7 +503,7 @@ ENDSCRIPT my $omitextra; if ($headextra_exempt ne '') { my @exempt = split(',',$headextra_exempt); - my $ip = $ENV{'REMOTE_ADDR'}; + my $ip = &Apache::lonnet::get_requestor_ip(); if (grep(/^\Q$ip\E$/,@exempt)) { $omitextra = 1; } @@ -725,7 +746,7 @@ sub check_loginvia { my $output; if ($loginvia ne '') { my $noredirect; - my $ip = $ENV{'REMOTE_ADDR'}; + my $ip = &Apache::lonnet::get_requestor_ip(); if ($ip eq '127.0.0.1') { $noredirect = 1; } else {