Diff for /loncom/auth/lonlogin.pm between versions 1.87 and 1.170

version 1.87, 2007/01/14 02:00:04 version 1.170, 2017/02/25 19:56:09
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 CGI::Cookie();  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;  use CGI::Cookie();
     
 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']);    'token','role','symb','iptoken']);
       if (!defined($env{'form.firsturl'})) {
 # -- check if they are a migrating user          &Apache::lonacc::get_posted_cgi($r,['firsturl']);
     if (defined($env{'form.token'})) {      }
  return &Apache::migrateuser::handler($r);  
     }  # -- check if they are a migrating user
       if (defined($env{'form.token'})) {
     &Apache::loncommon::no_cache($r);   return &Apache::migrateuser::handler($r);
     &Apache::lonlocal::get_language_handle($r);      }
     &Apache::loncommon::content_type($r,'text/html');  
     $r->send_http_header;  # For "public user" - remove any exising "public" cookie, as user really wants to log-in
     return OK if $r->header_only;      my ($handle,$lonidsdir,$expire);
       unless ($r->header_only) {
           $handle = &Apache::lonnet::check_for_valid_session($r);
 # Are we re-routing?          if ($handle ne '') {
     if (-e '/home/httpd/html/lon-status/reroute.txt') {              $lonidsdir=$r->dir_config('lonIDsDir');
  &Apache::lonauth::reroute($r);              if ($handle=~/^publicuser\_/) {
  return OK;                  unlink($r->dir_config('lonIDsDir')."/$handle.id");
     }                  undef($handle);
                   $expire = 1;
               }
 # -------------------------------- Prevent users from attempting to login twice          }
     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));      }
     my $lonid=$cookies{'lonID'};  
     my $cookie;      &Apache::loncommon::no_cache($r);
     if ($lonid) {      &Apache::lonlocal::get_language_handle($r);
  my $handle=&LONCAPA::clean_handle($lonid->value);      &Apache::loncommon::content_type($r,'text/html');
         my $lonidsdir=$r->dir_config('lonIDsDir');      if ($expire) {
  if (-e "$lonidsdir/$handle.id") {          my $c = new CGI::Cookie(-name    => 'lonPubID',
 # Is there an existing token file?                                  -value   => '',
     if ($handle=~/^publicuser\_/) {                                  -expires => '-10y',);
 # For "public user" - remove it, we apparently really want to login          $r->header_out('Set-cookie' => $c);
  unlink("$lonidsdir/$handle.id");      }
     } elsif ($handle ne '') {      $r->send_http_header;
 # Indeed, a valid token is found      return OK if $r->header_only;
  my $start_page =   
     &Apache::loncommon::start_page('Already logged in');  
  my $end_page =   # Are we re-routing?
     &Apache::loncommon::end_page();      my $londocroot = $r->dir_config('lonDocRoot');
  $r->print(<<ENDFAILED);      if (-e "$londocroot/lon-status/reroute.txt") {
 $start_page   &Apache::lonauth::reroute($r);
 <h1>You are already logged in</h1>   return OK;
 <p>Please either <a href="/adm/roles">continue the current session</a> or      }
 <a href="/adm/logout">logout</a>.</p>  
 <p>      $env{'form.firsturl'} =~ s/(`)/'/g;
 <a href="/adm/loginproblems.html">Problems?</a></p>  
 $end_page  # -------------------------------- Prevent users from attempting to login twice
 ENDFAILED      if ($handle ne '') {
                 return OK;          &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
      }     my $start_page =
  }      &Apache::loncommon::start_page('Already logged in');
     }   my $end_page =
       &Apache::loncommon::end_page();
 # ---------------------------------------------------- No valid token, continue          my $dest = '/adm/roles';
           if ($env{'form.firsturl'} ne '') {
  # ---------------------------- Not possible to really login to domain "public"              $dest = $env{'form.firsturl'};
     if ($env{'form.domain'} eq 'public') {          }
  $env{'form.domain'}='';   $r->print(
  $env{'form.username'}='';                    $start_page
     }                   .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
 # ----------------------------------------------------------- Process Interface                   .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
     $env{'form.interface'}=~s/\W//g;                    '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
                    .$end_page
     my $textbrowsers=$r->dir_config('lonTextBrowsers');                   );
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};          return OK;
           }
     foreach (split(/\:/,$textbrowsers)) {  
  if ($httpbrowser=~/$_/i) {  # ---------------------------------------------------- No valid token, continue
     $env{'form.interface'}='textual';  
         }  # ---------------------------- Not possible to really login to domain "public"
     }      if ($env{'form.domain'} eq 'public') {
    $env{'form.domain'}='';
     my $fullgraph=($env{'form.interface'} ne 'textual');   $env{'form.username'}='';
     my $port_to_use=$r->dir_config('lonhttpdPort');      }
     if (!defined($port_to_use)) {  
  $port_to_use='8080';  # ------ Is this page requested because /adm/migrateuser detected an IP change?
     }      my %sessiondata;
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.      if ($env{'form.iptoken'}) {
                   $r->dir_config('lonIconsURL');          %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
     my $domain = &Apache::lonnet::default_login_domain();          unless ($sessiondata{'sessionserver'}) {
     if (($env{'form.domain'}) &&               my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
  ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {              delete($env{'form.iptoken'});
  $domain=$env{'form.domain'};          }
     }      }
     my $role    = $r->dir_config('lonRole');  # ----------------------------------------------------------- Process Interface
     my $loadlim = $r->dir_config('lonLoadLim');      $env{'form.interface'}=~s/\W//g;
     my $lonhost = $r->dir_config('lonHostID');  
     my $tabdir  = $r->dir_config('lonTabDir');      (undef,undef,undef,undef,undef,undef,my $clientmobile) =
     my $include = $r->dir_config('lonIncludes');          &Apache::loncommon::decode_user_agent();
     my $expire  = $r->dir_config('lonExpire');  
     my $version = $r->dir_config('lonVersion');      my $iconpath=
     my $host_name = $Apache::lonnet::hostname{$lonhost};   &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
   
 # --------------------------------------------- Default values for login fields      my $lonhost = $r->dir_config('lonHostID');
       my $domain = &Apache::lonnet::default_login_domain();
     my $authusername=($env{'form.username'}?$env{'form.username'}:'');      my $defdom = $domain;
     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);      if ($lonhost ne '') {
           unless ($sessiondata{'sessionserver'}) {
 # ---------------------------------------------------------- Determine own load              my $redirect = &check_loginvia($domain,$lonhost);
     my $loadavg;              if ($redirect) {
     {                  $r->print($redirect);
  my $loadfile=Apache::File->new('/proc/loadavg');                  return OK;
  $loadavg=<$loadfile>;              }
     }          }
     $loadavg =~ s/\s.*//g;      }
     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);  
     my $userloadpercent=&Apache::lonnet::userload();      if (($sessiondata{'domain'}) &&
           (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
 # ------------------------------------------------------- Do the load balancing          $domain=$sessiondata{'domain'};
     my $otherserver= &Apache::lonnet::absolute_url($host_name);      } elsif (($env{'form.domain'}) &&
     my $firsturl=   (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});   $domain=$env{'form.domain'};
 # ---------------------------------------- Are we access server and overloaded?      }
     if (($role eq 'access') &&  
  (($userloadpercent>100.0)||($loadpercent>100.0))) {      my $role    = $r->dir_config('lonRole');
         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);      my $loadlim = $r->dir_config('lonLoadLim');
  if ($unloaded) { $otherserver=$unloaded; }      my $uloadlim= $r->dir_config('lonUserLoadLim');
     }      my $servadm = $r->dir_config('lonAdmEMail');
       my $tabdir  = $r->dir_config('lonTabDir');
 # ----------------------------------------------------------- Get announcements      my $include = $r->dir_config('lonIncludes');
     my $announcements=&Apache::lonnet::getannounce();      my $expire  = $r->dir_config('lonExpire');
 # -------------------------------------------------------- Set login parameters      my $version = $r->dir_config('lonVersion');
       my $host_name = &Apache::lonnet::hostname($lonhost);
     my @hexstr=('0','1','2','3','4','5','6','7',  
                 '8','9','a','b','c','d','e','f');  # --------------------------------------------- Default values for login fields
     my $lkey='';     
     for (0..7) {      my ($authusername,$authdomain);
         $lkey.=$hexstr[rand(15)];      if ($sessiondata{'username'}) {
     }          $authusername=$sessiondata{'username'};
       } else {
     my $ukey='';          $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
     for (0..7) {          $authusername=($env{'form.username'}?$env{'form.username'}:'');
         $ukey.=$hexstr[rand(15)];      }
     }      if ($sessiondata{'domain'}) {
           $authdomain=$sessiondata{'domain'};
     my $lextkey=hex($lkey);      } else {
     if ($lextkey>2147483647) { $lextkey-=4294967296; }          $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
           $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
     my $uextkey=hex($ukey);      }
     if ($uextkey>2147483647) { $uextkey-=4294967296; }  
   # ---------------------------------------------------------- Determine own load
 # -------------------------------------------------------- Store away log token      my $loadavg;
     my $logtoken=Apache::lonnet::reply(      {
        'tmpput:'.$ukey.$lkey.'&'.$firsturl,   my $loadfile=Apache::File->new('/proc/loadavg');
        $lonhost);   $loadavg=<$loadfile>;
       }
 # ------------------- If we cannot talk to ourselves, we are in serious trouble      $loadavg =~ s/\s.*//g;
   
     if ($logtoken eq 'con_lost') {      my ($loadpercent,$userloadpercent);
         my $spares='';      if ($loadlim) {
  my $last;          $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
         foreach my $hostid (sort      }
     {      if ($uloadlim) {
  $Apache::lonnet::hostname{$a} cmp          $userloadpercent=&Apache::lonnet::userload();
     $Apache::lonnet::hostname{$b};      }
     }  
     keys(%Apache::lonnet::spareid)) {      my $firsturl=
             next if ($hostid eq $lonhost);      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
             next if ($last eq $Apache::lonnet::hostname{$hostid});  
             $spares.='<br /><font size="+1"><a href="http://'.  # ----------------------------------------------------------- Get announcements
                 $Apache::lonnet::hostname{$hostid}.      my $announcements=&Apache::lonnet::getannounce();
                 '/adm/login?domain='.$authdomain.'">'.  # -------------------------------------------------------- Set login parameters
                 $Apache::lonnet::hostname{$hostid}.'</a>'.  
                 ' (preferred)</font>'.$/;      my @hexstr=('0','1','2','3','4','5','6','7',
     $last=$Apache::lonnet::hostname{$hostid};                  '8','9','a','b','c','d','e','f');
         }      my $lkey='';
         $spares.= '<br />';      for (0..7) {
         foreach my $hostid (sort          $lkey.=$hexstr[rand(15)];
     {      }
  $Apache::lonnet::hostname{$a} cmp  
     $Apache::lonnet::hostname{$b};      my $ukey='';
     }      for (0..7) {
     keys(%Apache::lonnet::hostname)) {          $ukey.=$hexstr[rand(15)];
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});      }
             next if ($last eq $Apache::lonnet::hostname{$hostid});  
             $spares.='<br /><a href="http://'.      my $lextkey=hex($lkey);
                 $Apache::lonnet::hostname{$hostid}.      if ($lextkey>2147483647) { $lextkey-=4294967296; }
                 '/adm/login?domain='.$authdomain.'">'.  
                 $Apache::lonnet::hostname{$hostid}.'</a>';      my $uextkey=hex($ukey);
     $last=$Apache::lonnet::hostname{$hostid};      if ($uextkey>2147483647) { $uextkey-=4294967296; }
         }  
  $r->print(<<ENDTROUBLE);  # -------------------------------------------------------- Store away log token
 <html>      my $tokenextras;
 <head><title>The LearningOnline Network with CAPA</title></head>      if ($env{'form.role'}) {
 <body bgcolor="#FFFFFF">          $tokenextras = '&role='.&escape($env{'form.role'});
 <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />      }
 <h3>This LON-CAPA server is temporarily not available for login</h3>      if ($env{'form.symb'}) {
 <p>Please attempt to login to one of the following servers:</p>$spares          if (!$tokenextras) {
 </body>              $tokenextras = '&';
 </html>          }
 ENDTROUBLE          $tokenextras .= '&symb='.&escape($env{'form.symb'});
         return OK;      }
     }      if ($env{'form.iptoken'}) {
           if (!$tokenextras) {
 # ----------------------------------------------- Apparently we are in business              $tokenextras = '&&';
           }
     my $domainlogo=&Apache::loncommon::domainlogo($domain);          $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
       }
 # --------------------------------------------------- Print login screen header      my $logtoken=Apache::lonnet::reply(
     $r->print(<<ENDHEADER);         'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
 <html>         $lonhost);
 <head>  
 <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />  # -- If we cannot talk to ourselves, or hostID does not map to a hostname
 <title>The LearningOnline Network with CAPA Login</title>  #    we are in serious trouble
 </head>  
 ENDHEADER      if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
 # ---------------------------------------------------- Serve out DES JavaScript          if ($logtoken eq 'no_such_host') {
     {              &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
  my $jsh=Apache::File->new($include."/londes.js");          }
         $r->print(<$jsh>);          my $spares='';
     }   my $last;
           foreach my $hostid (sort
 # ----------------------------------------------------------- Front page design      {
     my $pgbg=   &Apache::lonnet::hostname($a) cmp
       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');      &Apache::lonnet::hostname($b);
     my $font=      }
       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');      keys(%Apache::lonnet::spareid)) {
     my $link=              next if ($hostid eq $lonhost);
       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');      my $hostname = &Apache::lonnet::hostname($hostid);
     my $vlink=      next if (($last eq $hostname) || ($hostname eq ''));
       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');              $spares.='<br /><font size="+1"><a href="http://'.
     my $alink=&Apache::loncommon::designparm('login.alink',$domain);                  $hostname.
     my $mainbg=                  '/adm/login?domain='.$authdomain.'">'.
       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');                  $hostname.'</a>'.
     my $sidebg=                  ' '.&mt('(preferred)').'</font>'.$/;
       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');      $last=$hostname;
     my $logo=&Apache::loncommon::designparm('login.logo',$domain);          }
     my $img=&Apache::loncommon::designparm('login.img',$domain);          if ($spares) {
               $spares.= '<br />';
 # ----------------------------------------------------------------------- Texts          }
           my %all_hostnames = &Apache::lonnet::all_hostnames();
 my %lt=&Apache::lonlocal::texthash(          foreach my $hostid (sort
   'un'  => 'Username',      {
   'pw'  => 'Password',   &Apache::lonnet::hostname($a) cmp
   'dom' => 'Domain',      &Apache::lonnet::hostname($b);
   'perc' => 'percent',      }
   'load' => 'Load',      keys(%all_hostnames)) {
                   'userload' => 'User Load',              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
                   'about'  => 'About LON-CAPA',              my $hostname = &Apache::lonnet::hostname($hostid);
                   'access' => 'Accessibility Options',              next if (($last eq $hostname) || ($hostname eq ''));
                   'catalog' => 'Course Catalog',              $spares.='<br /><a href="http://'.
   'auth' => 'userauthentication.gif',               $hostname.
   'log' => 'Log in',               '/adm/login?domain='.$authdomain.'">'.
   'help' => 'Log-in Help',               $hostname.'</a>';
   'serv' => 'Server',              $last=$hostname;
                   'helpdesk' => 'Contact Helpdesk',           }
                   'forgotpw' => 'Forgot password?');           $r->print(
 # -------------------------------------------------- Change password field name     '<html>'
     my $now=time;    .'<head><title>'
     my $forgotpw = &forgotpwdisplay(%lt);    .&mt('The LearningOnline Network with CAPA')
     my $loginhelp = &loginhelpdisplay(%lt);    .'</title></head>'
 # ---------------------------------------------------------- Serve rest of page    .'<body bgcolor="#FFFFFF">'
     $r->print(<<ENDSCRIPT);    .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
     .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
 <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"    .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>          if ($spares) {
               $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
  <script language="JavaScript">                       .'</p>'
     function send()                       .$spares);
     {          }
  this.document.server.elements.uname.value          $r->print('</body>'
        =this.document.client.elements.uname.value;                   .'</html>'
           );
         this.document.server.elements.udom.value          return OK;
        =this.document.client.elements.udom.value;      }
   
         this.document.server.elements.imagesuppress.value  # ----------------------------------------------- Apparently we are in business
        =this.document.client.elements.imagesuppress.checked;      $servadm=~s/\,/\<br \/\>/g;
   
         this.document.server.elements.embedsuppress.value  # ----------------------------------------------------------- Front page design
        =this.document.client.elements.embedsuppress.checked;      my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
       my $font=&Apache::loncommon::designparm('login.font',$domain);
         this.document.server.elements.appletsuppress.value      my $link=&Apache::loncommon::designparm('login.link',$domain);
        =this.document.client.elements.appletsuppress.checked;      my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
       my $alink=&Apache::loncommon::designparm('login.alink',$domain);
         this.document.server.elements.fontenhance.value      my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
        =this.document.client.elements.fontenhance.checked;      my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
       my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
         this.document.server.elements.blackwhite.value      my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
        =this.document.client.elements.blackwhite.checked;      my $logo=&Apache::loncommon::designparm('login.logo',$domain);
       my $img=&Apache::loncommon::designparm('login.img',$domain);
         this.document.server.elements.remember.value      my $domainlogo=&Apache::loncommon::domainlogo($domain);
        =this.document.client.elements.remember.checked;      my $showbanner = 1;
       my $showmainlogo = 1;
         uextkey=this.document.client.elements.uextkey.value;      if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
         lextkey=this.document.client.elements.lextkey.value;          $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
         initkeys();      }
       if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
         this.document.server.elements.upass0.value          $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
     =crypted(this.document.client.elements.upass$now.value.substr(0,15));      }
  this.document.server.elements.upass1.value      my $showadminmail;
     =crypted(this.document.client.elements.upass$now.value.substr(15,15));      my @possdoms = &Apache::lonnet::current_machine_domains();
  this.document.server.elements.upass2.value      if (grep(/^\Q$domain\E$/,@possdoms)) {
     =crypted(this.document.client.elements.upass$now.value.substr(30,15));          $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
       }
         this.document.client.elements.uname.value='';      my $showcoursecat =
         this.document.client.elements.upass$now.value='';          &Apache::loncommon::designparm('login.coursecatalog',$domain);
       my $shownewuserlink =
         this.document.server.submit();          &Apache::loncommon::designparm('login.newuser',$domain);
  return false;      my $showhelpdesk =
     }          &Apache::loncommon::designparm('login.helpdesk',$domain);
  </script>      my $now=time;
 ENDSCRIPT      my $js = (<<ENDSCRIPT);
   
     if ($fullgraph) {  <script type="text/javascript" language="JavaScript">
  $r->print(  // <![CDATA[
   '<table width="100%" cellpadding=0 cellspacing=0 border=0>');  function send()
     }  {
   this.document.server.elements.uname.value
     $r->print(<<ENDSERVERFORM);  =this.document.client.elements.uname.value;
   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">  
    <input type="hidden" name="logtoken" value="$logtoken" />  this.document.server.elements.udom.value
    <input type="hidden" name="serverid" value="$lonhost" />  =this.document.client.elements.udom.value;
    <input type="hidden" name="interface" value="$env{'form.interface'}" />  
    <input type="hidden" name="uname" value="" />  uextkey=this.document.client.elements.uextkey.value;
    <input type="hidden" name="upass0" value="" />  lextkey=this.document.client.elements.lextkey.value;
    <input type="hidden" name="upass1" value="" />  initkeys();
    <input type="hidden" name="upass2" value="" />  
    <input type="hidden" name="udom" value="" />  if(this.document.server.action.substr(0,5) === 'http:'){
    <input type="hidden" name="imagesuppress"  value="" />      this.document.server.elements.upass0.value
    <input type="hidden" name="appletsuppress"  value="" />          =getCrypted(this.document.client.elements.upass$now.value);
    <input type="hidden" name="embedsuppress"  value="" />  } else {
    <input type="hidden" name="fontenhance"  value="" />      this.document.server.elements.upass0.value
    <input type="hidden" name="blackwhite"  value="" />          =this.document.client.elements.upass$now.value;
    <input type="hidden" name="remember"  value="" />  }
    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />  
    <input type="hidden" name="localres" value="$env{'form.localres'}" />  this.document.client.elements.uname.value='';
   </form>  this.document.client.elements.upass$now.value='';
 ENDSERVERFORM  
     if ($fullgraph) { $r->print(<<ENDTOP);  this.document.server.submit();
   <!-- The LON-CAPA Header -->  return false;
   <tr>  }
   
    <!-- Row 1 Columns 2-4 -->  function enableInput() {
    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>      this.document.client.elements.upass$now.removeAttribute("readOnly");
   </tr>      this.document.client.elements.uname.removeAttribute("readOnly");
       this.document.client.elements.udom.removeAttribute("readOnly");
   <!-- The gray bar that starts the two table frames -->      return;
   <tr>  }
   
    <!-- Row 2 Column 1 -->  // ]]>
    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>  </script>
   
    <!-- Row 2 Column 2 -->  ENDSCRIPT
    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>  
   # --------------------------------------------------- Print login screen header
    <!-- Row 2 Column 3 -->  
    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>      my %add_entries = (
          bgcolor      => "$mainbg",
    <!-- Row 2 Column 4 -->         text         => "$font",
    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>         link         => "$link",
   </tr>         vlink        => "$vlink",
   <tr>         alink        => "$alink",
                     onload       => 'javascript:enableInput();',);
    <!-- A cell that will hold the 'access', 'about', and 'catalog' links -->  
    <!-- Row 3 Column 1 -->      my ($lonhost_in_use,$headextra,$headextra_exempt,@hosts,%defaultdomconf);
    <td valign="top" height="60" align="left" bgcolor="$sidebg">      @hosts = &Apache::lonnet::current_machine_ids();
     <table cellpadding="0" cellspacing="2" border="0">      $lonhost_in_use = $lonhost;
      <tr>      if (@hosts > 1) {
       <td>&nbsp;</td>          foreach my $hostid (@hosts) {
       <td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td>              if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
      </tr>                  $lonhost_in_use = $hostid;
      <tr>                  last;
       <td>&nbsp;</td>              }
       <td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td>          }
      </tr>      }
      <tr>      %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
       <td>&nbsp;</td>      $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
       <td><a href="/adm/coursecatalog"><b>$lt{'catalog'}</b></a></td>      $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
      </tr>      if ($headextra) {
      <tr>          my $omitextra;
       <td colspan="2">&nbsp;</td>          if ($headextra_exempt ne '') {
      </tr>              my @exempt = split(',',$headextra_exempt);
     </table>              my $ip = $ENV{'REMOTE_ADDR'};
    </td>              if (grep(/^\Q$ip\E$/,@exempt)) {
    <!-- The shaded space between the two main columns -->                  $omitextra = 1;
    <!-- Row 3 Column 2 -->              }
    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>          }
           unless ($omitextra) {
    <!-- The right main column holding the large LON-CAPA logo-->              my $confname = $defdom.'-domainconfig';
    <!-- Rows 3-4 Column 3 -->              if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">                  my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
     <center>                  unless ($extra eq '-1') {
      <img src="$logo" alt="" />                      $js .= "\n".$extra."\n";
     </center>                  }
    </td>              }
           }
    <!-- Row 3 Column 4 -->      }
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>  
   </tr>      $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
   <tr>         { 'redirect'       => [$expire,'/adm/roles'],
    'add_entries' => \%add_entries,
    <!-- The entry form -->   'only_body'   => 1,}));
    <!-- Row 4 Column 1 -->  
    <td align="center" valign="middle" bgcolor="$sidebg">  # ----------------------------------------------------------------------- Texts
 ENDTOP  
 } else {      my %lt=&Apache::lonlocal::texthash(
     $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements);            'un'       => 'Username',
 }            'pw'       => 'Password',
     $r->print('<form name="client" onsubmit="return(send())">');            'dom'      => 'Domain',
     unless ($fullgraph) {            'perc'     => 'percent',
         $r->print(<<ENDACCESSOPTIONS);            'load'     => 'Server Load',
 <h3>Select Accessibility Options</h3>            'userload' => 'User Load',
 <label><input type="checkbox" name="imagesuppress" /> Suppress rendering of images</label><br />            'catalog'  => 'Course/Community Catalog',
 <label><input type="checkbox" name="appletsuppress" /> Suppress Java applets</label><br />            'log'      => 'Log in',
 <label><input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia</label><br />            'help'     => 'Log-in Help',
 <label><input type="checkbox" name="fontenhance" /> Increase font size</label><br />            'serv'     => 'Server',
 <label><input type="checkbox" name="blackwhite" /> Switch to black and white mode</label><br />            'servadm'  => 'Server Administration',
 <input type="checkbox" name="remember" /> Remember these settings for next login<hr />            'helpdesk' => 'Contact Helpdesk',
 ENDACCESSOPTIONS            'forgotpw' => 'Forgot password?',
 } else {            'newuser'  => 'New User?',
     $r->print(<<ENDNOOPT);         );
 <input type="hidden" name="imagesuppress"  value="" />  # -------------------------------------------------- Change password field name
 <input type="hidden" name="embedsuppress"  value="" />  
 <input type="hidden" name="appletsuppress"  value="" />      my $forgotpw = &forgotpwdisplay(%lt);
 <input type="hidden" name="fontenhance"  value="" />      $forgotpw .= '<br />' if $forgotpw;
 <input type="hidden" name="blackwhite"  value="" />      my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
 <input type="hidden" name="remember"  value="" />      if ($loginhelp) {
 ENDNOOPT          $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
 }      }
     $r->print(<<ENDLOGIN);  
      <input type="hidden" name="lextkey" value="$lextkey">  # ---------------------------------------------------- Serve out DES JavaScript
      <input type="hidden" name="uextkey" value="$uextkey">      {
       my $jsh=Apache::File->new($include."/londes.js");
      <!-- Start the sub-table for text and input alignment -->      $r->print(<$jsh>);
      <table border=0 cellspacing=0 cellpadding=0>      }
       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr>  # ---------------------------------------------------------- Serve rest of page
       <tr>  
        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'un'}:</b></font></td>      $r->print(
        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>      '<div class="LC_Box"'
       </tr>     .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
       <tr>  );
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'pw'}:</b></font></td>  
        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>      $r->print(<<ENDSERVERFORM);
       </tr>  <form name="server" action="/adm/authenticate" method="post" target="_top">
       <tr>     <input type="hidden" name="logtoken" value="$logtoken" />
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>     <input type="hidden" name="serverid" value="$lonhost" />
        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>     <input type="hidden" name="uname" value="" />
       </tr>     <input type="hidden" name="upass0" value="" />
       <tr>     <input type="hidden" name="udom" value="" />
        <td bgcolor="$mainbg">&nbsp;</td>     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
        <td bgcolor="$mainbg" valign="bottom" align="center">     <input type="hidden" name="localres" value="$env{'form.localres'}" />
         <br />    </form>
         <input type="submit" value="$lt{'log'}" />  ENDSERVERFORM
        </td>      my $coursecatalog;
       </tr>      if (($showcoursecat eq '') || ($showcoursecat)) {
       <tr>          $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
        <td bgcolor="$mainbg" valign="bottom" align="left" colspan="2">      }
         $loginhelp      my $newuserlink;
         $forgotpw      if ($shownewuserlink) {
        </td>          $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
       </tr>      }
      </table>      my $logintitle =
      <!-- End sub-table -->          '<h2 class="LC_hcell"'
     </form>         .' style="background:'.$loginbox_header_bgcol.';'
 ENDLOGIN         .' color:'.$loginbox_header_textcol.'">'
     if ($fullgraph) {         .$lt{'log'}
         my $helpdeskscript;         .'</h2>';
         my $contactblock = &contactdisplay(\%lt,$version,$authdomain,\$helpdeskscript);  
  $r->print(<<ENDDOCUMENT);      my $noscript_warning='<noscript><span class="LC_warning"><b>'
    </td>                          .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                           .'</b></span></noscript>';
    <!-- Row 4 Column 2 -->      my $helpdeskscript;
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>      my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                                          $authdomain,\$helpdeskscript,
    <!-- Row 4 Column 3 -->                                         $showhelpdesk,\@possdoms);
 <td bgcolor="$mainbg">$announcements</td>  
       my $mobileargs;
    <!-- Row 4 Column 4 -->      if ($clientmobile) {
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>          $mobileargs = 'autocapitalize="off" autocorrect="off"';
   </tr>      }
   <tr>      my $loginform=(<<LFORM);
   <form name="client" action="" onsubmit="return(send())">
    <!-- Row 5 Column 1 -->    <input type="hidden" name="lextkey" value="$lextkey" />
    <td bgcolor="$sidebg" valign="middle" align="left">    <input type="hidden" name="uextkey" value="$uextkey" />
      <br />    <b><label for="uname">$lt{'un'}</label>:</b><br />
      <table border=0 cellspacing=0 cellpadding=0>    <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
       <tr>    <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
        <td bgcolor="$sidebg" align="left" valign="top">    <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>    <b><label for="udom">$lt{'dom'}</label>:</b><br />
        </td>    <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
        <td bgcolor="$sidebg" align="left" valign="top">    <input type="submit" value="$lt{'log'}" />
         <small><tt>&nbsp;$domain</tt></small>  </form>
        </td>  LFORM
       </tr>  
       <tr>      if ($showbanner) {
        <td bgcolor="$sidebg" align="left" valign="top">          $r->print(<<HEADER);
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>  <!-- The LON-CAPA Header -->
        </td>  <div style="background:$pgbg;margin:0;width:100%;">
        <td bgcolor="$sidebg" align="left" valign="top">    <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
         <small><tt>&nbsp;$lonhost ($role)</tt></small>  </div>
        </td>  HEADER
       </tr>      }
       <tr>      $r->print(<<ENDTOP);
        <td bgcolor="$sidebg" align="left" valign="top">  <div style="float:left;margin-top:0;">
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>  <div class="LC_Box" style="background:$loginbox_bg;">
        </td>    $logintitle
        <td bgcolor="$sidebg" align="left" valign="top">    $loginform
         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>    $noscript_warning
        </td>  </div>
       </tr>   
       <tr>  <div class="LC_Box" style="padding-top: 10px;">
        <td bgcolor="$sidebg" align="left" valign="top">    $loginhelp
         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>    $forgotpw
        </td>    $contactblock
        <td bgcolor="$sidebg" align="left" valign="top">    $newuserlink
         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>    $coursecatalog
        </td>  </div>
       </tr>  </div>
      </table>  
      <br />  <div>
     $contactblock  ENDTOP
    </td>      if ($showmainlogo) {
           $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
    <!-- Row 5 Column 2 -->      }
    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>  $r->print(<<ENDTOP);
   $announcements
    <!-- Row 5 Column 3 -->  </div>
    <td width="100%" valign="bottom" bgcolor="$mainbg">  <hr style="clear:both;" />
 $domainlogo  ENDTOP
 </td>      my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
       $domainrow = <<"END";
    <!-- Row 5 Column 4 -->        <tr>
    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>         <td  align="left" valign="top">
   </tr>          <small><b>$lt{'dom'}:&nbsp;</b></small>
   <tr>         </td>
          <td  align="left" valign="top">
    <!-- Row 6 Column 1 -->          <small><tt>&nbsp;$domain</tt></small>
    <td bgcolor="$sidebg">&nbsp;</td>         </td>
         </tr>
    <!-- Row 6 Column 2 -->  END
    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>      $serverrow = <<"END";
         <tr>
    <!-- Row 6 Column 3 -->         <td  align="left" valign="top">
    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>          <small><b>$lt{'serv'}:&nbsp;</b></small>
          </td>
    <!-- Row 6 Column 4 -->         <td align="left" valign="top">
    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>          <small><tt>&nbsp;$lonhost ($role)</tt></small>
   </tr>         </td>
  </table>        </tr>
   END
 <script type="text/javascript">      if ($loadlim) {
 // the if prevents the script error if the browser can not handle this          $loadrow = <<"END";
 if ( document.client.uname ) { document.client.uname.focus(); }        <tr>
 </script>         <td align="left" valign="top">
 $helpdeskscript          <small><b>$lt{'load'}:&nbsp;</b></small>
          </td>
 ENDDOCUMENT         <td align="left" valign="top">
 }          <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
     $r->print('</body></html>');         </td>
     return OK;        </tr>
 }  END
       }
 sub contactdisplay {      if ($uloadlim) {
     my ($lt,$version,$authdomain,$helpdeskscript) = @_;          $userloadrow = <<"END";
     my $contactblock;        <tr>
     my $showhelpdesk = 0;         <td align="left" valign="top">
     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};          <small><b>$lt{'userload'}:&nbsp;</b></small>
     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {         </td>
         $showhelpdesk = 1;         <td align="left" valign="top">
     }          <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
     if ($showhelpdesk) {         </td>
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />';        </tr>
         my $thisurl = &escape('/adm/login');  END
         $$helpdeskscript = <<"ENDSCRIPT";      }
 <script type="text/javascript">      if (($version ne '') && ($version ne '<!-- VERSION -->')) {
 function helpdesk() {          $versionrow = <<"END";
     var codedom = document.client.udom.value;        <tr>
     if (codedom == '') {         <td colspan="2" align="left">
         codedom = "$authdomain";          <small>$version</small>
     }         </td>
     var querystr = "origurl=$thisurl&codedom="+codedom;        </tr>
     document.location.href = "/adm/helpdesk?"+querystr;  END
     return;      }
 }  
 </script>      $r->print(<<ENDDOCUMENT);
 ENDSCRIPT      <div style="float: left;">
     }       <table border="0" cellspacing="0" cellpadding="0">
     $contactblock .= <<"ENDBLOCK";  $domainrow
      &nbsp;&nbsp;&nbsp;$version  $serverrow
 ENDBLOCK  $loadrow    
     return $contactblock;  $userloadrow
 }  $versionrow
        </table>
 sub forgotpwdisplay {      </div>
     my (%lt) = @_;      <div style="float: right;">
     my $prompt_for_resetpw = 1;       $domainlogo
     if ($prompt_for_resetpw) {      </div>
         return '<br />&nbsp;&nbsp;&nbsp;<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a></b><br /><br />';      <br style="clear:both;" />
     }   </div>
     return;  
 }  <script type="text/javascript">
   // <![CDATA[
 sub loginhelpdisplay {  // the if prevents the script error if the browser can not handle this
     my (%lt) = @_;  if ( document.client.uname ) { document.client.uname.focus(); }
     my $login_help = 1;  // ]]>
     if ($login_help) {  </script>
         return '&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a></b>';  $helpdeskscript
     }  
     return;  ENDDOCUMENT
 }      my %endargs = ( 'noredirectlink' => 1, );
       $r->print(&Apache::loncommon::end_page(\%endargs));
 1;      return OK;
 __END__  }
   
   sub check_loginvia {
       my ($domain,$lonhost) = @_;
       if ($domain eq '' || $lonhost eq '') {
           return;
       }
       my %domconfhash = &Apache::loncommon::get_domainconf($domain);
       my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
       my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
       my $output;
       if ($loginvia ne '') {
           my $noredirect;
           my $ip = $ENV{'REMOTE_ADDR'};
           if ($ip eq '127.0.0.1') {
               $noredirect = 1;
           } else {
               if ($loginvia_exempt ne '') {
                   my @exempt = split(',',$loginvia_exempt);
                   if (grep(/^\Q$ip\E$/,@exempt)) {
                       $noredirect = 1;
                   }
               }
           }
           unless ($noredirect) {
               my ($newhost,$path);
               if ($loginvia =~ /:/) {
                   ($newhost,$path) = split(':',$loginvia);
               } else {
                   $newhost = $loginvia;
               }
               if ($newhost ne $lonhost) {
                   if (&Apache::lonnet::hostname($newhost) ne '') {
                       $output = &redirect_page($newhost,$path);
                   }
               }
           }
       }
       return $output;
   }
   
   sub redirect_page {
       my ($desthost,$path) = @_;
       my $protocol = $Apache::lonnet::protocol{$desthost};
       $protocol = 'http' if ($protocol ne 'https');
       unless ($path =~ m{^/}) {
           $path = '/'.$path;
       }
       my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
       if ($env{'form.firsturl'} ne '') {
           $url .='?firsturl='.$env{'form.firsturl'};
       }
       my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
                                                       {'redirect' => [0,$url],});
       my $end_page   = &Apache::loncommon::end_page();
       return $start_page.$end_page;
   }
   
   sub contactdisplay {
       my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
           $possdoms) = @_;
       my $contactblock;
       my $origmail;
       if (ref($possdoms) eq 'ARRAY') {
           if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
               $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
           }
       }
       my $requestmail =
           &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
                                                    $authdomain,$origmail);
       unless ($showhelpdesk eq '0') {
           if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
               $showhelpdesk = 1;
           } 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.87  
changed lines
  Added in v.1.170


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