Diff for /loncom/auth/lonlogin.pm between versions 1.111 and 1.174

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


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.