Diff for /loncom/auth/lonlogin.pm between versions 1.158.2.1 and 1.162

version 1.158.2.1, 2015/03/06 22:32:39 version 1.162, 2015/03/06 20:39:22
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'});
         my $delete = &Apache::lonnet::tmpdel($env{'form.token'});          unless ($sessiondata{'sessionserver'}) {
     }              my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
 # ----------------------------------------------------------- Process Interface              delete($env{'form.iptoken'});
     $env{'form.interface'}=~s/\W//g;          }
       }
     (undef,undef,undef,undef,undef,undef,my $clientmobile) =  # ----------------------------------------------------------- Process Interface
         &Apache::loncommon::decode_user_agent();      $env{'form.interface'}=~s/\W//g;
   
     my $iconpath=       (undef,undef,undef,undef,undef,undef,my $clientmobile) =
  &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));          &Apache::loncommon::decode_user_agent();
   
     my $lonhost = $r->dir_config('lonHostID');      my $iconpath=
     my $domain = &Apache::lonnet::default_login_domain();   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
     if ($lonhost ne '') {  
         unless ($sessiondata{'sessionserver'}) {      my $lonhost = $r->dir_config('lonHostID');
             my $redirect = &check_loginvia($domain,$lonhost);      my $domain = &Apache::lonnet::default_login_domain();
             if ($redirect) {      my $defdom = $domain;
                 $r->print($redirect);      if ($lonhost ne '') {
                 return OK;          unless ($sessiondata{'sessionserver'}) {
             }              my $redirect = &check_loginvia($domain,$lonhost);
         }              if ($redirect) {
     }                  $r->print($redirect);
                   return OK;
     if (($sessiondata{'domain'}) &&              }
         (&Apache::lonnet::domain($env{'form.domain'},'description'))) {          }
         $domain=$sessiondata{'domain'};      }
     } elsif (($env{'form.domain'}) &&   
  (&Apache::lonnet::domain($env{'form.domain'},'description'))) {      if (($sessiondata{'domain'}) &&
  $domain=$env{'form.domain'};          (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
     }          $domain=$sessiondata{'domain'};
       } elsif (($env{'form.domain'}) &&
     my $role    = $r->dir_config('lonRole');   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
     my $loadlim = $r->dir_config('lonLoadLim');   $domain=$env{'form.domain'};
     my $uloadlim= $r->dir_config('lonUserLoadLim');      }
     my $servadm = $r->dir_config('lonAdmEMail');  
     my $tabdir  = $r->dir_config('lonTabDir');      my $role    = $r->dir_config('lonRole');
     my $include = $r->dir_config('lonIncludes');      my $loadlim = $r->dir_config('lonLoadLim');
     my $expire  = $r->dir_config('lonExpire');      my $uloadlim= $r->dir_config('lonUserLoadLim');
     my $version = $r->dir_config('lonVersion');      my $servadm = $r->dir_config('lonAdmEMail');
     my $host_name = &Apache::lonnet::hostname($lonhost);      my $tabdir  = $r->dir_config('lonTabDir');
       my $include = $r->dir_config('lonIncludes');
 # --------------------------------------------- Default values for login fields      my $expire  = $r->dir_config('lonExpire');
           my $version = $r->dir_config('lonVersion');
     my ($authusername,$authdomain);      my $host_name = &Apache::lonnet::hostname($lonhost);
     if ($sessiondata{'username'}) {  
         $authusername=$sessiondata{'username'};  # --------------------------------------------- Default values for login fields
     } else {     
         $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});      my ($authusername,$authdomain);
         $authusername=($env{'form.username'}?$env{'form.username'}:'');      if ($sessiondata{'username'}) {
     }          $authusername=$sessiondata{'username'};
     if ($sessiondata{'domain'}) {      } else {
         $authdomain=$sessiondata{'domain'};          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
     } else {          $authusername=($env{'form.username'}?$env{'form.username'}:'');
         $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});      }
         $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);      if ($sessiondata{'domain'}) {
     }          $authdomain=$sessiondata{'domain'};
       } else {
 # ---------------------------------------------------------- Determine own load          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
     my $loadavg;          $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
     {      }
  my $loadfile=Apache::File->new('/proc/loadavg');  
  $loadavg=<$loadfile>;  # ---------------------------------------------------------- Determine own load
     }      my $loadavg;
     $loadavg =~ s/\s.*//g;      {
    my $loadfile=Apache::File->new('/proc/loadavg');
     my ($loadpercent,$userloadpercent);   $loadavg=<$loadfile>;
     if ($loadlim) {      }
         $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);      $loadavg =~ s/\s.*//g;
     }  
     if ($uloadlim) {      my ($loadpercent,$userloadpercent);
         $userloadpercent=&Apache::lonnet::userload();      if ($loadlim) {
     }          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
       }
     my $firsturl=      if ($uloadlim) {
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});          $userloadpercent=&Apache::lonnet::userload();
       }
 # ----------------------------------------------------------- Get announcements  
     my $announcements=&Apache::lonnet::getannounce();      my $firsturl=
 # -------------------------------------------------------- Set login parameters      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
   
     my @hexstr=('0','1','2','3','4','5','6','7',  # ----------------------------------------------------------- Get announcements
                 '8','9','a','b','c','d','e','f');      my $announcements=&Apache::lonnet::getannounce();
     my $lkey='';  # -------------------------------------------------------- Set login parameters
     for (0..7) {  
         $lkey.=$hexstr[rand(15)];      my @hexstr=('0','1','2','3','4','5','6','7',
     }                  '8','9','a','b','c','d','e','f');
       my $lkey='';
     my $ukey='';      for (0..7) {
     for (0..7) {          $lkey.=$hexstr[rand(15)];
         $ukey.=$hexstr[rand(15)];      }
     }  
       my $ukey='';
     my $lextkey=hex($lkey);      for (0..7) {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }          $ukey.=$hexstr[rand(15)];
       }
     my $uextkey=hex($ukey);  
     if ($uextkey>2147483647) { $uextkey-=4294967296; }      my $lextkey=hex($lkey);
       if ($lextkey>2147483647) { $lextkey-=4294967296; }
 # -------------------------------------------------------- Store away log token  
     my $tokenextras;      my $uextkey=hex($ukey);
     if ($env{'form.role'}) {      if ($uextkey>2147483647) { $uextkey-=4294967296; }
         $tokenextras = '&role='.&escape($env{'form.role'});  
     }  # -------------------------------------------------------- Store away log token
     if ($env{'form.symb'}) {      my $tokenextras;
         if (!$tokenextras) {      if ($env{'form.role'}) {
             $tokenextras = '&';          $tokenextras = '&role='.&escape($env{'form.role'});
         }      }
         $tokenextras .= '&symb='.&escape($env{'form.symb'});      if ($env{'form.symb'}) {
     }          if (!$tokenextras) {
     my $logtoken=Apache::lonnet::reply(              $tokenextras = '&';
        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,          }
        $lonhost);          $tokenextras .= '&symb='.&escape($env{'form.symb'});
       }
 # -- If we cannot talk to ourselves, or hostID does not map to a hostname      if ($env{'form.iptoken'}) {
 #    we are in serious trouble          if (!$tokenextras) {
               $tokenextras = '&&';
     if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {          }
         if ($logtoken eq 'no_such_host') {          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
             &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');      }
         }      my $logtoken=Apache::lonnet::reply(
         my $spares='';         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
  my $last;         $lonhost);
         foreach my $hostid (sort  
     {  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
  &Apache::lonnet::hostname($a) cmp  #    we are in serious trouble
     &Apache::lonnet::hostname($b);  
     }      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
     keys(%Apache::lonnet::spareid)) {          if ($logtoken eq 'no_such_host') {
             next if ($hostid eq $lonhost);              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
     my $hostname = &Apache::lonnet::hostname($hostid);          }
     next if (($last eq $hostname) || ($hostname eq ''));          my $spares='';
             $spares.='<br /><font size="+1"><a href="http://'.   my $last;
                 $hostname.          foreach my $hostid (sort
                 '/adm/login?domain='.$authdomain.'">'.      {
                 $hostname.'</a>'.   &Apache::lonnet::hostname($a) cmp
                 ' '.&mt('(preferred)').'</font>'.$/;      &Apache::lonnet::hostname($b);
     $last=$hostname;      }
         }      keys(%Apache::lonnet::spareid)) {
         if ($spares) {              next if ($hostid eq $lonhost);
             $spares.= '<br />';      my $hostname = &Apache::lonnet::hostname($hostid);
         }      next if (($last eq $hostname) || ($hostname eq ''));
         my %all_hostnames = &Apache::lonnet::all_hostnames();              $spares.='<br /><font size="+1"><a href="http://'.
         foreach my $hostid (sort                  $hostname.
     {                  '/adm/login?domain='.$authdomain.'">'.
  &Apache::lonnet::hostname($a) cmp                  $hostname.'</a>'.
     &Apache::lonnet::hostname($b);                  ' '.&mt('(preferred)').'</font>'.$/;
     }      $last=$hostname;
     keys(%all_hostnames)) {          }
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});          if ($spares) {
             my $hostname = &Apache::lonnet::hostname($hostid);              $spares.= '<br />';
             next if (($last eq $hostname) || ($hostname eq ''));          }
             $spares.='<br /><a href="http://'.          my %all_hostnames = &Apache::lonnet::all_hostnames();
              $hostname.          foreach my $hostid (sort
              '/adm/login?domain='.$authdomain.'">'.      {
              $hostname.'</a>';   &Apache::lonnet::hostname($a) cmp
             $last=$hostname;      &Apache::lonnet::hostname($b);
          }      }
          $r->print(      keys(%all_hostnames)) {
    '<html>'              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
   .'<head><title>'              my $hostname = &Apache::lonnet::hostname($hostid);
   .&mt('The LearningOnline Network with CAPA')              next if (($last eq $hostname) || ($hostname eq ''));
   .'</title></head>'              $spares.='<br /><a href="http://'.
   .'<body bgcolor="#FFFFFF">'               $hostname.
   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'               '/adm/login?domain='.$authdomain.'">'.
   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'               $hostname.'</a>';
   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');              $last=$hostname;
         if ($spares) {           }
             $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')           $r->print(
                      .'</p>'     '<html>'
                      .$spares);    .'<head><title>'
         }    .&mt('The LearningOnline Network with CAPA')
         $r->print('</body>'    .'</title></head>'
                  .'</html>'    .'<body bgcolor="#FFFFFF">'
         );    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
         return OK;    .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
     }    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
           if ($spares) {
 # ----------------------------------------------- Apparently we are in business              $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
     $servadm=~s/\,/\<br \/\>/g;                       .'</p>'
                        .$spares);
 # ----------------------------------------------------------- Front page design          }
     my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);          $r->print('</body>'
     my $font=&Apache::loncommon::designparm('login.font',$domain);                   .'</html>'
     my $link=&Apache::loncommon::designparm('login.link',$domain);          );
     my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);          return OK;
     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);  # ----------------------------------------------- Apparently we are in business
     my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);      $servadm=~s/\,/\<br \/\>/g;
     my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);  
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);  # ----------------------------------------------------------- Front page design
     my $img=&Apache::loncommon::designparm('login.img',$domain);      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
     my $domainlogo=&Apache::loncommon::domainlogo($domain);      my $font=&Apache::loncommon::designparm('login.font',$domain);
     my $showbanner = 1;      my $link=&Apache::loncommon::designparm('login.link',$domain);
     my $showmainlogo = 1;      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {      my $alink=&Apache::loncommon::designparm('login.alink',$domain);
         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
     }      my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {      my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
     }      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
     my $showadminmail;      my $img=&Apache::loncommon::designparm('login.img',$domain);
     my @possdoms = &Apache::lonnet::current_machine_domains();      my $domainlogo=&Apache::loncommon::domainlogo($domain);
     if (grep(/^\Q$domain\E$/,@possdoms)) {      my $showbanner = 1;
         $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);      my $showmainlogo = 1;
     }      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
     my $showcoursecat =          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
         &Apache::loncommon::designparm('login.coursecatalog',$domain);      }
     my $shownewuserlink =       if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
         &Apache::loncommon::designparm('login.newuser',$domain);          $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
     my $showhelpdesk =      }
         &Apache::loncommon::designparm('login.helpdesk',$domain);      my $showadminmail;
     my $now=time;      my @possdoms = &Apache::lonnet::current_machine_domains();
     my $js = (<<ENDSCRIPT);      if (grep(/^\Q$domain\E$/,@possdoms)) {
           $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
 <script type="text/javascript" language="JavaScript">      }
 // <![CDATA[      my $showcoursecat =
 function send()          &Apache::loncommon::designparm('login.coursecatalog',$domain);
 {      my $shownewuserlink =
 this.document.server.elements.uname.value          &Apache::loncommon::designparm('login.newuser',$domain);
 =this.document.client.elements.uname.value;      my $showhelpdesk =
           &Apache::loncommon::designparm('login.helpdesk',$domain);
 this.document.server.elements.udom.value      my $now=time;
 =this.document.client.elements.udom.value;      my $js = (<<ENDSCRIPT);
   
 uextkey=this.document.client.elements.uextkey.value;  <script type="text/javascript" language="JavaScript">
 lextkey=this.document.client.elements.lextkey.value;  // <![CDATA[
 initkeys();  function send()
   {
 this.document.server.elements.upass0.value  this.document.server.elements.uname.value
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));  =this.document.client.elements.uname.value;
 this.document.server.elements.upass1.value  
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));  this.document.server.elements.udom.value
 this.document.server.elements.upass2.value  =this.document.client.elements.udom.value;
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));  
   uextkey=this.document.client.elements.uextkey.value;
 this.document.client.elements.uname.value='';  lextkey=this.document.client.elements.lextkey.value;
 this.document.client.elements.upass$now.value='';  initkeys();
   
 this.document.server.submit();  this.document.server.elements.upass0.value
 return false;      =this.document.client.elements.upass$now.value.substr(0,15);
 }  this.document.server.elements.upass1.value
       =this.document.client.elements.upass$now.value.substr(15,15);
 function enableInput() {  this.document.server.elements.upass2.value
     this.document.client.elements.upass$now.removeAttribute("readOnly");      =this.document.client.elements.upass$now.value.substr(30,15);
     this.document.client.elements.uname.removeAttribute("readOnly");  
     this.document.client.elements.udom.removeAttribute("readOnly");  if(this.document.server.action.substr(0,5) === 'http:'){
     return;      for (var idx in [1,2,3]){
 }          this.document.server.elements['upass' + idx].value =
               crypted(this.document.server.elements['upass' + idx].value);
 // ]]>      }
 </script>  }
   
 ENDSCRIPT  this.document.client.elements.uname.value='';
   this.document.client.elements.upass$now.value='';
 # --------------------------------------------------- Print login screen header  
   this.document.server.submit();
     my %add_entries = (  return false;
        bgcolor      => "$mainbg",  }
        text         => "$font",  
        link         => "$link",  function enableInput() {
        vlink        => "$vlink",      this.document.client.elements.upass$now.removeAttribute("readOnly");
        alink        => "$alink",      this.document.client.elements.uname.removeAttribute("readOnly");
                onload       => 'javascript:enableInput();',);      this.document.client.elements.udom.removeAttribute("readOnly");
       return;
     my %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);  }
     my $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost};  
     my $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost};  // ]]>
     if ($headextra) {  </script>
         my $omitextra;  
         if ($headextra_exempt ne '') {  ENDSCRIPT
             my @exempt = split(',',$headextra_exempt);  
             my $ip = $ENV{'REMOTE_ADDR'};  # --------------------------------------------------- Print login screen header
             if (grep(/^\Q$ip\E$/,@exempt)) {  
                 $omitextra = 1;      my %add_entries = (
             }         bgcolor      => "$mainbg",
         }         text         => "$font",
         unless ($omitextra) {         link         => "$link",
             my $confname = $defdom.'-domainconfig';         vlink        => "$vlink",
             if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost/\E}) {         alink        => "$alink",
                 my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));                 onload       => 'javascript:enableInput();',);
                 unless ($extra eq '-1') {  
                     $js .= "\n".$extra."\n";      my %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
                 }      my $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost};
             }      my $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost};
         }      if ($headextra) {
     }          my $omitextra;
           if ($headextra_exempt ne '') {
     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,              my @exempt = split(',',$headextra_exempt);
        { 'redirect'       => [$expire,'/adm/roles'],               my $ip = $ENV{'REMOTE_ADDR'};
  'add_entries' => \%add_entries,              if (grep(/^\Q$ip\E$/,@exempt)) {
  'only_body'   => 1,}));                  $omitextra = 1;
               }
 # ----------------------------------------------------------------------- Texts          }
           unless ($omitextra) {
     my %lt=&Apache::lonlocal::texthash(              my $confname = $defdom.'-domainconfig';
           'un'       => 'Username',              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost/\E}) {
           'pw'       => 'Password',                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
           'dom'      => 'Domain',                  unless ($extra eq '-1') {
           'perc'     => 'percent',                      $js .= "\n".$extra."\n";
           'load'     => 'Server Load',                  }
           'userload' => 'User Load',              }
           'catalog'  => 'Course/Community Catalog',          }
           'log'      => 'Log in',      }
           'help'     => 'Log-in Help',  
           'serv'     => 'Server',      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
           'servadm'  => 'Server Administration',         { 'redirect'       => [$expire,'/adm/roles'],
           'helpdesk' => 'Contact Helpdesk',   'add_entries' => \%add_entries,
           'forgotpw' => 'Forgot password?',   'only_body'   => 1,}));
           'newuser'  => 'New User?',  
        );  # ----------------------------------------------------------------------- Texts
 # -------------------------------------------------- Change password field name  
       my %lt=&Apache::lonlocal::texthash(
     my $forgotpw = &forgotpwdisplay(%lt);            'un'       => 'Username',
     $forgotpw .= '<br />' if $forgotpw;            'pw'       => 'Password',
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);            'dom'      => 'Domain',
     if ($loginhelp) {            'perc'     => 'percent',
         $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';            'load'     => 'Server Load',
     }            'userload' => 'User Load',
             'catalog'  => 'Course/Community Catalog',
 # ---------------------------------------------------- Serve out DES JavaScript            'log'      => 'Log in',
     {            'help'     => 'Log-in Help',
     my $jsh=Apache::File->new($include."/londes.js");            'serv'     => 'Server',
     $r->print(<$jsh>);            'servadm'  => 'Server Administration',
     }            'helpdesk' => 'Contact Helpdesk',
 # ---------------------------------------------------------- Serve rest of page            'forgotpw' => 'Forgot password?',
             'newuser'  => 'New User?',
     $r->print(         );
     '<div class="LC_Box"'  # -------------------------------------------------- Change password field name
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'  
 );      my $forgotpw = &forgotpwdisplay(%lt);
       $forgotpw .= '<br />' if $forgotpw;
     $r->print(<<ENDSERVERFORM);      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
 <form name="server" action="/adm/authenticate" method="post" target="_top">      if ($loginhelp) {
    <input type="hidden" name="logtoken" value="$logtoken" />          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
    <input type="hidden" name="serverid" value="$lonhost" />      }
    <input type="hidden" name="uname" value="" />  
    <input type="hidden" name="upass0" value="" />  # ---------------------------------------------------- Serve out DES JavaScript
    <input type="hidden" name="upass1" value="" />      {
    <input type="hidden" name="upass2" value="" />      my $jsh=Apache::File->new($include."/londes.js");
    <input type="hidden" name="udom" value="" />      $r->print(<$jsh>);
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />      }
    <input type="hidden" name="localres" value="$env{'form.localres'}" />  # ---------------------------------------------------------- Serve rest of page
   </form>  
 ENDSERVERFORM      $r->print(
     my $coursecatalog;      '<div class="LC_Box"'
     if (($showcoursecat eq '') || ($showcoursecat)) {     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';  );
     }  
     my $newuserlink;      $r->print(<<ENDSERVERFORM);
     if ($shownewuserlink) {  <form name="server" action="/adm/authenticate" method="post" target="_top">
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';     <input type="hidden" name="logtoken" value="$logtoken" />
     }     <input type="hidden" name="serverid" value="$lonhost" />
     my $logintitle =     <input type="hidden" name="uname" value="" />
         '<h2 class="LC_hcell"'     <input type="hidden" name="upass0" value="" />
        .' style="background:'.$loginbox_header_bgcol.';'     <input type="hidden" name="upass1" value="" />
        .' color:'.$loginbox_header_textcol.'">'     <input type="hidden" name="upass2" value="" />
        .$lt{'log'}     <input type="hidden" name="udom" value="" />
        .'</h2>';     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
      <input type="hidden" name="localres" value="$env{'form.localres'}" />
     my $noscript_warning='<noscript><span class="LC_warning"><b>'    </form>
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')  ENDSERVERFORM
                         .'</b></span></noscript>';      my $coursecatalog;
     my $helpdeskscript;      if (($showcoursecat eq '') || ($showcoursecat)) {
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
                                        $authdomain,\$helpdeskscript,      }
                                        $showhelpdesk,\@possdoms);      my $newuserlink;
       if ($shownewuserlink) {
     my $mobileargs;          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
     if ($clientmobile) {      }
         $mobileargs = 'autocapitalize="off" autocorrect="off"';       my $logintitle =
     }          '<h2 class="LC_hcell"'
     my $loginform=(<<LFORM);         .' style="background:'.$loginbox_header_bgcol.';'
 <form name="client" action="" onsubmit="return(send())">         .' color:'.$loginbox_header_textcol.'">'
   <input type="hidden" name="lextkey" value="$lextkey" />         .$lt{'log'}
   <input type="hidden" name="uextkey" value="$uextkey" />         .'</h2>';
   <b><label for="uname">$lt{'un'}</label>:</b><br />  
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />      my $noscript_warning='<noscript><span class="LC_warning"><b>'
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />                          .'</b></span></noscript>';
   <b><label for="udom">$lt{'dom'}</label>:</b><br />      my $helpdeskscript;
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
   <input type="submit" value="$lt{'log'}" />                                         $authdomain,\$helpdeskscript,
 </form>                                         $showhelpdesk,\@possdoms);
 LFORM  
       my $mobileargs;
     if ($showbanner) {      if ($clientmobile) {
         $r->print(<<HEADER);          $mobileargs = 'autocapitalize="off" autocorrect="off"';
 <!-- The LON-CAPA Header -->      }
 <div style="background:$pgbg;margin:0;width:100%;">      my $loginform=(<<LFORM);
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" />  <form name="client" action="" onsubmit="return(send())">
 </div>    <input type="hidden" name="lextkey" value="$lextkey" />
 HEADER    <input type="hidden" name="uextkey" value="$uextkey" />
     }    <b><label for="uname">$lt{'un'}</label>:</b><br />
     $r->print(<<ENDTOP);    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
 <div style="float:left;margin-top:0;">    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
 <div class="LC_Box" style="background:$loginbox_bg;">    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
   $logintitle    <b><label for="udom">$lt{'dom'}</label>:</b><br />
   $loginform    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
   $noscript_warning    <input type="submit" value="$lt{'log'}" />
 </div>  </form>
     LFORM
 <div class="LC_Box" style="padding-top: 10px;">  
   $loginhelp      if ($showbanner) {
   $forgotpw          $r->print(<<HEADER);
   $contactblock  <!-- The LON-CAPA Header -->
   $newuserlink  <div style="background:$pgbg;margin:0;width:100%;">
   $coursecatalog    <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
 </div>  </div>
 </div>  HEADER
       }
 <div>      $r->print(<<ENDTOP);
 ENDTOP  <div style="float:left;margin-top:0;">
     if ($showmainlogo) {  <div class="LC_Box" style="background:$loginbox_bg;">
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");    $logintitle
     }    $loginform
 $r->print(<<ENDTOP);    $noscript_warning
 $announcements  </div>
 </div>   
 <hr style="clear:both;" />  <div class="LC_Box" style="padding-top: 10px;">
 ENDTOP    $loginhelp
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);    $forgotpw
     $domainrow = <<"END";    $contactblock
       <tr>    $newuserlink
        <td  align="left" valign="top">    $coursecatalog
         <small><b>$lt{'dom'}:&nbsp;</b></small>  </div>
        </td>  </div>
        <td  align="left" valign="top">  
         <small><tt>&nbsp;$domain</tt></small>  <div>
        </td>  ENDTOP
       </tr>      if ($showmainlogo) {
 END          $r->print(' <img src="'.$logo.'" alt="" />'."\n");
     $serverrow = <<"END";      }
       <tr>  $r->print(<<ENDTOP);
        <td  align="left" valign="top">  $announcements
         <small><b>$lt{'serv'}:&nbsp;</b></small>  </div>
        </td>  <hr style="clear:both;" />
        <td align="left" valign="top">  ENDTOP
         <small><tt>&nbsp;$lonhost ($role)</tt></small>      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
        </td>      $domainrow = <<"END";
       </tr>        <tr>
 END         <td  align="left" valign="top">
     if ($loadlim) {          <small><b>$lt{'dom'}:&nbsp;</b></small>
         $loadrow = <<"END";         </td>
       <tr>         <td  align="left" valign="top">
        <td align="left" valign="top">          <small><tt>&nbsp;$domain</tt></small>
         <small><b>$lt{'load'}:&nbsp;</b></small>         </td>
        </td>        </tr>
        <td align="left" valign="top">  END
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>      $serverrow = <<"END";
        </td>        <tr>
       </tr>         <td  align="left" valign="top">
 END          <small><b>$lt{'serv'}:&nbsp;</b></small>
     }         </td>
     if ($uloadlim) {         <td align="left" valign="top">
         $userloadrow = <<"END";          <small><tt>&nbsp;$lonhost ($role)</tt></small>
       <tr>         </td>
        <td align="left" valign="top">        </tr>
         <small><b>$lt{'userload'}:&nbsp;</b></small>  END
        </td>      if ($loadlim) {
        <td align="left" valign="top">          $loadrow = <<"END";
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>        <tr>
        </td>         <td align="left" valign="top">
       </tr>          <small><b>$lt{'load'}:&nbsp;</b></small>
 END         </td>
     }         <td align="left" valign="top">
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
         $versionrow = <<"END";         </td>
       <tr>        </tr>
        <td colspan="2" align="left">  END
         <small>$version</small>      }
        </td>      if ($uloadlim) {
       </tr>          $userloadrow = <<"END";
 END        <tr>
     }         <td align="left" valign="top">
           <small><b>$lt{'userload'}:&nbsp;</b></small>
     $r->print(<<ENDDOCUMENT);         </td>
     <div style="float: left;">         <td align="left" valign="top">
      <table border="0" cellspacing="0" cellpadding="0">          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
 $domainrow         </td>
 $serverrow        </tr>
 $loadrow      END
 $userloadrow      }
 $versionrow      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
      </table>          $versionrow = <<"END";
     </div>        <tr>
     <div style="float: right;">         <td colspan="2" align="left">
     $domainlogo          <small>$version</small>
     </div>         </td>
     <br style="clear:both;" />        </tr>
  </div>  END
       }
 <script type="text/javascript">  
 // <![CDATA[      $r->print(<<ENDDOCUMENT);
 // the if prevents the script error if the browser can not handle this      <div style="float: left;">
 if ( document.client.uname ) { document.client.uname.focus(); }       <table border="0" cellspacing="0" cellpadding="0">
 // ]]>  $domainrow
 </script>  $serverrow
 $helpdeskscript  $loadrow    
   $userloadrow
 ENDDOCUMENT  $versionrow
     my %endargs = ( 'noredirectlink' => 1, );       </table>
     $r->print(&Apache::loncommon::end_page(\%endargs));      </div>
     return OK;      <div style="float: right;">
 }      $domainlogo
       </div>
 sub check_loginvia {      <br style="clear:both;" />
     my ($domain,$lonhost) = @_;   </div>
     if ($domain eq '' || $lonhost eq '') {  
         return;  <script type="text/javascript">
     }  // <![CDATA[
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);  // the if prevents the script error if the browser can not handle this
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};  if ( document.client.uname ) { document.client.uname.focus(); }
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};  // ]]>
     my $output;  </script>
     if ($loginvia ne '') {  $helpdeskscript
         my $noredirect;  
         my $ip = $ENV{'REMOTE_ADDR'};  ENDDOCUMENT
         if ($ip eq '127.0.0.1') {      my %endargs = ( 'noredirectlink' => 1, );
             $noredirect = 1;      $r->print(&Apache::loncommon::end_page(\%endargs));
         } else {      return OK;
             if ($loginvia_exempt ne '') {  }
                 my @exempt = split(',',$loginvia_exempt);  
                 if (grep(/^\Q$ip\E$/,@exempt)) {  sub check_loginvia {
                     $noredirect = 1;      my ($domain,$lonhost) = @_;
                 }      if ($domain eq '' || $lonhost eq '') {
             }          return;
         }      }
         unless ($noredirect) {      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
             my ($newhost,$path);      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
             if ($loginvia =~ /:/) {      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
                 ($newhost,$path) = split(':',$loginvia);      my $output;
             } else {      if ($loginvia ne '') {
                 $newhost = $loginvia;          my $noredirect;
             }          my $ip = $ENV{'REMOTE_ADDR'};
             if ($newhost ne $lonhost) {          if ($ip eq '127.0.0.1') {
                 if (&Apache::lonnet::hostname($newhost) ne '') {              $noredirect = 1;
                     $output = &redirect_page($newhost,$path);          } else {
                 }              if ($loginvia_exempt ne '') {
             }                  my @exempt = split(',',$loginvia_exempt);
         }                  if (grep(/^\Q$ip\E$/,@exempt)) {
     }                      $noredirect = 1;
     return $output;                  }
 }              }
           }
 sub redirect_page {          unless ($noredirect) {
     my ($desthost,$path) = @_;              my ($newhost,$path);
     my $protocol = $Apache::lonnet::protocol{$desthost};              if ($loginvia =~ /:/) {
     $protocol = 'http' if ($protocol ne 'https');                  ($newhost,$path) = split(':',$loginvia);
     unless ($path =~ m{^/}) {              } else {
         $path = '/'.$path;                  $newhost = $loginvia;
     }              }
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;              if ($newhost ne $lonhost) {
     if ($env{'form.firsturl'} ne '') {                  if (&Apache::lonnet::hostname($newhost) ne '') {
         $url .='?firsturl='.$env{'form.firsturl'};                      $output = &redirect_page($newhost,$path);
     }                  }
     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;      return $output;
 }  }
   
 sub contactdisplay {  sub redirect_page {
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,      my ($desthost,$path) = @_;
         $possdoms) = @_;      my $protocol = $Apache::lonnet::protocol{$desthost};
     my $contactblock;      $protocol = 'http' if ($protocol ne 'https');
     my $origmail;      unless ($path =~ m{^/}) {
     if (ref($possdoms) eq 'ARRAY') {          $path = '/'.$path;
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {       }
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};      my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
         }      if ($env{'form.firsturl'} ne '') {
     }          $url .='?firsturl='.$env{'form.firsturl'};
     my $requestmail =       }
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                  $authdomain,$origmail);                                                      {'redirect' => [0,$url],});
     unless ($showhelpdesk eq '0') {      my $end_page   = &Apache::loncommon::end_page();
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {      return $start_page.$end_page;
             $showhelpdesk = 1;  }
         } else {  
             $showhelpdesk = 0;  sub contactdisplay {
         }      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
     }          $possdoms) = @_;
     if ($servadm && $showadminmail) {      my $contactblock;
         $contactblock .= $$lt{'servadm'}.':<br />'.      my $origmail;
                          '<tt>'.$servadm.'</tt><br />';      if (ref($possdoms) eq 'ARRAY') {
     }          if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
     if ($showhelpdesk) {              $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';          }
         my $thisurl = &escape('/adm/login');      }
         $$helpdeskscript = <<"ENDSCRIPT";      my $requestmail =
 <script type="text/javascript">          &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
 // <![CDATA[                                                   $authdomain,$origmail);
 function helpdesk() {      unless ($showhelpdesk eq '0') {
     var possdom = document.client.udom.value;          if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');              $showhelpdesk = 1;
     if (codedom == '') {          } else {
         codedom = "$authdomain";              $showhelpdesk = 0;
     }          }
     var querystr = "origurl=$thisurl&codedom="+codedom;      }
     document.location.href = "/adm/helpdesk?"+querystr;      if ($servadm && $showadminmail) {
     return;          $contactblock .= $$lt{'servadm'}.':<br />'.
 }                           '<tt>'.$servadm.'</tt><br />';
 // ]]>      }
 </script>      if ($showhelpdesk) {
 ENDSCRIPT          $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
     }          my $thisurl = &escape('/adm/login');
     return $contactblock;          $$helpdeskscript = <<"ENDSCRIPT";
 }  <script type="text/javascript">
   // <![CDATA[
 sub forgotpwdisplay {  function helpdesk() {
     my (%lt) = @_;      var possdom = document.client.udom.value;
     my $prompt_for_resetpw = 1;       var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
     if ($prompt_for_resetpw) {      if (codedom == '') {
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';          codedom = "$authdomain";
     }      }
     return;      var querystr = "origurl=$thisurl&codedom="+codedom;
 }      document.location.href = "/adm/helpdesk?"+querystr;
       return;
 sub coursecatalog_link {  }
     my ($linkname) = @_;  // ]]>
     return <<"END";  </script>
       <a href="/adm/coursecatalog">$linkname</a>  ENDSCRIPT
 END      }
 }      return $contactblock;
   }
 sub newuser_link {  
     my ($linkname) = @_;  sub forgotpwdisplay {
     return '<a href="/adm/createaccount">'.$linkname.'</a>';      my (%lt) = @_;
 }      my $prompt_for_resetpw = 1;
       if ($prompt_for_resetpw) {
 1;          return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
 __END__      }
       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.158.2.1  
changed lines
  Added in v.1.162


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