Diff for /loncom/auth/lonlogin.pm between versions 1.156 and 1.162

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


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