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

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


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