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

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


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