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

version 1.156, 2013/09/13 21:28:18 version 1.166, 2016/04/19 18:09:11
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();',);  if(this.document.server.action.substr(0,5) === 'http:'){
       this.document.server.elements.upass0.value
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,          =getCrypted(this.document.client.elements.upass$now.value);
        { 'redirect'       => [$expire,'/adm/roles'],   } else {
  'add_entries' => \%add_entries,      this.document.server.elements.upass0.value
  'only_body'   => 1,}));          =this.document.client.elements.upass$now.value;
   
 # ----------------------------------------------------------------------- Texts  this.document.client.elements.uname.value='';
   this.document.client.elements.upass$now.value='';
     my %lt=&Apache::lonlocal::texthash(  
           'un'       => 'Username',  this.document.server.submit();
           'pw'       => 'Password',  return false;
           'dom'      => 'Domain',  }
           'perc'     => 'percent',  
           'load'     => 'Server Load',  function enableInput() {
           'userload' => 'User Load',      this.document.client.elements.upass$now.removeAttribute("readOnly");
           'catalog'  => 'Course/Community Catalog',      this.document.client.elements.uname.removeAttribute("readOnly");
           'log'      => 'Log in',      this.document.client.elements.udom.removeAttribute("readOnly");
           'help'     => 'Log-in Help',      return;
           'serv'     => 'Server',  }
           'servadm'  => 'Server Administration',  
           'helpdesk' => 'Contact Helpdesk',  // ]]>
           'forgotpw' => 'Forgot password?',  </script>
           'newuser'  => 'New User?',  
        );  ENDSCRIPT
 # -------------------------------------------------- Change password field name  
   # --------------------------------------------------- Print login screen header
     my $forgotpw = &forgotpwdisplay(%lt);  
     $forgotpw .= '<br />' if $forgotpw;      my %add_entries = (
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);         bgcolor      => "$mainbg",
     if ($loginhelp) {         text         => "$font",
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';         link         => "$link",
     }         vlink        => "$vlink",
          alink        => "$alink",
 # ---------------------------------------------------- Serve out DES JavaScript                 onload       => 'javascript:enableInput();',);
     {  
     my $jsh=Apache::File->new($include."/londes.js");      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
     $r->print(<$jsh>);      @hosts = &Apache::lonnet::current_machine_ids();
     }      $lonhost_in_use = $lonhost;
 # ---------------------------------------------------------- Serve rest of page      if (@hosts > 1) {
           foreach my $hostid (@hosts) {
     $r->print(              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
     '<div class="LC_Box"'                  $lonhost_in_use = $hostid;
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'                  last;
 );              }
           }
     $r->print(<<ENDSERVERFORM);      }
 <form name="server" action="/adm/authenticate" method="post" target="_top">      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
    <input type="hidden" name="logtoken" value="$logtoken" />      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
    <input type="hidden" name="serverid" value="$lonhost" />      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
    <input type="hidden" name="uname" value="" />      if ($headextra) {
    <input type="hidden" name="upass0" value="" />          my $omitextra;
    <input type="hidden" name="upass1" value="" />          if ($headextra_exempt ne '') {
    <input type="hidden" name="upass2" value="" />              my @exempt = split(',',$headextra_exempt);
    <input type="hidden" name="udom" value="" />              my $ip = $ENV{'REMOTE_ADDR'};
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />              if (grep(/^\Q$ip\E$/,@exempt)) {
    <input type="hidden" name="localres" value="$env{'form.localres'}" />                  $omitextra = 1;
   </form>              }
 ENDSERVERFORM          }
     my $coursecatalog;          unless ($omitextra) {
     if (($showcoursecat eq '') || ($showcoursecat)) {              my $confname = $defdom.'-domainconfig';
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
     }                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
     my $newuserlink;                  unless ($extra eq '-1') {
     if ($shownewuserlink) {                      $js .= "\n".$extra."\n";
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';                  }
     }              }
     my $logintitle =          }
         '<h2 class="LC_hcell"'      }
        .' style="background:'.$loginbox_header_bgcol.';'  
        .' color:'.$loginbox_header_textcol.'">'      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
        .$lt{'log'}         { 'redirect'       => [$expire,'/adm/roles'],
        .'</h2>';   'add_entries' => \%add_entries,
    'only_body'   => 1,}));
     my $noscript_warning='<noscript><span class="LC_warning"><b>'  
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')  # ----------------------------------------------------------------------- Texts
                         .'</b></span></noscript>';  
     my $helpdeskscript;      my %lt=&Apache::lonlocal::texthash(
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,            'un'       => 'Username',
                                        $authdomain,\$helpdeskscript,            'pw'       => 'Password',
                                        $showhelpdesk,\@possdoms);            'dom'      => 'Domain',
             'perc'     => 'percent',
     my $mobileargs;            'load'     => 'Server Load',
     if ($clientmobile) {            'userload' => 'User Load',
         $mobileargs = 'autocapitalize="off" autocorrect="off"';             'catalog'  => 'Course/Community Catalog',
     }            'log'      => 'Log in',
     my $loginform=(<<LFORM);            'help'     => 'Log-in Help',
 <form name="client" action="" onsubmit="return(send())">            'serv'     => 'Server',
   <input type="hidden" name="lextkey" value="$lextkey" />            'servadm'  => 'Server Administration',
   <input type="hidden" name="uextkey" value="$uextkey" />            'helpdesk' => 'Contact Helpdesk',
   <b><label for="uname">$lt{'un'}</label>:</b><br />            'forgotpw' => 'Forgot password?',
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />            'newuser'  => 'New User?',
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />         );
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />  # -------------------------------------------------- Change password field name
   <b><label for="udom">$lt{'dom'}</label>:</b><br />  
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />      my $forgotpw = &forgotpwdisplay(%lt);
   <input type="submit" value="$lt{'log'}" />      $forgotpw .= '<br />' if $forgotpw;
 </form>      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
 LFORM      if ($loginhelp) {
           $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
     if ($showbanner) {      }
         $r->print(<<HEADER);  
 <!-- The LON-CAPA Header -->  # ---------------------------------------------------- Serve out DES JavaScript
 <div style="background:$pgbg;margin:0;width:100%;">      {
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" />      my $jsh=Apache::File->new($include."/londes.js");
 </div>      $r->print(<$jsh>);
 HEADER      }
     }  # ---------------------------------------------------------- Serve rest of page
     $r->print(<<ENDTOP);  
 <div style="float:left;margin-top:0;">      $r->print(
 <div class="LC_Box" style="background:$loginbox_bg;">      '<div class="LC_Box"'
   $logintitle     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
   $loginform  );
   $noscript_warning  
 </div>      $r->print(<<ENDSERVERFORM);
     <form name="server" action="/adm/authenticate" method="post" target="_top">
 <div class="LC_Box" style="padding-top: 10px;">     <input type="hidden" name="logtoken" value="$logtoken" />
   $loginhelp     <input type="hidden" name="serverid" value="$lonhost" />
   $forgotpw     <input type="hidden" name="uname" value="" />
   $contactblock     <input type="hidden" name="upass0" value="" />
   $newuserlink     <input type="hidden" name="udom" value="" />
   $coursecatalog     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
 </div>     <input type="hidden" name="localres" value="$env{'form.localres'}" />
 </div>    </form>
   ENDSERVERFORM
 <div>      my $coursecatalog;
 ENDTOP      if (($showcoursecat eq '') || ($showcoursecat)) {
     if ($showmainlogo) {          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");      }
     }      my $newuserlink;
 $r->print(<<ENDTOP);      if ($shownewuserlink) {
 $announcements          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
 </div>      }
 <hr style="clear:both;" />      my $logintitle =
 ENDTOP          '<h2 class="LC_hcell"'
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);         .' style="background:'.$loginbox_header_bgcol.';'
     $domainrow = <<"END";         .' color:'.$loginbox_header_textcol.'">'
       <tr>         .$lt{'log'}
        <td  align="left" valign="top">         .'</h2>';
         <small><b>$lt{'dom'}:&nbsp;</b></small>  
        </td>      my $noscript_warning='<noscript><span class="LC_warning"><b>'
        <td  align="left" valign="top">                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
         <small><tt>&nbsp;$domain</tt></small>                          .'</b></span></noscript>';
        </td>      my $helpdeskscript;
       </tr>      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
 END                                         $authdomain,\$helpdeskscript,
     $serverrow = <<"END";                                         $showhelpdesk,\@possdoms);
       <tr>  
        <td  align="left" valign="top">      my $mobileargs;
         <small><b>$lt{'serv'}:&nbsp;</b></small>      if ($clientmobile) {
        </td>          $mobileargs = 'autocapitalize="off" autocorrect="off"';
        <td align="left" valign="top">      }
         <small><tt>&nbsp;$lonhost ($role)</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" />
     if ($loadlim) {    <b><label for="uname">$lt{'un'}</label>:</b><br />
         $loadrow = <<"END";    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
       <tr>    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
        <td align="left" valign="top">    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
         <small><b>$lt{'load'}:&nbsp;</b></small>    <b><label for="udom">$lt{'dom'}</label>:</b><br />
        </td>    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
        <td align="left" valign="top">    <input type="submit" value="$lt{'log'}" />
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>  </form>
        </td>  LFORM
       </tr>  
 END      if ($showbanner) {
     }          $r->print(<<HEADER);
     if ($uloadlim) {  <!-- The LON-CAPA Header -->
         $userloadrow = <<"END";  <div style="background:$pgbg;margin:0;width:100%;">
       <tr>    <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
        <td align="left" valign="top">  </div>
         <small><b>$lt{'userload'}:&nbsp;</b></small>  HEADER
        </td>      }
        <td align="left" valign="top">      $r->print(<<ENDTOP);
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>  <div style="float:left;margin-top:0;">
        </td>  <div class="LC_Box" style="background:$loginbox_bg;">
       </tr>    $logintitle
 END    $loginform
     }    $noscript_warning
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {  </div>
         $versionrow = <<"END";   
       <tr>  <div class="LC_Box" style="padding-top: 10px;">
        <td colspan="2" align="left">    $loginhelp
         <small>$version</small>    $forgotpw
        </td>    $contactblock
       </tr>    $newuserlink
 END    $coursecatalog
     }  </div>
   </div>
     $r->print(<<ENDDOCUMENT);  
     <div style="float: left;">  <div>
      <table border="0" cellspacing="0" cellpadding="0">  ENDTOP
 $domainrow      if ($showmainlogo) {
 $serverrow          $r->print(' <img src="'.$logo.'" alt="" />'."\n");
 $loadrow          }
 $userloadrow  $r->print(<<ENDTOP);
 $versionrow  $announcements
      </table>  </div>
     </div>  <hr style="clear:both;" />
     <div style="float: right;">  ENDTOP
     $domainlogo      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
     </div>      $domainrow = <<"END";
     <br style="clear:both;" />        <tr>
  </div>         <td  align="left" valign="top">
           <small><b>$lt{'dom'}:&nbsp;</b></small>
 <script type="text/javascript">         </td>
 // <![CDATA[         <td  align="left" valign="top">
 // the if prevents the script error if the browser can not handle this          <small><tt>&nbsp;$domain</tt></small>
 if ( document.client.uname ) { document.client.uname.focus(); }         </td>
 // ]]>        </tr>
 </script>  END
 $helpdeskscript      $serverrow = <<"END";
         <tr>
 ENDDOCUMENT         <td  align="left" valign="top">
     my %endargs = ( 'noredirectlink' => 1, );          <small><b>$lt{'serv'}:&nbsp;</b></small>
     $r->print(&Apache::loncommon::end_page(\%endargs));         </td>
     return OK;         <td align="left" valign="top">
 }          <small><tt>&nbsp;$lonhost ($role)</tt></small>
          </td>
 sub check_loginvia {        </tr>
     my ($domain,$lonhost) = @_;  END
     if ($domain eq '' || $lonhost eq '') {      if ($loadlim) {
         return;          $loadrow = <<"END";
     }        <tr>
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);         <td align="left" valign="top">
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};          <small><b>$lt{'load'}:&nbsp;</b></small>
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};         </td>
     my $output;         <td align="left" valign="top">
     if ($loginvia ne '') {          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
         my $noredirect;         </td>
         my $ip = $ENV{'REMOTE_ADDR'};        </tr>
         if ($ip eq '127.0.0.1') {  END
             $noredirect = 1;      }
         } else {      if ($uloadlim) {
             if ($loginvia_exempt ne '') {          $userloadrow = <<"END";
                 my @exempt = split(',',$loginvia_exempt);        <tr>
                 if (grep(/^\Q$ip\E$/,@exempt)) {         <td align="left" valign="top">
                     $noredirect = 1;          <small><b>$lt{'userload'}:&nbsp;</b></small>
                 }         </td>
             }         <td align="left" valign="top">
         }          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
         unless ($noredirect) {         </td>
             my ($newhost,$path);        </tr>
             if ($loginvia =~ /:/) {  END
                 ($newhost,$path) = split(':',$loginvia);      }
             } else {      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
                 $newhost = $loginvia;          $versionrow = <<"END";
             }        <tr>
             if ($newhost ne $lonhost) {         <td colspan="2" align="left">
                 if (&Apache::lonnet::hostname($newhost) ne '') {          <small>$version</small>
                     $output = &redirect_page($newhost,$path);         </td>
                 }        </tr>
             }  END
         }      }
     }  
     return $output;      $r->print(<<ENDDOCUMENT);
 }      <div style="float: left;">
        <table border="0" cellspacing="0" cellpadding="0">
 sub redirect_page {  $domainrow
     my ($desthost,$path) = @_;  $serverrow
     my $protocol = $Apache::lonnet::protocol{$desthost};  $loadrow    
     $protocol = 'http' if ($protocol ne 'https');  $userloadrow
     unless ($path =~ m{^/}) {  $versionrow
         $path = '/'.$path;       </table>
     }      </div>
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;      <div style="float: right;">
     if ($env{'form.firsturl'} ne '') {      $domainlogo
         $url .='?firsturl='.$env{'form.firsturl'};      </div>
     }      <br style="clear:both;" />
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,   </div>
                                                     {'redirect' => [0,$url],});  
     my $end_page   = &Apache::loncommon::end_page();  <script type="text/javascript">
     return $start_page.$end_page;  // <![CDATA[
 }  // the if prevents the script error if the browser can not handle this
   if ( document.client.uname ) { document.client.uname.focus(); }
 sub contactdisplay {  // ]]>
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,  </script>
         $possdoms) = @_;  $helpdeskscript
     my $contactblock;  
     my $origmail;  ENDDOCUMENT
     if (ref($possdoms) eq 'ARRAY') {      my %endargs = ( 'noredirectlink' => 1, );
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {       $r->print(&Apache::loncommon::end_page(\%endargs));
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      return OK;
         }  }
     }  
     my $requestmail =   sub check_loginvia {
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',      my ($domain,$lonhost) = @_;
                                                  $authdomain,$origmail);      if ($domain eq '' || $lonhost eq '') {
     unless ($showhelpdesk eq '0') {          return;
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {      }
             $showhelpdesk = 1;      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
         } else {      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
             $showhelpdesk = 0;      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
         }      my $output;
     }      if ($loginvia ne '') {
     if ($servadm && $showadminmail) {          my $noredirect;
         $contactblock .= $$lt{'servadm'}.':<br />'.          my $ip = $ENV{'REMOTE_ADDR'};
                          '<tt>'.$servadm.'</tt><br />';          if ($ip eq '127.0.0.1') {
     }              $noredirect = 1;
     if ($showhelpdesk) {          } else {
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';              if ($loginvia_exempt ne '') {
         my $thisurl = &escape('/adm/login');                  my @exempt = split(',',$loginvia_exempt);
         $$helpdeskscript = <<"ENDSCRIPT";                  if (grep(/^\Q$ip\E$/,@exempt)) {
 <script type="text/javascript">                      $noredirect = 1;
 // <![CDATA[                  }
 function helpdesk() {              }
     var possdom = document.client.udom.value;          }
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');          unless ($noredirect) {
     if (codedom == '') {              my ($newhost,$path);
         codedom = "$authdomain";              if ($loginvia =~ /:/) {
     }                  ($newhost,$path) = split(':',$loginvia);
     var querystr = "origurl=$thisurl&codedom="+codedom;              } else {
     document.location.href = "/adm/helpdesk?"+querystr;                  $newhost = $loginvia;
     return;              }
 }              if ($newhost ne $lonhost) {
 // ]]>                  if (&Apache::lonnet::hostname($newhost) ne '') {
 </script>                      $output = &redirect_page($newhost,$path);
 ENDSCRIPT                  }
     }              }
     return $contactblock;          }
 }      }
       return $output;
 sub forgotpwdisplay {  }
     my (%lt) = @_;  
     my $prompt_for_resetpw = 1;   sub redirect_page {
     if ($prompt_for_resetpw) {      my ($desthost,$path) = @_;
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';      my $protocol = $Apache::lonnet::protocol{$desthost};
     }      $protocol = 'http' if ($protocol ne 'https');
     return;      unless ($path =~ m{^/}) {
 }          $path = '/'.$path;
       }
 sub coursecatalog_link {      my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
     my ($linkname) = @_;      if ($env{'form.firsturl'} ne '') {
     return <<"END";          $url .='?firsturl='.$env{'form.firsturl'};
       <a href="/adm/coursecatalog">$linkname</a>      }
 END      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
 }                                                      {'redirect' => [0,$url],});
       my $end_page   = &Apache::loncommon::end_page();
 sub newuser_link {      return $start_page.$end_page;
     my ($linkname) = @_;  }
     return '<a href="/adm/createaccount">'.$linkname.'</a>';  
 }  sub contactdisplay {
       my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
 1;          $possdoms) = @_;
 __END__      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.156  
changed lines
  Added in v.1.166


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