File:  [LON-CAPA] / loncom / auth / lonlogin.pm
Revision 1.26: download - view: text, annotated - select for diffs
Tue Oct 29 20:57:31 2002 UTC (21 years, 7 months ago) by www
Branches: MAIN
CVS tags: version_0_6, HEAD
Get small GIFs from lonhttpd

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

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