Diff for /loncom/auth/lonlogin.pm between versions 1.158.2.13.2.9 and 1.191

version 1.158.2.13.2.9, 2023/02/03 23:11:31 version 1.191, 2021/10/10 23:22:30
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # Login Screen  # Login Screen
 #  #
 # $Id$  # $Id$
 #  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
 #  #
 # LON-CAPA is free software; you can redistribute it and/or modify  # LON-CAPA is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or  # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  # (at your option) any later version.
 #  #
 # LON-CAPA is distributed in the hope that it will be useful,  # LON-CAPA is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of  # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.  # GNU General Public License for more details.
 #  #
 # You should have received a copy of the GNU General Public License  # You should have received a copy of the GNU General Public License
 # along with LON-CAPA; if not, write to the Free Software  # along with LON-CAPA; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #  #
 # /home/httpd/html/adm/gpl.txt  # /home/httpd/html/adm/gpl.txt
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
 package Apache::lonlogin;  package Apache::lonlogin;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::File ();  use Apache::File ();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonauth();  use Apache::lonauth();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::migrateuser();  use Apache::migrateuser();
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA qw(:DEFAULT :match);  use LONCAPA qw(:DEFAULT :match);
 use URI::Escape;  use URI::Escape;
 use HTML::Entities();  use HTML::Entities();
 use CGI::Cookie();  use CGI::Cookie();
     
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
   
     &Apache::loncommon::get_unprocessed_cgi      &Apache::loncommon::get_unprocessed_cgi
  (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},   (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
       $ENV{'REDIRECT_QUERY_STRING'}),        $ENV{'REDIRECT_QUERY_STRING'}),
  ['interface','username','domain','firsturl','localpath','localres',   ['interface','username','domain','firsturl','localpath','localres',
   'token','role','symb','iptoken','btoken','ltoken','ttoken','linkkey',    'token','role','symb','iptoken','btoken','ltoken','linkkey','saml']);
           'saml','sso','retry','display']);      if (!defined($env{'form.firsturl'})) {
           &Apache::lonacc::get_posted_cgi($r,['firsturl']);
 # -- check if they are a migrating user      }
     if (defined($env{'form.token'})) {      if (!defined($env{'form.firsturl'})) {
  return &Apache::migrateuser::handler($r);          if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {
     }              $env{'form.firsturl'} = $ENV{'REDIRECT_URL'};
           }
     my $lonhost = $r->dir_config('lonHostID');      }
     if ($env{'form.ttoken'}) {      if (($env{'form.firsturl'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) &&
         my %info = &Apache::lonnet::tmpget($env{'form.ttoken'});          (!$env{'form.ltoken'}) && (!$env{'form.linkkey'})) {
         &Apache::lonnet::tmpdel($env{'form.ttoken'});          &Apache::lonacc::get_posted_cgi($r,['linkkey']);
         if ($info{'origurl'}) {      }
             $env{'form.firsturl'} = $info{'origurl'};      if ($env{'form.firsturl'} eq '/adm/logout') {
         }          delete($env{'form.firsturl'});
         if ($info{'ltoken'}) {      }
             $env{'form.ltoken'} = $info{'ltoken'};  
         } elsif ($info{'linkprot'}) {  # -- check if they are a migrating user
             $env{'form.linkprot'} = $info{'linkprot'};      if (defined($env{'form.token'})) {
             foreach my $item ('linkprotuser','linkprotexit') {   return &Apache::migrateuser::handler($r);
                 if ($info{$item} ne '') {      }
                     $env{'form.'.$item} = $info{$item};  
                 }  # For "public user" - remove any exising "public" cookie, as user really wants to log-in
             }      my ($handle,$lonidsdir,$expirepub,$userdom);
         } elsif ($info{'linkkey'} ne '') {      $lonidsdir=$r->dir_config('lonIDsDir');
             $env{'form.linkkey'} = $info{'linkkey'};      unless ($r->header_only) {
         }          $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
     } elsif (($env{'form.sso'}) || ($env{'form.retry'})) {          if ($handle ne '') {
         my $infotoken;              if ($handle=~/^publicuser\_/) {
         if ($env{'form.sso'}) {                  unlink($r->dir_config('lonIDsDir')."/$handle.id");
             $infotoken = $env{'form.sso'};                  undef($handle);
         } else {                  undef($userdom);
             $infotoken = $env{'form.retry'};                  $expirepub = 1;
         }              }
         my $data = &Apache::lonnet::reply('tmpget:'.$infotoken,$lonhost);          }
         unless (($data=~/^error/) || ($data eq 'con_lost') ||      }
                 ($data eq 'no_such_host')) {  
             my %info = &decode_token($data);      &Apache::loncommon::no_cache($r);
             foreach my $item (keys(%info)) {      &Apache::lonlocal::get_language_handle($r);
                 $env{'form.'.$item} = $info{$item};      &Apache::loncommon::content_type($r,'text/html');
             }      if ($expirepub) {
             &Apache::lonnet::tmpdel($infotoken);          my $c = new CGI::Cookie(-name    => 'lonPubID',
         }                                  -value   => '',
     } else {                                  -expires => '-10y',);
         if (!defined($env{'form.firsturl'})) {          $r->header_out('Set-cookie' => $c);
             &Apache::lonacc::get_posted_cgi($r,['firsturl']);      } elsif (($handle eq '') && ($userdom ne '')) {
         }          my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
         if (!defined($env{'form.firsturl'})) {          foreach my $name (keys(%cookies)) {
             if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {              next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
                 $env{'form.firsturl'} = $ENV{'REDIRECT_URL'};              my $c = new CGI::Cookie(-name    => $name,
             }                                      -value   => '',
         }                                      -expires => '-10y',);
         if (($env{'form.firsturl'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) &&              $r->headers_out->add('Set-cookie' => $c);
             (!$env{'form.ltoken'}) && (!$env{'form.linkprot'}) && (!$env{'form.linkkey'})) {          }
             &Apache::lonacc::get_posted_cgi($r,['linkkey']);      }
         }      $r->send_http_header;
         if ($env{'form.firsturl'} eq '/adm/logout') {      return OK if $r->header_only;
             delete($env{'form.firsturl'});  
         }  
     }  # Are we re-routing?
       my $londocroot = $r->dir_config('lonDocRoot');
 # For "public user" - remove any exising "public" cookie, as user really wants to log-in      if (-e "$londocroot/lon-status/reroute.txt") {
     my ($handle,$lonidsdir,$expirepub,$userdom);   &Apache::lonauth::reroute($r);
     $lonidsdir=$r->dir_config('lonIDsDir');   return OK;
     unless ($r->header_only) {      }
         $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);  
         if ($handle ne '') {      my $lonhost = $r->dir_config('lonHostID');
             if ($handle=~/^publicuser\_/) {  
                 unlink($r->dir_config('lonIDsDir')."/$handle.id");  # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
                 undef($handle);  
                 undef($userdom);      my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r,1);
                 $expirepub = 1;      if ($found_server) {
             }          my $hostname = &Apache::lonnet::hostname($found_server);
         }          if ($hostname ne '') {
     }              my $protocol = $Apache::lonnet::protocol{$found_server};
               $protocol = 'http' if ($protocol ne 'https');
     &Apache::loncommon::no_cache($r);              my $dest = '/adm/roles';
     &Apache::lonlocal::get_language_handle($r);              if ($env{'form.firsturl'} ne '') {
     &Apache::loncommon::content_type($r,'text/html');                  if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
     if ($expirepub) {                      $dest = &uri_escape_utf8($env{'form.firsturl'});
         my $c = new CGI::Cookie(-name    => 'lonPubID',                  } else {
                                 -value   => '',                      $dest = &uri_escape($env{'form.firsturl'});
                                 -expires => '-10y',);                  }
         $r->header_out('Set-cookie' => $c);                  $dest = &HTML::Entities::encode($dest,"'");
     } elsif (($handle eq '') && ($userdom ne '')) {              }
         my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));              my %info = (
         foreach my $name (keys(%cookies)) {                           balcookie => $lonhost.':'.$balancer_cookie,
             next unless ($name =~ /^lon(|S|Link|Pub)ID$/);                         );
             my $c = new CGI::Cookie(-name    => $name,              if ($env{'form.ltoken'}) {
                                     -value   => '',                  my %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});
                                     -expires => '-10y',);                  if ($link_info{'linkprot'}) {
             $r->headers_out->add('Set-cookie' => $c);                      $info{'linkprot'} = $link_info{'linkprot'};
         }                  }
     }                  &Apache::lonnet::tmpdel($env{'form.ltoken'});
     $r->send_http_header;                  delete($env{'form.ltoken'});
     return OK if $r->header_only;              } elsif ($env{'form.linkkey'}) {
                   $info{'linkkey'} = $env{'form.linkkey'};
                   delete($env{'form.linkkey'});
 # Are we re-routing?              }
     my $londocroot = $r->dir_config('lonDocRoot');               my $balancer_token = &Apache::lonnet::tmpput(\%info,$found_server);
     if (-e "$londocroot/lon-status/reroute.txt") {              if ($balancer_token) {
  &Apache::lonauth::reroute($r);                  $dest .=  (($dest=~/\?/)?'&':'?') . 'btoken='.$balancer_token;
  return OK;              }
     }              unless ($found_server eq $lonhost) {
                   my $alias = &Apache::lonnet::use_proxy_alias($r,$found_server);
 # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)                  $hostname = $alias if ($alias ne '');
               }
     my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r,1);              my $url = $protocol.'://'.$hostname.$dest;
     if ($found_server) {              my $start_page =
         my $hostname = &Apache::lonnet::hostname($found_server);                  &Apache::loncommon::start_page('Switching Server ...',undef,
         if ($hostname ne '') {                                                 {'redirect'       => [0,$url],});
             my $protocol = $Apache::lonnet::protocol{$found_server};              my $end_page   = &Apache::loncommon::end_page();
             $protocol = 'http' if ($protocol ne 'https');              $r->print($start_page.$end_page);
             my $dest = '/adm/roles';              return OK;
             if ($env{'form.firsturl'} ne '') {          }
                 $dest = &HTML::Entities::encode($env{'form.firsturl'},'\'"<>&');      }
             }  
             my %info = (  #
                          balcookie => $lonhost.':'.$balancer_cookie,  # Check if a LON-CAPA load balancer sent user here because user's browser sent
                        );  # it a balancer cookie for an active session on this server.
             if ($env{'form.role'}) {  #
                 $info{'role'} = $env{'form.role'};  
             }      my ($balcookie,$linkprot,$linkkey);
             if ($env{'form.symb'}) {      if ($env{'form.btoken'}) {
                 $info{'symb'} = $env{'form.symb'};          my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
             }          $balcookie = $info{'balcookie'};
             if (($env{'form.firsturl'} eq '/adm/email') && ($env{'form.display'} ne '')) {          if ($balcookie) {
                 if ($env{'form.sso'}) {              if ($info{'linkprot'}) {
                     if ($env{'form.mailrecip'}) {                  $linkprot = $info{'linkprot'};
                         $info{'display'} = &escape($env{'form.display'});              } elsif ($info{'linkkey'}) {
                         $info{'mailrecip'} = &escape($env{'form.mailrecip'});                  $linkkey = $info{'linkkey'};
                     }              }
                 } else {          }    
                     if (($env{'form.username'}) && ($env{'form.domain'})) {          &Apache::lonnet::tmpdel($env{'form.btoken'});
                         $info{'display'} = &escape($env{'form.display'});          delete($env{'form.btoken'});
                         $info{'mailrecip'} = &escape($env{'form.username'}.':'.$env{'form.domain'});      }
                     }  
                 }  #
             }  # If browser sent an old cookie for which the session file had been removed
             my $balancer_token = &Apache::lonnet::tmpput(\%info,$found_server);  # check if configuration for user's domain has a portal URL set.  If so
             unless (($balancer_token eq 'con_lost') || ($balancer_token eq 'refused') ||  # switch user's log-in to the portal.
                     ($balancer_token eq 'unknown_cmd') || ($balancer_token eq 'no_such_host')) {  #
                 $dest .=  (($dest=~/\?/)?'&amp;':'?') . 'btoken='.$balancer_token;  
             }      if (($handle eq '') && ($userdom ne '')) {
             if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {          my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
                 my %link_info;          if ($domdefaults{'portal_def'} =~ /^https?\:/) {
                 if ($env{'form.ltoken'}) {              my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                     $link_info{'ltoken'} = $env{'form.ltoken'};                                            {'redirect' => [0,$domdefaults{'portal_def'}],});
                 } elsif ($env{'form.linkprot'}) {              my $end_page   = &Apache::loncommon::end_page();
                     $link_info{'linkprot'} = $env{'form.linkprot'};              $r->print($start_page.$end_page);
                     foreach my $item ('linkprotuser','linkprotexit') {              return OK;
                         if ($env{'form.'.$item} ne '') {          }
                             $link_info{$item} = $env{'form.'.$item};      }
                         }  
                     }  # -------------------------------- Prevent users from attempting to login twice
                 } elsif ($env{'form.linkkey'} ne '') {      if ($handle ne '') {
                     $link_info{'linkkey'} = $env{'form.linkkey'};          &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
                 }   my $start_page =
                 if (keys(%link_info)) {      &Apache::loncommon::start_page('Already logged in');
                     $link_info{'origurl'} = $env{'form.firsturl'};   my $end_page =
                     my $token = &Apache::lonnet::tmpput(\%link_info,$found_server,'link');      &Apache::loncommon::end_page();
                     unless (($token eq 'con_lost') || ($token eq 'refused') ||          my $dest = '/adm/roles';
                             ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {          if ($env{'form.firsturl'} ne '') {
                         $dest .=  (($dest=~/\?/)?'&amp;':'?') . 'ttoken='.$token;              if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
                     }                  $dest = &uri_escape_utf8($env{'form.firsturl'});
                 }              } else {
             }                  $dest = &uri_escape($env{'form.firsturl'});
             unless ($found_server eq $lonhost) {              }
                 my $alias = &Apache::lonnet::use_proxy_alias($r,$found_server);              $dest = &HTML::Entities::encode($dest,"'");
                 $hostname = $alias if ($alias ne '');          }
             }          if (($env{'form.ltoken'}) || ($linkprot)) {
             my $url = $protocol.'://'.$hostname.$dest;              unless ($linkprot) {
             my $start_page =                  my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
                 &Apache::loncommon::start_page('Switching Server ...',undef,                  $linkprot = $info{'linkprot'};
                                                {'redirect'       => [0,$url],});                  my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'});
             my $end_page   = &Apache::loncommon::end_page();                  delete($env{'form.ltoken'});
             $r->print($start_page.$end_page);              }
             return OK;              if ($linkprot) {
         }                  my ($linkprotector,$deeplink) = split(/:/,$linkprot,2);
     }                  if ($env{'user.linkprotector'}) {
                       my @protectors = split(/,/,$env{'user.linkprotector'});
 #                      unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
 # Check if a LON-CAPA load balancer sent user here because user's browser sent                          push(@protectors,$linkprotector);
 # it a balancer cookie for an active session on this server.                          @protectors = sort { $a <=> $b } @protectors;
 #                          &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
                       }
     my $balcookie;                  } else {
     if ($env{'form.btoken'}) {                      &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
         my %info = &Apache::lonnet::tmpget($env{'form.btoken'});                  }
         $balcookie = $info{'balcookie'};                  if ($env{'user.linkproturi'}) {
         &Apache::lonnet::tmpdel($env{'form.btoken'});                      my @proturis = split(/,/,$env{'user.linkproturi'});
         delete($env{'form.btoken'});                      unless (grep(/^\Q$deeplink\E$/,@proturis)) {
         if (($env{'form.firsturl'} eq '/adm/email') &&                          push(@proturis,$deeplink);
             (exists($info{'display'})) && (exists($info{'mailrecip'}))) {                          @proturis = sort @proturis;
             $env{'form.display'} = &unescape($info{'display'});                          &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
             $env{'form.mailrecip'} = &unescape($info{'mailrecip'});                      }
         }                  } else {
     }                      &Apache::lonnet::appenv({'user.linkproturi' => $deeplink});
                   }
 #              }
 # If browser sent an old cookie for which the session file had been removed          } elsif (($env{'form.linkkey'}) || ($linkkey)) {
 # check if configuration for user's domain has a portal URL set.  If so              if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
 # switch user's log-in to the portal.                  if ($linkkey eq '') {
 #                      $linkkey = $env{'form.linkkey'};
                   }
     if (($handle eq '') && ($userdom ne '')) {                  if ($env{'user.deeplinkkey'}) {
         my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);                      my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
         if ($domdefaults{'portal_def'} =~ /^https?\:/) {                      unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
             my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,                          push(@linkkeys,$linkkey);
                                           {'redirect' => [0,$domdefaults{'portal_def'}],});                          &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});  
             my $end_page   = &Apache::loncommon::end_page();                      }
             $r->print($start_page.$end_page);                  } else {
             return OK;                      &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
         }                  }
     }                  my $deeplink = $env{'form.firsturl'};
                   if ($env{'user.keyedlinkuri'}) {
 # -------------------------------- Prevent users from attempting to login twice                      my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
     if ($handle ne '') {                      unless (grep(/^\Q$deeplink\E$/,@keyeduris)) {
         &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);                          push(@keyeduris,$deeplink);
  my $start_page =                           &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
     &Apache::loncommon::start_page('Already logged in');                      }
  my $end_page =                   } else {
     &Apache::loncommon::end_page();                      &Apache::lonnet::appenv({'user.keyedlinkuri' => $deeplink});
         my $dest = '/adm/roles';                  }
         if ($env{'form.firsturl'} ne '') {              }
             $dest = &HTML::Entities::encode($env{'form.firsturl'},'\'"<>&');          }
         }   $r->print(
         if (($env{'form.ltoken'}) || ($env{'form.linkprot'})) {                    $start_page
             my ($linkprot,$linkprotuser,$linkprotexit);                   .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
             if ($env{'form.ltoken'}) {                   .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
                 my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
                 $linkprot = $info{'linkprot'};                   .$end_page
                 if ($info{'linkprotuser'} ne '') {                   );
                     $linkprotuser = $info{'linkprotuser'};          return OK;
                 }      }
                 if ($info{'linkprotexit'} ne '') {  
                     $linkprotexit = $info{'linkprotexit'};  # ---------------------------------------------------- No valid token, continue
                 }  
             } else {  # ---------------------------- Not possible to really login to domain "public"
                 $linkprot = $env{'form.linkprot'};      if ($env{'form.domain'} eq 'public') {
                 $linkprotuser = $env{'form.linkprotuser'};   $env{'form.domain'}='';
                 $linkprotexit = $env{'form.linkprotexit'};   $env{'form.username'}='';
             }      }
             if ($linkprot) {  
                 my ($linkprotector,$deeplink) = split(/:/,$linkprot,2);  # ------ Is this page requested because /adm/migrateuser detected an IP change?
                 if (($deeplink =~ m{^/tiny/$match_domain/\w+$}) &&      my %sessiondata;
                     ($linkprotuser ne '') && ($linkprotuser ne $env{'user.name'}.':'.$env{'user.domain'})) {      if ($env{'form.iptoken'}) {
                     my $ip = &Apache::lonnet::get_requestor_ip();          %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
                     my %linkprotinfo = (          unless ($sessiondata{'sessionserver'}) {
                                           origurl => $deeplink,              my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
                                           linkprot => $linkprot,              delete($env{'form.iptoken'});
                                           linkprotuser => $linkprotuser,          }
                                           linkprotexit => $linkprotexit,      }
                                        );  # ----------------------------------------------------------- Process Interface
                     if ($env{'form.ltoken'}) {      $env{'form.interface'}=~s/\W//g;
                         my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'});  
                     }      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
                     &Apache::migrateuser::logout($r,$ip,$handle,undef,undef,\%linkprotinfo);          &Apache::loncommon::decode_user_agent();
                     return OK;  
                 }      my $iconpath=
                 if ($env{'user.linkprotector'}) {   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
                     my @protectors = split(/,/,$env{'user.linkprotector'});  
                     unless (grep(/^\Q$linkprotector\E$/,@protectors)) {      my $domain = &Apache::lonnet::default_login_domain();
                         push(@protectors,$linkprotector);      my $defdom = $domain;
                         @protectors = sort { $a <=> $b } @protectors;      if ($lonhost ne '') {
                         &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});          unless ($sessiondata{'sessionserver'}) {
                     }              my $redirect = &check_loginvia($domain,$lonhost,$lonidsdir,$balcookie,$linkprot);
                 } else {              if ($redirect) {
                     &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });                  $r->print($redirect);
                 }                  return OK;
                 if ($env{'user.linkproturi'}) {              }
                     my @proturis = split(/,/,$env{'user.linkproturi'});          }
                     unless (grep(/^\Q$deeplink\E$/,@proturis)) {      }
                         push(@proturis,$deeplink);  
                         @proturis = sort @proturis;      if (($sessiondata{'domain'}) &&
                         &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});          (&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {
                     }          $domain=$sessiondata{'domain'};
                 } else {      } elsif (($env{'form.domain'}) &&
                     &Apache::lonnet::appenv({'user.linkproturi' => $deeplink});   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
                 }   $domain=$env{'form.domain'};
             }      }
         } elsif ($env{'form.linkkey'} ne '') {  
             if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {      my $role    = $r->dir_config('lonRole');
                 my $linkkey = $env{'form.linkkey'};      my $loadlim = $r->dir_config('lonLoadLim');
                 if ($env{'user.deeplinkkey'}) {      my $uloadlim= $r->dir_config('lonUserLoadLim');
                     my @linkkeys = split(/,/,$env{'user.deeplinkkey'});      my $servadm = $r->dir_config('lonAdmEMail');
                     unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {      my $tabdir  = $r->dir_config('lonTabDir');
                         push(@linkkeys,$linkkey);      my $include = $r->dir_config('lonIncludes');
                         &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});      my $expire  = $r->dir_config('lonExpire');
                     }      my $version = $r->dir_config('lonVersion');
                 } else {      my $host_name = &Apache::lonnet::hostname($lonhost);
                     &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});  
                 }  # --------------------------------------------- Default values for login fields
                 my $deeplink = $env{'form.firsturl'};     
                 if ($env{'user.keyedlinkuri'}) {      my ($authusername,$authdomain);
                     my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});      if ($sessiondata{'username'}) {
                     unless (grep(/^\Q$deeplink\E$/,@keyeduris)) {          $authusername=$sessiondata{'username'};
                         push(@keyeduris,$deeplink);      } else {
                         &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
                     }          $authusername=($env{'form.username'}?$env{'form.username'}:'');
                 } else {      }
                     &Apache::lonnet::appenv({'user.keyedlinkuri' => $deeplink});      if ($sessiondata{'domain'}) {
                 }          $authdomain=$sessiondata{'domain'};
             }      } else {
         }          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
         if ($env{'form.ltoken'}) {          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
             my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'});      }
         }  
         if (($env{'form.firsturl'} eq '/adm/email') && ($env{'form.display'})) {  # ---------------------------------------------------------- Determine own load
             if ($env{'form.mailrecip'}) {      my $loadavg;
                 if ($env{'form.mailrecip'} eq "$env{'user.name'}:$env{'user.domain'}") {      {
                     $dest .= (($dest=~/\?/)?'&amp;':'?') . 'display='.&escape($env{'form.display'}).   my $loadfile=Apache::File->new('/proc/loadavg');
                                                            '&amp;mailrecip='.&escape($env{'form.mailrecip'});   $loadavg=<$loadfile>;
                 }      }
             } elsif (($env{'form.username'} eq $env{'user.name'}) && ($env{'form.domain'} eq $env{'user.domain'})) {      $loadavg =~ s/\s.*//g;
                 $dest .= (($dest=~/\?/)?'&amp;':'?') . 'display='.&escape($env{'form.display'}).  
                                                        '&amp;mailrecip='.&escape("$env{'user.name'}:$env{'form.domain'}");      my ($loadpercent,$userloadpercent);
             }      if ($loadlim) {
         }          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
  $r->print(      }
               $start_page      if ($uloadlim) {
              .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'          $userloadpercent=&Apache::lonnet::userload();
              .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',      }
               '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'  
              .$end_page      my $firsturl=
              );      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
         return OK;  
     }  # ----------------------------------------------------------- Get announcements
       my $announcements=&Apache::lonnet::getannounce();
 # ---------------------------------------------------- No valid token, continue  # -------------------------------------------------------- Set login parameters
   
 # ---------------------------- Not possible to really login to domain "public"      my @hexstr=('0','1','2','3','4','5','6','7',
     if ($env{'form.domain'} eq 'public') {                  '8','9','a','b','c','d','e','f');
  $env{'form.domain'}='';      my $lkey='';
  $env{'form.username'}='';      for (0..7) {
     }          $lkey.=$hexstr[rand(15)];
       }
 # ------ Is this page requested because /adm/migrateuser detected an IP change?  
     my %sessiondata;      my $ukey='';
     if ($env{'form.iptoken'}) {      for (0..7) {
         %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});          $ukey.=$hexstr[rand(15)];
         unless ($sessiondata{'sessionserver'}) {      }
             my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});  
             delete($env{'form.iptoken'});      my $lextkey=hex($lkey);
         }      if ($lextkey>2147483647) { $lextkey-=4294967296; }
     }  
 # ----------------------------------------------------------- Process Interface      my $uextkey=hex($ukey);
     $env{'form.interface'}=~s/\W//g;      if ($uextkey>2147483647) { $uextkey-=4294967296; }
   
     (undef,undef,undef,undef,undef,undef,my $clientmobile) =  # -------------------------------------------------------- Store away log token
         &Apache::loncommon::decode_user_agent($r);      my $tokenextras;
       if ($env{'form.role'}) {
     my $iconpath=           $tokenextras = '&role='.&escape($env{'form.role'});
  &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));      }
       if ($env{'form.symb'}) {
     my $domain = &Apache::lonnet::default_login_domain();          if (!$tokenextras) {
     my $defdom = $domain;              $tokenextras = '&';
     if ($lonhost ne '') {          }
         unless ($sessiondata{'sessionserver'}) {          $tokenextras .= '&symb='.&escape($env{'form.symb'});
             my $redirect = &check_loginvia($domain,$lonhost,$lonidsdir,$balcookie);      }
             if ($redirect) {      if ($env{'form.iptoken'}) {
                 $r->print($redirect);          if (!$tokenextras) {
                 return OK;              $tokenextras = '&&';
             }          }
         }          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
     }      }
       if ($env{'form.ltoken'}) {
     if (($sessiondata{'domain'}) &&          my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
         (&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {          if ($info{'linkprot'}) {
         $domain=$sessiondata{'domain'};              if (!$tokenextras) {
     } elsif (($env{'form.domain'}) &&                   $tokenextras = '&&&';
  (&Apache::lonnet::domain($env{'form.domain'},'description'))) {              }
  $domain=$env{'form.domain'};              $tokenextras .= '&linkprot='.&escape($info{'linkprot'});
     }          }
       } elsif ($env{'form.linkkey'}) {
     my $role    = $r->dir_config('lonRole');          if (!$tokenextras) {
     my $loadlim = $r->dir_config('lonLoadLim');              $tokenextras = '&&&';
     my $uloadlim= $r->dir_config('lonUserLoadLim');          }
     my $servadm = $r->dir_config('lonAdmEMail');          $tokenextras .= '&linkkey='.&escape($env{'form.linkkey'});
     my $tabdir  = $r->dir_config('lonTabDir');      }
     my $include = $r->dir_config('lonIncludes');      my $logtoken=Apache::lonnet::reply(
     my $expire  = $r->dir_config('lonExpire');         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
     my $version = $r->dir_config('lonVersion');         $lonhost);
     my $host_name = &Apache::lonnet::hostname($lonhost);  
   # -- If we cannot talk to ourselves, or hostID does not map to a hostname
 # --------------------------------------------- Default values for login fields  #    we are in serious trouble
       
     my ($authusername,$authdomain);      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
     if ($sessiondata{'username'}) {          if ($logtoken eq 'no_such_host') {
         $authusername=$sessiondata{'username'};              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
     } else {          }
         $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});          if ($env{'form.ltoken'}) {
         $authusername=($env{'form.username'}?$env{'form.username'}:'');              &Apache::lonnet::tmpdel($env{'form.ltoken'});
     }              delete($env{'form.ltoken'});
     if ($sessiondata{'domain'}) {          }
         $authdomain=$sessiondata{'domain'};          my $spares='';
     } else {          my (@sparehosts,%spareservers);
         $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});          my $sparesref = &Apache::lonnet::this_host_spares($defdom);
         $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);          if (ref($sparesref) eq 'HASH') {
     }              foreach my $key (keys(%{$sparesref})) {
                   if (ref($sparesref->{$key}) eq 'ARRAY') {
 # ---------------------------------------------------------- Determine own load                      my @sorted = sort { &Apache::lonnet::hostname($a) cmp
     my $loadavg;                                          &Apache::lonnet::hostname($b);
     {                                        } @{$sparesref->{$key}};
  my $loadfile=Apache::File->new('/proc/loadavg');                      if (@sorted) {
  $loadavg=<$loadfile>;                          if ($key eq 'primary') {
     }                              unshift(@sparehosts,@sorted);
     $loadavg =~ s/\s.*//g;                          } elsif ($key eq 'default') {
                               push(@sparehosts,@sorted);
     my ($loadpercent,$userloadpercent);                          }
     if ($loadlim) {                      }
         $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);                  }
     }              }
     if ($uloadlim) {          }
         $userloadpercent=&Apache::lonnet::userload();          foreach my $hostid (@sparehosts) {
     }              next if ($hostid eq $lonhost);
       my $hostname = &Apache::lonnet::hostname($hostid);
     my $firsturl=      next if (($hostname eq '') || ($spareservers{$hostname}));
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});              $spareservers{$hostname} = 1;
               my $protocol = $Apache::lonnet::protocol{$hostid};
 # ----------------------------------------------------------- Get announcements              $protocol = 'http' if ($protocol ne 'https');
     my $announcements=&Apache::lonnet::getannounce();              $spares.='<br /><span style="font-size: larger;"><a href="'.$protocol.'://'.
 # -------------------------------------------------------- Set login parameters                  $hostname.
                   '/adm/login?domain='.$authdomain.'">'.
     my @hexstr=('0','1','2','3','4','5','6','7',                  $hostname.'</a>'.
                 '8','9','a','b','c','d','e','f');                  ' '.&mt('(preferred)').'</span>'.$/;
     my $lkey='';          }
     for (0..7) {          if ($spares) {
         $lkey.=$hexstr[rand(15)];              $spares.= '<br />';
     }          }
           my %all_hostnames = &Apache::lonnet::all_hostnames();
     my $ukey='';          foreach my $hostid (sort
     for (0..7) {      {
         $ukey.=$hexstr[rand(15)];   &Apache::lonnet::hostname($a) cmp
     }      &Apache::lonnet::hostname($b);
       }
     my $lextkey=hex($lkey);      keys(%all_hostnames)) {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }              next if ($hostid eq $lonhost);
               my $hostname = &Apache::lonnet::hostname($hostid);
     my $uextkey=hex($ukey);              next if (($hostname eq '') || ($spareservers{$hostname}));
     if ($uextkey>2147483647) { $uextkey-=4294967296; }              $spareservers{$hostname} = 1;
               my $protocol = $Apache::lonnet::protocol{$hostid};
 # -------------------------------------------------------- Store away log token              $protocol = 'http' if ($protocol ne 'https');
     my ($tokenextras,$tokentype,$linkprot_for_login);              $spares.='<br /><a href="'.$protocol.'://'.
     my @names = ('role','symb','iptoken','ltoken','linkprotuser','linkprotexit','linkprot','linkkey','display');               $hostname.
     foreach my $name (@names) {               '/adm/login?domain='.$authdomain.'">'.
         if ($env{'form.'.$name} ne '') {               $hostname.'</a>';
             if ($name eq 'ltoken') {           }
                 my %info = &Apache::lonnet::tmpget($env{'form.'.$name});           $r->print(
                 if ($info{'linkprot'}) {     '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
                     $linkprot_for_login = $info{'linkprot'};    .'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
                     $tokenextras .= '&linkprot='.&escape($info{'linkprot'});    .'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'
                     foreach my $item ('linkprotuser','linkprotexit') {    .&mt('The LearningOnline Network with CAPA')
                         if ($info{$item}) {    .'</title></head>'
                             $tokenextras .= '&'.$item.'='.&escape($info{$item});    .'<body bgcolor="#FFFFFF">'
                         }    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
                     }    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" alt="broken icon" align="right" />'
                     $tokentype = 'link';    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
                     last;          if ($spares) {
                 }              $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
             } elsif ($env{'form.display'} && ($env{'form.firsturl'} eq '/adm/email')) {                       .'</p>'
                 if (($env{'form.mailrecip'}) ||                       .$spares);
                     ($env{'form.username'} =~ /^$match_username$/) && ($env{'form.domain'} =~ /^$match_domain$/)) {          }
                     $tokenextras .= '&'.$name.'='.&escape($env{'form.display'});          $r->print('</body>'
                     if ($env{'form.mailrecip'}) {                   .'</html>'
                         $tokenextras .= '&mailrecip='.&escape($env{'form.mailrecip'});          );
                     } else {          return OK;
                         $tokenextras .= '&mailrecip='.&escape($env{'form.username'}.':'.$env{'form.domain'});      }
                     }  
                 }  # ----------------------------------------------- Apparently we are in business
             } else {      $servadm=~s/\,/\<br \/\>/g;
                 $tokenextras .= '&'.$name.'='.&escape($env{'form.'.$name});  
                 if (($name eq 'linkkey') || ($name eq 'linkprot')) {  # ----------------------------------------------------------- Front page design
                     if ((($env{'form.retry'}) || ($env{'form.sso'})) &&      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
                         (!$env{'form.ltoken'}) && ($name eq 'linkprot')) {      my $font=&Apache::loncommon::designparm('login.font',$domain);
                         $linkprot_for_login = $env{'form.linkprot'};      my $link=&Apache::loncommon::designparm('login.link',$domain);
                     }      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
                     $tokentype = 'link';      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
                 }      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
             }      my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
         }      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
     }      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
     if ($tokentype) {      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
         $tokenextras .= ":$tokentype";      my $img=&Apache::loncommon::designparm('login.img',$domain);
     }      my $domainlogo=&Apache::loncommon::domainlogo($domain);
     my $logtoken=Apache::lonnet::reply(      my $showbanner = 1;
        'tmpput:'.$ukey.$lkey.'&'.&escape($firsturl).$tokenextras,      my $showmainlogo = 1;
        $lonhost);      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
           $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
 # -- If we cannot talk to ourselves, or hostID does not map to a hostname      }
 #    we are in serious trouble      if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
           $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
     if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {      }
         if ($logtoken eq 'no_such_host') {      my $showadminmail;
             &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');      my @possdoms = &Apache::lonnet::current_machine_domains();
         }      if (grep(/^\Q$domain\E$/,@possdoms)) {
         if ($env{'form.ltoken'}) {          $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
             &Apache::lonnet::tmpdel($env{'form.ltoken'});      }
             delete($env{'form.ltoken'});      my $showcoursecat =
         }          &Apache::loncommon::designparm('login.coursecatalog',$domain);
         my $spares='';      my $shownewuserlink =
         my (@sparehosts,%spareservers);          &Apache::loncommon::designparm('login.newuser',$domain);
         my $sparesref = &Apache::lonnet::this_host_spares($defdom);      my $showhelpdesk =
         if (ref($sparesref) eq 'HASH') {          &Apache::loncommon::designparm('login.helpdesk',$domain);
             foreach my $key (keys(%{$sparesref})) {      my $now=time;
                 if (ref($sparesref->{$key}) eq 'ARRAY') {      my $js = (<<ENDSCRIPT);
                     my @sorted = sort { &Apache::lonnet::hostname($a) cmp  
                                         &Apache::lonnet::hostname($b);  <script type="text/javascript" language="JavaScript">
                                       } @{$sparesref->{$key}};  // <![CDATA[
                     if (@sorted) {  function send()
                         if ($key eq 'primary') {  {
                             unshift(@sparehosts,@sorted);  this.document.server.elements.uname.value
                         } elsif ($key eq 'default') {  =this.document.client.elements.uname.value;
                             push(@sparehosts,@sorted);  
                         }  this.document.server.elements.udom.value
                     }  =this.document.client.elements.udom.value;
                 }  
             }  uextkey=this.document.client.elements.uextkey.value;
         }  lextkey=this.document.client.elements.lextkey.value;
         foreach my $hostid (@sparehosts) {  initkeys();
             next if ($hostid eq $lonhost);  
     my $hostname = &Apache::lonnet::hostname($hostid);  if(this.document.server.action.substr(0,5) === 'http:'){
     next if (($hostname eq '') || ($spareservers{$hostname}));      this.document.server.elements.upass0.value
             $spareservers{$hostname} = 1;          =getCrypted(this.document.client.elements.upass$now.value);
             my $protocol = $Apache::lonnet::protocol{$hostid};  } else {
             $protocol = 'http' if ($protocol ne 'https');      this.document.server.elements.upass0.value
             $spares.='<br /><span style="font-size: larger;"><a href="'.$protocol.'://'.          =this.document.client.elements.upass$now.value;
                 $hostname.  }
                 '/adm/login?domain='.$authdomain.'">'.  
                 $hostname.'</a>'.  this.document.client.elements.uname.value='';
                 ' '.&mt('(preferred)').'</span>'.$/;  this.document.client.elements.upass$now.value='';
         }  
         if ($spares) {  this.document.server.submit();
             $spares.= '<br />';  return false;
         }  }
         my %all_hostnames = &Apache::lonnet::all_hostnames();  
         foreach my $hostid (sort  function enableInput() {
     {      this.document.client.elements.upass$now.removeAttribute("readOnly");
  &Apache::lonnet::hostname($a) cmp      this.document.client.elements.uname.removeAttribute("readOnly");
     &Apache::lonnet::hostname($b);      this.document.client.elements.udom.removeAttribute("readOnly");
     }      return;
     keys(%all_hostnames)) {  }
             next if ($hostid eq $lonhost);  
             my $hostname = &Apache::lonnet::hostname($hostid);  // ]]>
             next if (($hostname eq '') || ($spareservers{$hostname}));  </script>
             $spareservers{$hostname} = 1;  
             my $protocol = $Apache::lonnet::protocol{$hostid};  ENDSCRIPT
             $protocol = 'http' if ($protocol ne 'https');  
             $spares.='<br /><a href="'.$protocol.'://'.      my ($lonhost_in_use,@hosts,%defaultdomconf,$saml_prefix,$saml_landing,
              $hostname.          $samlssotext,$samlnonsso,$samlssoimg,$samlssoalt,$samlssourl,$samltooltip);
              '/adm/login?domain='.$authdomain.'">'.      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
              $hostname.'</a>';      @hosts = &Apache::lonnet::current_machine_ids();
          }      $lonhost_in_use = $lonhost;
          $r->print(      if (@hosts > 1) {
    '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'          foreach my $hostid (@hosts) {
   .'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
   .'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'                  $lonhost_in_use = $hostid;
   .&mt('The LearningOnline Network with CAPA')                  last;
   .'</title></head>'              }
   .'<body bgcolor="#FFFFFF">'          }
   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'      }
   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" alt="broken icon" align="right" />'      $saml_prefix = $defdom.'.login.saml_';
   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');      if ($defaultdomconf{$saml_prefix.$lonhost_in_use}) {
         if ($spares) {          $saml_landing = 1;
             $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')          $samlssotext = $defaultdomconf{$saml_prefix.'text_'.$lonhost_in_use};
                      .'</p>'          $samlnonsso = $defaultdomconf{$saml_prefix.'notsso_'.$lonhost_in_use};
                      .$spares);          $samlssoimg = $defaultdomconf{$saml_prefix.'img_'.$lonhost_in_use};
         }          $samlssoalt = $defaultdomconf{$saml_prefix.'alt_'.$lonhost_in_use};
         $r->print('</body>'          $samlssourl = $defaultdomconf{$saml_prefix.'url_'.$lonhost_in_use};
                  .'</html>'          $samltooltip = $defaultdomconf{$saml_prefix.'title_'.$lonhost_in_use};
         );      }
         return OK;      if ($saml_landing) {
     }         if ($samlssotext eq '') {
              $samlssotext = 'SSO Login';
 # ----------------------------------------------- Apparently we are in business         }
     $servadm=~s/\,/\<br \/\>/g;         if ($samlnonsso eq '') {
              $samlnonsso = 'Non-SSO Login';
 # ----------------------------------------------------------- Front page design         }
     my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);         $js .= <<"ENDSAMLJS";
     my $font=&Apache::loncommon::designparm('login.font',$domain);  
     my $link=&Apache::loncommon::designparm('login.link',$domain);  <script type="text/javascript">
     my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);  // <![CDATA[
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);  function toggleLClogin() {
     my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);      if (document.getElementById('LC_standard_login')) {
     my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);          if (document.getElementById('LC_standard_login').style.display == 'none') {
     my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);              document.getElementById('LC_standard_login').style.display = 'inline-block';
     my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);              if (document.getElementById('LC_login_text')) {
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);                  document.getElementById('LC_login_text').innerHTML = '$samlnonsso';
     my $img=&Apache::loncommon::designparm('login.img',$domain);              }
     my $domainlogo=&Apache::loncommon::domainlogo($domain);              if (document.getElementById('LC_SSO_login')) {
     my $showbanner = 1;                  document.getElementById('LC_SSO_login').style.display = 'none';
     my $showmainlogo = 1;              }
     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {          } else {
         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);              document.getElementById('LC_standard_login').style.display = 'none';
     }              if (document.getElementById('LC_login_text')) {
     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {                  document.getElementById('LC_login_text').innerHTML = '$samlssotext';
         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);              }
     }              if (document.getElementById('LC_SSO_login')) {
     my $showadminmail;                  document.getElementById('LC_SSO_login').style.display = 'inline-block';
     my @possdoms = &Apache::lonnet::current_machine_domains();              }
     if (grep(/^\Q$domain\E$/,@possdoms)) {          }
         $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);      }
     }      return;
     my $showcoursecat =  }
         &Apache::loncommon::designparm('login.coursecatalog',$domain);  
     my $shownewuserlink =   // ]]>
         &Apache::loncommon::designparm('login.newuser',$domain);  </script>
     my $showhelpdesk =  
         &Apache::loncommon::designparm('login.helpdesk',$domain);  ENDSAMLJS
     my $now=time;      }
     my $js = (<<ENDSCRIPT);  
   # --------------------------------------------------- Print login screen header
 <script type="text/javascript" language="JavaScript">  
 // <![CDATA[      my %add_entries = (
 function send()         bgcolor      => "$mainbg",
 {         text         => "$font",
 this.document.server.elements.uname.value         link         => "$link",
 =this.document.client.elements.uname.value;         vlink        => "$vlink",
          alink        => "$alink",
 this.document.server.elements.udom.value                 onload       => 'javascript:enableInput();',);
 =this.document.client.elements.udom.value;  
       my ($headextra,$headextra_exempt);
 uextkey=this.document.client.elements.uextkey.value;      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
 lextkey=this.document.client.elements.lextkey.value;      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
 initkeys();      if ($headextra) {
           my $omitextra;
 this.document.server.elements.upass0.value          if ($headextra_exempt ne '') {
     =getCrypted(this.document.client.elements.upass$now.value);              my @exempt = split(',',$headextra_exempt);
               my $ip = &Apache::lonnet::get_requestor_ip();
 this.document.client.elements.uname.value='';              if (grep(/^\Q$ip\E$/,@exempt)) {
 this.document.client.elements.upass$now.value='';                  $omitextra = 1;
               }
 this.document.server.submit();          }
 return false;          unless ($omitextra) {
 }              my $confname = $defdom.'-domainconfig';
               if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
 function enableInput() {                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
     this.document.client.elements.upass$now.removeAttribute("readOnly");                  unless ($extra eq '-1') {
     this.document.client.elements.uname.removeAttribute("readOnly");                      $js .= "\n".$extra."\n";
     this.document.client.elements.udom.removeAttribute("readOnly");                  }
     return;              }
 }          }
       }
 // ]]>  
 </script>      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
          { 'redirect'       => [$expire,'/adm/roles'],
 ENDSCRIPT   'add_entries' => \%add_entries,
    'only_body'   => 1,}));
     my ($lonhost_in_use,@hosts,%defaultdomconf,$saml_prefix,$saml_landing,  
         $samlssotext,$samlnonsso,$samlssoimg,$samlssoalt,$samlssourl,$samltooltip,  # ----------------------------------------------------------------------- Texts
         $samlwindow);  
     %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);      my %lt=&Apache::lonlocal::texthash(
     @hosts = &Apache::lonnet::current_machine_ids();            'un'       => 'Username',
     $lonhost_in_use = $lonhost;            'pw'       => 'Password',
     if (@hosts > 1) {            'dom'      => 'Domain',
         foreach my $hostid (@hosts) {            'perc'     => 'percent',
             if (&Apache::lonnet::host_domain($hostid) eq $defdom) {            'load'     => 'Server Load',
                 $lonhost_in_use = $hostid;            'userload' => 'User Load',
                 last;            'catalog'  => 'Course/Community Catalog',
             }            'log'      => 'Log in',
         }            'help'     => 'Log-in Help',
     }            'serv'     => 'Server',
     $saml_prefix = $defdom.'.login.saml_';            'servadm'  => 'Server Administration',
     if ($defaultdomconf{$saml_prefix.$lonhost_in_use}) {            'helpdesk' => 'Contact Helpdesk',
         $saml_landing = 1;            'forgotpw' => 'Forgot password?',
         $samlssotext = $defaultdomconf{$saml_prefix.'text_'.$lonhost_in_use};            'newuser'  => 'New User?',
         $samlnonsso = $defaultdomconf{$saml_prefix.'notsso_'.$lonhost_in_use};            'change'   => 'Change?',
         $samlssoimg = $defaultdomconf{$saml_prefix.'img_'.$lonhost_in_use};         );
         $samlssoalt = $defaultdomconf{$saml_prefix.'alt_'.$lonhost_in_use};  # -------------------------------------------------- Change password field name
         $samlssourl = $defaultdomconf{$saml_prefix.'url_'.$lonhost_in_use};  
         $samltooltip = $defaultdomconf{$saml_prefix.'title_'.$lonhost_in_use};      my $forgotpw = &forgotpwdisplay(%lt);
         $samlwindow = $defaultdomconf{$saml_prefix.'window_'.$lonhost_in_use};      $forgotpw .= '<br />' if $forgotpw;
     }      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
     if ($saml_landing) {      if ($loginhelp) {
        if ($samlssotext eq '') {          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
            $samlssotext = 'SSO Login';      }
        }  
        if ($samlnonsso eq '') {  # ---------------------------------------------------- Serve out DES JavaScript
            $samlnonsso = 'Non-SSO Login';      {
        }      my $jsh=Apache::File->new($include."/londes.js");
        $js .= <<"ENDSAMLJS";      $r->print(<$jsh>);
       }
 <script type="text/javascript">  # ---------------------------------------------------------- Serve rest of page
 // <![CDATA[  
 function toggleLClogin() {      $r->print(
     if (document.getElementById('LC_standard_login')) {      '<div class="LC_Box"'
         if (document.getElementById('LC_standard_login').style.display == 'none') {     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
             document.getElementById('LC_standard_login').style.display = 'inline-block';  );
             if (document.getElementById('LC_login_text')) {  
                 document.getElementById('LC_login_text').innerHTML = '$samlnonsso';      $r->print(<<ENDSERVERFORM);
             }  <form name="server" action="/adm/authenticate" method="post" target="_top">
             if ( document.client.uname ) { document.client.uname.focus(); }     <input type="hidden" name="logtoken" value="$logtoken" />
             if (document.getElementById('LC_SSO_login')) {     <input type="hidden" name="serverid" value="$lonhost" />
                 document.getElementById('LC_SSO_login').style.display = 'none';     <input type="hidden" name="uname" value="" />
             }     <input type="hidden" name="upass0" value="" />
         } else {     <input type="hidden" name="udom" value="" />
             document.getElementById('LC_standard_login').style.display = 'none';     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
             if (document.getElementById('LC_login_text')) {     <input type="hidden" name="localres" value="$env{'form.localres'}" />
                 document.getElementById('LC_login_text').innerHTML = '$samlssotext';    </form>
             }  ENDSERVERFORM
             if (document.getElementById('LC_SSO_login')) {      my $coursecatalog;
                 document.getElementById('LC_SSO_login').style.display = 'inline-block';      if (($showcoursecat eq '') || ($showcoursecat)) {
             }          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
         }      }
     }      my $newuserlink;
     return;      if ($shownewuserlink) {
 }          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
       }
 // ]]>      my $logintitle =
 </script>          '<h2 class="LC_hcell"'
          .' style="background:'.$loginbox_header_bgcol.';'
 ENDSAMLJS         .' color:'.$loginbox_header_textcol.'">'
     }         .$lt{'log'}
          .'</h2>';
 # --------------------------------------------------- Print login screen header  
       my $noscript_warning='<noscript><span class="LC_warning"><b>'
     my %add_entries = (                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
        bgcolor      => "$mainbg",                          .'</b></span></noscript>';
        text         => "$font",      my $helpdeskscript;
        link         => "$link",      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
        vlink        => "$vlink",                                         $authdomain,\$helpdeskscript,
        alink        => "$alink",                                         $showhelpdesk,\@possdoms);
                onload       => 'javascript:enableInput();',);  
       my $mobileargs;
     my ($headextra,$headextra_exempt);      if ($clientmobile) {
     $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};          $mobileargs = 'autocapitalize="off" autocorrect="off"';
     $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};      }
     if ($headextra) {      my $loginform=(<<LFORM);
         my $omitextra;  <form name="client" action="" onsubmit="return(send())" id="lclogin">
         if ($headextra_exempt ne '') {    <input type="hidden" name="lextkey" value="$lextkey" />
             my @exempt = split(',',$headextra_exempt);    <input type="hidden" name="uextkey" value="$uextkey" />
             my $ip = &Apache::lonnet::get_requestor_ip();    <b><label for="uname">$lt{'un'}</label>:</b><br />
             if (grep(/^\Q$ip\E$/,@exempt)) {    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
                 $omitextra = 1;    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
             }    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
         }    <b><label for="udom">$lt{'dom'}</label>:</b><br />
         unless ($omitextra) {    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
             my $confname = $defdom.'-domainconfig';    <input type="submit" value="$lt{'log'}" />
             if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {  </form>
                 my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));  LFORM
                 unless ($extra eq '-1') {  
                     $js .= "\n".$extra."\n";      if ($showbanner) {
                 }          $r->print(<<HEADER);
             }  <!-- The LON-CAPA Header -->
         }  <div style="background:$pgbg;margin:0;width:100%;">
     }    <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
   </div>
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,  HEADER
        { 'redirect'       => [$expire,'/adm/roles'],       }
  'add_entries' => \%add_entries,  
  'only_body'   => 1,}));      my $stdauthformstyle = 'inline-block';
       my $ssoauthstyle = 'none';
 # ----------------------------------------------------------------------- Texts      my $logintype;
       $r->print('<div style="float:left;margin-top:0;">');
     my %lt=&Apache::lonlocal::texthash(      if ($saml_landing) {
           'un'       => 'Username',          $ssoauthstyle = 'inline-block';
           'pw'       => 'Password',          $stdauthformstyle = 'none';
           'dom'      => 'Domain',          $logintype = $samlssotext;
           'perc'     => 'percent',          my $ssologin = '/adm/sso';
           'load'     => 'Server Load',          if ($samlssourl  ne '') {
           'userload' => 'User Load',              $ssologin = $samlssourl;
           'catalog'  => 'Course/Community Catalog',          }
           'log'      => 'Log in',          if ($env{'form.firsturl'} ne '') {
           'help'     => 'Log-in Help',              my $querystring = 'origurl=';
           'serv'     => 'Server',              if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
           'servadm'  => 'Server Administration',                  $querystring .= &uri_escape_utf8($env{'form.firsturl'});
           'helpdesk' => 'Contact Helpdesk',              } else {
           'forgotpw' => 'Forgot password?',                  $querystring .= &uri_escape($env{'form.firsturl'});
           'newuser'  => 'New User?',              }
           'change'   => 'Change?',              $querystring = &HTML::Entities::encode($querystring,"'");
        );              $ssologin .= (($ssologin=~/\?/)?'&amp;':'?') . $querystring;
 # -------------------------------------------------- Change password field name          }
           if ($env{'form.ltoken'} ne '') {
     my $forgotpw = &forgotpwdisplay(%lt);              $querystring .= (($querystring eq '')?'':'&amp;') . 'ltoken='.
     $forgotpw .= '<br />' if $forgotpw;                                &HTML::Entities::encode(&uri_escape($env{'form.ltoken'}));
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);          } elsif ($env{'form.linkkey'}) {
     if ($loginhelp) {              $querystring .= (($querystring eq '')?'':'&amp;') . 'linkkey='.
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';                                &HTML::Entities::encode(&uri_escape($env{'form.linkkey'}));
     }          }
           my $ssohref;
 # ---------------------------------------------------- Serve out DES JavaScript          if ($samlssoimg ne '') {
     {              $ssohref = '<a href="'.$ssologin.'" title="'.$samltooltip.'"><img src="'.$samlssoimg.'" alt="'.$samlssoalt.'" /></a>';
     my $jsh=Apache::File->new($include."/londes.js");          } else {
     $r->print(<$jsh>);              $ssohref = '<a href="'.$ssologin.'">'.$samlssotext.'</a>';
     }          }
 # ---------------------------------------------------------- Serve rest of page          if (($env{'form.saml'} eq 'no') ||
               (($env{'form.username'} ne '') && ($env{'form.domain'} ne ''))) {
     $r->print(              $ssoauthstyle = 'none';
     '<div class="LC_Box"'              $stdauthformstyle = 'inline-block';
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'              $logintype = $samlnonsso;
 );          }
           $r->print(<<ENDSAML);
     $r->print(<<ENDSERVERFORM);  <p>
 <form name="server" action="/adm/authenticate" method="post" target="_top">  Log-in type:
    <input type="hidden" name="logtoken" value="$logtoken" />  <span style="font-weight:bold" id="LC_login_text">$logintype</span><br />
    <input type="hidden" name="serverid" value="$lonhost" />  <span><a href="javascript:toggleLClogin();" style="color:#000000">$lt{'change'}</a></span>
    <input type="hidden" name="uname" value="" />  </p>
    <input type="hidden" name="upass0" value="" />  <div style="display:$ssoauthstyle" id="LC_SSO_login">
    <input type="hidden" name="udom" value="" />  <div class="LC_Box" style="padding-top: 10px;">
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />  $ssohref
    <input type="hidden" name="localres" value="$env{'form.localres'}" />  $noscript_warning
   </form>  </div>
 ENDSERVERFORM  <div class="LC_Box" style="padding-top: 10px;">
     my $coursecatalog;  $loginhelp
     if (($showcoursecat eq '') || ($showcoursecat)) {  $contactblock
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';  $coursecatalog
     }  </div>
     my $newuserlink;  </div>
     if ($shownewuserlink) {  ENDSAML
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';      } else {
     }          if ($env{'form.ltoken'}) {
     my $logintitle =              &Apache::lonnet::tmpdel($env{'form.ltoken'});
         '<h2 class="LC_hcell"'              delete($env{'form.ltoken'});
        .' style="background:'.$loginbox_header_bgcol.';'          }
        .' color:'.$loginbox_header_textcol.'">'      }
        .$lt{'log'}  
        .'</h2>';      $r->print(<<ENDLOGIN);
   <div style="display:$stdauthformstyle;" id="LC_standard_login">
     my $noscript_warning='<noscript><span class="LC_warning"><b>'  <div class="LC_Box" style="background:$loginbox_bg;">
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')    $logintitle
                         .'</b></span></noscript>';    $loginform
     my $helpdeskscript;    $noscript_warning
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,  </div>
                                        $authdomain,\$helpdeskscript,   
                                        $showhelpdesk,\@possdoms);  <div class="LC_Box" style="padding-top: 10px;">
     $loginhelp
     my $mobileargs;    $forgotpw
     if ($clientmobile) {    $contactblock
         $mobileargs = 'autocapitalize="off" autocorrect="off"';     $newuserlink
     }    $coursecatalog
     my $loginform=(<<LFORM);  </div>
 <form name="client" action="" onsubmit="return(send())" id="lclogin">  </div>
   <input type="hidden" name="lextkey" value="$lextkey" />  
   <input type="hidden" name="uextkey" value="$uextkey" />  ENDLOGIN
   <b><label for="uname">$lt{'un'}</label>:</b><br />      $r->print('</div><div>'."\n");
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />      if ($showmainlogo) {
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />          $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />      }
   <b><label for="udom">$lt{'dom'}</label>:</b><br />  $r->print(<<ENDTOP);
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />  $announcements
   <input type="submit" value="$lt{'log'}" />  </div>
 </form>  <hr style="clear:both;" />
 LFORM  ENDTOP
       my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
     if ($showbanner) {      $domainrow = <<"END";
         my $alttext = &Apache::loncommon::designparm('login.alttext_img',$domain);        <tr>
         if ($alttext eq '') {         <td  align="left" valign="top">
             $alttext = 'The Learning Online Network with CAPA';          <small><b>$lt{'dom'}:&nbsp;</b></small>
         }         </td>
         $r->print(<<HEADER);         <td  align="left" valign="top">
 <!-- The LON-CAPA Header -->          <small><tt>&nbsp;$domain</tt></small>
 <div style="background:$pgbg;margin:0;width:100%;">         </td>
   <img src="$img" border="0" alt="$alttext" class="LC_maxwidth" id="lcloginbanner" />        </tr>
 </div>  END
 HEADER      $serverrow = <<"END";
     }        <tr>
          <td  align="left" valign="top">
     my $stdauthformstyle = 'inline-block';          <small><b>$lt{'serv'}:&nbsp;</b></small>
     my $ssoauthstyle = 'none';         </td>
     my $sso_onclick;         <td align="left" valign="top">
     my $logintype;          <small><tt>&nbsp;$lonhost ($role)</tt></small>
     $r->print('<div style="float:left;margin-top:0;">');         </td>
     if ($saml_landing) {        </tr>
         $ssoauthstyle = 'inline-block';  END
         $stdauthformstyle = 'none';      if ($loadlim) {
         $logintype = $samlssotext;          $loadrow = <<"END";
         my $ssologin = '/adm/sso';        <tr>
         if ($samlssourl  ne '') {         <td align="left" valign="top">
             $ssologin = $samlssourl;          <small><b>$lt{'load'}:&nbsp;</b></small>
         }         </td>
         my $ssologin_for_js = &js_escape($ssologin);         <td align="left" valign="top">
         my $querystr_for_js;          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
         if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {         </td>
             my $querystring;        </tr>
             if ($env{'form.firsturl'} ne '') {  END
                 $querystring = 'origurl=';      }
                 if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {      if ($uloadlim) {
                     $querystring .= &uri_escape_utf8($env{'form.firsturl'});          $userloadrow = <<"END";
                 } else {        <tr>
                     $querystring .= &uri_escape($env{'form.firsturl'});         <td align="left" valign="top">
                 }          <small><b>$lt{'userload'}:&nbsp;</b></small>
                 $querystring = &HTML::Entities::encode($querystring,"'");         </td>
             }         <td align="left" valign="top">
             if ($env{'form.ltoken'} ne '') {          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
                 $querystring .= (($querystring eq '')?'':'&amp;') . 'ltoken='.         </td>
                                   &HTML::Entities::encode(&uri_escape($env{'form.ltoken'}));        </tr>
             } elsif ($env{'form.linkkey'}) {  END
                 $querystring .= (($querystring eq '')?'':'&amp;') . 'linkkey='.      }
                                   &HTML::Entities::encode(&uri_escape($env{'form.linkkey'}));      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
             }          $versionrow = <<"END";
             if ($querystring ne '') {        <tr>
                 $ssologin .= (($ssologin=~/\?/)?'&amp;':'?') . $querystring;         <td colspan="2" align="left">
                 $querystr_for_js = &js_escape($querystring);          <small>$version</small>
             }         </td>
         } elsif ($logtoken ne '') {        </tr>
             $ssologin .= (($ssologin=~/\?/)?'&amp;':'?') . 'logtoken='.$logtoken;  END
             $querystr_for_js = &js_escape('logtoken='.$logtoken);      }
         }  
         my $ssohref;      $r->print(<<ENDDOCUMENT);
         if ($samlwindow) {      <div style="float: left;">
             $sso_onclick = <<"ENDJS";       <table border="0" cellspacing="0" cellpadding="0">
 if (document.getElementById('LC_sso_login_link')) {  $domainrow
     var ssoelem = document.getElementById('LC_sso_login_link')  $serverrow
     ssoelem.addEventListener('click',samlWinFunction,false);  $loadrow    
     var windows = {};  $userloadrow
     function samlWinFunction(evt) {  $versionrow
         evt.preventDefault();       </table>
         var url = '$ssologin_for_js';      </div>
         var name = 'lcssowin';      <div style="float: right;">
         var querystr = '$querystr_for_js';      $domainlogo
         if (querystr) {      </div>
             url += '?'+querystr+'&lcssowin=1';      <br style="clear:both;" />
         } else {   </div>
             url += '?lcssowin=1';  
         }  <script type="text/javascript">
         if ((typeof windows[name] !== 'undefined') && (!windows[name].closed)) {  // <![CDATA[
             windows[name].close();  // the if prevents the script error if the browser can not handle this
         }  if ( document.client.uname ) { document.client.uname.focus(); }
         windows[name]=window.open(url,name,'width=350,height=600');  // ]]>
         windows[name].focus();  </script>
         return false;  $helpdeskscript
     }  
 }  ENDDOCUMENT
 ENDJS      my %endargs = ( 'noredirectlink' => 1, );
         }      $r->print(&Apache::loncommon::end_page(\%endargs));
         if ($samlssoimg ne '') {      return OK;
             $ssohref = '<a href="'.$ssologin.'" title="'.$samltooltip.'" id="LC_sso_login_link">'.  }
                        '<img src="'.$samlssoimg.'" alt="'.$samlssoalt.'" id="lcssobutton" /></a>';  
         } else {  sub check_loginvia {
             $ssohref = '<a href="'.$ssologin.'" id="LC_sso_login_link">'.$samlssotext.'</a>';      my ($domain,$lonhost,$lonidsdir,$balcookie,$linkprot) = @_;
         }      if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {
         if (($env{'form.saml'} eq 'no') ||          return;
             (($env{'form.username'} ne '') && ($env{'form.domain'} ne ''))) {      }
             $ssoauthstyle = 'none';      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
             $stdauthformstyle = 'inline-block';      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
             $logintype = $samlnonsso;      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
         }      my $output;
         $r->print(<<ENDSAML);      if ($loginvia ne '') {
 <p>          my $noredirect;
 Log-in type:          my $ip = &Apache::lonnet::get_requestor_ip();  
 <span style="font-weight:bold" id="LC_login_text">$logintype</span><br />          if ($ip eq '127.0.0.1') {
 <span><a href="javascript:toggleLClogin();" style="color:#000000">$lt{'change'}</a></span>              $noredirect = 1;
 </p>          } else {
 <div style="display:$ssoauthstyle" id="LC_SSO_login">              if ($loginvia_exempt ne '') {
 <div class="LC_Box" style="padding-top: 10px;">                  my @exempt = split(',',$loginvia_exempt);
 $ssohref                  if (grep(/^\Q$ip\E$/,@exempt)) {
 $noscript_warning                      $noredirect = 1;
 </div>                  }
 <div class="LC_Box" style="padding-top: 10px;">              }
 $loginhelp          }
 $contactblock          unless ($noredirect) {
 $coursecatalog              my ($newhost,$path);
 </div>              if ($loginvia =~ /:/) {
 </div>                  ($newhost,$path) = split(':',$loginvia);
 ENDSAML              } else {
     } else {                  $newhost = $loginvia;
         if ($env{'form.ltoken'}) {              }
             &Apache::lonnet::tmpdel($env{'form.ltoken'});              if ($newhost ne $lonhost) {
             delete($env{'form.ltoken'});                  if (&Apache::lonnet::hostname($newhost) ne '') {
         }                      if ($balcookie) {
     }                          my ($balancer,$cookie) = split(/:/,$balcookie);
     my $in_frame_js;                          if ($cookie =~ /^($match_domain)_($match_username)_([a-f0-9]+)$/) {
     if ($linkprot_for_login) {                              my ($udom,$uname,$cookieid) = ($1,$2,$3);
         my ($linkprotector,$linkproturi) = split(/:/,$linkprot_for_login,2);                              unless (&Apache::lonnet::delbalcookie($cookie,$balancer) eq 'ok') {
         if (($linkprotector =~ /^\d+(c|d)$/) && ($linkproturi =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$})) {                                  if ((-d $lonidsdir) && (opendir(my $dh,$lonidsdir))) {
             my $set_target;                                      while (my $filename=readdir($dh)) {
             if (($env{'form.retry'}) || ($env{'form.sso'})) {                                          if ($filename=~/^(\Q$uname\E_\d+_\Q$udom\E_$match_lonid)\.id$/) {
                 if ($linkproturi eq $env{'form.firsturl'}) {                                              my $handle = $1;
                     $set_target = "    document.server.target = '_self';";                                              my %hash =
                 }                                                  &Apache::lonnet::get_sessionfile_vars($handle,$lonidsdir,
             } else {                                                                                       ['request.balancercookie',
                 $set_target = <<ENDTARG;                                                                                        'user.linkedenv']);
     var linkproturi = '$linkproturi';                                              if ($hash{'request.balancercookie'} eq "$balancer:$cookieid") {
     var path = document.location.pathname.replace( new RegExp('^/adm/launch'),'');                                                  if (unlink("$lonidsdir/$filename")) {
     if (linkproturi == path) {                                                      if (($hash{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
         document.server.target = '_self';                                                          (-l "$lonidsdir/$hash{'user.linkedenv'}.id") &&
     }                                                          (readlink("$lonidsdir/$hash{'user.linkedenv'}.id") eq "$lonidsdir/$filename")) {
 ENDTARG                                                          unlink("$lonidsdir/$hash{'user.linkedenv'}.id");
             }                                                      }
             $in_frame_js = <<ENDJS;                                                  }
 <script type="text/javascript">                                              }
 // <![CDATA[                                              last;
 if ((window.self !== window.top) && (document.server.target != '_self')) {                                          }
     $set_target                                      }
     $sso_onclick                                      closedir($dh);
 }                                  }
 // ]]>                              }
 </script>                          }
 ENDJS                      }
         }                      $output = &redirect_page($newhost,$path,$linkprot);
     } elsif ($samlwindow) {                  }
         $in_frame_js = <<ENDJS;              }
 <script type="text/javascript">          }
 // <![CDATA[      }
 if ((window.self !== window.top) && (document.server.target != '_self')) {      return $output;
     $sso_onclick  }
 }  
 // ]]>  sub redirect_page {
 </script>      my ($desthost,$path,$linkprot) = @_;
 ENDJS      my $hostname = &Apache::lonnet::hostname($desthost);
     }      my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
     $r->print(<<ENDLOGIN);      unless ($path =~ m{^/}) {
 <div style="display:$stdauthformstyle;" id="LC_standard_login">          $path = '/'.$path;
 <div class="LC_Box" style="background:$loginbox_bg;">      }
   $logintitle      my $url = $protocol.'://'.$hostname.$path;
   $loginform      if ($env{'form.firsturl'} ne '') {
   $noscript_warning          my $querystring;
 </div>          if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
                 $querystring = &uri_escape_utf8($env{'form.firsturl'});
 <div class="LC_Box" style="padding-top: 10px;">          } else {
   $loginhelp              $querystring = &uri_escape($env{'form.firsturl'});
   $forgotpw          }
   $contactblock          $querystring = &HTML::Entities::encode($querystring,"'");
   $newuserlink          $url .='?firsturl='.$querystring
   $coursecatalog      }
 </div>      if ($linkprot) {
 </div>          my $ltoken = &Apache::lonnet::tmpput({linkprot => $linkprot},$desthost);
           if ($ltoken) {
 ENDLOGIN              $url .= (($url =~ /\?/) ? '&amp;' : '?').'ltoken='.$ltoken;
     $r->print('</div><div>'."\n");          }
     if ($showmainlogo) {      }
         my $alttext = &Apache::loncommon::designparm('login.alttext_logo',$domain);      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
         $r->print(' <img src="'.$logo.'" alt="'.$alttext.'" class="LC_maxwidth" id="lcloginmainlogo" />'."\n");                                                      {'redirect' => [0,$url],});
     }      my $end_page   = &Apache::loncommon::end_page();
 $r->print(<<ENDTOP);      return $start_page.$end_page;
 $announcements  }
 </div>  
 <hr style="clear:both;" />  sub contactdisplay {
 ENDTOP      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);          $possdoms) = @_;
     $domainrow = <<"END";      my $contactblock;
       <tr>      my $origmail;
        <td  align="left" valign="top">      if (ref($possdoms) eq 'ARRAY') {
         <small><b>$lt{'dom'}:&nbsp;</b></small>          if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
        </td>              $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
        <td  align="left" valign="top">          }
         <small><tt>&nbsp;$domain</tt></small>      }
        </td>      my $requestmail =
       </tr>          &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
 END                                                   $authdomain,$origmail);
     $serverrow = <<"END";      unless ($showhelpdesk eq '0') {
       <tr>          if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
        <td  align="left" valign="top">              $showhelpdesk = 1;
         <small><b>$lt{'serv'}:&nbsp;</b></small>          } else {
        </td>              $showhelpdesk = 0;
        <td align="left" valign="top">          }
         <small><tt>&nbsp;$lonhost ($role)</tt></small>      }
        </td>      if ($servadm && $showadminmail) {
       </tr>          $contactblock .= $$lt{'servadm'}.':<br />'.
 END                           '<tt>'.$servadm.'</tt><br />';
     if ($loadlim) {      }
         $loadrow = <<"END";      if ($showhelpdesk) {
       <tr>          $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
        <td align="left" valign="top">          my $thisurl = &escape('/adm/login');
         <small><b>$lt{'load'}:&nbsp;</b></small>          $$helpdeskscript = <<"ENDSCRIPT";
        </td>  <script type="text/javascript">
        <td align="left" valign="top">  // <![CDATA[
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>  function helpdesk() {
        </td>      var possdom = document.client.udom.value;
       </tr>      var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
 END      if (codedom == '') {
     }          codedom = "$authdomain";
     if ($uloadlim) {      }
         $userloadrow = <<"END";      var querystr = "origurl=$thisurl&codedom="+codedom;
       <tr>      document.location.href = "/adm/helpdesk?"+querystr;
        <td align="left" valign="top">      return;
         <small><b>$lt{'userload'}:&nbsp;</b></small>  }
        </td>  // ]]>
        <td align="left" valign="top">  </script>
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>  ENDSCRIPT
        </td>      }
       </tr>      return $contactblock;
 END  }
     }  
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {  sub forgotpwdisplay {
         $versionrow = <<"END";      my (%lt) = @_;
       <tr>      my $prompt_for_resetpw = 1;
        <td colspan="2" align="left">      if ($prompt_for_resetpw) {
         <small>$version</small>          return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
        </td>      }
       </tr>      return;
 END  }
     }  
   sub coursecatalog_link {
     $r->print(<<ENDDOCUMENT);      my ($linkname) = @_;
     <div style="float: left;">      return <<"END";
      <table border="0" cellspacing="0" cellpadding="0">        <a href="/adm/coursecatalog">$linkname</a>
 $domainrow  END
 $serverrow  }
 $loadrow      
 $userloadrow  sub newuser_link {
 $versionrow      my ($linkname) = @_;
      </table>      return '<a href="/adm/createaccount">'.$linkname.'</a>';
     </div>  }
     <div style="float: right;">  
     $domainlogo  1;
     </div>  __END__
     <br style="clear:both;" />  
  </div>  
   
 $in_frame_js  
 <script type="text/javascript">  
 // <![CDATA[  
 // the if prevents the script error if the browser can not handle this  
 if ( document.client.uname ) { document.client.uname.focus(); }  
 // ]]>  
 </script>  
 $helpdeskscript  
   
 ENDDOCUMENT  
     my %endargs = ( 'noredirectlink' => 1, );  
     $r->print(&Apache::loncommon::end_page(\%endargs));  
     return OK;  
 }  
   
 sub check_loginvia {  
     my ($domain,$lonhost,$lonidsdir,$balcookie) = @_;  
     if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {  
         return;  
     }  
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);  
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};  
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};  
     my $output;  
     if ($loginvia ne '') {  
         my $noredirect;  
         my $ip = &Apache::lonnet::get_requestor_ip();  
         if ($ip eq '127.0.0.1') {  
             $noredirect = 1;  
         } else {  
             if ($loginvia_exempt ne '') {  
                 my @exempt = split(',',$loginvia_exempt);  
                 if (grep(/^\Q$ip\E$/,@exempt)) {  
                     $noredirect = 1;  
                 }  
             }  
         }  
         unless ($noredirect) {  
             my ($newhost,$path);  
             if ($loginvia =~ /:/) {  
                 ($newhost,$path) = split(':',$loginvia);  
             } else {  
                 $newhost = $loginvia;  
             }  
             if ($newhost ne $lonhost) {  
                 if (&Apache::lonnet::hostname($newhost) ne '') {  
                     if ($balcookie) {  
                         my ($balancer,$cookie) = split(/:/,$balcookie);  
                         if ($cookie =~ /^($match_domain)_($match_username)_([a-f0-9]+)$/) {  
                             my ($udom,$uname,$cookieid) = ($1,$2,$3);  
                             unless (&Apache::lonnet::delbalcookie($cookie,$balancer) eq 'ok') {  
                                 if ((-d $lonidsdir) && (opendir(my $dh,$lonidsdir))) {  
                                     while (my $filename=readdir($dh)) {  
                                         if ($filename=~/^(\Q$uname\E_\d+_\Q$udom\E_$match_lonid)\.id$/) {  
                                             my $handle = $1;  
                                             my %hash =  
                                                 &Apache::lonnet::get_sessionfile_vars($handle,$lonidsdir,  
                                                                                      ['request.balancercookie',  
                                                                                       'user.linkedenv']);  
                                             if ($hash{'request.balancercookie'} eq "$balancer:$cookieid") {  
                                                 if (unlink("$lonidsdir/$filename")) {  
                                                     if (($hash{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&  
                                                         (-l "$lonidsdir/$hash{'user.linkedenv'}.id") &&  
                                                         (readlink("$lonidsdir/$hash{'user.linkedenv'}.id") eq "$lonidsdir/$filename")) {  
                                                         unlink("$lonidsdir/$hash{'user.linkedenv'}.id");  
                                                     }  
                                                 }  
                                             }  
                                             last;  
                                         }  
                                     }  
                                     closedir($dh);  
                                 }  
                             }  
                         }  
                     }  
                     $output = &redirect_page($newhost,$path);  
                 }  
             }  
         }  
     }  
     return $output;  
 }  
   
 sub redirect_page {  
     my ($desthost,$path) = @_;  
     my $hostname = &Apache::lonnet::hostname($desthost);  
     my $protocol = $Apache::lonnet::protocol{$desthost};  
     $protocol = 'http' if ($protocol ne 'https');  
     unless ($path =~ m{^/}) {  
         $path = '/'.$path;  
     }  
     my $url = $protocol.'://'.$hostname.$path;  
     my $args = {};  
     if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {  
         $url = $protocol.'://'.$hostname.$env{'form.firsturl'};  
         if (($env{'form.ltoken'}) || ($env{'form.linkprot'} ne '') ||  
             ($env{'form.linkkey'} ne '')) {  
             my %link_info;  
             if ($env{'form.ltoken'}) {  
                 %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});  
                 &Apache::lonnet::tmpdel($env{'form.ltoken'});  
                 $args->{'only_body'} = 1;  
             } elsif ($env{'form.linkprot'}) {  
                 $link_info{'linkprot'} = $env{'form.linkprot'};  
                 foreach my $item ('linkprotuser','linkprotexit') {  
                     if ($env{'form.'.$item}) {  
                         $link_info{$item} = $env{'form.'.$item};  
                     }  
                 }  
                 $args->{'only_body'} = 1;  
             } elsif ($env{'form.linkkey'} ne '') {  
                 $link_info{'linkkey'} = $env{'form.linkkey'};  
             }  
             my $token = &Apache::lonnet::tmpput(\%link_info,$desthost,'link');  
             unless (($token eq 'con_lost') || ($token eq 'refused') ||  
                     ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {  
                 $url .= '?ltoken='.$token;  
             }  
         }  
     } else {  
         my $querystring;  
         if ($env{'form.firsturl'} ne '') {  
             if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {  
                 $querystring = &uri_escape_utf8($env{'form.firsturl'});  
             } else {  
                 $querystring = &uri_escape($env{'form.firsturl'});  
             }  
             $querystring = &HTML::Entities::encode($querystring,"'");  
             $querystring = '?firsturl='.$querystring;  
         }  
         if ($env{'form.ltoken'}) {  
             my %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});  
             &Apache::lonnet::tmpdel($env{'form.ltoken'});  
             my $token = &Apache::lonnet::tmpput(\%link_info,$desthost,'link');  
             unless (($token eq 'con_lost') || ($token eq 'refused') || ($token =~ /^error:/) ||  
                     ($token eq 'unknown_cmd') || ($token eq 'no_such_host')) {  
                 unless (($path eq '/adm/roles') || ($path eq '/adm/login')) {  
                     $url = $protocol.'://'.$hostname.'/adm/roles';  
                 }  
                 $querystring .= (($querystring =~/^\?/)?'&amp;':'?') . 'ttoken='.$token;  
             }  
         }  
         $url .= $querystring;  
     }  
     $args->{'redirect'} = [0,$url];  
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,$args);  
     my $end_page   = &Apache::loncommon::end_page();  
     return $start_page.$end_page;  
 }  
   
 sub contactdisplay {  
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,  
         $possdoms) = @_;  
     my $contactblock;  
     my $origmail;  
     if (ref($possdoms) eq 'ARRAY') {  
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {   
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};  
         }  
     }  
     my $requestmail =   
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',  
                                                  $authdomain,$origmail);  
     unless ($showhelpdesk eq '0') {  
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {  
             $showhelpdesk = 1;  
         } else {  
             $showhelpdesk = 0;  
         }  
     }  
     if ($servadm && $showadminmail) {  
         $contactblock .= $$lt{'servadm'}.':<br />'.  
                          '<tt>'.$servadm.'</tt><br />';  
     }  
     if ($showhelpdesk) {  
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';  
         my $thisurl = &escape('/adm/login');  
         $$helpdeskscript = <<"ENDSCRIPT";  
 <script type="text/javascript">  
 // <![CDATA[  
 function helpdesk() {  
     var possdom = document.client.udom.value;  
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');  
     if (codedom == '') {  
         codedom = "$authdomain";  
     }  
     var querystr = "origurl=$thisurl&codedom="+codedom;  
     document.location.href = "/adm/helpdesk?"+querystr;  
     return;  
 }  
 // ]]>  
 </script>  
 ENDSCRIPT  
     }  
     return $contactblock;  
 }  
   
 sub forgotpwdisplay {  
     my (%lt) = @_;  
     my $prompt_for_resetpw = 1;   
     if ($prompt_for_resetpw) {  
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';  
     }  
     return;  
 }  
   
 sub coursecatalog_link {  
     my ($linkname) = @_;  
     return <<"END";  
       <a href="/adm/coursecatalog">$linkname</a>  
 END  
 }  
   
 sub newuser_link {  
     my ($linkname) = @_;  
     return '<a href="/adm/createaccount">'.$linkname.'</a>';  
 }  
   
 sub decode_token {  
     my ($info) = @_;  
     my ($firsturl,@rest)=split(/\&/,$info);  
     my %form;  
     if ($firsturl ne '') {  
         $form{'firsturl'} = &unescape($firsturl);  
     }  
     foreach my $item (@rest) {  
         my ($key,$value) = split(/=/,$item);  
         $form{$key} = &unescape($value);  
     }  
     return %form;  
 }  
   
 1;  
 __END__  

Removed from v.1.158.2.13.2.9  
changed lines
  Added in v.1.191


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>