Diff for /loncom/auth/lonlogin.pm between versions 1.61 and 1.67

version 1.61, 2004/12/18 23:58:34 version 1.67, 2005/06/14 20:09:13
Line 32  use strict; Line 32  use strict;
 use Apache::Constants qw(:common);  use Apache::Constants qw(:common);
 use CGI::Cookie();  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;
Line 84  ENDFAILED Line 84  ENDFAILED
 # ---------------------------------------------------- No valid token, continue  # ---------------------------------------------------- No valid token, continue
   
     &Apache::loncommon::get_unprocessed_cgi      &Apache::loncommon::get_unprocessed_cgi
      ($ENV{'QUERY_STRING'}.'&'.$ENV{'request.querystring'},       ($ENV{'QUERY_STRING'}.'&'.$env{'request.querystring'},
       ['interface','username','domain','firsturl','localpath','localres']);        ['interface','username','domain','firsturl','localpath','localres']);
     
   
 # ----------------------------------------------------------- Process Interface  # ----------------------------------------------------------- Process Interface
     $ENV{'form.interface'}=~s/\W//g;      $env{'form.interface'}=~s/\W//g;
   
     my $textbrowsers=$r->dir_config('lonTextBrowsers');      my $textbrowsers=$r->dir_config('lonTextBrowsers');
     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};      my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
           
     foreach (split(/\:/,$textbrowsers)) {      foreach (split(/\:/,$textbrowsers)) {
  if ($httpbrowser=~/$_/i) {   if ($httpbrowser=~/$_/i) {
     $ENV{'form.interface'}='textual';      $env{'form.interface'}='textual';
         }          }
     }      }
   
     my $fullgraph=($ENV{'form.interface'} ne 'textual');      my $fullgraph=($env{'form.interface'} ne 'textual');
     my $port_to_use=$r->dir_config('lonhttpdPort');      my $port_to_use=$r->dir_config('lonhttpdPort');
     if (!defined($port_to_use)) {      if (!defined($port_to_use)) {
  $port_to_use='8080';   $port_to_use='8080';
Line 108  ENDFAILED Line 108  ENDFAILED
     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.      my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.
                   $r->dir_config('lonIconsURL');                    $r->dir_config('lonIconsURL');
     my $domain  = $r->dir_config('lonDefDomain');      my $domain  = $r->dir_config('lonDefDomain');
     if (($ENV{'form.domain'}) &&       if (($env{'form.domain'}) && 
  ($Apache::lonnet::domaindescription{$ENV{'form.domain'}})) {   ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {
  $domain=$ENV{'form.domain'};   $domain=$env{'form.domain'};
     }      }
     my $role    = $r->dir_config('lonRole');      my $role    = $r->dir_config('lonRole');
     my $loadlim = $r->dir_config('lonLoadLim');      my $loadlim = $r->dir_config('lonLoadLim');
Line 124  ENDFAILED Line 124  ENDFAILED
   
 # --------------------------------------------- Default values for login fields  # --------------------------------------------- Default values for login fields
   
     my $authusername=($ENV{'form.username'}?$ENV{'form.username'}:'');      my $authusername=($env{'form.username'}?$env{'form.username'}:'');
     my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain);      my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
   
 # ---------------------------------------------------------- Determine own load  # ---------------------------------------------------------- Determine own load
     my $loadavg;      my $loadavg;
Line 140  ENDFAILED Line 140  ENDFAILED
 # ------------------------------------------------------- Do the load balancing  # ------------------------------------------------------- Do the load balancing
     my $otherserver='http://'.$ENV{'SERVER_NAME'};      my $otherserver='http://'.$ENV{'SERVER_NAME'};
     my $firsturl=      my $firsturl=
     ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});      ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
 # ---------------------------------------- Are we access server and overloaded?  # ---------------------------------------- Are we access server and overloaded?
     if (($role eq 'access') &&      if (($role eq 'access') &&
  (($userloadpercent>100.0)||($loadpercent>100.0))) {   (($userloadpercent>100.0)||($loadpercent>100.0))) {
Line 179  ENDFAILED Line 179  ENDFAILED
   
     if ($logtoken eq 'con_lost') {      if ($logtoken eq 'con_lost') {
         my $spares='';          my $spares='';
    my $last;
         foreach my $hostid (keys(%Apache::lonnet::spareid)) {          foreach my $hostid (sort
       {
    $Apache::lonnet::hostname{$a} cmp
       $Apache::lonnet::hostname{$b};
       }
       keys(%Apache::lonnet::spareid)) {
             next if ($hostid eq $lonhost);              next if ($hostid eq $lonhost);
               next if ($last eq $Apache::lonnet::hostname{$hostid});
             $spares.='<br /><font size="+1"><a href="http://'.              $spares.='<br /><font size="+1"><a href="http://'.
                 $Apache::lonnet::hostname{$hostid}.                  $Apache::lonnet::hostname{$hostid}.
                 '/adm/login?domain='.$authdomain.'">'.                  '/adm/login?domain='.$authdomain.'">'.
                 $Apache::lonnet::hostname{$hostid}.'</a>'.                  $Apache::lonnet::hostname{$hostid}.'</a>'.
                 ' (preferred)</font>'.$/;                  ' (preferred)</font>'.$/;
       $last=$Apache::lonnet::hostname{$hostid};
         }          }
         $spares.= '<br />';          $spares.= '<br />';
         foreach my $hostid (keys(%Apache::lonnet::hostname)) {          foreach my $hostid (sort
       {
    $Apache::lonnet::hostname{$a} cmp
       $Apache::lonnet::hostname{$b};
       }
       keys(%Apache::lonnet::hostname)) {
             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});              next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
               next if ($last eq $Apache::lonnet::hostname{$hostid});
             $spares.='<br /><a href="http://'.              $spares.='<br /><a href="http://'.
                 $Apache::lonnet::hostname{$hostid}.                  $Apache::lonnet::hostname{$hostid}.
                 '/adm/login?domain='.$authdomain.'">'.                  '/adm/login?domain='.$authdomain.'">'.
                 $Apache::lonnet::hostname{$hostid}.'</a>';                  $Apache::lonnet::hostname{$hostid}.'</a>';
       $last=$Apache::lonnet::hostname{$hostid};
         }          }
  $r->print(<<ENDTROUBLE);   $r->print(<<ENDTROUBLE);
 <html>  <html>
Line 265  my %lt=&Apache::lonlocal::texthash( Line 279  my %lt=&Apache::lonlocal::texthash(
                   'servadm' => 'Server Administration',                    'servadm' => 'Server Administration',
                   'sysadm' => 'System Administration',                    'sysadm' => 'System Administration',
                   'helpdesk' => 'Contact Helpdesk');                    'helpdesk' => 'Contact Helpdesk');
   # -------------------------------------------------- Change password field name
       my $now=time;
 # ---------------------------------------------------------- Serve rest of page  # ---------------------------------------------------------- Serve rest of page
     $r->print(<<ENDSCRIPT);      $r->print(<<ENDSCRIPT);
   
Line 303  my %lt=&Apache::lonlocal::texthash( Line 318  my %lt=&Apache::lonlocal::texthash(
         lextkey=this.document.client.elements.lextkey.value;          lextkey=this.document.client.elements.lextkey.value;
         initkeys();          initkeys();
   
         this.document.server.elements.upass.value          this.document.server.elements.upass0.value
     =crypted(this.document.client.elements.upass.value);      =crypted(this.document.client.elements.upass$now.value.substr(0,15));
    this.document.server.elements.upass1.value
       =crypted(this.document.client.elements.upass$now.value.substr(15,15));
    this.document.server.elements.upass2.value
       =crypted(this.document.client.elements.upass$now.value.substr(30,15));
   
           this.document.client.elements.uname.value='';
           this.document.client.elements.upass$now.value='';
   
         this.document.server.submit();          this.document.server.submit();
  return false;   return false;
Line 321  ENDSCRIPT Line 343  ENDSCRIPT
   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">    <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
    <input type="hidden" name="logtoken" value="$logtoken" />     <input type="hidden" name="logtoken" value="$logtoken" />
    <input type="hidden" name="serverid" value="$lonhost" />     <input type="hidden" name="serverid" value="$lonhost" />
    <input type="hidden" name="interface" value="$ENV{'form.interface'}" />     <input type="hidden" name="interface" value="$env{'form.interface'}" />
    <input type="hidden" name="uname" value="" />     <input type="hidden" name="uname" value="" />
    <input type="hidden" name="upass" value="" />     <input type="hidden" name="upass0" value="" />
      <input type="hidden" name="upass1" value="" />
      <input type="hidden" name="upass2" value="" />
    <input type="hidden" name="udom" value="" />     <input type="hidden" name="udom" value="" />
    <input type="hidden" name="imagesuppress"  value="" />     <input type="hidden" name="imagesuppress"  value="" />
    <input type="hidden" name="appletsuppress"  value="" />     <input type="hidden" name="appletsuppress"  value="" />
Line 331  ENDSCRIPT Line 355  ENDSCRIPT
    <input type="hidden" name="fontenhance"  value="" />     <input type="hidden" name="fontenhance"  value="" />
    <input type="hidden" name="blackwhite"  value="" />     <input type="hidden" name="blackwhite"  value="" />
    <input type="hidden" name="remember"  value="" />     <input type="hidden" name="remember"  value="" />
    <input type="hidden" name="localpath" value="$ENV{'form.localpath'}" />     <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
    <input type="hidden" name="localres" value="$ENV{'form.localres'}" />     <input type="hidden" name="localres" value="$env{'form.localres'}" />
   </form>    </form>
 ENDSERVERFORM  ENDSERVERFORM
     if ($fullgraph) { $r->print(<<ENDTOP);      if ($fullgraph) { $r->print(<<ENDTOP);
Line 396  ENDTOP Line 420  ENDTOP
     unless ($fullgraph) {      unless ($fullgraph) {
         $r->print(<<ENDACCESSOPTIONS);          $r->print(<<ENDACCESSOPTIONS);
 <h3>Select Accessibility Options</h3>  <h3>Select Accessibility Options</h3>
 <input type="checkbox" name="imagesuppress" /> Suppress rendering of images<br />  <label><input type="checkbox" name="imagesuppress" /> Suppress rendering of images</label><br />
 <input type="checkbox" name="appletsuppress" /> Suppress Java applets<br />  <label><input type="checkbox" name="appletsuppress" /> Suppress Java applets</label><br />
 <input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia<br />  <label><input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia</label><br />
 <input type="checkbox" name="fontenhance" /> Increase font size<br />  <label><input type="checkbox" name="fontenhance" /> Increase font size</label><br />
 <input type="checkbox" name="blackwhite" /> Switch to black and white mode<br />  <label><input type="checkbox" name="blackwhite" /> Switch to black and white mode</label><br />
 <p>If you have accessibility needs that are not addressed by this interface,   <p>If you have accessibility needs that are not addressed by this interface, 
 please  please
 contact the system administrator at <tt>$sysadm</tt>.</p><br />  contact the system administrator at <tt>$sysadm</tt>.</p><br />
Line 429  ENDNOOPT Line 453  ENDNOOPT
       </tr>        </tr>
       <tr>        <tr>
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'pw'}:</b></font></td>         <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>         <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>
       </tr>        </tr>
       <tr>        <tr>
        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>         <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>
Line 447  ENDNOOPT Line 471  ENDNOOPT
     </form>      </form>
 ENDLOGIN  ENDLOGIN
     if ($fullgraph) {      if ($fullgraph) {
         my $contactblock = &contactdisplay(\%lt,$sysadm,$servadm,$version);          my $helpdeskscript;
           my $contactblock = &contactdisplay(\%lt,$sysadm,$servadm,$version,$authdomain,\$helpdeskscript);
  $r->print(<<ENDDOCUMENT);   $r->print(<<ENDDOCUMENT);
    </td>     </td>
   
Line 534  $domainlogo Line 559  $domainlogo
 // the if prevents the script error if the browser can not handle this  // the if prevents the script error if the browser can not handle this
 if ( document.client.uname ) { document.client.uname.focus(); }  if ( document.client.uname ) { document.client.uname.focus(); }
 </script>  </script>
   $helpdeskscript
   
 ENDDOCUMENT  ENDDOCUMENT
 }  }
Line 542  ENDDOCUMENT Line 568  ENDDOCUMENT
 }  }
   
 sub contactdisplay {  sub contactdisplay {
     my ($lt,$sysadm,$servadm,$version) = @_;      my ($lt,$sysadm,$servadm,$version,$authdomain,$helpdeskscript) = @_;
     my $contactblock;      my $contactblock;
     my $showsysadm = 1;      my $showsysadm = 1;
     my $showservadm = 1;      my $showservadm = 1;
     my $showhelpdesk = 1;      my $showhelpdesk = 0;
       my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
       if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
           $showhelpdesk = 1;
       }
     if ($showsysadm) {      if ($showsysadm) {
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'sysadm'}.':</b><br />'.          $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'sysadm'}.':</b><br />'.
                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$sysadm.'</tt><br />';                           '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$sysadm.'</tt><br />';
Line 556  sub contactdisplay { Line 586  sub contactdisplay {
                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';                           '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';
     }      }
     if ($showhelpdesk) {      if ($showhelpdesk) {
         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="/adm/helpdesk?origurl='.&Apache::lonnet::escape('/adm/login').'">'.$$lt{'helpdesk'}.'</a></b><br />';          $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()">'.$$lt{'helpdesk'}.'</a></b><br />';
           my $thisurl = &Apache::lonnet::escape('/adm/login');
           $$helpdeskscript = <<"ENDSCRIPT";
   <script type="text/javascript">
   function helpdesk() {
       var codedom = document.client.udom.value;
       if (codedom == '') {
           codedom = "$authdomain";
       }
       var querystr = "origurl=$thisurl&codedom="+codedom;
       document.location.href = "/adm/helpdesk?"+querystr;
       return;
   }
   </script>
   ENDSCRIPT
     }      }
     $contactblock .= <<"ENDBLOCK";      $contactblock .= <<"ENDBLOCK";
      &nbsp;&nbsp;&nbsp;$version       &nbsp;&nbsp;&nbsp;$version

Removed from v.1.61  
changed lines
  Added in v.1.67


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