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

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


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