--- loncom/auth/lonlogin.pm 2019/08/01 14:21:37 1.158.2.8
+++ loncom/auth/lonlogin.pm 2020/10/24 19:49:06 1.158.2.10
@@ -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.10 2020/10/24 19:49:06 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,25 @@ 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:')