File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.13: download - view: text, annotated - select for diffs
Tue Mar 12 19:34:59 2002 UTC (22 years, 2 months ago) by albertel
Branches: MAIN
CVS tags: HEAD
- testing things out

    1: # The LearningOnline Network
    2: # Login Screen
    3: #
    4: # $Id: lonlogin.pm,v 1.13 2002/03/12 19:34:59 albertel 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: package Apache::lonlogin;
   33: 
   34: use strict;
   35: use Apache::Constants qw(:common);
   36: use Apache::File ();
   37: use Apache::lonnet();
   38: use Apache::loncommon();
   39: 
   40: sub handler {
   41:     my $r = shift;
   42:     $r->content_type('text/html');
   43:     &Apache::loncommon::no_cache($r);
   44:     $r->send_http_header;
   45:     return OK if $r->header_only;
   46: 
   47:     my $iconpath= $r->dir_config('lonIconsURL');
   48:     my $domain  = $r->dir_config('lonDefDomain');
   49:     my $role    = $r->dir_config('lonRole');
   50:     my $loadlim = $r->dir_config('lonLoadLim');
   51:     my $servadm = $r->dir_config('lonAdmEMail');
   52:     my $sysadm  = $r->dir_config('lonSysEMail');
   53:     my $lonhost = $r->dir_config('lonHostID');
   54:     my $tabdir  = $r->dir_config('lonTabDir');
   55:     my $include = $r->dir_config('lonIncludes');
   56: 
   57:     my $loadavg;
   58:    {
   59:        my $loadfile=Apache::File->new('/proc/loadavg');
   60:        $loadavg=<$loadfile>;
   61:    }
   62:     $loadavg =~ s/\s.*//g;
   63:     my $loadpercent=100*$loadavg/$loadlim;
   64: 
   65:     my $otherserver='http://'.$ENV{'SERVER_NAME'};
   66:     my $firsturl=$ENV{'request.firsturl'};
   67: # ---------------------------------------- Are we access server and overloaded?
   68:     if (($role eq 'access') && ($loadpercent>100.0)) {
   69:         $otherserver=Apache::lonnet::spareserver();
   70:     }
   71: 
   72: # -------------------------------------------------------- Set login parameters
   73: 
   74:     my @hexstr=('0','1','2','3','4','5','6','7',
   75:                 '8','9','a','b','c','d','e','f');
   76:     my $lkey='';
   77:     for (0..7) {
   78:         $lkey.=$hexstr[rand(15)];
   79:     }
   80: 
   81:     my $ukey='';
   82:     for (0..7) {
   83:         $ukey.=$hexstr[rand(15)];
   84:     }
   85: 
   86:     my $lextkey=hex($lkey);
   87:     my $uextkey=hex($ukey);
   88:     my $logtoken=Apache::lonnet::reply(
   89:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
   90:        $lonhost);
   91: 
   92: # --------------------------------------------------- Print login screen header
   93:     $r->print(<<ENDHEADER);
   94: <html>
   95: <head>
   96: <title>The LearningOnline Network with CAPA Login</title>
   97: </head>
   98: ENDHEADER
   99: # ---------------------------------------------------- Serve out DES JavaScript
  100:     {
  101: 	my $jsh=Apache::File->new($include."/londes.js");
  102:         $r->print(<$jsh>);
  103:     }
  104: # ---------------------------------------------------------- Serve rest of page
  105:     $r->print(<<ENDDOCUMENT);
  106: 
  107: <body bgcolor="#FFFFFE" text="#000000" link="#999999" vlink="#999999"
  108:  onLoad="init();">
  109: 
  110: <script language="JavaScript">
  111: 
  112:     function send() {
  113: 	this.document.server.elements.uname.value
  114:        =this.document.client.elements.uname.value;
  115: 
  116:         this.document.server.elements.udom.value
  117:        =this.document.client.elements.udom.value;
  118: 
  119:         uextkey=this.document.client.elements.uextkey.value;
  120:         lextkey=this.document.client.elements.lextkey.value;
  121:         initkeys();
  122: 
  123:         this.document.server.elements.upass.value
  124: 	    =crypted(this.document.client.elements.upass.value);
  125: 
  126:         this.document.server.submit();
  127:     }
  128: 
  129: </script>
  130: 
  131: <a href="/adm/accessibility.html">Accessibility Options</a>
  132: &nbsp;&nbsp;
  133: <a href="/adm/about.html">About LON-CAPA</a><p>
  134: <table width=600>
  135: <tr><td>
  136: <img src="$iconpath/lonlogo.gif"></td>
  137: <td colspan=2 bgcolor="#DDDDDD">
  138: <font size=+1><b>User Authentication</b></font><p>
  139: 
  140:  <form name="server" action="$otherserver/adm/authenticate" 
  141:   method="post" target="_top">
  142:   <input type=hidden name=logtoken value="$logtoken">
  143:   <input type=hidden name=serverid value="$lonhost">
  144:   <input type=hidden name=uname value="">
  145:   <input type=hidden name=upass value="">
  146:   <input type=hidden name=udom value="">
  147:  </form>
  148: 
  149:  <form name="client">
  150:  <table border=2 bgcolor="#BBBBBB">
  151:  <tr><td>Username:</td><td><input type=text size=10 name=uname></td></tr>
  152:  <tr><td>Password:</td><td><input type=password size=10 name=upass></td></tr>
  153:  <tr><td>Domain:</td><td><input type=text size=10 value=$domain name=udom></td>
  154:  </tr>
  155:  <tr><td colspan=2><input type=button value=Login onClick="send();"></td></tr>
  156:  </table>
  157:  <input type=hidden name=lextkey value="$lextkey">
  158:  <input type=hidden name=uextkey value="$uextkey">
  159:  </form>
  160: 
  161: </td>
  162: </tr><tr><td bgcolor="#DDDDDD">
  163: <table border=1 bgcolor="#BBBBBB">
  164: <tr><td><font size="-1"><b>Domain:</b></font></td>
  165:     <td><font size="-1"><tt>$domain</tt></font></td>
  166:     <td rowspan=3><font size="-1"><b>System Administration:</b><br>
  167:                   <tt>$sysadm</tt><br>
  168:                   <b>Server Administration:</b><br>
  169:                   <tt>$servadm</tt></font></td></tr>
  170: <tr><td><font size="-1"><b>Server:</b></font></td>
  171:     <td><font size="-1"><tt>$lonhost ($role)</tt></font></td></tr>
  172: <tr><td><font size="-1"><b>Load:</b></font></td>
  173:     <td><font size="-1"><tt>$loadpercent</tt> percent</font></td></tr>
  174: </table>
  175: </td><td>
  176: <font size="+1">
  177: <b>L</b>aboratory&nbsp;for<br>
  178: <b>I</b>nstructional<br>
  179: <b>T</b>echnology&nbsp;in<br>
  180: <b>E</b>ducation</td><td>
  181: <img src="$iconpath/liteani.gif"></font></td></tr></table>
  182: </body>
  183: </html>
  184: ENDDOCUMENT
  185:     return OK;
  186: } 
  187: 
  188: 1;
  189: __END__

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