Diff for /loncom/auth/lonlogin.pm between versions 1.158.2.6.2.1 and 1.171

version 1.158.2.6.2.1, 2017/10/14 20:59:35 version 1.171, 2017/09/25 00:36: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;  use LONCAPA;
 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']);    'token','role','symb','iptoken']);
     if (!defined($env{'form.firsturl'})) {      if (!defined($env{'form.firsturl'})) {
         &Apache::lonacc::get_posted_cgi($r,['firsturl']);          &Apache::lonacc::get_posted_cgi($r,['firsturl']);
     }      }
   
 # -- check if they are a migrating user  # -- check if they are a migrating user
     if (defined($env{'form.token'})) {      if (defined($env{'form.token'})) {
  return &Apache::migrateuser::handler($r);   return &Apache::migrateuser::handler($r);
     }      }
   
 # For "public user" - remove any exising "public" cookie, as user really wants to log-in  # For "public user" - remove any exising "public" cookie, as user really wants to log-in
     my ($handle,$lonidsdir,$expirepub,$userdom);      my ($handle,$lonidsdir,$expirepub,$userdom);
     unless ($r->header_only) {      unless ($r->header_only) {
         $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);          $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
         if ($handle ne '') {          if ($handle ne '') {
             $lonidsdir=$r->dir_config('lonIDsDir');              $lonidsdir=$r->dir_config('lonIDsDir');
             if ($handle=~/^publicuser\_/) {              if ($handle=~/^publicuser\_/) {
                 unlink($r->dir_config('lonIDsDir')."/$handle.id");                  unlink($r->dir_config('lonIDsDir')."/$handle.id");
                 undef($handle);                  undef($handle);
                 undef($userdom);                  undef($userdom);
                 $expirepub = 1;                  $expirepub = 1;
             }              }
         }          }
     }      }
   
     &Apache::loncommon::no_cache($r);      &Apache::loncommon::no_cache($r);
     &Apache::lonlocal::get_language_handle($r);      &Apache::lonlocal::get_language_handle($r);
     &Apache::loncommon::content_type($r,'text/html');      &Apache::loncommon::content_type($r,'text/html');
     if ($expirepub) {      if ($expirepub) {
         my $c = new CGI::Cookie(-name    => 'lonID',          my $c = new CGI::Cookie(-name    => 'lonPubID',
                                 -value   => '',                                  -value   => '',
                                 -expires => '-10y',);                                  -expires => '-10y',);
         $r->header_out('Set-cookie' => $c);          $r->header_out('Set-cookie' => $c);
     } elsif (($handle eq '') && ($userdom ne '')) {      } elsif (($handle eq '') && ($userdom ne '')) {
         my $c = new CGI::Cookie(-name    => 'lonID',          my $c = new CGI::Cookie(-name    => 'lonID',
                                 -value   => '',                                  -value   => '',
                                 -expires => '-10y',);                                  -expires => '-10y',);
         $r->headers_out->add('Set-cookie' => $c);          $r->headers_out->add('Set-cookie' => $c);
     }      }
     $r->send_http_header;      $r->send_http_header;
     return OK if $r->header_only;      return OK if $r->header_only;
   
   
 # Are we re-routing?  # Are we re-routing?
     my $londocroot = $r->dir_config('lonDocRoot');       my $londocroot = $r->dir_config('lonDocRoot');
     if (-e "$londocroot/lon-status/reroute.txt") {      if (-e "$londocroot/lon-status/reroute.txt") {
  &Apache::lonauth::reroute($r);   &Apache::lonauth::reroute($r);
  return OK;   return OK;
     }      }
   
 #  #
 # If browser sent an old cookie for which the session file had been removed  # If browser sent an old cookie for which the session file had been removed
 # check if configuration for user's domain has a portal URL set.  If so  # check if configuration for user's domain has a portal URL set.  If so
 # switch user's log-in to the portal.  # switch user's log-in to the portal.
 #  #
   
     if (($handle eq '') && ($userdom ne '')) {      if (($handle eq '') && ($userdom ne '')) {
         my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);          my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
         if ($domdefaults{'portal_def'} =~ /^https?\:/) {          if ($domdefaults{'portal_def'} =~ /^https?\:/) {
             my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,              my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                           {'redirect' => [0,$domdefaults{'portal_def'}],});                                            {'redirect' => [0,$domdefaults{'portal_def'}],});
             my $end_page   = &Apache::loncommon::end_page();              my $end_page   = &Apache::loncommon::end_page();
             $r->print($start_page.$end_page);              $r->print($start_page.$end_page);
             return OK;              return OK;
         }          }
     }      }
   
     $env{'form.firsturl'} =~ s/(`)/'/g;      $env{'form.firsturl'} =~ s/(`)/'/g;
   
 # -------------------------------- Prevent users from attempting to login twice  # -------------------------------- Prevent users from attempting to login twice
     my $handle = &Apache::lonnet::check_for_valid_session($r);      if ($handle ne '') {
     if ($handle ne '') {          &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
         my $lonidsdir=$r->dir_config('lonIDsDir');   my $start_page =
         if ($handle=~/^publicuser\_/) {      &Apache::loncommon::start_page('Already logged in');
 # For "public user" - remove it, we apparently really want to login   my $end_page =
     unlink($r->dir_config('lonIDsDir')."/$handle.id");      &Apache::loncommon::end_page();
         } else {          my $dest = '/adm/roles';
 # Indeed, a valid token is found          if ($env{'form.firsturl'} ne '') {
             &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);              $dest = $env{'form.firsturl'};
     my $start_page =           }
         &Apache::loncommon::start_page('Already logged in');   $r->print(
     my $end_page =                     $start_page
         &Apache::loncommon::end_page();                   .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
             my $dest = '/adm/roles';                   .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
             if ($env{'form.firsturl'} ne '') {                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
                 $dest = $env{'form.firsturl'};                    .$end_page
             }                   );
     $r->print(          return OK;
                   $start_page      }
                  .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'  
                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',  # ---------------------------------------------------- No valid token, continue
                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'  
                  .$end_page  # ---------------------------- Not possible to really login to domain "public"
                  );      if ($env{'form.domain'} eq 'public') {
             return OK;   $env{'form.domain'}='';
         }   $env{'form.username'}='';
     }      }
   
 # ---------------------------------------------------- No valid token, continue  # ------ Is this page requested because /adm/migrateuser detected an IP change?
       my %sessiondata;
 # ---------------------------- Not possible to really login to domain "public"      if ($env{'form.iptoken'}) {
     if ($env{'form.domain'} eq 'public') {          %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
  $env{'form.domain'}='';          unless ($sessiondata{'sessionserver'}) {
  $env{'form.username'}='';              my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
     }              delete($env{'form.iptoken'});
           }
 # ------ Is this page requested because /adm/migrateuser detected an IP change?      }
     my %sessiondata;  # ----------------------------------------------------------- Process Interface
     if ($env{'form.iptoken'}) {      $env{'form.interface'}=~s/\W//g;
         %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});  
         unless ($sessiondata{'sessionserver'}) {      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
             my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});          &Apache::loncommon::decode_user_agent();
             delete($env{'form.iptoken'});  
         }      my $iconpath=
     }   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
 # ----------------------------------------------------------- Process Interface  
     $env{'form.interface'}=~s/\W//g;      my $lonhost = $r->dir_config('lonHostID');
       my $domain = &Apache::lonnet::default_login_domain();
     (undef,undef,undef,undef,undef,undef,my $clientmobile) =      my $defdom = $domain;
         &Apache::loncommon::decode_user_agent();      if ($lonhost ne '') {
           unless ($sessiondata{'sessionserver'}) {
     my $iconpath=               my $redirect = &check_loginvia($domain,$lonhost);
  &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));              if ($redirect) {
                   $r->print($redirect);
     my $lonhost = $r->dir_config('lonHostID');                  return OK;
     my $domain = &Apache::lonnet::default_login_domain();              }
     my $defdom = $domain;          }
     if ($lonhost ne '') {      }
         unless ($sessiondata{'sessionserver'}) {  
             my $redirect = &check_loginvia($domain,$lonhost);      if (($sessiondata{'domain'}) &&
             if ($redirect) {          (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
                 $r->print($redirect);          $domain=$sessiondata{'domain'};
                 return OK;      } elsif (($env{'form.domain'}) &&
             }   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
         }   $domain=$env{'form.domain'};
     }      }
   
     if (($sessiondata{'domain'}) &&      my $role    = $r->dir_config('lonRole');
         (&Apache::lonnet::domain($env{'form.domain'},'description'))) {      my $loadlim = $r->dir_config('lonLoadLim');
         $domain=$sessiondata{'domain'};      my $uloadlim= $r->dir_config('lonUserLoadLim');
     } elsif (($env{'form.domain'}) &&       my $servadm = $r->dir_config('lonAdmEMail');
  (&Apache::lonnet::domain($env{'form.domain'},'description'))) {      my $tabdir  = $r->dir_config('lonTabDir');
  $domain=$env{'form.domain'};      my $include = $r->dir_config('lonIncludes');
     }      my $expire  = $r->dir_config('lonExpire');
       my $version = $r->dir_config('lonVersion');
     my $role    = $r->dir_config('lonRole');      my $host_name = &Apache::lonnet::hostname($lonhost);
     my $loadlim = $r->dir_config('lonLoadLim');  
     my $uloadlim= $r->dir_config('lonUserLoadLim');  # --------------------------------------------- Default values for login fields
     my $servadm = $r->dir_config('lonAdmEMail');     
     my $tabdir  = $r->dir_config('lonTabDir');      my ($authusername,$authdomain);
     my $include = $r->dir_config('lonIncludes');      if ($sessiondata{'username'}) {
     my $expire  = $r->dir_config('lonExpire');          $authusername=$sessiondata{'username'};
     my $version = $r->dir_config('lonVersion');      } else {
     my $host_name = &Apache::lonnet::hostname($lonhost);          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
           $authusername=($env{'form.username'}?$env{'form.username'}:'');
 # --------------------------------------------- Default values for login fields      }
           if ($sessiondata{'domain'}) {
     my ($authusername,$authdomain);          $authdomain=$sessiondata{'domain'};
     if ($sessiondata{'username'}) {      } else {
         $authusername=$sessiondata{'username'};          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
     } else {          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
         $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});      }
         $authusername=($env{'form.username'}?$env{'form.username'}:'');  
     }  # ---------------------------------------------------------- Determine own load
     if ($sessiondata{'domain'}) {      my $loadavg;
         $authdomain=$sessiondata{'domain'};      {
     } else {   my $loadfile=Apache::File->new('/proc/loadavg');
         $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});   $loadavg=<$loadfile>;
         $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);      }
     }      $loadavg =~ s/\s.*//g;
   
 # ---------------------------------------------------------- Determine own load      my ($loadpercent,$userloadpercent);
     my $loadavg;      if ($loadlim) {
     {          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
  my $loadfile=Apache::File->new('/proc/loadavg');      }
  $loadavg=<$loadfile>;      if ($uloadlim) {
     }          $userloadpercent=&Apache::lonnet::userload();
     $loadavg =~ s/\s.*//g;      }
   
     my ($loadpercent,$userloadpercent);      my $firsturl=
     if ($loadlim) {      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
         $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);  
     }  # ----------------------------------------------------------- Get announcements
     if ($uloadlim) {      my $announcements=&Apache::lonnet::getannounce();
         $userloadpercent=&Apache::lonnet::userload();  # -------------------------------------------------------- Set login parameters
     }  
       my @hexstr=('0','1','2','3','4','5','6','7',
     my $firsturl=                  '8','9','a','b','c','d','e','f');
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});      my $lkey='';
       for (0..7) {
 # ----------------------------------------------------------- Get announcements          $lkey.=$hexstr[rand(15)];
     my $announcements=&Apache::lonnet::getannounce();      }
 # -------------------------------------------------------- Set login parameters  
       my $ukey='';
     my @hexstr=('0','1','2','3','4','5','6','7',      for (0..7) {
                 '8','9','a','b','c','d','e','f');          $ukey.=$hexstr[rand(15)];
     my $lkey='';      }
     for (0..7) {  
         $lkey.=$hexstr[rand(15)];      my $lextkey=hex($lkey);
     }      if ($lextkey>2147483647) { $lextkey-=4294967296; }
   
     my $ukey='';      my $uextkey=hex($ukey);
     for (0..7) {      if ($uextkey>2147483647) { $uextkey-=4294967296; }
         $ukey.=$hexstr[rand(15)];  
     }  # -------------------------------------------------------- Store away log token
       my $tokenextras;
     my $lextkey=hex($lkey);      if ($env{'form.role'}) {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }          $tokenextras = '&role='.&escape($env{'form.role'});
       }
     my $uextkey=hex($ukey);      if ($env{'form.symb'}) {
     if ($uextkey>2147483647) { $uextkey-=4294967296; }          if (!$tokenextras) {
               $tokenextras = '&';
 # -------------------------------------------------------- Store away log token          }
     my $tokenextras;          $tokenextras .= '&symb='.&escape($env{'form.symb'});
     if ($env{'form.role'}) {      }
         $tokenextras = '&role='.&escape($env{'form.role'});      if ($env{'form.iptoken'}) {
     }          if (!$tokenextras) {
     if ($env{'form.symb'}) {              $tokenextras = '&&';
         if (!$tokenextras) {          }
             $tokenextras = '&';          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
         }      }
         $tokenextras .= '&symb='.&escape($env{'form.symb'});      my $logtoken=Apache::lonnet::reply(
     }         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
     if ($env{'form.iptoken'}) {         $lonhost);
         if (!$tokenextras) {  
             $tokenextras = '&&';  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
         }  #    we are in serious trouble
         $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});  
     }      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
     my $logtoken=Apache::lonnet::reply(          if ($logtoken eq 'no_such_host') {
        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
        $lonhost);          }
           my $spares='';
 # -- If we cannot talk to ourselves, or hostID does not map to a hostname   my $last;
 #    we are in serious trouble          foreach my $hostid (sort
       {
     if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {   &Apache::lonnet::hostname($a) cmp
         if ($logtoken eq 'no_such_host') {      &Apache::lonnet::hostname($b);
             &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');      }
         }      keys(%Apache::lonnet::spareid)) {
         my $spares='';              next if ($hostid eq $lonhost);
  my $last;      my $hostname = &Apache::lonnet::hostname($hostid);
         foreach my $hostid (sort      next if (($last eq $hostname) || ($hostname eq ''));
     {              $spares.='<br /><font size="+1"><a href="http://'.
  &Apache::lonnet::hostname($a) cmp                  $hostname.
     &Apache::lonnet::hostname($b);                  '/adm/login?domain='.$authdomain.'">'.
     }                  $hostname.'</a>'.
     keys(%Apache::lonnet::spareid)) {                  ' '.&mt('(preferred)').'</font>'.$/;
             next if ($hostid eq $lonhost);      $last=$hostname;
     my $hostname = &Apache::lonnet::hostname($hostid);          }
     next if (($last eq $hostname) || ($hostname eq ''));          if ($spares) {
             $spares.='<br /><font size="+1"><a href="http://'.              $spares.= '<br />';
                 $hostname.          }
                 '/adm/login?domain='.$authdomain.'">'.          my %all_hostnames = &Apache::lonnet::all_hostnames();
                 $hostname.'</a>'.          foreach my $hostid (sort
                 ' '.&mt('(preferred)').'</font>'.$/;      {
     $last=$hostname;   &Apache::lonnet::hostname($a) cmp
         }      &Apache::lonnet::hostname($b);
         if ($spares) {      }
             $spares.= '<br />';      keys(%all_hostnames)) {
         }              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
         my %all_hostnames = &Apache::lonnet::all_hostnames();              my $hostname = &Apache::lonnet::hostname($hostid);
         foreach my $hostid (sort              next if (($last eq $hostname) || ($hostname eq ''));
     {              $spares.='<br /><a href="http://'.
  &Apache::lonnet::hostname($a) cmp               $hostname.
     &Apache::lonnet::hostname($b);               '/adm/login?domain='.$authdomain.'">'.
     }               $hostname.'</a>';
     keys(%all_hostnames)) {              $last=$hostname;
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});           }
             my $hostname = &Apache::lonnet::hostname($hostid);           $r->print(
             next if (($last eq $hostname) || ($hostname eq ''));     '<html>'
             $spares.='<br /><a href="http://'.    .'<head><title>'
              $hostname.    .&mt('The LearningOnline Network with CAPA')
              '/adm/login?domain='.$authdomain.'">'.    .'</title></head>'
              $hostname.'</a>';    .'<body bgcolor="#FFFFFF">'
             $last=$hostname;    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
          }    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
          $r->print(    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
    '<html>'          if ($spares) {
   .'<head><title>'              $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
   .&mt('The LearningOnline Network with CAPA')                       .'</p>'
   .'</title></head>'                       .$spares);
   .'<body bgcolor="#FFFFFF">'          }
   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'          $r->print('</body>'
   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'                   .'</html>'
   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');          );
         if ($spares) {          return OK;
             $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')      }
                      .'</p>'  
                      .$spares);  # ----------------------------------------------- Apparently we are in business
         }      $servadm=~s/\,/\<br \/\>/g;
         $r->print('</body>'  
                  .'</html>'  # ----------------------------------------------------------- Front page design
         );      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
         return OK;      my $font=&Apache::loncommon::designparm('login.font',$domain);
     }      my $link=&Apache::loncommon::designparm('login.link',$domain);
       my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
 # ----------------------------------------------- Apparently we are in business      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
     $servadm=~s/\,/\<br \/\>/g;      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
       my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
 # ----------------------------------------------------------- Front page design      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
     my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
     my $font=&Apache::loncommon::designparm('login.font',$domain);      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
     my $link=&Apache::loncommon::designparm('login.link',$domain);      my $img=&Apache::loncommon::designparm('login.img',$domain);
     my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);      my $domainlogo=&Apache::loncommon::domainlogo($domain);
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);      my $showbanner = 1;
     my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);      my $showmainlogo = 1;
     my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
     my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
     my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);      }
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);      if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
     my $img=&Apache::loncommon::designparm('login.img',$domain);          $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
     my $domainlogo=&Apache::loncommon::domainlogo($domain);      }
     my $showbanner = 1;      my $showadminmail;
     my $showmainlogo = 1;      my @possdoms = &Apache::lonnet::current_machine_domains();
     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {      if (grep(/^\Q$domain\E$/,@possdoms)) {
         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);          $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
     }      }
     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {      my $showcoursecat =
         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);          &Apache::loncommon::designparm('login.coursecatalog',$domain);
     }      my $shownewuserlink =
     my $showadminmail;          &Apache::loncommon::designparm('login.newuser',$domain);
     my @possdoms = &Apache::lonnet::current_machine_domains();      my $showhelpdesk =
     if (grep(/^\Q$domain\E$/,@possdoms)) {          &Apache::loncommon::designparm('login.helpdesk',$domain);
         $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);      my $now=time;
     }      my $js = (<<ENDSCRIPT);
     my $showcoursecat =  
         &Apache::loncommon::designparm('login.coursecatalog',$domain);  <script type="text/javascript" language="JavaScript">
     my $shownewuserlink =   // <![CDATA[
         &Apache::loncommon::designparm('login.newuser',$domain);  function send()
     my $showhelpdesk =  {
         &Apache::loncommon::designparm('login.helpdesk',$domain);  this.document.server.elements.uname.value
     my $now=time;  =this.document.client.elements.uname.value;
     my $js = (<<ENDSCRIPT);  
   this.document.server.elements.udom.value
 <script type="text/javascript" language="JavaScript">  =this.document.client.elements.udom.value;
 // <![CDATA[  
 function send()  uextkey=this.document.client.elements.uextkey.value;
 {  lextkey=this.document.client.elements.lextkey.value;
 this.document.server.elements.uname.value  initkeys();
 =this.document.client.elements.uname.value;  
   if(this.document.server.action.substr(0,5) === 'http:'){
 this.document.server.elements.udom.value      this.document.server.elements.upass0.value
 =this.document.client.elements.udom.value;          =getCrypted(this.document.client.elements.upass$now.value);
   } else {
 uextkey=this.document.client.elements.uextkey.value;      this.document.server.elements.upass0.value
 lextkey=this.document.client.elements.lextkey.value;          =this.document.client.elements.upass$now.value;
 initkeys();  }
   
 this.document.server.elements.upass0.value  this.document.client.elements.uname.value='';
     =getCrypted(this.document.client.elements.upass$now.value);  this.document.client.elements.upass$now.value='';
   
 this.document.client.elements.uname.value='';  this.document.server.submit();
 this.document.client.elements.upass$now.value='';  return false;
   }
 this.document.server.submit();  
 return false;  function enableInput() {
 }      this.document.client.elements.upass$now.removeAttribute("readOnly");
       this.document.client.elements.uname.removeAttribute("readOnly");
 function enableInput() {      this.document.client.elements.udom.removeAttribute("readOnly");
     this.document.client.elements.upass$now.removeAttribute("readOnly");      return;
     this.document.client.elements.uname.removeAttribute("readOnly");  }
     this.document.client.elements.udom.removeAttribute("readOnly");  
     return;  // ]]>
 }  </script>
   
 // ]]>  ENDSCRIPT
 </script>  
   # --------------------------------------------------- Print login screen header
 ENDSCRIPT  
       my %add_entries = (
 # --------------------------------------------------- Print login screen header         bgcolor      => "$mainbg",
          text         => "$font",
     my %add_entries = (         link         => "$link",
        bgcolor      => "$mainbg",         vlink        => "$vlink",
        text         => "$font",         alink        => "$alink",
        link         => "$link",                 onload       => 'javascript:enableInput();',);
        vlink        => "$vlink",  
        alink        => "$alink",      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
                onload       => 'javascript:enableInput();',);      @hosts = &Apache::lonnet::current_machine_ids();
       $lonhost_in_use = $lonhost;
     my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);      if (@hosts > 1) {
     @hosts = &Apache::lonnet::current_machine_ids();          foreach my $hostid (@hosts) {
     $lonhost_in_use = $lonhost;              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
     if (@hosts > 1) {                  $lonhost_in_use = $hostid;
         foreach my $hostid (@hosts) {                  last;
             if (&Apache::lonnet::host_domain($hostid) eq $defdom) {              }
                 $lonhost_in_use = $hostid;          }
                 last;      }
             }      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
         }      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
     }      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
     %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);      if ($headextra) {
     $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};          my $omitextra;
     $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};          if ($headextra_exempt ne '') {
     if ($headextra) {              my @exempt = split(',',$headextra_exempt);
         my $omitextra;              my $ip = $ENV{'REMOTE_ADDR'};
         if ($headextra_exempt ne '') {              if (grep(/^\Q$ip\E$/,@exempt)) {
             my @exempt = split(',',$headextra_exempt);                  $omitextra = 1;
             my $ip = $ENV{'REMOTE_ADDR'};              }
             if (grep(/^\Q$ip\E$/,@exempt)) {          }
                 $omitextra = 1;          unless ($omitextra) {
             }              my $confname = $defdom.'-domainconfig';
         }              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
         unless ($omitextra) {                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
             my $confname = $defdom.'-domainconfig';                  unless ($extra eq '-1') {
             if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {                      $js .= "\n".$extra."\n";
                 my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));                  }
                 unless ($extra eq '-1') {              }
                     $js .= "\n".$extra."\n";          }
                 }      }
             }  
         }      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
     }         { 'redirect'       => [$expire,'/adm/roles'],
    'add_entries' => \%add_entries,
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,   'only_body'   => 1,}));
        { 'redirect'       => [$expire,'/adm/roles'],   
  'add_entries' => \%add_entries,  # ----------------------------------------------------------------------- Texts
  'only_body'   => 1,}));  
       my %lt=&Apache::lonlocal::texthash(
 # ----------------------------------------------------------------------- Texts            'un'       => 'Username',
             'pw'       => 'Password',
     my %lt=&Apache::lonlocal::texthash(            'dom'      => 'Domain',
           'un'       => 'Username',            'perc'     => 'percent',
           'pw'       => 'Password',            'load'     => 'Server Load',
           'dom'      => 'Domain',            'userload' => 'User Load',
           'perc'     => 'percent',            'catalog'  => 'Course/Community Catalog',
           'load'     => 'Server Load',            'log'      => 'Log in',
           'userload' => 'User Load',            'help'     => 'Log-in Help',
           'catalog'  => 'Course/Community Catalog',            'serv'     => 'Server',
           'log'      => 'Log in',            'servadm'  => 'Server Administration',
           'help'     => 'Log-in Help',            'helpdesk' => 'Contact Helpdesk',
           'serv'     => 'Server',            'forgotpw' => 'Forgot password?',
           'servadm'  => 'Server Administration',            'newuser'  => 'New User?',
           'helpdesk' => 'Contact Helpdesk',         );
           'forgotpw' => 'Forgot password?',  # -------------------------------------------------- Change password field name
           'newuser'  => 'New User?',  
        );      my $forgotpw = &forgotpwdisplay(%lt);
 # -------------------------------------------------- Change password field name      $forgotpw .= '<br />' if $forgotpw;
       my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
     my $forgotpw = &forgotpwdisplay(%lt);      if ($loginhelp) {
     $forgotpw .= '<br />' if $forgotpw;          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);      }
     if ($loginhelp) {  
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';  # ---------------------------------------------------- Serve out DES JavaScript
     }      {
       my $jsh=Apache::File->new($include."/londes.js");
 # ---------------------------------------------------- Serve out DES JavaScript      $r->print(<$jsh>);
     {      }
     my $jsh=Apache::File->new($include."/londes.js");  # ---------------------------------------------------------- Serve rest of page
     $r->print(<$jsh>);  
     }      $r->print(
 # ---------------------------------------------------------- Serve rest of page      '<div class="LC_Box"'
      .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
     $r->print(  );
     '<div class="LC_Box"'  
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'      $r->print(<<ENDSERVERFORM);
 );  <form name="server" action="/adm/authenticate" method="post" target="_top">
      <input type="hidden" name="logtoken" value="$logtoken" />
     $r->print(<<ENDSERVERFORM);     <input type="hidden" name="serverid" value="$lonhost" />
 <form name="server" action="/adm/authenticate" method="post" target="_top">     <input type="hidden" name="uname" value="" />
    <input type="hidden" name="logtoken" value="$logtoken" />     <input type="hidden" name="upass0" value="" />
    <input type="hidden" name="serverid" value="$lonhost" />     <input type="hidden" name="udom" value="" />
    <input type="hidden" name="uname" value="" />     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
    <input type="hidden" name="upass0" value="" />     <input type="hidden" name="localres" value="$env{'form.localres'}" />
    <input type="hidden" name="udom" value="" />    </form>
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />  ENDSERVERFORM
    <input type="hidden" name="localres" value="$env{'form.localres'}" />      my $coursecatalog;
   </form>      if (($showcoursecat eq '') || ($showcoursecat)) {
 ENDSERVERFORM          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
     my $coursecatalog;      }
     if (($showcoursecat eq '') || ($showcoursecat)) {      my $newuserlink;
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';      if ($shownewuserlink) {
     }          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
     my $newuserlink;      }
     if ($shownewuserlink) {      my $logintitle =
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';          '<h2 class="LC_hcell"'
     }         .' style="background:'.$loginbox_header_bgcol.';'
     my $logintitle =         .' color:'.$loginbox_header_textcol.'">'
         '<h2 class="LC_hcell"'         .$lt{'log'}
        .' style="background:'.$loginbox_header_bgcol.';'         .'</h2>';
        .' color:'.$loginbox_header_textcol.'">'  
        .$lt{'log'}      my $noscript_warning='<noscript><span class="LC_warning"><b>'
        .'</h2>';                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                           .'</b></span></noscript>';
     my $noscript_warning='<noscript><span class="LC_warning"><b>'      my $helpdeskscript;
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                         .'</b></span></noscript>';                                         $authdomain,\$helpdeskscript,
     my $helpdeskscript;                                         $showhelpdesk,\@possdoms);
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,  
                                        $authdomain,\$helpdeskscript,      my $mobileargs;
                                        $showhelpdesk,\@possdoms);      if ($clientmobile) {
           $mobileargs = 'autocapitalize="off" autocorrect="off"';
     my $mobileargs;      }
     if ($clientmobile) {      my $loginform=(<<LFORM);
         $mobileargs = 'autocapitalize="off" autocorrect="off"';   <form name="client" action="" onsubmit="return(send())">
     }    <input type="hidden" name="lextkey" value="$lextkey" />
     my $loginform=(<<LFORM);    <input type="hidden" name="uextkey" value="$uextkey" />
 <form name="client" action="" onsubmit="return(send())">    <b><label for="uname">$lt{'un'}</label>:</b><br />
   <input type="hidden" name="lextkey" value="$lextkey" />    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
   <input type="hidden" name="uextkey" value="$uextkey" />    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
   <b><label for="uname">$lt{'un'}</label>:</b><br />    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />    <b><label for="udom">$lt{'dom'}</label>:</b><br />
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />    <input type="submit" value="$lt{'log'}" />
   <b><label for="udom">$lt{'dom'}</label>:</b><br />  </form>
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />  LFORM
   <input type="submit" value="$lt{'log'}" />  
 </form>      if ($showbanner) {
 LFORM          $r->print(<<HEADER);
   <!-- The LON-CAPA Header -->
     if ($showbanner) {  <div style="background:$pgbg;margin:0;width:100%;">
         $r->print(<<HEADER);    <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
 <!-- The LON-CAPA Header -->  </div>
 <div style="background:$pgbg;margin:0;width:100%;">  HEADER
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />      }
 </div>      $r->print(<<ENDTOP);
 HEADER  <div style="float:left;margin-top:0;">
     }  <div class="LC_Box" style="background:$loginbox_bg;">
     $r->print(<<ENDTOP);    $logintitle
 <div style="float:left;margin-top:0;">    $loginform
 <div class="LC_Box" style="background:$loginbox_bg;">    $noscript_warning
   $logintitle  </div>
   $loginform   
   $noscript_warning  <div class="LC_Box" style="padding-top: 10px;">
 </div>    $loginhelp
       $forgotpw
 <div class="LC_Box" style="padding-top: 10px;">    $contactblock
   $loginhelp    $newuserlink
   $forgotpw    $coursecatalog
   $contactblock  </div>
   $newuserlink  </div>
   $coursecatalog  
 </div>  <div>
 </div>  ENDTOP
       if ($showmainlogo) {
 <div>          $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
 ENDTOP      }
     if ($showmainlogo) {  $r->print(<<ENDTOP);
         $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");  $announcements
     }  </div>
 $r->print(<<ENDTOP);  <hr style="clear:both;" />
 $announcements  ENDTOP
 </div>      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
 <hr style="clear:both;" />      $domainrow = <<"END";
 ENDTOP        <tr>
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);         <td  align="left" valign="top">
     $domainrow = <<"END";          <small><b>$lt{'dom'}:&nbsp;</b></small>
       <tr>         </td>
        <td  align="left" valign="top">         <td  align="left" valign="top">
         <small><b>$lt{'dom'}:&nbsp;</b></small>          <small><tt>&nbsp;$domain</tt></small>
        </td>         </td>
        <td  align="left" valign="top">        </tr>
         <small><tt>&nbsp;$domain</tt></small>  END
        </td>      $serverrow = <<"END";
       </tr>        <tr>
 END         <td  align="left" valign="top">
     $serverrow = <<"END";          <small><b>$lt{'serv'}:&nbsp;</b></small>
       <tr>         </td>
        <td  align="left" valign="top">         <td align="left" valign="top">
         <small><b>$lt{'serv'}:&nbsp;</b></small>          <small><tt>&nbsp;$lonhost ($role)</tt></small>
        </td>         </td>
        <td align="left" valign="top">        </tr>
         <small><tt>&nbsp;$lonhost ($role)</tt></small>  END
        </td>      if ($loadlim) {
       </tr>          $loadrow = <<"END";
 END        <tr>
     if ($loadlim) {         <td align="left" valign="top">
         $loadrow = <<"END";          <small><b>$lt{'load'}:&nbsp;</b></small>
       <tr>         </td>
        <td align="left" valign="top">         <td align="left" valign="top">
         <small><b>$lt{'load'}:&nbsp;</b></small>          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
        </td>         </td>
        <td align="left" valign="top">        </tr>
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>  END
        </td>      }
       </tr>      if ($uloadlim) {
 END          $userloadrow = <<"END";
     }        <tr>
     if ($uloadlim) {         <td align="left" valign="top">
         $userloadrow = <<"END";          <small><b>$lt{'userload'}:&nbsp;</b></small>
       <tr>         </td>
        <td align="left" valign="top">         <td align="left" valign="top">
         <small><b>$lt{'userload'}:&nbsp;</b></small>          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
        </td>         </td>
        <td align="left" valign="top">        </tr>
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>  END
        </td>      }
       </tr>      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
 END          $versionrow = <<"END";
     }        <tr>
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {         <td colspan="2" align="left">
         $versionrow = <<"END";          <small>$version</small>
       <tr>         </td>
        <td colspan="2" align="left">        </tr>
         <small>$version</small>  END
        </td>      }
       </tr>  
 END      $r->print(<<ENDDOCUMENT);
     }      <div style="float: left;">
        <table border="0" cellspacing="0" cellpadding="0">
     $r->print(<<ENDDOCUMENT);  $domainrow
     <div style="float: left;">  $serverrow
      <table border="0" cellspacing="0" cellpadding="0">  $loadrow    
 $domainrow  $userloadrow
 $serverrow  $versionrow
 $loadrow           </table>
 $userloadrow      </div>
 $versionrow      <div style="float: right;">
      </table>      $domainlogo
     </div>      </div>
     <div style="float: right;">      <br style="clear:both;" />
     $domainlogo   </div>
     </div>  
     <br style="clear:both;" />  <script type="text/javascript">
  </div>  // <![CDATA[
   // the if prevents the script error if the browser can not handle this
 <script type="text/javascript">  if ( document.client.uname ) { document.client.uname.focus(); }
 // <![CDATA[  // ]]>
 // the if prevents the script error if the browser can not handle this  </script>
 if ( document.client.uname ) { document.client.uname.focus(); }  $helpdeskscript
 // ]]>  
 </script>  ENDDOCUMENT
 $helpdeskscript      my %endargs = ( 'noredirectlink' => 1, );
       $r->print(&Apache::loncommon::end_page(\%endargs));
 ENDDOCUMENT      return OK;
     my %endargs = ( 'noredirectlink' => 1, );  }
     $r->print(&Apache::loncommon::end_page(\%endargs));  
     return OK;  sub check_loginvia {
 }      my ($domain,$lonhost) = @_;
       if ($domain eq '' || $lonhost eq '') {
 sub check_loginvia {          return;
     my ($domain,$lonhost) = @_;      }
     if ($domain eq '' || $lonhost eq '') {      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
         return;      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
     }      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);      my $output;
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};      if ($loginvia ne '') {
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};          my $noredirect;
     my $output;          my $ip = $ENV{'REMOTE_ADDR'};
     if ($loginvia ne '') {          if ($ip eq '127.0.0.1') {
         my $noredirect;              $noredirect = 1;
         my $ip = $ENV{'REMOTE_ADDR'};          } else {
         if ($ip eq '127.0.0.1') {              if ($loginvia_exempt ne '') {
             $noredirect = 1;                  my @exempt = split(',',$loginvia_exempt);
         } else {                  if (grep(/^\Q$ip\E$/,@exempt)) {
             if ($loginvia_exempt ne '') {                      $noredirect = 1;
                 my @exempt = split(',',$loginvia_exempt);                  }
                 if (grep(/^\Q$ip\E$/,@exempt)) {              }
                     $noredirect = 1;          }
                 }          unless ($noredirect) {
             }              my ($newhost,$path);
         }              if ($loginvia =~ /:/) {
         unless ($noredirect) {                  ($newhost,$path) = split(':',$loginvia);
             my ($newhost,$path);              } else {
             if ($loginvia =~ /:/) {                  $newhost = $loginvia;
                 ($newhost,$path) = split(':',$loginvia);              }
             } else {              if ($newhost ne $lonhost) {
                 $newhost = $loginvia;                  if (&Apache::lonnet::hostname($newhost) ne '') {
             }                      $output = &redirect_page($newhost,$path);
             if ($newhost ne $lonhost) {                  }
                 if (&Apache::lonnet::hostname($newhost) ne '') {              }
                     $output = &redirect_page($newhost,$path);          }
                 }      }
             }      return $output;
         }  }
     }  
     return $output;  sub redirect_page {
 }      my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
 sub redirect_page {      $protocol = 'http' if ($protocol ne 'https');
     my ($desthost,$path) = @_;      unless ($path =~ m{^/}) {
     my $protocol = $Apache::lonnet::protocol{$desthost};          $path = '/'.$path;
     $protocol = 'http' if ($protocol ne 'https');      }
     unless ($path =~ m{^/}) {      my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
         $path = '/'.$path;      if ($env{'form.firsturl'} ne '') {
     }          $url .='?firsturl='.$env{'form.firsturl'};
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;      }
     if ($env{'form.firsturl'} ne '') {      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
         $url .='?firsturl='.$env{'form.firsturl'};                                                      {'redirect' => [0,$url],});
     }      my $end_page   = &Apache::loncommon::end_page();
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,      return $start_page.$end_page;
                                                     {'redirect' => [0,$url],});  }
     my $end_page   = &Apache::loncommon::end_page();  
     return $start_page.$end_page;  sub contactdisplay {
 }      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
           $possdoms) = @_;
 sub contactdisplay {      my $contactblock;
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,      my $origmail;
         $possdoms) = @_;      if (ref($possdoms) eq 'ARRAY') {
     my $contactblock;          if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
     my $origmail;              $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
     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);
     my $requestmail =       unless ($showhelpdesk eq '0') {
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',          if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
                                                  $authdomain,$origmail);              $showhelpdesk = 1;
     unless ($showhelpdesk eq '0') {          } else {
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {              $showhelpdesk = 0;
             $showhelpdesk = 1;          }
         } else {      }
             $showhelpdesk = 0;      if ($servadm && $showadminmail) {
         }          $contactblock .= $$lt{'servadm'}.':<br />'.
     }                           '<tt>'.$servadm.'</tt><br />';
     if ($servadm && $showadminmail) {      }
         $contactblock .= $$lt{'servadm'}.':<br />'.      if ($showhelpdesk) {
                          '<tt>'.$servadm.'</tt><br />';          $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
     }          my $thisurl = &escape('/adm/login');
     if ($showhelpdesk) {          $$helpdeskscript = <<"ENDSCRIPT";
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';  <script type="text/javascript">
         my $thisurl = &escape('/adm/login');  // <![CDATA[
         $$helpdeskscript = <<"ENDSCRIPT";  function helpdesk() {
 <script type="text/javascript">      var possdom = document.client.udom.value;
 // <![CDATA[      var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
 function helpdesk() {      if (codedom == '') {
     var possdom = document.client.udom.value;          codedom = "$authdomain";
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');      }
     if (codedom == '') {      var querystr = "origurl=$thisurl&codedom="+codedom;
         codedom = "$authdomain";      document.location.href = "/adm/helpdesk?"+querystr;
     }      return;
     var querystr = "origurl=$thisurl&codedom="+codedom;  }
     document.location.href = "/adm/helpdesk?"+querystr;  // ]]>
     return;  </script>
 }  ENDSCRIPT
 // ]]>      }
 </script>      return $contactblock;
 ENDSCRIPT  }
     }  
     return $contactblock;  sub forgotpwdisplay {
 }      my (%lt) = @_;
       my $prompt_for_resetpw = 1;
 sub forgotpwdisplay {      if ($prompt_for_resetpw) {
     my (%lt) = @_;          return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
     my $prompt_for_resetpw = 1;       }
     if ($prompt_for_resetpw) {      return;
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';  }
     }  
     return;  sub coursecatalog_link {
 }      my ($linkname) = @_;
       return <<"END";
 sub coursecatalog_link {        <a href="/adm/coursecatalog">$linkname</a>
     my ($linkname) = @_;  END
     return <<"END";  }
       <a href="/adm/coursecatalog">$linkname</a>  
 END  sub newuser_link {
 }      my ($linkname) = @_;
       return '<a href="/adm/createaccount">'.$linkname.'</a>';
 sub newuser_link {  }
     my ($linkname) = @_;  
     return '<a href="/adm/createaccount">'.$linkname.'</a>';  1;
 }  __END__
   
 1;  
 __END__  

Removed from v.1.158.2.6.2.1  
changed lines
  Added in v.1.171


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