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

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


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