Diff for /loncom/auth/lonlogin.pm between versions 1.73 and 1.175

version 1.73, 2006/02/28 16:44:19 version 1.175, 2018/12/02 14:55:59
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 CGI::Cookie();  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 LONCAPA;
 sub handler {  use CGI::Cookie();
     my $r = shift;   
   sub handler {
     &Apache::loncommon::get_unprocessed_cgi      my $r = shift;
  ($ENV{'QUERY_STRING'}.'&'.$env{'request.querystring'},  
  ['interface','username','domain','firsturl','localpath','localres',      &Apache::loncommon::get_unprocessed_cgi
   'token']);   (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
         $ENV{'REDIRECT_QUERY_STRING'}),
 # -- check if they are a migrating user   ['interface','username','domain','firsturl','localpath','localres',
     if (defined($env{'form.token'})) {    'token','role','symb','iptoken']);
  return &Apache::migrateuser::handler($r);      if (!defined($env{'form.firsturl'})) {
     }          &Apache::lonacc::get_posted_cgi($r,['firsturl']);
       }
     &Apache::loncommon::no_cache($r);      if (!defined($env{'form.firsturl'})) {
     &Apache::lonlocal::get_language_handle($r);          if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {
     &Apache::loncommon::content_type($r,'text/html');              $env{'form.firsturl'} = $ENV{'REDIRECT_URL'};
     $r->send_http_header;          }
     return OK if $r->header_only;      }
   
   # -- check if they are a migrating user
 # Are we re-routing?      if (defined($env{'form.token'})) {
     if (-e '/home/httpd/html/lon-status/reroute.txt') {   return &Apache::migrateuser::handler($r);
  &Apache::lonauth::reroute($r);      }
  return OK;  
     }  # For "public user" - remove any exising "public" cookie, as user really wants to log-in
       my ($handle,$lonidsdir,$expirepub,$userdom);
       unless ($r->header_only) {
 # -------------------------------- Prevent users from attempting to login twice          $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));          if ($handle ne '') {
     my $lonid=$cookies{'lonID'};              $lonidsdir=$r->dir_config('lonIDsDir');
     my $cookie;              if ($handle=~/^publicuser\_/) {
     if ($lonid) {                  unlink($r->dir_config('lonIDsDir')."/$handle.id");
  my $handle=$lonid->value;                  undef($handle);
         $handle=~s/\W//g;                  undef($userdom);
         my $lonidsdir=$r->dir_config('lonIDsDir');                  $expirepub = 1;
  if (-e "$lonidsdir/$handle.id") {              }
 # Is there an existing token file?          }
     if ($handle=~/^publicuser\_/) {      }
 # For "public user" - remove it, we apparently really want to login  
  unlink("$lonidsdir/$handle.id");      &Apache::loncommon::no_cache($r);
     } elsif ($handle ne '') {      &Apache::lonlocal::get_language_handle($r);
 # Indeed, a valid token is found      &Apache::loncommon::content_type($r,'text/html');
  my $bodytag=&Apache::loncommon::bodytag('Already logged in');      if ($expirepub) {
  $r->print(<<ENDFAILED);          my $c = new CGI::Cookie(-name    => 'lonPubID',
 <html>                                  -value   => '',
 <head>                                  -expires => '-10y',);
 <title>Already logged in</title>          $r->header_out('Set-cookie' => $c);
 </head>      } elsif (($handle eq '') && ($userdom ne '')) {
 $bodytag          my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
 <h1>You are already logged in</h1>          foreach my $name (keys(%cookies)) {
 <p>Please either <a href="/adm/roles">continue the current session</a> or              next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
 <a href="/adm/logout">logout</a>.</p>              my $c = new CGI::Cookie(-name    => $name,
 <p>                                      -value   => '',
 <a href="/adm/loginproblems.html">Problems?</a></p>                                      -expires => '-10y',);
 </body>              $r->headers_out->add('Set-cookie' => $c);
 </html>          }
 ENDFAILED      }
                 return OK;      $r->send_http_header;
      }        return OK if $r->header_only;
  }  
     }  
   # Are we re-routing?
 # ---------------------------------------------------- No valid token, continue      my $londocroot = $r->dir_config('lonDocRoot');
       if (-e "$londocroot/lon-status/reroute.txt") {
  # ---------------------------- Not possible to really login to domain "public"   &Apache::lonauth::reroute($r);
     if ($env{'form.domain'} eq 'public') {   return OK;
  $env{'form.domain'}='';      }
  $env{'form.username'}='';  
     }      $env{'form.firsturl'} =~ s/(`)/'/g;
 # ----------------------------------------------------------- Process Interface  
     $env{'form.interface'}=~s/\W//g;  # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
   
     my $textbrowsers=$r->dir_config('lonTextBrowsers');      my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r,1);
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};      if ($found_server) {
               my $hostname = &Apache::lonnet::hostname($found_server);
     foreach (split(/\:/,$textbrowsers)) {          if ($hostname ne '') {
  if ($httpbrowser=~/$_/i) {              my $protocol = $Apache::lonnet::protocol{$found_server};
     $env{'form.interface'}='textual';              $protocol = 'http' if ($protocol ne 'https');
         }              my $dest = '/adm/roles';
     }              if ($env{'form.firsturl'} ne '') {
                   $dest = $env{'form.firsturl'};
     my $fullgraph=($env{'form.interface'} ne 'textual');              }
     my $port_to_use=$r->dir_config('lonhttpdPort');              my $url = $protocol.'://'.$hostname.$dest;
     if (!defined($port_to_use)) {              my $start_page =
  $port_to_use='8080';                  &Apache::loncommon::start_page('Switching Server ...',undef,
     }                                                 {'redirect'       => [0,$url],});
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.              my $end_page   = &Apache::loncommon::end_page();
                   $r->dir_config('lonIconsURL');              $r->print($start_page.$end_page);
     my $domain  = $r->dir_config('lonDefDomain');              return OK;
     my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0];          }
     foreach my $posdom (&Apache::lonnet::current_machine_domains()) {      }
  if (lc($posdom) eq lc($testdomain)) { $domain=$posdom; }  
     }  #
     if (($env{'form.domain'}) &&   # If browser sent an old cookie for which the session file had been removed
  ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {  # check if configuration for user's domain has a portal URL set.  If so
  $domain=$env{'form.domain'};  # switch user's log-in to the portal.
     }  #
     my $role    = $r->dir_config('lonRole');  
     my $loadlim = $r->dir_config('lonLoadLim');      if (($handle eq '') && ($userdom ne '')) {
     my $servadm = $r->dir_config('lonAdmEMail');          my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
     my $sysadm  = $r->dir_config('lonSysEMail');          if ($domdefaults{'portal_def'} =~ /^https?\:/) {
     my $lonhost = $r->dir_config('lonHostID');              my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
     my $tabdir  = $r->dir_config('lonTabDir');                                            {'redirect' => [0,$domdefaults{'portal_def'}],});
     my $include = $r->dir_config('lonIncludes');              my $end_page   = &Apache::loncommon::end_page();
     my $expire  = $r->dir_config('lonExpire');              $r->print($start_page.$end_page);
     my $version = $r->dir_config('lonVersion');              return OK;
           }
 # --------------------------------------------- Default values for login fields      }
   
     my $authusername=($env{'form.username'}?$env{'form.username'}:'');  # -------------------------------- Prevent users from attempting to login twice
     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);      if ($handle ne '') {
           &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
 # ---------------------------------------------------------- Determine own load   my $start_page =
     my $loadavg;      &Apache::loncommon::start_page('Already logged in');
     {   my $end_page =
  my $loadfile=Apache::File->new('/proc/loadavg');      &Apache::loncommon::end_page();
  $loadavg=<$loadfile>;          my $dest = '/adm/roles';
     }          if ($env{'form.firsturl'} ne '') {
     $loadavg =~ s/\s.*//g;              $dest = $env{'form.firsturl'};
     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);          }
     my $userloadpercent=&Apache::lonnet::userload();   $r->print(
                     $start_page
 # ------------------------------------------------------- Do the load balancing                   .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
     my $otherserver='http://'.$ENV{'SERVER_NAME'};                   .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
     my $firsturl=                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});                   .$end_page
 # ---------------------------------------- Are we access server and overloaded?                   );
     if (($role eq 'access') &&          return OK;
  (($userloadpercent>100.0)||($loadpercent>100.0))) {      }
         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);  
  if ($unloaded) { $otherserver=$unloaded; }  # ---------------------------------------------------- No valid token, continue
     }  
   # ---------------------------- Not possible to really login to domain "public"
 # ----------------------------------------------------------- Get announcements      if ($env{'form.domain'} eq 'public') {
     my $announcements=&Apache::lonnet::getannounce();   $env{'form.domain'}='';
 # -------------------------------------------------------- Set login parameters   $env{'form.username'}='';
       }
     my @hexstr=('0','1','2','3','4','5','6','7',  
                 '8','9','a','b','c','d','e','f');  # ------ Is this page requested because /adm/migrateuser detected an IP change?
     my $lkey='';      my %sessiondata;
     for (0..7) {      if ($env{'form.iptoken'}) {
         $lkey.=$hexstr[rand(15)];          %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
     }          unless ($sessiondata{'sessionserver'}) {
               my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
     my $ukey='';              delete($env{'form.iptoken'});
     for (0..7) {          }
         $ukey.=$hexstr[rand(15)];      }
     }  # ----------------------------------------------------------- Process Interface
       $env{'form.interface'}=~s/\W//g;
     my $lextkey=hex($lkey);  
     if ($lextkey>2147483647) { $lextkey-=4294967296; }      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
           &Apache::loncommon::decode_user_agent();
     my $uextkey=hex($ukey);  
     if ($uextkey>2147483647) { $uextkey-=4294967296; }      my $iconpath=
    &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
 # -------------------------------------------------------- Store away log token  
     my $logtoken=Apache::lonnet::reply(      my $lonhost = $r->dir_config('lonHostID');
        'tmpput:'.$ukey.$lkey.'&'.$firsturl,      my $domain = &Apache::lonnet::default_login_domain();
        $lonhost);      my $defdom = $domain;
       if ($lonhost ne '') {
 # ------------------- If we cannot talk to ourselves, we are in serious trouble          unless ($sessiondata{'sessionserver'}) {
               my $redirect = &check_loginvia($domain,$lonhost);
     if ($logtoken eq 'con_lost') {              if ($redirect) {
         my $spares='';                  $r->print($redirect);
  my $last;                  return OK;
         foreach my $hostid (sort              }
     {          }
  $Apache::lonnet::hostname{$a} cmp      }
     $Apache::lonnet::hostname{$b};  
     }      if (($sessiondata{'domain'}) &&
     keys(%Apache::lonnet::spareid)) {          (&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {
             next if ($hostid eq $lonhost);          $domain=$sessiondata{'domain'};
             next if ($last eq $Apache::lonnet::hostname{$hostid});      } elsif (($env{'form.domain'}) &&
             $spares.='<br /><font size="+1"><a href="http://'.   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
                 $Apache::lonnet::hostname{$hostid}.   $domain=$env{'form.domain'};
                 '/adm/login?domain='.$authdomain.'">'.      }
                 $Apache::lonnet::hostname{$hostid}.'</a>'.  
                 ' (preferred)</font>'.$/;      my $role    = $r->dir_config('lonRole');
     $last=$Apache::lonnet::hostname{$hostid};      my $loadlim = $r->dir_config('lonLoadLim');
         }      my $uloadlim= $r->dir_config('lonUserLoadLim');
         $spares.= '<br />';      my $servadm = $r->dir_config('lonAdmEMail');
         foreach my $hostid (sort      my $tabdir  = $r->dir_config('lonTabDir');
     {      my $include = $r->dir_config('lonIncludes');
  $Apache::lonnet::hostname{$a} cmp      my $expire  = $r->dir_config('lonExpire');
     $Apache::lonnet::hostname{$b};      my $version = $r->dir_config('lonVersion');
     }      my $host_name = &Apache::lonnet::hostname($lonhost);
     keys(%Apache::lonnet::hostname)) {  
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});  # --------------------------------------------- Default values for login fields
             next if ($last eq $Apache::lonnet::hostname{$hostid});     
             $spares.='<br /><a href="http://'.      my ($authusername,$authdomain);
                 $Apache::lonnet::hostname{$hostid}.      if ($sessiondata{'username'}) {
                 '/adm/login?domain='.$authdomain.'">'.          $authusername=$sessiondata{'username'};
                 $Apache::lonnet::hostname{$hostid}.'</a>';      } else {
     $last=$Apache::lonnet::hostname{$hostid};          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
         }          $authusername=($env{'form.username'}?$env{'form.username'}:'');
  $r->print(<<ENDTROUBLE);      }
 <html>      if ($sessiondata{'domain'}) {
 <head><title>The LearningOnline Network with CAPA</title></head>          $authdomain=$sessiondata{'domain'};
 <body bgcolor="#FFFFFF">      } else {
 <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
 <h3>This LON-CAPA server is temporarily not available for login</h3>          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
 <p>Please attempt to login to one of the following servers:</p>$spares      }
 <p>If the problem persists, please contact <tt>$servadm</tt>.</p>  
 </body>  # ---------------------------------------------------------- Determine own load
 </html>      my $loadavg;
 ENDTROUBLE      {
         return OK;   my $loadfile=Apache::File->new('/proc/loadavg');
     }   $loadavg=<$loadfile>;
       }
 # ----------------------------------------------- Apparently we are in business      $loadavg =~ s/\s.*//g;
   
     my $domainlogo=&Apache::loncommon::domainlogo($domain);      my ($loadpercent,$userloadpercent);
     $servadm=~s/\,/\<br \/\>/g;      if ($loadlim) {
     $sysadm=~s/\,/\<br \/\>/g;          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
       }
 # --------------------------------------------------- Print login screen header      if ($uloadlim) {
     $r->print(<<ENDHEADER);          $userloadpercent=&Apache::lonnet::userload();
 <html>      }
 <head>  
 <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />      my $firsturl=
 <title>The LearningOnline Network with CAPA Login</title>      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 </head>  
 ENDHEADER  # ----------------------------------------------------------- Get announcements
 # ---------------------------------------------------- Serve out DES JavaScript      my $announcements=&Apache::lonnet::getannounce();
     {  # -------------------------------------------------------- Set login parameters
  my $jsh=Apache::File->new($include."/londes.js");  
         $r->print(<$jsh>);      my @hexstr=('0','1','2','3','4','5','6','7',
     }                  '8','9','a','b','c','d','e','f');
       my $lkey='';
 # ----------------------------------------------------------- Front page design      for (0..7) {
     my $pgbg=          $lkey.=$hexstr[rand(15)];
       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');      }
     my $font=  
       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');      my $ukey='';
     my $link=      for (0..7) {
       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');          $ukey.=$hexstr[rand(15)];
     my $vlink=      }
       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');  
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);      my $lextkey=hex($lkey);
     my $mainbg=      if ($lextkey>2147483647) { $lextkey-=4294967296; }
       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');  
     my $sidebg=      my $uextkey=hex($ukey);
       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');      if ($uextkey>2147483647) { $uextkey-=4294967296; }
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);  
     my $img=&Apache::loncommon::designparm('login.img',$domain);  # -------------------------------------------------------- Store away log token
       my $tokenextras;
 # ----------------------------------------------------------------------- Texts      if ($env{'form.role'}) {
           $tokenextras = '&role='.&escape($env{'form.role'});
 my %lt=&Apache::lonlocal::texthash(      }
   'un'  => 'Username',      if ($env{'form.symb'}) {
   'pw'  => 'Password',          if (!$tokenextras) {
   'dom' => 'Domain',              $tokenextras = '&';
   'perc' => 'percent',          }
   'load' => 'Load',          $tokenextras .= '&symb='.&escape($env{'form.symb'});
                   'userload' => 'User Load',      }
                   'about'  => 'aboutlon.gif',      if ($env{'form.iptoken'}) {
                   'access' => 'accessbutton.gif',          if (!$tokenextras) {
   'auth' => 'userauthentication.gif',              $tokenextras = '&&';
   'log' => 'Log in',          }
   'help' => 'Help',          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
   'serv' => 'Server',      }
                   'servadm' => 'Server Administration',      my $logtoken=Apache::lonnet::reply(
                   'sysadm' => 'System Administration',         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
                   'helpdesk' => 'Contact Helpdesk');         $lonhost);
 # -------------------------------------------------- Change password field name  
     my $now=time;  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
 # ---------------------------------------------------------- Serve rest of page  #    we are in serious trouble
     $r->print(<<ENDSCRIPT);  
       if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
 <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"          if ($logtoken eq 'no_such_host') {
   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
           }
  <script language="JavaScript">          my $spares='';
     function send()   my $last;
     {          foreach my $hostid (sort
  this.document.server.elements.uname.value      {
        =this.document.client.elements.uname.value;   &Apache::lonnet::hostname($a) cmp
       &Apache::lonnet::hostname($b);
         this.document.server.elements.udom.value      }
        =this.document.client.elements.udom.value;      keys(%Apache::lonnet::spareid)) {
               next if ($hostid eq $lonhost);
         this.document.server.elements.imagesuppress.value      my $hostname = &Apache::lonnet::hostname($hostid);
        =this.document.client.elements.imagesuppress.checked;      next if (($last eq $hostname) || ($hostname eq ''));
               $spares.='<br /><font size="+1"><a href="http://'.
         this.document.server.elements.embedsuppress.value                  $hostname.
        =this.document.client.elements.embedsuppress.checked;                  '/adm/login?domain='.$authdomain.'">'.
                   $hostname.'</a>'.
         this.document.server.elements.appletsuppress.value                  ' '.&mt('(preferred)').'</font>'.$/;
        =this.document.client.elements.appletsuppress.checked;      $last=$hostname;
           }
         this.document.server.elements.fontenhance.value          if ($spares) {
        =this.document.client.elements.fontenhance.checked;              $spares.= '<br />';
           }
         this.document.server.elements.blackwhite.value          my %all_hostnames = &Apache::lonnet::all_hostnames();
        =this.document.client.elements.blackwhite.checked;          foreach my $hostid (sort
       {
         this.document.server.elements.remember.value   &Apache::lonnet::hostname($a) cmp
        =this.document.client.elements.remember.checked;      &Apache::lonnet::hostname($b);
       }
         uextkey=this.document.client.elements.uextkey.value;      keys(%all_hostnames)) {
         lextkey=this.document.client.elements.lextkey.value;              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
         initkeys();              my $hostname = &Apache::lonnet::hostname($hostid);
               next if (($last eq $hostname) || ($hostname eq ''));
         this.document.server.elements.upass0.value              $spares.='<br /><a href="http://'.
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));               $hostname.
  this.document.server.elements.upass1.value               '/adm/login?domain='.$authdomain.'">'.
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));               $hostname.'</a>';
  this.document.server.elements.upass2.value              $last=$hostname;
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));           }
            $r->print(
         this.document.client.elements.uname.value='';     '<html>'
         this.document.client.elements.upass$now.value='';    .'<head><title>'
     .&mt('The LearningOnline Network with CAPA')
         this.document.server.submit();    .'</title></head>'
  return false;    .'<body bgcolor="#FFFFFF">'
     }    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
  </script>    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
 ENDSCRIPT    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
           if ($spares) {
     if ($fullgraph) {              $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
  $r->print(                       .'</p>'
   '<table width="100%" cellpadding=0 cellspacing=0 border=0>');                       .$spares);
     }          }
           $r->print('</body>'
     $r->print(<<ENDSERVERFORM);                   .'</html>'
   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">          );
    <input type="hidden" name="logtoken" value="$logtoken" />          return OK;
    <input type="hidden" name="serverid" value="$lonhost" />      }
    <input type="hidden" name="interface" value="$env{'form.interface'}" />  
    <input type="hidden" name="uname" value="" />  # ----------------------------------------------- Apparently we are in business
    <input type="hidden" name="upass0" value="" />      $servadm=~s/\,/\<br \/\>/g;
    <input type="hidden" name="upass1" value="" />  
    <input type="hidden" name="upass2" value="" />  # ----------------------------------------------------------- Front page design
    <input type="hidden" name="udom" value="" />      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
    <input type="hidden" name="imagesuppress"  value="" />      my $font=&Apache::loncommon::designparm('login.font',$domain);
    <input type="hidden" name="appletsuppress"  value="" />      my $link=&Apache::loncommon::designparm('login.link',$domain);
    <input type="hidden" name="embedsuppress"  value="" />      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
    <input type="hidden" name="fontenhance"  value="" />      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
    <input type="hidden" name="blackwhite"  value="" />      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
    <input type="hidden" name="remember"  value="" />      my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
    <input type="hidden" name="localres" value="$env{'form.localres'}" />      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
   </form>      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
 ENDSERVERFORM      my $img=&Apache::loncommon::designparm('login.img',$domain);
     if ($fullgraph) { $r->print(<<ENDTOP);      my $domainlogo=&Apache::loncommon::domainlogo($domain);
   <!-- The LON-CAPA Header -->      my $showbanner = 1;
   <tr>      my $showmainlogo = 1;
       if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
    <!-- Row 1 Columns 2-4 -->          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>      }
   </tr>      if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
           $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
   <!-- The gray bar that starts the two table frames -->      }
   <tr>      my $showadminmail;
       my @possdoms = &Apache::lonnet::current_machine_domains();
    <!-- Row 2 Column 1 -->      if (grep(/^\Q$domain\E$/,@possdoms)) {
    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>          $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
       }
    <!-- Row 2 Column 2 -->      my $showcoursecat =
    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>          &Apache::loncommon::designparm('login.coursecatalog',$domain);
       my $shownewuserlink =
    <!-- Row 2 Column 3 -->          &Apache::loncommon::designparm('login.newuser',$domain);
    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>      my $showhelpdesk =
           &Apache::loncommon::designparm('login.helpdesk',$domain);
    <!-- Row 2 Column 4 -->      my $now=time;
    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>      my $js = (<<ENDSCRIPT);
   </tr>  
   <tr>  <script type="text/javascript" language="JavaScript">
      // <![CDATA[
    <!-- A cell that will hold the 'access' and 'about' buttons -->  function send()
    <!-- Row 3 Column 1 -->  {
    <td valign="top" height=60 align="center" bgcolor="$sidebg">  this.document.server.elements.uname.value
     <a href="/adm/login?interface=textual"><img src="$iconpath/$lt{'access'}" border=0 alt="Accessibility Options" /></a>  =this.document.client.elements.uname.value;
     <br />  
     <a href="/adm/about.html"><img src="$iconpath/$lt{'about'}" border=0 alt="About LON-CAPA" /></a>  this.document.server.elements.udom.value
    </td>  =this.document.client.elements.udom.value;
   
    <!-- The shaded space between the two main columns -->  uextkey=this.document.client.elements.uextkey.value;
    <!-- Row 3 Column 2 -->  lextkey=this.document.client.elements.lextkey.value;
    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>  initkeys();
   
    <!-- The right main column holding the large LON-CAPA logo-->  if(this.document.server.action.substr(0,5) === 'http:'){
    <!-- Rows 3-4 Column 3 -->      this.document.server.elements.upass0.value
    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">          =getCrypted(this.document.client.elements.upass$now.value);
     <center>  } else {
      <img src="$logo" alt="" />      this.document.server.elements.upass0.value
     </center>          =this.document.client.elements.upass$now.value;
    </td>  }
   
    <!-- Row 3 Column 4 -->  this.document.client.elements.uname.value='';
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>  this.document.client.elements.upass$now.value='';
   </tr>  
   <tr>  this.document.server.submit();
   return false;
    <!-- The entry form -->  }
    <!-- Row 4 Column 1 -->  
    <td align="center" valign="middle" bgcolor="$sidebg">  function enableInput() {
 ENDTOP      this.document.client.elements.upass$now.removeAttribute("readOnly");
 } else {      this.document.client.elements.uname.removeAttribute("readOnly");
     $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements);      this.document.client.elements.udom.removeAttribute("readOnly");
 }      return;
     $r->print('<form name="client" onsubmit="return(send())">');  }
     unless ($fullgraph) {  
         $r->print(<<ENDACCESSOPTIONS);  // ]]>
 <h3>Select Accessibility Options</h3>  </script>
 <label><input type="checkbox" name="imagesuppress" /> Suppress rendering of images</label><br />  
 <label><input type="checkbox" name="appletsuppress" /> Suppress Java applets</label><br />  ENDSCRIPT
 <label><input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia</label><br />  
 <label><input type="checkbox" name="fontenhance" /> Increase font size</label><br />  # --------------------------------------------------- Print login screen header
 <label><input type="checkbox" name="blackwhite" /> Switch to black and white mode</label><br />  
 <p>If you have accessibility needs that are not addressed by this interface,       my %add_entries = (
 please         bgcolor      => "$mainbg",
 contact the system administrator at <tt>$sysadm</tt>.</p><br />         text         => "$font",
 <input type="checkbox" name="remember" /> Remember these settings for next login<hr />         link         => "$link",
 ENDACCESSOPTIONS         vlink        => "$vlink",
 } else {         alink        => "$alink",
     $r->print(<<ENDNOOPT);                 onload       => 'javascript:enableInput();',);
 <input type="hidden" name="imagesuppress"  value="" />  
 <input type="hidden" name="embedsuppress"  value="" />      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
 <input type="hidden" name="appletsuppress"  value="" />      @hosts = &Apache::lonnet::current_machine_ids();
 <input type="hidden" name="fontenhance"  value="" />      $lonhost_in_use = $lonhost;
 <input type="hidden" name="blackwhite"  value="" />      if (@hosts > 1) {
 <input type="hidden" name="remember"  value="" />          foreach my $hostid (@hosts) {
 ENDNOOPT              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
 }                  $lonhost_in_use = $hostid;
     $r->print(<<ENDLOGIN);                  last;
      <input type="hidden" name="lextkey" value="$lextkey">              }
      <input type="hidden" name="uextkey" value="$uextkey">          }
       }
      <!-- Start the sub-table for text and input alignment -->      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
      <table border=0 cellspacing=0 cellpadding=0>      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr>      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
       <tr>      if ($headextra) {
        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'un'}:</b></font></td>          my $omitextra;
        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>          if ($headextra_exempt ne '') {
       </tr>              my @exempt = split(',',$headextra_exempt);
       <tr>              my $ip = $ENV{'REMOTE_ADDR'};
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'pw'}:</b></font></td>              if (grep(/^\Q$ip\E$/,@exempt)) {
        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>                  $omitextra = 1;
       </tr>              }
       <tr>          }
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>          unless ($omitextra) {
        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>              my $confname = $defdom.'-domainconfig';
       </tr>              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
       <tr>                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
        <td bgcolor="$mainbg">&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">$lt{'help'}</a></td>                  unless ($extra eq '-1') {
        <td bgcolor="$mainbg" valign="bottom" align="center">                      $js .= "\n".$extra."\n";
         <br />                  }
         <input type="submit" value="$lt{'log'}" />              }
        </td>          }
       </tr>      }
      </table>  
      <!-- End sub-table -->      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
     </form>         { 'redirect'       => [$expire,'/adm/roles'],
 ENDLOGIN   'add_entries' => \%add_entries,
     if ($fullgraph) {   'only_body'   => 1,}));
         my $helpdeskscript;  
         my $contactblock = &contactdisplay(\%lt,$sysadm,$servadm,$version,$authdomain,\$helpdeskscript);  # ----------------------------------------------------------------------- Texts
  $r->print(<<ENDDOCUMENT);  
    </td>      my %lt=&Apache::lonlocal::texthash(
             'un'       => 'Username',
    <!-- Row 4 Column 2 -->            'pw'       => 'Password',
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>            'dom'      => 'Domain',
             'perc'     => 'percent',
    <!-- Row 4 Column 3 -->            'load'     => 'Server Load',
 <td bgcolor="$mainbg">$announcements</td>            'userload' => 'User Load',
             'catalog'  => 'Course/Community Catalog',
    <!-- Row 4 Column 4 -->            'log'      => 'Log in',
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>            'help'     => 'Log-in Help',
   </tr>            'serv'     => 'Server',
   <tr>            'servadm'  => 'Server Administration',
             'helpdesk' => 'Contact Helpdesk',
    <!-- Row 5 Column 1 -->            'forgotpw' => 'Forgot password?',
    <td bgcolor="$sidebg" valign="middle" align="left">            'newuser'  => 'New User?',
      <br />         );
      <table border=0 cellspacing=0 cellpadding=0>  # -------------------------------------------------- Change password field name
       <tr>  
        <td bgcolor="$sidebg" align="left" valign="top">      my $forgotpw = &forgotpwdisplay(%lt);
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>      $forgotpw .= '<br />' if $forgotpw;
        </td>      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
        <td bgcolor="$sidebg" align="left" valign="top">      if ($loginhelp) {
         <small><tt>&nbsp;$domain</tt></small>          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
        </td>      }
       </tr>  
       <tr>  # ---------------------------------------------------- Serve out DES JavaScript
        <td bgcolor="$sidebg" align="left" valign="top">      {
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>      my $jsh=Apache::File->new($include."/londes.js");
        </td>      $r->print(<$jsh>);
        <td bgcolor="$sidebg" align="left" valign="top">      }
         <small><tt>&nbsp;$lonhost ($role)</tt></small>  # ---------------------------------------------------------- Serve rest of page
        </td>  
       </tr>      $r->print(
       <tr>      '<div class="LC_Box"'
        <td bgcolor="$sidebg" align="left" valign="top">     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>  );
        </td>  
        <td bgcolor="$sidebg" align="left" valign="top">      $r->print(<<ENDSERVERFORM);
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>  <form name="server" action="/adm/authenticate" method="post" target="_top">
        </td>     <input type="hidden" name="logtoken" value="$logtoken" />
       </tr>     <input type="hidden" name="serverid" value="$lonhost" />
       <tr>     <input type="hidden" name="uname" value="" />
        <td bgcolor="$sidebg" align="left" valign="top">     <input type="hidden" name="upass0" value="" />
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>     <input type="hidden" name="udom" value="" />
        </td>     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
        <td bgcolor="$sidebg" align="left" valign="top">     <input type="hidden" name="localres" value="$env{'form.localres'}" />
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>    </form>
        </td>  ENDSERVERFORM
       </tr>      my $coursecatalog;
      </table>      if (($showcoursecat eq '') || ($showcoursecat)) {
      <br />          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
     $contactblock      }
    </td>      my $newuserlink;
       if ($shownewuserlink) {
    <!-- Row 5 Column 2 -->          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>      }
       my $logintitle =
    <!-- Row 5 Column 3 -->          '<h2 class="LC_hcell"'
    <td width="100%" valign="bottom" bgcolor="$mainbg">         .' style="background:'.$loginbox_header_bgcol.';'
 $domainlogo         .' color:'.$loginbox_header_textcol.'">'
 </td>         .$lt{'log'}
          .'</h2>';
    <!-- Row 5 Column 4 -->  
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>      my $noscript_warning='<noscript><span class="LC_warning"><b>'
   </tr>                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
   <tr>                          .'</b></span></noscript>';
       my $helpdeskscript;
    <!-- Row 6 Column 1 -->      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
    <td bgcolor="$sidebg">&nbsp;</td>                                         $authdomain,\$helpdeskscript,
                                          $showhelpdesk,\@possdoms);
    <!-- Row 6 Column 2 -->  
    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>      my $mobileargs;
       if ($clientmobile) {
    <!-- Row 6 Column 3 -->          $mobileargs = 'autocapitalize="off" autocorrect="off"';
    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>      }
       my $loginform=(<<LFORM);
    <!-- Row 6 Column 4 -->  <form name="client" action="" onsubmit="return(send())">
    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>    <input type="hidden" name="lextkey" value="$lextkey" />
   </tr>    <input type="hidden" name="uextkey" value="$uextkey" />
  </table>    <b><label for="uname">$lt{'un'}</label>:</b><br />
     <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
 <script type="text/javascript">    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
 // the if prevents the script error if the browser can not handle this    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
 if ( document.client.uname ) { document.client.uname.focus(); }    <b><label for="udom">$lt{'dom'}</label>:</b><br />
 </script>    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
 $helpdeskscript    <input type="submit" value="$lt{'log'}" />
   </form>
 ENDDOCUMENT  LFORM
 }  
     $r->print('</body></html>');      if ($showbanner) {
     return OK;          $r->print(<<HEADER);
 }  <!-- The LON-CAPA Header -->
   <div style="background:$pgbg;margin:0;width:100%;">
 sub contactdisplay {    <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
     my ($lt,$sysadm,$servadm,$version,$authdomain,$helpdeskscript) = @_;  </div>
     my $contactblock;  HEADER
     my $showsysadm = 1;      }
     my $showservadm = 1;      $r->print(<<ENDTOP);
     my $showhelpdesk = 0;  <div style="float:left;margin-top:0;">
     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};  <div class="LC_Box" style="background:$loginbox_bg;">
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {    $logintitle
         $showhelpdesk = 1;    $loginform
     }    $noscript_warning
     if ($showsysadm) {  </div>
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'sysadm'}.':</b><br />'.   
                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$sysadm.'</tt><br />';  <div class="LC_Box" style="padding-top: 10px;">
     }    $loginhelp
     if ($showservadm) {    $forgotpw
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.    $contactblock
                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';    $newuserlink
     }    $coursecatalog
     if ($showhelpdesk) {  </div>
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()">'.$$lt{'helpdesk'}.'</a></b><br />';  </div>
         my $thisurl = &Apache::lonnet::escape('/adm/login');  
         $$helpdeskscript = <<"ENDSCRIPT";  <div>
 <script type="text/javascript">  ENDTOP
 function helpdesk() {      if ($showmainlogo) {
     var codedom = document.client.udom.value;          $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
     if (codedom == '') {      }
         codedom = "$authdomain";  $r->print(<<ENDTOP);
     }  $announcements
     var querystr = "origurl=$thisurl&codedom="+codedom;  </div>
     document.location.href = "/adm/helpdesk?"+querystr;  <hr style="clear:both;" />
     return;  ENDTOP
 }      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
 </script>      $domainrow = <<"END";
 ENDSCRIPT        <tr>
     }         <td  align="left" valign="top">
     $contactblock .= <<"ENDBLOCK";          <small><b>$lt{'dom'}:&nbsp;</b></small>
      &nbsp;&nbsp;&nbsp;$version         </td>
 ENDBLOCK         <td  align="left" valign="top">
     return $contactblock;          <small><tt>&nbsp;$domain</tt></small>
 }         </td>
          </tr>
   END
 1;      $serverrow = <<"END";
 __END__        <tr>
          <td  align="left" valign="top">
           <small><b>$lt{'serv'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$lonhost ($role)</tt></small>
          </td>
         </tr>
   END
       if ($loadlim) {
           $loadrow = <<"END";
         <tr>
          <td align="left" valign="top">
           <small><b>$lt{'load'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
          </td>
         </tr>
   END
       }
       if ($uloadlim) {
           $userloadrow = <<"END";
         <tr>
          <td align="left" valign="top">
           <small><b>$lt{'userload'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
          </td>
         </tr>
   END
       }
       if (($version ne '') && ($version ne '<!-- VERSION -->')) {
           $versionrow = <<"END";
         <tr>
          <td colspan="2" align="left">
           <small>$version</small>
          </td>
         </tr>
   END
       }
   
       $r->print(<<ENDDOCUMENT);
       <div style="float: left;">
        <table border="0" cellspacing="0" cellpadding="0">
   $domainrow
   $serverrow
   $loadrow    
   $userloadrow
   $versionrow
        </table>
       </div>
       <div style="float: right;">
       $domainlogo
       </div>
       <br style="clear:both;" />
    </div>
   
   <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) = @_;
       if ($domain eq '' || $lonhost 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 = $ENV{'REMOTE_ADDR'};
           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 '') {
                       $output = &redirect_page($newhost,$path);
                   }
               }
           }
       }
       return $output;
   }
   
   sub redirect_page {
       my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
       unless ($path =~ m{^/}) {
           $path = '/'.$path;
       }
       my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
       if ($env{'form.firsturl'} ne '') {
           $url .='?firsturl='.$env{'form.firsturl'};
       }
       my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                       {'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) = @_;
       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>';
   }
   
   1;
   __END__

Removed from v.1.73  
changed lines
  Added in v.1.175


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