File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.19: download - view: text, annotated - select for diffs
Wed Jul 10 17:47:01 2002 UTC (21 years, 10 months ago) by bowersj2
Branches: MAIN
CVS tags: version_0_5_1, version_0_5, fixes_0_5, HEAD
On modern browsers, can now use "enter" key to submit login form.
(Tested on Netscape 4, Mozilla, and IE6; should work everywhere.) Make
"Log in" an actual submit button, importent for screen readers. Added
alt tags to images.

    1: # The LearningOnline Network
    2: # Login Screen
    3: #
    4: # $Id: lonlogin.pm,v 1.19 2002/07/10 17:47:01 bowersj2 Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   29: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9,
   30: # 1/17/01 Gerd Kortemeyer
   31: #
   32: # 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole
   33: # 
   34: # 7/10/02 Jeremy Bowers
   35: 
   36: package Apache::lonlogin;
   37: 
   38: use strict;
   39: use Apache::Constants qw(:common);
   40: use Apache::File ();
   41: use Apache::lonnet();
   42: use Apache::loncommon();
   43: 
   44: sub handler {
   45:     my $r = shift;
   46:     $r->content_type('text/html');
   47:     &Apache::loncommon::no_cache($r);
   48:     $r->send_http_header;
   49:     return OK if $r->header_only;
   50: 
   51: 
   52:     &Apache::loncommon::get_unprocessed_cgi
   53:                          ($ENV{'QUERY_STRING'},['interface']);
   54: 
   55:     $ENV{'form.interface'}=~s/\W//g;
   56: 
   57:     my $fullgraph=($ENV{'form.interface'} ne 'textual');
   58: 
   59:     my $iconpath= $r->dir_config('lonIconsURL');
   60:     my $domain  = $r->dir_config('lonDefDomain');
   61:     my $role    = $r->dir_config('lonRole');
   62:     my $loadlim = $r->dir_config('lonLoadLim');
   63:     my $servadm = $r->dir_config('lonAdmEMail');
   64:     my $sysadm  = $r->dir_config('lonSysEMail');
   65:     my $lonhost = $r->dir_config('lonHostID');
   66:     my $tabdir  = $r->dir_config('lonTabDir');
   67:     my $include = $r->dir_config('lonIncludes');
   68: 
   69:     my $loadavg;
   70:    {
   71:        my $loadfile=Apache::File->new('/proc/loadavg');
   72:        $loadavg=<$loadfile>;
   73:    }
   74:     $loadavg =~ s/\s.*//g;
   75:     my $loadpercent=100*$loadavg/$loadlim;
   76: 
   77:     my $otherserver='http://'.$ENV{'SERVER_NAME'};
   78:     my $firsturl=$ENV{'request.firsturl'};
   79: # ---------------------------------------- Are we access server and overloaded?
   80:     if (($role eq 'access') && ($loadpercent>100.0)) {
   81:         $otherserver=Apache::lonnet::spareserver();
   82:     }
   83: 
   84: # -------------------------------------------------------- Set login parameters
   85: 
   86:     my @hexstr=('0','1','2','3','4','5','6','7',
   87:                 '8','9','a','b','c','d','e','f');
   88:     my $lkey='';
   89:     for (0..7) {
   90:         $lkey.=$hexstr[rand(15)];
   91:     }
   92: 
   93:     my $ukey='';
   94:     for (0..7) {
   95:         $ukey.=$hexstr[rand(15)];
   96:     }
   97: 
   98:     my $lextkey=hex($lkey);
   99:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
  100: 
  101:     my $uextkey=hex($ukey);
  102:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
  103: 
  104:     my $logtoken=Apache::lonnet::reply(
  105:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
  106:        $lonhost);
  107: 
  108: # --------------------------------------------------- Print login screen header
  109:     $r->print(<<ENDHEADER);
  110: <html>
  111: <head>
  112: <title>The LearningOnline Network with CAPA Login</title>
  113: </head>
  114: ENDHEADER
  115: # ---------------------------------------------------- Serve out DES JavaScript
  116:     {
  117: 	my $jsh=Apache::File->new($include."/londes.js");
  118:         $r->print(<$jsh>);
  119:     }
  120: # ---------------------------------------------------------- Serve rest of page
  121:     $r->print(<<ENDSCRIPT);
  122: 
  123: <body bgcolor="#006600" text="#000000" link="#999999" vlink="#999999"
  124:  onLoad="init();" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
  125: 
  126:  <script language="JavaScript">
  127:     function send()
  128:     {
  129: 	this.document.server.elements.uname.value
  130:        =this.document.client.elements.uname.value;
  131: 
  132:         this.document.server.elements.udom.value
  133:        =this.document.client.elements.udom.value;
  134: 
  135:         uextkey=this.document.client.elements.uextkey.value;
  136:         lextkey=this.document.client.elements.lextkey.value;
  137:         initkeys();
  138: 
  139:         this.document.server.elements.upass.value
  140: 	    =crypted(this.document.client.elements.upass.value);
  141: 
  142:         this.document.server.submit();
  143: 	return false;
  144:     }
  145:  </script>
  146: ENDSCRIPT
  147: 
  148:     if ($fullgraph) {
  149: 	$r->print(
  150: 		  '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
  151:     }
  152: 
  153:     $r->print(<<ENDSERVERFORM);
  154:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
  155:    <input type=hidden name=logtoken value="$logtoken">
  156:    <input type=hidden name=serverid value="$lonhost">
  157:    <input type=hidden name=interface value="$ENV{'form.interface'}">
  158:    <input type=hidden name=uname value="">
  159:    <input type=hidden name=upass value="">
  160:    <input type=hidden name=udom value="">
  161:   </form>
  162: ENDSERVERFORM
  163:     if ($fullgraph) { $r->print(<<ENDTOP);
  164:   <!-- The LON-CAPA Header -->
  165:   <tr>
  166: 
  167:    <!-- Row 1 Columns 2-4 -->
  168:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="#006600"><img src="$iconpath/header.gif" border=0 alt="The Learning Online Network with CAPA" /></td>
  169:   </tr>
  170: 
  171:   <!-- The gray bar that starts the two table frames -->
  172:   <tr>
  173: 
  174:    <!-- Row 2 Column 1 -->
  175:    <td width=182 height=27 bgcolor="#cccccc">&nbsp;</td>
  176: 
  177:    <!-- Row 2 Column 2 -->
  178:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
  179: 
  180:    <!-- Row 2 Column 3 -->
  181:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
  182: 
  183:    <!-- Row 2 Column 4 -->
  184:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
  185:   </tr>
  186:   <tr>
  187:    
  188:    <!-- A cell that will hold the 'access' and 'about' buttons -->
  189:    <!-- Row 3 Column 1 -->
  190:    <td valign="top" height=60 align="center" bgcolor="#cccccc">
  191:     <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
  192:     <br />
  193:     <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
  194:    </td>
  195: 
  196:    <!-- The shaded space between the two main columns -->
  197:    <!-- Row 3 Column 2 -->
  198:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  199: 
  200:    <!-- The right main column holding the large LON-CAPA logo-->
  201:    <!-- Rows 3-4 Column 3 -->
  202:    <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="#ffffff">
  203:     <center>
  204:      <img src="$iconpath/loncapalogo.gif" alt="" />
  205:     </center>
  206:    </td>
  207: 
  208:    <!-- Row 3 Column 4 -->
  209:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  210:   </tr>
  211:   <tr>
  212: 
  213:    <!-- The entry form -->
  214:    <!-- Row 4 Column 1 -->
  215:    <td align="center" valign="middle" bgcolor="#cccccc">
  216: ENDTOP
  217: }
  218:     $r->print(<<ENDLOGIN);
  219:     <form name="client" onsubmit="return(send())">
  220:      <input type="hidden" name="lextkey" value="$lextkey">
  221:      <input type="hidden" name="uextkey" value="$uextkey">
  222: 
  223:      <!-- Start the sub-table for text and input alignment -->
  224:      <table border=0 cellspacing=0 cellpadding=0>
  225:       <tr><td bgcolor="#cccccc" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
  226:       <tr>
  227:        <td bgcolor="#ffffff"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;User Name:</b></font></td>
  228:        <td bgcolor="#ffffff"><br /><input type="text" name="uname" size="10" /></td>
  229:       </tr>
  230:       <tr>
  231:        <td bgcolor="#ffffff"><font size=-1><b>&nbsp;&nbsp;&nbsp;Password:</b></font></td>
  232:        <td bgcolor="#ffffff"><input type="password" name="upass" size="10" /></td>
  233:       </tr>
  234:       <tr>
  235:        <td bgcolor="#ffffff"><font size=-1><b>&nbsp;&nbsp;&nbsp;Domain:</b></font></td>
  236:        <td bgcolor="#ffffff"><input type="text" name="udom" size="10" value=$domain /></td>
  237:       </tr>
  238:       <tr>
  239:        <td bgcolor="#ffffff" valign="bottom" align="center" colspan=2>
  240:         <br />
  241:         <input type="submit" value="Log In" />
  242:        </td>
  243:       </tr>
  244:      </table>
  245:      <!-- End sub-table -->
  246:     </form>
  247: ENDLOGIN
  248:     if ($fullgraph) {
  249: 	$r->print(<<ENDDOCUMENT);
  250:    </td>
  251: 
  252:    <!-- Row 4 Column 2 -->
  253:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  254: 
  255:    <!-- Row 4 Column 4 -->
  256:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  257:   </tr>
  258:   <tr>
  259: 
  260:    <!-- Row 5 Column 1 -->
  261:    <td bgcolor="#cccccc" valign="middle" align="left">
  262:      <br />
  263:      <table border=0 cellspacing=0 cellpadding=0>
  264:       <tr>
  265:        <td bgcolor="#cccccc" align="left" valign="top">
  266:         <small><b>&nbsp;&nbsp;&nbsp;Domain:&nbsp;</b></small>
  267:        </td>
  268:        <td bgcolor="#cccccc" align="left" valign="top">
  269:         <small><tt>&nbsp;$domain</tt></small>
  270:        </td>
  271:       </tr>
  272:       <tr>
  273:        <td bgcolor="#cccccc" align="left" valign="top">
  274:         <small><b>&nbsp;&nbsp;&nbsp;Server:&nbsp;</b></small>
  275:        </td>
  276:        <td bgcolor="#cccccc" align="left" valign="top">
  277:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
  278:        </td>
  279:       </tr>
  280:       <tr>
  281:        <td bgcolor="#cccccc" align="left" valign="top">
  282:         <small><b>&nbsp;&nbsp;&nbsp;Load:&nbsp;</b></small>
  283:        </td>
  284:        <td bgcolor="#cccccc" align="left" valign="top">
  285:         <small><tt>&nbsp;$loadpercent percent</tt></small>
  286:        </td>
  287:       </tr>
  288:      </table>
  289:      <br />
  290:     <small>
  291:      <b>&nbsp;&nbsp;&nbsp;System Administration:</b><br />
  292:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />
  293:      <b>&nbsp;&nbsp;&nbsp;Server Administration:</b><br />
  294:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm<br />&nbsp;</tt>
  295:     </small>
  296:    </td>
  297: 
  298:    <!-- Row 5 Column 2 -->
  299:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
  300: 
  301:    <!-- Row 5 Column 3 -->
  302:    <td width="100%" valign="bottom" bgcolor="#ffffff"><img src="$iconpath/litetext.gif" alt="Laboratory for Instructional Technology in Education" /><img src="$iconpath/lite.gif" alt="" /></td>
  303: 
  304:    <!-- Row 5 Column 4 -->
  305:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
  306:   </tr>
  307:   <tr>
  308: 
  309:    <!-- Row 6 Column 1 -->
  310:    <td bgcolor="#cccccc">&nbsp;</td>
  311: 
  312:    <!-- Row 6 Column 2 -->
  313:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
  314: 
  315:    <!-- Row 6 Column 3 -->
  316:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
  317: 
  318:    <!-- Row 6 Column 4 -->
  319:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
  320:   </tr>
  321:  </table>
  322: 
  323: ENDDOCUMENT
  324: }
  325:     $r->print('</body></html>');
  326:     return OK;
  327: } 
  328: 
  329: 1;
  330: __END__

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