Diff for /loncom/auth/lonlogin.pm between versions 1.150 and 1.169

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


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