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

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

Removed from v.1.158.2.1  
changed lines
  Added in v.1.167


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