File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.17: download - view: text, annotated - select for diffs
Sat May 25 21:46:15 2002 UTC (21 years, 11 months ago) by www
Branches: MAIN
CVS tags: HEAD
Value of "interface" passed on.

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

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