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

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


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