Diff for /loncom/auth/lonlogin.pm between versions 1.158.2.5 and 1.166

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

Removed from v.1.158.2.5  
changed lines
  Added in v.1.166


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