Diff for /loncom/auth/lonlogin.pm between versions 1.128 and 1.173

version 1.128, 2009/10/21 12:29:40 version 1.173, 2018/07/04 16:58:19
Line 1 Line 1
 # The LearningOnline Network  # The LearningOnline Network
 # Login Screen  # Login Screen
 #  #
 # $Id$  # $Id$
 #  #
 # Copyright Michigan State University Board of Trustees  # Copyright Michigan State University Board of Trustees
 #  #
 # This file is part of the LearningOnline Network with CAPA (LON-CAPA).  # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
 #  #
 # LON-CAPA is free software; you can redistribute it and/or modify  # LON-CAPA is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by  # it under the terms of the GNU General Public License as published by
 # the Free Software Foundation; either version 2 of the License, or  # the Free Software Foundation; either version 2 of the License, or
 # (at your option) any later version.  # (at your option) any later version.
 #  #
 # LON-CAPA is distributed in the hope that it will be useful,  # LON-CAPA is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of  # but WITHOUT ANY WARRANTY; without even the implied warranty of
 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 # GNU General Public License for more details.  # GNU General Public License for more details.
 #  #
 # You should have received a copy of the GNU General Public License  # You should have received a copy of the GNU General Public License
 # along with LON-CAPA; if not, write to the Free Software  # along with LON-CAPA; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #  #
 # /home/httpd/html/adm/gpl.txt  # /home/httpd/html/adm/gpl.txt
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
   
 package Apache::lonlogin;  package Apache::lonlogin;
   
 use strict;  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use Apache::File ();  use Apache::File ();
 use Apache::lonnet;  use Apache::lonnet;
 use Apache::loncommon();  use Apache::loncommon();
 use Apache::lonauth();  use Apache::lonauth();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::migrateuser();  use Apache::migrateuser();
 use lib '/home/httpd/lib/perl/';  use lib '/home/httpd/lib/perl/';
 use LONCAPA;  use LONCAPA;
    use CGI::Cookie();
 sub handler {   
     my $r = shift;  sub handler {
       my $r = shift;
     &Apache::loncommon::get_unprocessed_cgi  
  (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},      &Apache::loncommon::get_unprocessed_cgi
       $ENV{'REDIRECT_QUERY_STRING'}),   (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
  ['interface','username','domain','firsturl','localpath','localres',        $ENV{'REDIRECT_QUERY_STRING'}),
   'token','role','symb']);   ['interface','username','domain','firsturl','localpath','localres',
     if (!defined($env{'form.firsturl'})) {    'token','role','symb','iptoken']);
         &Apache::lonacc::get_posted_cgi($r,['firsturl']);      if (!defined($env{'form.firsturl'})) {
     }          &Apache::lonacc::get_posted_cgi($r,['firsturl']);
       }
 # -- check if they are a migrating user      if (!defined($env{'form.firsturl'})) {
     if (defined($env{'form.token'})) {          if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {
  return &Apache::migrateuser::handler($r);              $env{'form.firsturl'} = $ENV{'REDIRECT_URL'};
     }          }
       }
     &Apache::loncommon::no_cache($r);  
     &Apache::lonlocal::get_language_handle($r);  # -- check if they are a migrating user
     &Apache::loncommon::content_type($r,'text/html');      if (defined($env{'form.token'})) {
     $r->send_http_header;   return &Apache::migrateuser::handler($r);
     return OK if $r->header_only;      }
   
   # For "public user" - remove any exising "public" cookie, as user really wants to log-in
 # Are we re-routing?      my ($handle,$lonidsdir,$expirepub,$userdom);
     if (-e '/home/httpd/html/lon-status/reroute.txt') {      unless ($r->header_only) {
  &Apache::lonauth::reroute($r);          $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
  return OK;          if ($handle ne '') {
     }              $lonidsdir=$r->dir_config('lonIDsDir');
               if ($handle=~/^publicuser\_/) {
                   unlink($r->dir_config('lonIDsDir')."/$handle.id");
 # -------------------------------- Prevent users from attempting to login twice                  undef($handle);
     my $handle = &Apache::lonnet::check_for_valid_session($r);                  undef($userdom);
     if ($handle=~/^publicuser\_/) {                  $expirepub = 1;
 # For "public user" - remove it, we apparently really want to login              }
  unlink($r->dir_config('lonIDsDir')."/$handle.id");          }
     } elsif ($handle ne '') {      }
 # Indeed, a valid token is found  
  my $start_page =       &Apache::loncommon::no_cache($r);
     &Apache::loncommon::start_page('Already logged in');      &Apache::lonlocal::get_language_handle($r);
  my $end_page =       &Apache::loncommon::content_type($r,'text/html');
     &Apache::loncommon::end_page();      if ($expirepub) {
         my $dest = '/adm/roles';          my $c = new CGI::Cookie(-name    => 'lonPubID',
         if ($env{'form.firsturl'} ne '') {                                  -value   => '',
             $dest = $env{'form.firsturl'};                                   -expires => '-10y',);
         }          $r->header_out('Set-cookie' => $c);
  $r->print(      } elsif (($handle eq '') && ($userdom ne '')) {
                   $start_page          my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
                  .'<h1>'.&mt('You are already logged in!').'</h1>'          foreach my $name (keys(%cookies)) {
                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',              next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'              my $c = new CGI::Cookie(-name    => $name,
                  .'<p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'                                      -value   => '',
                  .$end_page                                      -expires => '-10y',);
                  );              $r->headers_out->add('Set-cookie' => $c);
         return OK;          }
     }      }
       $r->send_http_header;
 # ---------------------------------------------------- No valid token, continue      return OK if $r->header_only;
   
  # ---------------------------- Not possible to really login to domain "public"  
     if ($env{'form.domain'} eq 'public') {  # Are we re-routing?
  $env{'form.domain'}='';      my $londocroot = $r->dir_config('lonDocRoot');
  $env{'form.username'}='';      if (-e "$londocroot/lon-status/reroute.txt") {
     }   &Apache::lonauth::reroute($r);
 # ----------------------------------------------------------- Process Interface   return OK;
     $env{'form.interface'}=~s/\W//g;      }
   
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};  #
   # If browser sent an old cookie for which the session file had been removed
     my $iconpath=   # check if configuration for user's domain has a portal URL set.  If so
  &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));  # switch user's log-in to the portal.
   #
     my $lonhost = $r->dir_config('lonHostID');  
     my $domain = &Apache::lonnet::default_login_domain();      if (($handle eq '') && ($userdom ne '')) {
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);          my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
     if ($lonhost ne '') {          if ($domdefaults{'portal_def'} =~ /^https?\:/) {
         my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};              my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
         if (($loginvia ne '') && ($loginvia ne $lonhost)) {                                            {'redirect' => [0,$domdefaults{'portal_def'}],});
             if (&Apache::lonnet::hostname($loginvia) ne '') {              my $end_page   = &Apache::loncommon::end_page();
                 $r->print(&redirect_page($loginvia));              $r->print($start_page.$end_page);
                 return OK;              return OK;
             }          }
         }      }
     }  
       $env{'form.firsturl'} =~ s/(`)/'/g;
     if (($env{'form.domain'}) &&   
  (&Apache::lonnet::domain($env{'form.domain'},'description'))) {  # -------------------------------- Prevent users from attempting to login twice
  $domain=$env{'form.domain'};      if ($handle ne '') {
     }          &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
     my $role    = $r->dir_config('lonRole');   my $start_page =
     my $loadlim = $r->dir_config('lonLoadLim');      &Apache::loncommon::start_page('Already logged in');
     my $servadm = $r->dir_config('lonAdmEMail');   my $end_page =
     my $tabdir  = $r->dir_config('lonTabDir');      &Apache::loncommon::end_page();
     my $include = $r->dir_config('lonIncludes');          my $dest = '/adm/roles';
     my $expire  = $r->dir_config('lonExpire');          if ($env{'form.firsturl'} ne '') {
     my $version = $r->dir_config('lonVersion');              $dest = $env{'form.firsturl'};
     my $host_name = &Apache::lonnet::hostname($lonhost);          }
    $r->print(
 # --------------------------------------------- Default values for login fields                    $start_page
                    .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
     my $authusername=($env{'form.username'}?$env{'form.username'}:'');                   .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
                    .$end_page
 # ---------------------------------------------------------- Determine own load                   );
     my $loadavg;          return OK;
     {      }
  my $loadfile=Apache::File->new('/proc/loadavg');  
  $loadavg=<$loadfile>;  # ---------------------------------------------------- No valid token, continue
     }  
     $loadavg =~ s/\s.*//g;  # ---------------------------- Not possible to really login to domain "public"
     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);      if ($env{'form.domain'} eq 'public') {
     my $userloadpercent=&Apache::lonnet::userload();   $env{'form.domain'}='';
    $env{'form.username'}='';
 # ------------------------------------------------------- Do the load balancing      }
     my $otherserver= &Apache::lonnet::absolute_url($host_name);  
     my $firsturl=  # ------ Is this page requested because /adm/migrateuser detected an IP change?
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});      my %sessiondata;
 # ---------------------------------------------------------- Are we overloaded?      if ($env{'form.iptoken'}) {
     if ((($userloadpercent>100.0)||($loadpercent>100.0))) {          %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);          unless ($sessiondata{'sessionserver'}) {
  if ($unloaded) { $otherserver=$unloaded; }              my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
     }              delete($env{'form.iptoken'});
           }
 # ----------------------------------------------------------- Get announcements      }
     my $announcements=&Apache::lonnet::getannounce();  # ----------------------------------------------------------- Process Interface
 # -------------------------------------------------------- Set login parameters      $env{'form.interface'}=~s/\W//g;
   
     my @hexstr=('0','1','2','3','4','5','6','7',      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
                 '8','9','a','b','c','d','e','f');          &Apache::loncommon::decode_user_agent();
     my $lkey='';  
     for (0..7) {      my $iconpath=
         $lkey.=$hexstr[rand(15)];   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
     }  
       my $lonhost = $r->dir_config('lonHostID');
     my $ukey='';      my $domain = &Apache::lonnet::default_login_domain();
     for (0..7) {      my $defdom = $domain;
         $ukey.=$hexstr[rand(15)];      if ($lonhost ne '') {
     }          unless ($sessiondata{'sessionserver'}) {
               my $redirect = &check_loginvia($domain,$lonhost);
     my $lextkey=hex($lkey);              if ($redirect) {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }                  $r->print($redirect);
                   return OK;
     my $uextkey=hex($ukey);              }
     if ($uextkey>2147483647) { $uextkey-=4294967296; }          }
       }
 # -------------------------------------------------------- Store away log token  
     my $tokenextras;      if (($sessiondata{'domain'}) &&
     if ($env{'form.role'}) {          (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
         $tokenextras = '&role='.&escape($env{'form.role'});          $domain=$sessiondata{'domain'};
     }      } elsif (($env{'form.domain'}) &&
     if ($env{'form.symb'}) {   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
         if (!$tokenextras) {   $domain=$env{'form.domain'};
             $tokenextras = '&';      }
         }  
         $tokenextras .= '&symb='.&escape($env{'form.symb'});      my $role    = $r->dir_config('lonRole');
     }      my $loadlim = $r->dir_config('lonLoadLim');
     my $logtoken=Apache::lonnet::reply(      my $uloadlim= $r->dir_config('lonUserLoadLim');
        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,      my $servadm = $r->dir_config('lonAdmEMail');
        $lonhost);      my $tabdir  = $r->dir_config('lonTabDir');
       my $include = $r->dir_config('lonIncludes');
 # ------------------- If we cannot talk to ourselves, we are in serious trouble      my $expire  = $r->dir_config('lonExpire');
       my $version = $r->dir_config('lonVersion');
     if ($logtoken eq 'con_lost') {      my $host_name = &Apache::lonnet::hostname($lonhost);
         my $spares='';  
  my $last;  # --------------------------------------------- Default values for login fields
         foreach my $hostid (sort     
     {      my ($authusername,$authdomain);
  &Apache::lonnet::hostname($a) cmp      if ($sessiondata{'username'}) {
     &Apache::lonnet::hostname($b);          $authusername=$sessiondata{'username'};
     }      } else {
     keys(%Apache::lonnet::spareid)) {          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
             next if ($hostid eq $lonhost);          $authusername=($env{'form.username'}?$env{'form.username'}:'');
     my $hostname = &Apache::lonnet::hostname($hostid);      }
     next if ($last eq $hostname);      if ($sessiondata{'domain'}) {
             $spares.='<br /><font size="+1"><a href="http://'.          $authdomain=$sessiondata{'domain'};
                 $hostname.      } else {
                 '/adm/login?domain='.$authdomain.'">'.          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
                 $hostname.'</a>'.          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
                 ' '.&mt('(preferred)').'</font>'.$/;      }
     $last=$hostname;  
         }  # ---------------------------------------------------------- Determine own load
 $spares.= '<br />';      my $loadavg;
 my %all_hostnames = &Apache::lonnet::all_hostnames();      {
 foreach my $hostid (sort   my $loadfile=Apache::File->new('/proc/loadavg');
     {   $loadavg=<$loadfile>;
  &Apache::lonnet::hostname($a) cmp      }
     &Apache::lonnet::hostname($b);      $loadavg =~ s/\s.*//g;
     }  
     keys(%all_hostnames)) {      my ($loadpercent,$userloadpercent);
     next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});      if ($loadlim) {
     my $hostname = &Apache::lonnet::hostname($hostid);          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
     next if ($last eq $hostname);      }
     $spares.='<br /><a href="http://'.      if ($uloadlim) {
  $hostname.          $userloadpercent=&Apache::lonnet::userload();
  '/adm/login?domain='.$authdomain.'">'.      }
  $hostname.'</a>';  
     $last=$hostname;      my $firsturl=
 }      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 $r->print(  
    '<html>'  # ----------------------------------------------------------- Get announcements
   .'<head><title>'      my $announcements=&Apache::lonnet::getannounce();
   .&mt('The LearningOnline Network with CAPA')  # -------------------------------------------------------- Set login parameters
   .'</title></head>'  
   .'<body bgcolor="#FFFFFF">'      my @hexstr=('0','1','2','3','4','5','6','7',
   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'                  '8','9','a','b','c','d','e','f');
   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'      my $lkey='';
   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>'      for (0..7) {
   .'<p>'.&mt('Please attempt to login to one of the following servers:').'</p>'          $lkey.=$hexstr[rand(15)];
   .$spares      }
   .'</body>'  
   .'</html>'      my $ukey='';
 );      for (0..7) {
 return OK;          $ukey.=$hexstr[rand(15)];
 }      }
   
 # ----------------------------------------------- Apparently we are in business      my $lextkey=hex($lkey);
 $servadm=~s/\,/\<br \/\>/g;      if ($lextkey>2147483647) { $lextkey-=4294967296; }
   
 # ----------------------------------------------------------- Front page design      my $uextkey=hex($ukey);
 my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);      if ($uextkey>2147483647) { $uextkey-=4294967296; }
 my $font=&Apache::loncommon::designparm('login.font',$domain);  
 my $link=&Apache::loncommon::designparm('login.link',$domain);  # -------------------------------------------------------- Store away log token
 my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);      my $tokenextras;
 my $alink=&Apache::loncommon::designparm('login.alink',$domain);      if ($env{'form.role'}) {
 my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);          $tokenextras = '&role='.&escape($env{'form.role'});
 my $logo=&Apache::loncommon::designparm('login.logo',$domain);      }
 my $img=&Apache::loncommon::designparm('login.img',$domain);      if ($env{'form.symb'}) {
 my $domainlogo=&Apache::loncommon::domainlogo($domain);          if (!$tokenextras) {
 my $login=&Apache::loncommon::designparm('login.login',$domain);              $tokenextras = '&';
 if ($login eq '') {          }
 $login = $iconpath.'/'.&mt('userauthentication.gif');          $tokenextras .= '&symb='.&escape($env{'form.symb'});
 }      }
 my $showbanner = 1;      if ($env{'form.iptoken'}) {
 my $showmainlogo = 1;          if (!$tokenextras) {
 if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {              $tokenextras = '&&';
     $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);          }
 }          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
 if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {      }
     $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);      my $logtoken=Apache::lonnet::reply(
 }         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
 my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);         $lonhost);
 my $showcoursecat =  
 &Apache::loncommon::designparm('login.coursecatalog',$domain);  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
 my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);  #    we are in serious trouble
 my $shownewuserlink =   
 &Apache::loncommon::designparm('login.newuser',$domain);      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
 my $now=time;          if ($logtoken eq 'no_such_host') {
 my $js = (<<ENDSCRIPT);              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
           }
 <script type="text/javascript" language="JavaScript">          my $spares='';
 // <![CDATA[   my $last;
 function send()          foreach my $hostid (sort
 {      {
 this.document.server.elements.uname.value   &Apache::lonnet::hostname($a) cmp
 =this.document.client.elements.uname.value;      &Apache::lonnet::hostname($b);
       }
 this.document.server.elements.udom.value      keys(%Apache::lonnet::spareid)) {
 =this.document.client.elements.udom.value;              next if ($hostid eq $lonhost);
       my $hostname = &Apache::lonnet::hostname($hostid);
 uextkey=this.document.client.elements.uextkey.value;      next if (($last eq $hostname) || ($hostname eq ''));
 lextkey=this.document.client.elements.lextkey.value;              $spares.='<br /><font size="+1"><a href="http://'.
 initkeys();                  $hostname.
                   '/adm/login?domain='.$authdomain.'">'.
 this.document.server.elements.upass0.value                  $hostname.'</a>'.
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));                  ' '.&mt('(preferred)').'</font>'.$/;
 this.document.server.elements.upass1.value      $last=$hostname;
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));          }
 this.document.server.elements.upass2.value          if ($spares) {
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));              $spares.= '<br />';
           }
 this.document.client.elements.uname.value='';          my %all_hostnames = &Apache::lonnet::all_hostnames();
 this.document.client.elements.upass$now.value='';          foreach my $hostid (sort
       {
 this.document.server.submit();   &Apache::lonnet::hostname($a) cmp
 return false;      &Apache::lonnet::hostname($b);
 }      }
 // ]]>      keys(%all_hostnames)) {
 </script>              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
               my $hostname = &Apache::lonnet::hostname($hostid);
 ENDSCRIPT              next if (($last eq $hostname) || ($hostname eq ''));
               $spares.='<br /><a href="http://'.
 # --------------------------------------------------- Print login screen header               $hostname.
                '/adm/login?domain='.$authdomain.'">'.
 my %add_entries = (               $hostname.'</a>';
        bgcolor      => "$mainbg",              $last=$hostname;
        text         => "$font",           }
        link         => "$link",           $r->print(
        vlink        => "$vlink",     '<html>'
        alink        => "$alink",);    .'<head><title>'
     .&mt('The LearningOnline Network with CAPA')
 $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,    .'</title></head>'
        { 'redirect'       => [$expire,'/adm/roles'],     .'<body bgcolor="#FFFFFF">'
  'add_entries' => \%add_entries,    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
  'only_body'   => 1,}));    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
     .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
 # ----------------------------------------------------------------------- Texts          if ($spares) {
               $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
 my %lt=&Apache::lonlocal::texthash(                       .'</p>'
   'un'  => 'Username',                       .$spares);
   'pw'  => 'Password',          }
   'dom' => 'Domain',          $r->print('</body>'
   'perc' => 'percent',                   .'</html>'
   'load' => 'Server Load',          );
   'userload' => 'User Load',          return OK;
   'catalog' => 'Course Catalog',      }
   'log' => 'Log in',  
   'help' => 'Log-in Help',  # ----------------------------------------------- Apparently we are in business
   'serv' => 'Server',      $servadm=~s/\,/\<br \/\>/g;
   'servadm' => 'Server Administration',  
   'helpdesk' => 'Contact Helpdesk',  # ----------------------------------------------------------- Front page design
   'forgotpw' => 'Forgot password?',      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
   'newuser'  => 'New User?',      my $font=&Apache::loncommon::designparm('login.font',$domain);
   );      my $link=&Apache::loncommon::designparm('login.link',$domain);
 # -------------------------------------------------- Change password field name      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
 my $forgotpw = &forgotpwdisplay(%lt);      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
 my $loginhelp = &loginhelpdisplay(%lt);      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
       my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
 # ---------------------------------------------------- Serve out DES JavaScript      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
 {      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
 my $jsh=Apache::File->new($include."/londes.js");      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
 $r->print(<$jsh>);      my $img=&Apache::loncommon::designparm('login.img',$domain);
 }      my $domainlogo=&Apache::loncommon::domainlogo($domain);
 # ---------------------------------------------------------- Serve rest of page      my $showbanner = 1;
       my $showmainlogo = 1;
 $r->print(      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
   '<div class="LC_loginpage_container">');          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
       }
 #      if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
 #  If the loadbalancing yielded just http:// because perhaps there's no loadbalancing?          $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
 #  then just us a relative link to authenticate:      }
 #      my $showadminmail;
       my @possdoms = &Apache::lonnet::current_machine_domains();
 $r->print(<<ENDSERVERFORM);      if (grep(/^\Q$domain\E$/,@possdoms)) {
 <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">          $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
    <input type="hidden" name="logtoken" value="$logtoken" />      }
    <input type="hidden" name="serverid" value="$lonhost" />      my $showcoursecat =
    <input type="hidden" name="uname" value="" />          &Apache::loncommon::designparm('login.coursecatalog',$domain);
    <input type="hidden" name="upass0" value="" />      my $shownewuserlink =
    <input type="hidden" name="upass1" value="" />          &Apache::loncommon::designparm('login.newuser',$domain);
    <input type="hidden" name="upass2" value="" />      my $showhelpdesk =
    <input type="hidden" name="udom" value="" />          &Apache::loncommon::designparm('login.helpdesk',$domain);
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />      my $now=time;
    <input type="hidden" name="localres" value="$env{'form.localres'}" />      my $js = (<<ENDSCRIPT);
   </form>  
 ENDSERVERFORM  <script type="text/javascript" language="JavaScript">
 my $coursecatalog;  // <![CDATA[
 if (($showcoursecat eq '') || ($showcoursecat)) {  function send()
     $coursecatalog = &coursecatalog_link($lt{'catalog'});  {
 }  this.document.server.elements.uname.value
 my $newuserlink;  =this.document.client.elements.uname.value;
 if ($shownewuserlink) {  
     $newuserlink = &newuser_link($lt{'newuser'}).'<br />';  this.document.server.elements.udom.value
 }  =this.document.client.elements.udom.value;
 my $logintitle;  
 if ($loginheader eq 'text') {  uextkey=this.document.client.elements.uextkey.value;
     $logintitle ='<h2>'.$lt{'log'}.'</h2>';  lextkey=this.document.client.elements.lextkey.value;
 } else {  initkeys();
     $logintitle = '<img src="'.$login.'" alt="'.  
                   &mt('User Authentication').'" />';  if(this.document.server.action.substr(0,5) === 'http:'){
 }      this.document.server.elements.upass0.value
           =getCrypted(this.document.client.elements.upass$now.value);
 my $noscript_warning='<noscript><span class="LC_warning"><b>'  } else {
                      .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')      this.document.server.elements.upass0.value
                     .'</b></span></noscript>';          =this.document.client.elements.upass$now.value;
 my $helpdeskscript;  }
 my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,  
                             $version,$authdomain,\$helpdeskscript);  this.document.client.elements.uname.value='';
   this.document.client.elements.upass$now.value='';
 my $loginform=(<<LFORM);  
 <form name="client" action="" onsubmit="return(send())">  this.document.server.submit();
   <input type="hidden" name="lextkey" value="$lextkey" />  return false;
   <input type="hidden" name="uextkey" value="$uextkey" />  }
   <b><label for="uname">$lt{'un'}</label>:</b><br />  
   <input type="text" name="uname" size="15" value="$authusername" /><br />  function enableInput() {
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />      this.document.client.elements.upass$now.removeAttribute("readOnly");
   <input type="password" name="upass$now" size="15" /><br />      this.document.client.elements.uname.removeAttribute("readOnly");
   <b><label for="udom">$lt{'dom'}</label>:</b><br />      this.document.client.elements.udom.removeAttribute("readOnly");
   <input type="text" name="udom" size="15" value="$authdomain" /><br />      return;
   <input type="submit" value="$lt{'log'}" />  }
 </form>  
 LFORM  // ]]>
   </script>
     if ($showbanner) {  
         $r->print(<<HEADER);  ENDSCRIPT
 <!-- The LON-CAPA Header -->  
 <table border="0" align="left" width="100%" cellspacing="0" cellpadding="1">  # --------------------------------------------------- Print login screen header
  <tr>  
   <td align="left" valign="top" bgcolor="$pgbg">      my %add_entries = (
       <img src="$img" border="0" alt="The Learning Online Network with CAPA" />         bgcolor      => "$mainbg",
   </td>         text         => "$font",
  </tr>         link         => "$link",
 </table>         vlink        => "$vlink",
 HEADER         alink        => "$alink",
     }                 onload       => 'javascript:enableInput();',);
     $r->print(<<ENDTOP);  
 <div class="LC_loginpage_space">&nbsp;</div>      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
 <div class="LC_loginpage_floatLeft">      @hosts = &Apache::lonnet::current_machine_ids();
 <div class="LC_loginpage_loginContainer">      $lonhost_in_use = $lonhost;
   $logintitle      if (@hosts > 1) {
    <table border="0" align="left" cellspacing="1" cellpadding="2" width="100%">          foreach my $hostid (@hosts) {
       <tr>              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
    <td>                  $lonhost_in_use = $hostid;
  $loginform                  last;
            </td>              }
       </tr>          }
    </table>        }
    $noscript_warning      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
 </div>      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
         $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
 <div class="LC_loginpage_loginInfo">      if ($headextra) {
         $loginhelp<br />          my $omitextra;
         $forgotpw<br />          if ($headextra_exempt ne '') {
  $contactblock<br />              my @exempt = split(',',$headextra_exempt);
         $newuserlink              my $ip = $ENV{'REMOTE_ADDR'};
         $coursecatalog              if (grep(/^\Q$ip\E$/,@exempt)) {
 </div>                  $omitextra = 1;
 </div>              }
 ENDTOP          }
     if ($showmainlogo) {          unless ($omitextra) {
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");              my $confname = $defdom.'-domainconfig';
     }              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
 $r->print(<<ENDTOP);                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
 $announcements                  unless ($extra eq '-1') {
 $domainlogo                      $js .= "\n".$extra."\n";
 <div class="LC_loginpage_space">&nbsp;</div>                  }
 ENDTOP              }
           }
 $r->print(<<ENDDOCUMENT);      }
      <table border="0" cellspacing="0" cellpadding="0">  
       <tr>      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
        <td  align="left" valign="top">         { 'redirect'       => [$expire,'/adm/roles'],
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>   'add_entries' => \%add_entries,
        </td>   'only_body'   => 1,}));
        <td  align="left" valign="top">  
         <small><tt>&nbsp;$domain</tt></small>  # ----------------------------------------------------------------------- Texts
        </td>  
       </tr>      my %lt=&Apache::lonlocal::texthash(
       <tr>            'un'       => 'Username',
        <td  align="left" valign="top">            'pw'       => 'Password',
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>            'dom'      => 'Domain',
        </td>            'perc'     => 'percent',
        <td align="left" valign="top">            'load'     => 'Server Load',
         <small><tt>&nbsp;$lonhost ($role)</tt></small>            'userload' => 'User Load',
        </td>            'catalog'  => 'Course/Community Catalog',
       </tr>            'log'      => 'Log in',
       <tr>            'help'     => 'Log-in Help',
        <td align="left" valign="top">            'serv'     => 'Server',
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>            'servadm'  => 'Server Administration',
        </td>            'helpdesk' => 'Contact Helpdesk',
        <td align="left" valign="top">            'forgotpw' => 'Forgot password?',
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>            'newuser'  => 'New User?',
        </td>         );
       </tr>  # -------------------------------------------------- Change password field name
       <tr>  
        <td align="left" valign="top">      my $forgotpw = &forgotpwdisplay(%lt);
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>      $forgotpw .= '<br />' if $forgotpw;
        </td>      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
        <td align="left" valign="top">      if ($loginhelp) {
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
        </td>      }
       </tr>  
      </table>  # ---------------------------------------------------- Serve out DES JavaScript
  </div>      {
       my $jsh=Apache::File->new($include."/londes.js");
 <script type="text/javascript">      $r->print(<$jsh>);
 // <![CDATA[      }
 // the if prevents the script error if the browser can not handle this  # ---------------------------------------------------------- Serve rest of page
 if ( document.client.uname ) { document.client.uname.focus(); }  
 // ]]>      $r->print(
 </script>      '<div class="LC_Box"'
 $helpdeskscript     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
   );
 ENDDOCUMENT  
     my %endargs = ( 'noredirectlink' => 1, );      $r->print(<<ENDSERVERFORM);
     $r->print(&Apache::loncommon::end_page(\%endargs));  <form name="server" action="/adm/authenticate" method="post" target="_top">
     return OK;     <input type="hidden" name="logtoken" value="$logtoken" />
 }     <input type="hidden" name="serverid" value="$lonhost" />
      <input type="hidden" name="uname" value="" />
 sub redirect_page {     <input type="hidden" name="upass0" value="" />
     my ($desthost) = @_;     <input type="hidden" name="udom" value="" />
     my $protocol = $Apache::lonnet::protocol{$desthost};     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
     $protocol = 'http' if ($protocol ne 'https');     <input type="hidden" name="localres" value="$env{'form.localres'}" />
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).'/';    </form>
     if ($env{'form.firsturl'} ne '') {  ENDSERVERFORM
         $url .='?firsturl='.$env{'form.firsturl'};      my $coursecatalog;
     }      if (($showcoursecat eq '') || ($showcoursecat)) {
     my $start_page = &Apache::loncommon::start_page('Switching Server',undef,          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
                                                     {'redirect' => [0,$url],});      }
     my $end_page   = &Apache::loncommon::end_page();      my $newuserlink;
     return $start_page.$end_page;      if ($shownewuserlink) {
 }          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
       }
 sub contactdisplay {      my $logintitle =
     my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_;          '<h2 class="LC_hcell"'
     my $contactblock;         .' style="background:'.$loginbox_header_bgcol.';'
     my $showhelpdesk = 0;         .' color:'.$loginbox_header_textcol.'">'
     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};         .$lt{'log'}
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {         .'</h2>';
         $showhelpdesk = 1;  
     }      my $noscript_warning='<noscript><span class="LC_warning"><b>'
     if ($servadm && $showadminmail) {                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.                          .'</b></span></noscript>';
                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';      my $helpdeskscript;
     }      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
     if ($showhelpdesk) {                                         $authdomain,\$helpdeskscript,
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';                                         $showhelpdesk,\@possdoms);
         my $thisurl = &escape('/adm/login');  
         $$helpdeskscript = <<"ENDSCRIPT";      my $mobileargs;
 <script type="text/javascript">      if ($clientmobile) {
 // <![CDATA[          $mobileargs = 'autocapitalize="off" autocorrect="off"';
 function helpdesk() {      }
     var codedom = document.client.udom.value;      my $loginform=(<<LFORM);
     if (codedom == '') {  <form name="client" action="" onsubmit="return(send())">
         codedom = "$authdomain";    <input type="hidden" name="lextkey" value="$lextkey" />
     }    <input type="hidden" name="uextkey" value="$uextkey" />
     var querystr = "origurl=$thisurl&codedom="+codedom;    <b><label for="uname">$lt{'un'}</label>:</b><br />
     document.location.href = "/adm/helpdesk?"+querystr;    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
     return;    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
 }    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
 // ]]>    <b><label for="udom">$lt{'dom'}</label>:</b><br />
 </script>    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
 ENDSCRIPT    <input type="submit" value="$lt{'log'}" />
     }  </form>
     $contactblock .= <<"ENDBLOCK";  LFORM
      &nbsp;&nbsp;&nbsp;$version  
 ENDBLOCK      if ($showbanner) {
     return $contactblock;          $r->print(<<HEADER);
 }  <!-- The LON-CAPA Header -->
   <div style="background:$pgbg;margin:0;width:100%;">
 sub forgotpwdisplay {    <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
     my (%lt) = @_;  </div>
     my $prompt_for_resetpw = 1;   HEADER
     if ($prompt_for_resetpw) {      }
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';      $r->print(<<ENDTOP);
     }  <div style="float:left;margin-top:0;">
     return;  <div class="LC_Box" style="background:$loginbox_bg;">
 }    $logintitle
     $loginform
 sub loginhelpdisplay {    $noscript_warning
     my (%lt) = @_;  </div>
     my $login_help = 1;   
     if ($login_help) {  <div class="LC_Box" style="padding-top: 10px;">
         return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';    $loginhelp
     }    $forgotpw
     return;    $contactblock
 }    $newuserlink
     $coursecatalog
 sub coursecatalog_link {  </div>
     my ($linkname) = @_;  </div>
     return <<"END";  
       <a href="/adm/coursecatalog">$linkname</a>  <div>
 END  ENDTOP
 }      if ($showmainlogo) {
           $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
 sub newuser_link {      }
     my ($linkname) = @_;  $r->print(<<ENDTOP);
     return '&nbsp;&nbsp;&nbsp;<a href="/adm/createaccount"><b>'.$linkname.'</b></a><br />';  $announcements
 }  </div>
   <hr style="clear:both;" />
 1;  ENDTOP
 __END__      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
       $domainrow = <<"END";
         <tr>
          <td  align="left" valign="top">
           <small><b>$lt{'dom'}:&nbsp;</b></small>
          </td>
          <td  align="left" valign="top">
           <small><tt>&nbsp;$domain</tt></small>
          </td>
         </tr>
   END
       $serverrow = <<"END";
         <tr>
          <td  align="left" valign="top">
           <small><b>$lt{'serv'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$lonhost ($role)</tt></small>
          </td>
         </tr>
   END
       if ($loadlim) {
           $loadrow = <<"END";
         <tr>
          <td align="left" valign="top">
           <small><b>$lt{'load'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
          </td>
         </tr>
   END
       }
       if ($uloadlim) {
           $userloadrow = <<"END";
         <tr>
          <td align="left" valign="top">
           <small><b>$lt{'userload'}:&nbsp;</b></small>
          </td>
          <td align="left" valign="top">
           <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
          </td>
         </tr>
   END
       }
       if (($version ne '') && ($version ne '<!-- VERSION -->')) {
           $versionrow = <<"END";
         <tr>
          <td colspan="2" align="left">
           <small>$version</small>
          </td>
         </tr>
   END
       }
   
       $r->print(<<ENDDOCUMENT);
       <div style="float: left;">
        <table border="0" cellspacing="0" cellpadding="0">
   $domainrow
   $serverrow
   $loadrow    
   $userloadrow
   $versionrow
        </table>
       </div>
       <div style="float: right;">
       $domainlogo
       </div>
       <br style="clear:both;" />
    </div>
   
   <script type="text/javascript">
   // <![CDATA[
   // the if prevents the script error if the browser can not handle this
   if ( document.client.uname ) { document.client.uname.focus(); }
   // ]]>
   </script>
   $helpdeskscript
   
   ENDDOCUMENT
       my %endargs = ( 'noredirectlink' => 1, );
       $r->print(&Apache::loncommon::end_page(\%endargs));
       return OK;
   }
   
   sub check_loginvia {
       my ($domain,$lonhost) = @_;
       if ($domain eq '' || $lonhost eq '') {
           return;
       }
       my %domconfhash = &Apache::loncommon::get_domainconf($domain);
       my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
       my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
       my $output;
       if ($loginvia ne '') {
           my $noredirect;
           my $ip = $ENV{'REMOTE_ADDR'};
           if ($ip eq '127.0.0.1') {
               $noredirect = 1;
           } else {
               if ($loginvia_exempt ne '') {
                   my @exempt = split(',',$loginvia_exempt);
                   if (grep(/^\Q$ip\E$/,@exempt)) {
                       $noredirect = 1;
                   }
               }
           }
           unless ($noredirect) {
               my ($newhost,$path);
               if ($loginvia =~ /:/) {
                   ($newhost,$path) = split(':',$loginvia);
               } else {
                   $newhost = $loginvia;
               }
               if ($newhost ne $lonhost) {
                   if (&Apache::lonnet::hostname($newhost) ne '') {
                       $output = &redirect_page($newhost,$path);
                   }
               }
           }
       }
       return $output;
   }
   
   sub redirect_page {
       my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
       unless ($path =~ m{^/}) {
           $path = '/'.$path;
       }
       my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
       if ($env{'form.firsturl'} ne '') {
           $url .='?firsturl='.$env{'form.firsturl'};
       }
       my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                       {'redirect' => [0,$url],});
       my $end_page   = &Apache::loncommon::end_page();
       return $start_page.$end_page;
   }
   
   sub contactdisplay {
       my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
           $possdoms) = @_;
       my $contactblock;
       my $origmail;
       if (ref($possdoms) eq 'ARRAY') {
           if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
               $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
           }
       }
       my $requestmail =
           &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                    $authdomain,$origmail);
       unless ($showhelpdesk eq '0') {
           if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
               $showhelpdesk = 1;
           } else {
               $showhelpdesk = 0;
           }
       }
       if ($servadm && $showadminmail) {
           $contactblock .= $$lt{'servadm'}.':<br />'.
                            '<tt>'.$servadm.'</tt><br />';
       }
       if ($showhelpdesk) {
           $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
           my $thisurl = &escape('/adm/login');
           $$helpdeskscript = <<"ENDSCRIPT";
   <script type="text/javascript">
   // <![CDATA[
   function helpdesk() {
       var possdom = document.client.udom.value;
       var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
       if (codedom == '') {
           codedom = "$authdomain";
       }
       var querystr = "origurl=$thisurl&codedom="+codedom;
       document.location.href = "/adm/helpdesk?"+querystr;
       return;
   }
   // ]]>
   </script>
   ENDSCRIPT
       }
       return $contactblock;
   }
   
   sub forgotpwdisplay {
       my (%lt) = @_;
       my $prompt_for_resetpw = 1;
       if ($prompt_for_resetpw) {
           return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
       }
       return;
   }
   
   sub coursecatalog_link {
       my ($linkname) = @_;
       return <<"END";
         <a href="/adm/coursecatalog">$linkname</a>
   END
   }
   
   sub newuser_link {
       my ($linkname) = @_;
       return '<a href="/adm/createaccount">'.$linkname.'</a>';
   }
   
   1;
   __END__

Removed from v.1.128  
changed lines
  Added in v.1.173


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