Diff for /loncom/auth/lonlogin.pm between versions 1.158.2.6 and 1.161

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

Removed from v.1.158.2.6  
changed lines
  Added in v.1.161


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