Diff for /loncom/auth/lonlogin.pm between versions 1.157 and 1.163

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


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