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

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


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.