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

version 1.158.2.4, 2015/06/06 14:40:28 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'});
         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  this.document.server.elements.upass0.value
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));      =this.document.client.elements.upass$now.value.substr(0,15);
 this.document.server.elements.upass1.value  this.document.server.elements.upass1.value
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));      =this.document.client.elements.upass$now.value.substr(15,15);
 this.document.server.elements.upass2.value  this.document.server.elements.upass2.value
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));      =this.document.client.elements.upass$now.value.substr(30,15);
   
 this.document.client.elements.uname.value='';  if(this.document.server.action.substr(0,5) === 'http:'){
 this.document.client.elements.upass$now.value='';      for (var idx in [1,2,3]){
           this.document.server.elements['upass' + idx].value =
 this.document.server.submit();              crypted(this.document.server.elements['upass' + idx].value);
 return false;      }
 }  }
   
 function enableInput() {  this.document.client.elements.uname.value='';
     this.document.client.elements.upass$now.removeAttribute("readOnly");  this.document.client.elements.upass$now.value='';
     this.document.client.elements.uname.removeAttribute("readOnly");  
     this.document.client.elements.udom.removeAttribute("readOnly");  this.document.server.submit();
     return;  return false;
 }  }
   
 // ]]>  function enableInput() {
 </script>      this.document.client.elements.upass$now.removeAttribute("readOnly");
       this.document.client.elements.uname.removeAttribute("readOnly");
 ENDSCRIPT      this.document.client.elements.udom.removeAttribute("readOnly");
       return;
 # --------------------------------------------------- Print login screen header  }
   
     my %add_entries = (  // ]]>
        bgcolor      => "$mainbg",  </script>
        text         => "$font",  
        link         => "$link",  ENDSCRIPT
        vlink        => "$vlink",  
        alink        => "$alink",  # --------------------------------------------------- Print login screen header
                onload       => 'javascript:enableInput();',);  
       my %add_entries = (
     my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);         bgcolor      => "$mainbg",
     @hosts = &Apache::lonnet::current_machine_ids();         text         => "$font",
     $lonhost_in_use = $lonhost;         link         => "$link",
     if (@hosts > 1) {         vlink        => "$vlink",
         foreach my $hostid (@hosts) {         alink        => "$alink",
             if (&Apache::lonnet::host_domain($hostid) eq $defdom) {                 onload       => 'javascript:enableInput();',);
                 $lonhost_in_use = $hostid;  
                 last;      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) {
     %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);          my $omitextra;
     $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};          if ($headextra_exempt ne '') {
     $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};              my @exempt = split(',',$headextra_exempt);
     if ($headextra) {              my $ip = $ENV{'REMOTE_ADDR'};
         my $omitextra;              if (grep(/^\Q$ip\E$/,@exempt)) {
         if ($headextra_exempt ne '') {                  $omitextra = 1;
             my @exempt = split(',',$headextra_exempt);              }
             my $ip = $ENV{'REMOTE_ADDR'};          }
             if (grep(/^\Q$ip\E$/,@exempt)) {          unless ($omitextra) {
                 $omitextra = 1;              my $confname = $defdom.'-domainconfig';
             }              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost/\E}) {
         }                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
         unless ($omitextra) {                  unless ($extra eq '-1') {
             my $confname = $defdom.'-domainconfig';                      $js .= "\n".$extra."\n";
             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,  
        { 'redirect'       => [$expire,'/adm/roles'],   # ----------------------------------------------------------------------- Texts
  'add_entries' => \%add_entries,  
  'only_body'   => 1,}));      my %lt=&Apache::lonlocal::texthash(
             'un'       => 'Username',
 # ----------------------------------------------------------------------- Texts            'pw'       => 'Password',
             'dom'      => 'Domain',
     my %lt=&Apache::lonlocal::texthash(            'perc'     => 'percent',
           'un'       => 'Username',            'load'     => 'Server Load',
           'pw'       => 'Password',            'userload' => 'User Load',
           'dom'      => 'Domain',            'catalog'  => 'Course/Community Catalog',
           'perc'     => 'percent',            'log'      => 'Log in',
           'load'     => 'Server Load',            'help'     => 'Log-in Help',
           'userload' => 'User Load',            'serv'     => 'Server',
           'catalog'  => 'Course/Community Catalog',            'servadm'  => 'Server Administration',
           'log'      => 'Log in',            'helpdesk' => 'Contact Helpdesk',
           'help'     => 'Log-in Help',            'forgotpw' => 'Forgot password?',
           'serv'     => 'Server',            'newuser'  => 'New User?',
           'servadm'  => 'Server Administration',         );
           'helpdesk' => 'Contact Helpdesk',  # -------------------------------------------------- Change password field name
           'forgotpw' => 'Forgot password?',  
           'newuser'  => 'New User?',      my $forgotpw = &forgotpwdisplay(%lt);
        );      $forgotpw .= '<br />' if $forgotpw;
 # -------------------------------------------------- Change password field name      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
       if ($loginhelp) {
     my $forgotpw = &forgotpwdisplay(%lt);          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
     $forgotpw .= '<br />' if $forgotpw;      }
     my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);  
     if ($loginhelp) {  # ---------------------------------------------------- Serve out DES JavaScript
         $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(<$jsh>);      $r->print(
     }      '<div class="LC_Box"'
 # ---------------------------------------------------------- Serve rest of page     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
   );
     $r->print(  
     '<div class="LC_Box"'      $r->print(<<ENDSERVERFORM);
    .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'  <form name="server" action="/adm/authenticate" method="post" target="_top">
 );     <input type="hidden" name="logtoken" value="$logtoken" />
      <input type="hidden" name="serverid" value="$lonhost" />
     $r->print(<<ENDSERVERFORM);     <input type="hidden" name="uname" value="" />
 <form name="server" action="/adm/authenticate" method="post" target="_top">     <input type="hidden" name="upass0" value="" />
    <input type="hidden" name="logtoken" value="$logtoken" />     <input type="hidden" name="upass1" value="" />
    <input type="hidden" name="serverid" value="$lonhost" />     <input type="hidden" name="upass2" value="" />
    <input type="hidden" name="uname" value="" />     <input type="hidden" name="udom" value="" />
    <input type="hidden" name="upass0" value="" />     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
    <input type="hidden" name="upass1" value="" />     <input type="hidden" name="localres" value="$env{'form.localres'}" />
    <input type="hidden" name="upass2" value="" />    </form>
    <input type="hidden" name="udom" value="" />  ENDSERVERFORM
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />      my $coursecatalog;
    <input type="hidden" name="localres" value="$env{'form.localres'}" />      if (($showcoursecat eq '') || ($showcoursecat)) {
   </form>          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
 ENDSERVERFORM      }
     my $coursecatalog;      my $newuserlink;
     if (($showcoursecat eq '') || ($showcoursecat)) {      if ($shownewuserlink) {
         $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
     }      }
     my $newuserlink;      my $logintitle =
     if ($shownewuserlink) {          '<h2 class="LC_hcell"'
         $newuserlink = &newuser_link($lt{'newuser'}).'<br />';         .' style="background:'.$loginbox_header_bgcol.';'
     }         .' color:'.$loginbox_header_textcol.'">'
     my $logintitle =         .$lt{'log'}
         '<h2 class="LC_hcell"'         .'</h2>';
        .' style="background:'.$loginbox_header_bgcol.';'  
        .' color:'.$loginbox_header_textcol.'">'      my $noscript_warning='<noscript><span class="LC_warning"><b>'
        .$lt{'log'}                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
        .'</h2>';                          .'</b></span></noscript>';
       my $helpdeskscript;
     my $noscript_warning='<noscript><span class="LC_warning"><b>'      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')                                         $authdomain,\$helpdeskscript,
                         .'</b></span></noscript>';                                         $showhelpdesk,\@possdoms);
     my $helpdeskscript;  
     my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,      my $mobileargs;
                                        $authdomain,\$helpdeskscript,      if ($clientmobile) {
                                        $showhelpdesk,\@possdoms);          $mobileargs = 'autocapitalize="off" autocorrect="off"';
       }
     my $mobileargs;      my $loginform=(<<LFORM);
     if ($clientmobile) {  <form name="client" action="" onsubmit="return(send())">
         $mobileargs = 'autocapitalize="off" autocorrect="off"';     <input type="hidden" name="lextkey" value="$lextkey" />
     }    <input type="hidden" name="uextkey" value="$uextkey" />
     my $loginform=(<<LFORM);    <b><label for="uname">$lt{'un'}</label>:</b><br />
 <form name="client" action="" onsubmit="return(send())">    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
   <input type="hidden" name="lextkey" value="$lextkey" />    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
   <input type="hidden" name="uextkey" value="$uextkey" />    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
   <b><label for="uname">$lt{'un'}</label>:</b><br />    <b><label for="udom">$lt{'dom'}</label>:</b><br />
   <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />    <input type="submit" value="$lt{'log'}" />
   <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />  </form>
   <b><label for="udom">$lt{'dom'}</label>:</b><br />  LFORM
   <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />  
   <input type="submit" value="$lt{'log'}" />      if ($showbanner) {
 </form>          $r->print(<<HEADER);
 LFORM  <!-- The LON-CAPA Header -->
   <div style="background:$pgbg;margin:0;width:100%;">
     if ($showbanner) {    <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
         $r->print(<<HEADER);  </div>
 <!-- The LON-CAPA Header -->  HEADER
 <div style="background:$pgbg;margin:0;width:100%;">      }
   <img src="$img" border="0" alt="The Learning Online Network with CAPA" />      $r->print(<<ENDTOP);
 </div>  <div style="float:left;margin-top:0;">
 HEADER  <div class="LC_Box" style="background:$loginbox_bg;">
     }    $logintitle
     $r->print(<<ENDTOP);    $loginform
 <div style="float:left;margin-top:0;">    $noscript_warning
 <div class="LC_Box" style="background:$loginbox_bg;">  </div>
   $logintitle   
   $loginform  <div class="LC_Box" style="padding-top: 10px;">
   $noscript_warning    $loginhelp
 </div>    $forgotpw
       $contactblock
 <div class="LC_Box" style="padding-top: 10px;">    $newuserlink
   $loginhelp    $coursecatalog
   $forgotpw  </div>
   $contactblock  </div>
   $newuserlink  
   $coursecatalog  <div>
 </div>  ENDTOP
 </div>      if ($showmainlogo) {
           $r->print(' <img src="'.$logo.'" alt="" />'."\n");
 <div>      }
 ENDTOP  $r->print(<<ENDTOP);
     if ($showmainlogo) {  $announcements
         $r->print(' <img src="'.$logo.'" alt="" />'."\n");  </div>
     }  <hr style="clear:both;" />
 $r->print(<<ENDTOP);  ENDTOP
 $announcements      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
 </div>      $domainrow = <<"END";
 <hr style="clear:both;" />        <tr>
 ENDTOP         <td  align="left" valign="top">
     my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);          <small><b>$lt{'dom'}:&nbsp;</b></small>
     $domainrow = <<"END";         </td>
       <tr>         <td  align="left" valign="top">
        <td  align="left" valign="top">          <small><tt>&nbsp;$domain</tt></small>
         <small><b>$lt{'dom'}:&nbsp;</b></small>         </td>
        </td>        </tr>
        <td  align="left" valign="top">  END
         <small><tt>&nbsp;$domain</tt></small>      $serverrow = <<"END";
        </td>        <tr>
       </tr>         <td  align="left" valign="top">
 END          <small><b>$lt{'serv'}:&nbsp;</b></small>
     $serverrow = <<"END";         </td>
       <tr>         <td align="left" valign="top">
        <td  align="left" valign="top">          <small><tt>&nbsp;$lonhost ($role)</tt></small>
         <small><b>$lt{'serv'}:&nbsp;</b></small>         </td>
        </td>        </tr>
        <td align="left" valign="top">  END
         <small><tt>&nbsp;$lonhost ($role)</tt></small>      if ($loadlim) {
        </td>          $loadrow = <<"END";
       </tr>        <tr>
 END         <td align="left" valign="top">
     if ($loadlim) {          <small><b>$lt{'load'}:&nbsp;</b></small>
         $loadrow = <<"END";         </td>
       <tr>         <td align="left" valign="top">
        <td align="left" valign="top">          <small><tt>&nbsp;$loadpercent $lt{'perc'}</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>      }
        </td>      if ($uloadlim) {
       </tr>          $userloadrow = <<"END";
 END        <tr>
     }         <td align="left" valign="top">
     if ($uloadlim) {          <small><b>$lt{'userload'}:&nbsp;</b></small>
         $userloadrow = <<"END";         </td>
       <tr>         <td align="left" valign="top">
        <td align="left" valign="top">          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
         <small><b>$lt{'userload'}:&nbsp;</b></small>         </td>
        </td>        </tr>
        <td align="left" valign="top">  END
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>      }
        </td>      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
       </tr>          $versionrow = <<"END";
 END        <tr>
     }         <td colspan="2" align="left">
     if (($version ne '') && ($version ne '<!-- VERSION -->')) {          <small>$version</small>
         $versionrow = <<"END";         </td>
       <tr>        </tr>
        <td colspan="2" align="left">  END
         <small>$version</small>      }
        </td>  
       </tr>      $r->print(<<ENDDOCUMENT);
 END      <div style="float: left;">
     }       <table border="0" cellspacing="0" cellpadding="0">
   $domainrow
     $r->print(<<ENDDOCUMENT);  $serverrow
     <div style="float: left;">  $loadrow    
      <table border="0" cellspacing="0" cellpadding="0">  $userloadrow
 $domainrow  $versionrow
 $serverrow       </table>
 $loadrow          </div>
 $userloadrow      <div style="float: right;">
 $versionrow      $domainlogo
      </table>      </div>
     </div>      <br style="clear:both;" />
     <div style="float: right;">   </div>
     $domainlogo  
     </div>  <script type="text/javascript">
     <br style="clear:both;" />  // <![CDATA[
  </div>  // the if prevents the script error if the browser can not handle this
   if ( document.client.uname ) { document.client.uname.focus(); }
 <script type="text/javascript">  // ]]>
 // <![CDATA[  </script>
 // the if prevents the script error if the browser can not handle this  $helpdeskscript
 if ( document.client.uname ) { document.client.uname.focus(); }  
 // ]]>  ENDDOCUMENT
 </script>      my %endargs = ( 'noredirectlink' => 1, );
 $helpdeskscript      $r->print(&Apache::loncommon::end_page(\%endargs));
       return OK;
 ENDDOCUMENT  }
     my %endargs = ( 'noredirectlink' => 1, );  
     $r->print(&Apache::loncommon::end_page(\%endargs));  sub check_loginvia {
     return OK;      my ($domain,$lonhost) = @_;
 }      if ($domain eq '' || $lonhost eq '') {
           return;
 sub check_loginvia {      }
     my ($domain,$lonhost) = @_;      my %domconfhash = &Apache::loncommon::get_domainconf($domain);
     if ($domain eq '' || $lonhost eq '') {      my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
         return;      my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
     }      my $output;
     my %domconfhash = &Apache::loncommon::get_domainconf($domain);      if ($loginvia ne '') {
     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};          my $noredirect;
     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};          my $ip = $ENV{'REMOTE_ADDR'};
     my $output;          if ($ip eq '127.0.0.1') {
     if ($loginvia ne '') {              $noredirect = 1;
         my $noredirect;          } else {
         my $ip = $ENV{'REMOTE_ADDR'};              if ($loginvia_exempt ne '') {
         if ($ip eq '127.0.0.1') {                  my @exempt = split(',',$loginvia_exempt);
             $noredirect = 1;                  if (grep(/^\Q$ip\E$/,@exempt)) {
         } else {                      $noredirect = 1;
             if ($loginvia_exempt ne '') {                  }
                 my @exempt = split(',',$loginvia_exempt);              }
                 if (grep(/^\Q$ip\E$/,@exempt)) {          }
                     $noredirect = 1;          unless ($noredirect) {
                 }              my ($newhost,$path);
             }              if ($loginvia =~ /:/) {
         }                  ($newhost,$path) = split(':',$loginvia);
         unless ($noredirect) {              } else {
             my ($newhost,$path);                  $newhost = $loginvia;
             if ($loginvia =~ /:/) {              }
                 ($newhost,$path) = split(':',$loginvia);              if ($newhost ne $lonhost) {
             } else {                  if (&Apache::lonnet::hostname($newhost) ne '') {
                 $newhost = $loginvia;                      $output = &redirect_page($newhost,$path);
             }                  }
             if ($newhost ne $lonhost) {              }
                 if (&Apache::lonnet::hostname($newhost) ne '') {          }
                     $output = &redirect_page($newhost,$path);      }
                 }      return $output;
             }  }
         }  
     }  sub redirect_page {
     return $output;      my ($desthost,$path) = @_;
 }      my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
 sub redirect_page {      unless ($path =~ m{^/}) {
     my ($desthost,$path) = @_;          $path = '/'.$path;
     my $protocol = $Apache::lonnet::protocol{$desthost};      }
     $protocol = 'http' if ($protocol ne 'https');      my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
     unless ($path =~ m{^/}) {      if ($env{'form.firsturl'} ne '') {
         $path = '/'.$path;          $url .='?firsturl='.$env{'form.firsturl'};
     }      }
     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;      my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
     if ($env{'form.firsturl'} ne '') {                                                      {'redirect' => [0,$url],});
         $url .='?firsturl='.$env{'form.firsturl'};      my $end_page   = &Apache::loncommon::end_page();
     }      return $start_page.$end_page;
     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,  }
                                                     {'redirect' => [0,$url],});  
     my $end_page   = &Apache::loncommon::end_page();  sub contactdisplay {
     return $start_page.$end_page;      my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
 }          $possdoms) = @_;
       my $contactblock;
 sub contactdisplay {      my $origmail;
     my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,      if (ref($possdoms) eq 'ARRAY') {
         $possdoms) = @_;          if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
     my $contactblock;              $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
     my $origmail;          }
     if (ref($possdoms) eq 'ARRAY') {      }
         if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {       my $requestmail =
             $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};          &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
         }                                                   $authdomain,$origmail);
     }      unless ($showhelpdesk eq '0') {
     my $requestmail =           if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
         &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',              $showhelpdesk = 1;
                                                  $authdomain,$origmail);          } else {
     unless ($showhelpdesk eq '0') {              $showhelpdesk = 0;
         if ($requestmail =~ m/[^\@]+\@[^\@]+/) {          }
             $showhelpdesk = 1;      }
         } else {      if ($servadm && $showadminmail) {
             $showhelpdesk = 0;          $contactblock .= $$lt{'servadm'}.':<br />'.
         }                           '<tt>'.$servadm.'</tt><br />';
     }      }
     if ($servadm && $showadminmail) {      if ($showhelpdesk) {
         $contactblock .= $$lt{'servadm'}.':<br />'.          $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
                          '<tt>'.$servadm.'</tt><br />';          my $thisurl = &escape('/adm/login');
     }          $$helpdeskscript = <<"ENDSCRIPT";
     if ($showhelpdesk) {  <script type="text/javascript">
         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';  // <![CDATA[
         my $thisurl = &escape('/adm/login');  function helpdesk() {
         $$helpdeskscript = <<"ENDSCRIPT";      var possdom = document.client.udom.value;
 <script type="text/javascript">      var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
 // <![CDATA[      if (codedom == '') {
 function helpdesk() {          codedom = "$authdomain";
     var possdom = document.client.udom.value;      }
     var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');      var querystr = "origurl=$thisurl&codedom="+codedom;
     if (codedom == '') {      document.location.href = "/adm/helpdesk?"+querystr;
         codedom = "$authdomain";      return;
     }  }
     var querystr = "origurl=$thisurl&codedom="+codedom;  // ]]>
     document.location.href = "/adm/helpdesk?"+querystr;  </script>
     return;  ENDSCRIPT
 }      }
 // ]]>      return $contactblock;
 </script>  }
 ENDSCRIPT  
     }  sub forgotpwdisplay {
     return $contactblock;      my (%lt) = @_;
 }      my $prompt_for_resetpw = 1;
       if ($prompt_for_resetpw) {
 sub forgotpwdisplay {          return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
     my (%lt) = @_;      }
     my $prompt_for_resetpw = 1;       return;
     if ($prompt_for_resetpw) {  }
         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';  
     }  sub coursecatalog_link {
     return;      my ($linkname) = @_;
 }      return <<"END";
         <a href="/adm/coursecatalog">$linkname</a>
 sub coursecatalog_link {  END
     my ($linkname) = @_;  }
     return <<"END";  
       <a href="/adm/coursecatalog">$linkname</a>  sub newuser_link {
 END      my ($linkname) = @_;
 }      return '<a href="/adm/createaccount">'.$linkname.'</a>';
   }
 sub newuser_link {  
     my ($linkname) = @_;  1;
     return '<a href="/adm/createaccount">'.$linkname.'</a>';  __END__
 }  
   
 1;  
 __END__  

Removed from v.1.158.2.4  
changed lines
  Added in v.1.162


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