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

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


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