Diff for /loncom/auth/lonlogin.pm between versions 1.131 and 1.173

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


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