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

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


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