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

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

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


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