Diff for /loncom/auth/lonlogin.pm between versions 1.72 and 1.161

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


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