File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.15: download - view: text, annotated - select for diffs
Sat Mar 23 21:06:54 2002 UTC (22 years, 2 months ago) by www
Branches: MAIN
CVS tags: stable_2002_april, HEAD
See if this simple solution works.

    1: # The LearningOnline Network
    2: # Login Screen
    3: #
    4: # $Id: lonlogin.pm,v 1.15 2002/03/23 21:06:54 www 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: package Apache::lonlogin;
   35: 
   36: use strict;
   37: use Apache::Constants qw(:common);
   38: use Apache::File ();
   39: use Apache::lonnet();
   40: use Apache::loncommon();
   41: 
   42: sub handler {
   43:     my $r = shift;
   44:     $r->content_type('text/html');
   45:     &Apache::loncommon::no_cache($r);
   46:     $r->send_http_header;
   47:     return OK if $r->header_only;
   48: 
   49:     my $iconpath= $r->dir_config('lonIconsURL');
   50:     my $domain  = $r->dir_config('lonDefDomain');
   51:     my $role    = $r->dir_config('lonRole');
   52:     my $loadlim = $r->dir_config('lonLoadLim');
   53:     my $servadm = $r->dir_config('lonAdmEMail');
   54:     my $sysadm  = $r->dir_config('lonSysEMail');
   55:     my $lonhost = $r->dir_config('lonHostID');
   56:     my $tabdir  = $r->dir_config('lonTabDir');
   57:     my $include = $r->dir_config('lonIncludes');
   58: 
   59:     my $loadavg;
   60:    {
   61:        my $loadfile=Apache::File->new('/proc/loadavg');
   62:        $loadavg=<$loadfile>;
   63:    }
   64:     $loadavg =~ s/\s.*//g;
   65:     my $loadpercent=100*$loadavg/$loadlim;
   66: 
   67:     my $otherserver='http://'.$ENV{'SERVER_NAME'};
   68:     my $firsturl=$ENV{'request.firsturl'};
   69: # ---------------------------------------- Are we access server and overloaded?
   70:     if (($role eq 'access') && ($loadpercent>100.0)) {
   71:         $otherserver=Apache::lonnet::spareserver();
   72:     }
   73: 
   74: # -------------------------------------------------------- Set login parameters
   75: 
   76:     my @hexstr=('0','1','2','3','4','5','6','7',
   77:                 '8','9','a','b','c','d','e','f');
   78:     my $lkey='';
   79:     for (0..7) {
   80:         $lkey.=$hexstr[rand(15)];
   81:     }
   82: 
   83:     my $ukey='';
   84:     for (0..7) {
   85:         $ukey.=$hexstr[rand(15)];
   86:     }
   87: 
   88:     my $lextkey=hex($lkey);
   89:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
   90: 
   91:     my $uextkey=hex($ukey);
   92:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
   93: 
   94:     my $logtoken=Apache::lonnet::reply(
   95:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
   96:        $lonhost);
   97: 
   98: # --------------------------------------------------- Print login screen header
   99:     $r->print(<<ENDHEADER);
  100: <html>
  101: <head>
  102: <title>The LearningOnline Network with CAPA Login</title>
  103: </head>
  104: ENDHEADER
  105: # ---------------------------------------------------- Serve out DES JavaScript
  106:     {
  107: 	my $jsh=Apache::File->new($include."/londes.js");
  108:         $r->print(<$jsh>);
  109:     }
  110: # ---------------------------------------------------------- Serve rest of page
  111:     $r->print(<<ENDDOCUMENT);
  112: 
  113: <body bgcolor="#006600" text="#000000" link="#999999" vlink="#999999"
  114:  onLoad="init();" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
  115: 
  116:  <script language="JavaScript">
  117:     function send()
  118:     {
  119: 	this.document.server.elements.uname.value
  120:        =this.document.client.elements.uname.value;
  121: 
  122:         this.document.server.elements.udom.value
  123:        =this.document.client.elements.udom.value;
  124: 
  125:         uextkey=this.document.client.elements.uextkey.value;
  126:         lextkey=this.document.client.elements.lextkey.value;
  127:         initkeys();
  128: 
  129:         this.document.server.elements.upass.value
  130: 	    =crypted(this.document.client.elements.upass.value);
  131: 
  132:         this.document.server.submit();
  133:     }
  134:  </script>
  135: 
  136:  <!-- The Main Table -->
  137:  <table width="100%" cellpadding=0 cellspacing=0 border=0>
  138: 
  139:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
  140:    <input type=hidden name=logtoken value="$logtoken">
  141:    <input type=hidden name=serverid value="$lonhost">
  142:    <input type=hidden name=uname value="">
  143:    <input type=hidden name=upass value="">
  144:    <input type=hidden name=udom value="">
  145:   </form>
  146: 
  147:   <!-- The LON-CAPA Header -->
  148:   <tr>
  149: 
  150:    <!-- Row 1 Columns 2-4 -->
  151:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="#006600"><img src="$iconpath/header.gif" border=0 /></td>
  152:   </tr>
  153: 
  154:   <!-- The gray bar that starts the two table frames -->
  155:   <tr>
  156: 
  157:    <!-- Row 2 Column 1 -->
  158:    <td width=182 height=27 bgcolor="#cccccc">&nbsp;</td>
  159: 
  160:    <!-- Row 2 Column 2 -->
  161:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 /></td>
  162: 
  163:    <!-- Row 2 Column 3 -->
  164:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" /></td>
  165: 
  166:    <!-- Row 2 Column 4 -->
  167:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 /></td>
  168:   </tr>
  169:   <tr>
  170:    
  171:    <!-- A cell that will hold the 'access' and 'about' buttons -->
  172:    <!-- Row 3 Column 1 -->
  173:    <td valign="top" height=60 align="center" bgcolor="#cccccc">
  174:     <a href="/adm/accessibility.html"><img src="$iconpath/accessbutton.gif" border=0 /></a>
  175:     <br />
  176:     <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 /></a>
  177:    </td>
  178: 
  179:    <!-- The shaded space between the two main columns -->
  180:    <!-- Row 3 Column 2 -->
  181:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
  182: 
  183:    <!-- The right main column holding the large LON-CAPA logo-->
  184:    <!-- Rows 3-4 Column 3 -->
  185:    <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="#ffffff">
  186:     <center>
  187:      <img src="$iconpath/loncapalogo.gif" />
  188:     </center>
  189:    </td>
  190: 
  191:    <!-- Row 3 Column 4 -->
  192:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
  193:   </tr>
  194:   <tr>
  195: 
  196:    <!-- The entry form -->
  197:    <!-- Row 4 Column 1 -->
  198:    <td align="center" valign="middle" bgcolor="#cccccc">
  199:     <form name="client">
  200:      <input type="hidden" name="lextkey" value="$lextkey">
  201:      <input type="hidden" name="uextkey" value="$uextkey">
  202: 
  203:      <!-- Start the sub-table for text and input alignment -->
  204:      <table border=0 cellspacing=0 cellpadding=0>
  205:       <tr><td bgcolor="#cccccc" colspan=2><img src="$iconpath/userauthentication.gif" /></td></tr>
  206:       <tr>
  207:        <td bgcolor="#ffffff"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;User Name:</b></font></td>
  208:        <td bgcolor="#ffffff"><br /><input type="text" name="uname" size="10" /></td>
  209:       </tr>
  210:       <tr>
  211:        <td bgcolor="#ffffff"><font size=-1><b>&nbsp;&nbsp;&nbsp;Password:</b></font></td>
  212:        <td bgcolor="#ffffff"><input type="password" name="upass" size="10" /></td>
  213:       </tr>
  214:       <tr>
  215:        <td bgcolor="#ffffff"><font size=-1><b>&nbsp;&nbsp;&nbsp;Domain:</b></font></td>
  216:        <td bgcolor="#ffffff"><input type="text" name="udom" size="10" value=$domain /></td>
  217:       </tr>
  218:       <tr>
  219:        <td bgcolor="#ffffff" valign="bottom" align="center" colspan=2>
  220:         <br />
  221:         <input type="button" value="Log In" onClick="send();" />
  222:        </td>
  223:       </tr>
  224:      </table>
  225:      <!-- End sub-table -->
  226: 
  227:     </form>
  228:    </td>
  229: 
  230:    <!-- Row 4 Column 2 -->
  231:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
  232: 
  233:    <!-- Row 4 Column 4 -->
  234:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
  235:   </tr>
  236:   <tr>
  237: 
  238:    <!-- Row 5 Column 1 -->
  239:    <td bgcolor="#cccccc" valign="middle" align="left">
  240:      <br />
  241:      <table border=0 cellspacing=0 cellpadding=0>
  242:       <tr>
  243:        <td bgcolor="#cccccc" align="left" valign="top">
  244:         <small><b>&nbsp;&nbsp;&nbsp;Domain:&nbsp;</b></small>
  245:        </td>
  246:        <td bgcolor="#cccccc" align="left" valign="top">
  247:         <small><tt>&nbsp;$domain</tt></small>
  248:        </td>
  249:       </tr>
  250:       <tr>
  251:        <td bgcolor="#cccccc" align="left" valign="top">
  252:         <small><b>&nbsp;&nbsp;&nbsp;Server:&nbsp;</b></small>
  253:        </td>
  254:        <td bgcolor="#cccccc" align="left" valign="top">
  255:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
  256:        </td>
  257:       </tr>
  258:       <tr>
  259:        <td bgcolor="#cccccc" align="left" valign="top">
  260:         <small><b>&nbsp;&nbsp;&nbsp;Load:&nbsp;</b></small>
  261:        </td>
  262:        <td bgcolor="#cccccc" align="left" valign="top">
  263:         <small><tt>&nbsp;$loadpercent percent</tt></small>
  264:        </td>
  265:       </tr>
  266:      </table>
  267:      <br />
  268:     <small>
  269:      <b>&nbsp;&nbsp;&nbsp;System Administration:</b><br />
  270:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />
  271:      <b>&nbsp;&nbsp;&nbsp;Server Administration:</b><br />
  272:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm</tt>
  273:     </small>
  274:    </td>
  275: 
  276:    <!-- Row 5 Column 2 -->
  277:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
  278: 
  279:    <!-- Row 5 Column 3 -->
  280:    <td width="100%" valign="bottom" bgcolor="#ffffff"><img src="$iconpath/litetext.gif" /><img src="$iconpath/lite.gif" /></td>
  281: 
  282:    <!-- Row 5 Column 4 -->
  283:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
  284:   </tr>
  285:   <tr>
  286: 
  287:    <!-- Row 6 Column 1 -->
  288:    <td bgcolor="#cccccc">&nbsp;</td>
  289: 
  290:    <!-- Row 6 Column 2 -->
  291:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" /></td>
  292: 
  293:    <!-- Row 6 Column 3 -->
  294:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" /></td>
  295: 
  296:    <!-- Row 6 Column 4 -->
  297:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" /></td>
  298:   </tr>
  299:  </table>
  300: </body>
  301: </html>
  302: 
  303: ENDDOCUMENT
  304:     return OK;
  305: } 
  306: 
  307: 1;
  308: __END__

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