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

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


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