Annotation of loncom/auth/lonlogin.pm, revision 1.29

1.1       albertel    1: # The LearningOnline Network
                      2: # Login Screen
1.11      www         3: #
1.29    ! www         4: # $Id: lonlogin.pm,v 1.28 2003/01/16 01:37:26 www Exp $
1.11      www         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: #
1.2       www        28: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
1.10      www        29: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9,
                     30: # 1/17/01 Gerd Kortemeyer
1.1       albertel   31: #
1.14      albertel   32: # 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole
1.19      bowersj2   33: # 
                     34: # 7/10/02 Jeremy Bowers
1.14      albertel   35: 
1.1       albertel   36: package Apache::lonlogin;
                     37: 
                     38: use strict;
                     39: use Apache::Constants qw(:common);
                     40: use Apache::File ();
                     41: use Apache::lonnet();
1.12      albertel   42: use Apache::loncommon();
1.1       albertel   43: 
                     44: sub handler {
                     45:     my $r = shift;
                     46:     $r->content_type('text/html');
1.12      albertel   47:     &Apache::loncommon::no_cache($r);
1.1       albertel   48:     $r->send_http_header;
                     49:     return OK if $r->header_only;
                     50: 
1.16      www        51: 
                     52:     &Apache::loncommon::get_unprocessed_cgi
                     53:                          ($ENV{'QUERY_STRING'},['interface']);
1.18      www        54: 
                     55:     $ENV{'form.interface'}=~s/\W//g;
1.16      www        56: 
                     57:     my $fullgraph=($ENV{'form.interface'} ne 'textual');
                     58: 
1.26      www        59:     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':8080'.
                     60:                   $r->dir_config('lonIconsURL');
1.1       albertel   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');
1.6       www        68:     my $include = $r->dir_config('lonIncludes');
1.1       albertel   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: 
1.10      www        78:     my $otherserver='http://'.$ENV{'SERVER_NAME'};
1.5       www        79:     my $firsturl=$ENV{'request.firsturl'};
1.1       albertel   80: # ---------------------------------------- Are we access server and overloaded?
1.24      matthew    81:     if (($role eq 'access') && ($loadpercent>100.0)) {
1.22      matthew    82:         $otherserver=Apache::lonnet::spareserver($loadpercent);
1.1       albertel   83:     }
1.6       www        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);
1.15      www       100:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
                    101: 
1.6       www       102:     my $uextkey=hex($ukey);
1.15      www       103:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
                    104: 
1.6       www       105:     my $logtoken=Apache::lonnet::reply(
1.7       www       106:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
1.6       www       107:        $lonhost);
1.20      www       108:     my $domainlogo=&Apache::loncommon::domainlogo();
1.6       www       109: # --------------------------------------------------- Print login screen header
                    110:     $r->print(<<ENDHEADER);
1.1       albertel  111: <html>
                    112: <head>
1.2       www       113: <title>The LearningOnline Network with CAPA Login</title>
1.1       albertel  114: </head>
1.6       www       115: ENDHEADER
                    116: # ---------------------------------------------------- Serve out DES JavaScript
                    117:     {
                    118: 	my $jsh=Apache::File->new($include."/londes.js");
                    119:         $r->print(<$jsh>);
                    120:     }
1.21      www       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: 
1.6       www       134: # ---------------------------------------------------------- Serve rest of page
1.16      www       135:     $r->print(<<ENDSCRIPT);
1.6       www       136: 
1.21      www       137: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
1.27      albertel  138:   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
1.6       www       139: 
1.14      albertel  140:  <script language="JavaScript">
                    141:     function send()
                    142:     {
1.6       www       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();
1.19      bowersj2  157: 	return false;
1.6       www       158:     }
1.14      albertel  159:  </script>
1.16      www       160: ENDSCRIPT
1.6       www       161: 
1.16      www       162:     if ($fullgraph) {
                    163: 	$r->print(
                    164: 		  '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
                    165:     }
1.6       www       166: 
1.16      www       167:     $r->print(<<ENDSERVERFORM);
1.14      albertel  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">
1.17      www       171:    <input type=hidden name=interface value="$ENV{'form.interface'}">
1.14      albertel  172:    <input type=hidden name=uname value="">
                    173:    <input type=hidden name=upass value="">
                    174:    <input type=hidden name=udom value="">
                    175:   </form>
1.16      www       176: ENDSERVERFORM
                    177:     if ($fullgraph) { $r->print(<<ENDTOP);
1.14      albertel  178:   <!-- The LON-CAPA Header -->
                    179:   <tr>
                    180: 
                    181:    <!-- Row 1 Columns 2-4 -->
1.29    ! www       182:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>
1.14      albertel  183:   </tr>
                    184: 
                    185:   <!-- The gray bar that starts the two table frames -->
                    186:   <tr>
                    187: 
                    188:    <!-- Row 2 Column 1 -->
1.21      www       189:    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  190: 
                    191:    <!-- Row 2 Column 2 -->
1.19      bowersj2  192:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
1.14      albertel  193: 
                    194:    <!-- Row 2 Column 3 -->
1.19      bowersj2  195:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
1.14      albertel  196: 
                    197:    <!-- Row 2 Column 4 -->
1.19      bowersj2  198:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
1.14      albertel  199:   </tr>
                    200:   <tr>
                    201:    
                    202:    <!-- A cell that will hold the 'access' and 'about' buttons -->
                    203:    <!-- Row 3 Column 1 -->
1.21      www       204:    <td valign="top" height=60 align="center" bgcolor="$sidebg">
1.19      bowersj2  205:     <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
1.14      albertel  206:     <br />
1.19      bowersj2  207:     <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
1.14      albertel  208:    </td>
                    209: 
                    210:    <!-- The shaded space between the two main columns -->
                    211:    <!-- Row 3 Column 2 -->
1.19      bowersj2  212:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  213: 
                    214:    <!-- The right main column holding the large LON-CAPA logo-->
                    215:    <!-- Rows 3-4 Column 3 -->
1.21      www       216:    <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
1.14      albertel  217:     <center>
1.21      www       218:      <img src="$logo" alt="" />
1.14      albertel  219:     </center>
                    220:    </td>
                    221: 
                    222:    <!-- Row 3 Column 4 -->
1.19      bowersj2  223:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  224:   </tr>
                    225:   <tr>
                    226: 
                    227:    <!-- The entry form -->
                    228:    <!-- Row 4 Column 1 -->
1.21      www       229:    <td align="center" valign="middle" bgcolor="$sidebg">
1.16      www       230: ENDTOP
                    231: }
                    232:     $r->print(<<ENDLOGIN);
1.19      bowersj2  233:     <form name="client" onsubmit="return(send())">
1.14      albertel  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>
1.21      www       239:       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
1.14      albertel  240:       <tr>
1.21      www       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>
1.14      albertel  243:       </tr>
                    244:       <tr>
1.21      www       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>
1.14      albertel  247:       </tr>
                    248:       <tr>
1.21      www       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>
1.14      albertel  251:       </tr>
                    252:       <tr>
1.28      www       253:        <td bgcolor="$mainbg">&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">Help</a></td>
                    254:        <td bgcolor="$mainbg" valign="bottom" align="center">
1.14      albertel  255:         <br />
1.19      bowersj2  256:         <input type="submit" value="Log In" />
1.14      albertel  257:        </td>
                    258:       </tr>
                    259:      </table>
                    260:      <!-- End sub-table -->
                    261:     </form>
1.16      www       262: ENDLOGIN
                    263:     if ($fullgraph) {
                    264: 	$r->print(<<ENDDOCUMENT);
1.14      albertel  265:    </td>
                    266: 
                    267:    <!-- Row 4 Column 2 -->
1.19      bowersj2  268:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  269: 
                    270:    <!-- Row 4 Column 4 -->
1.19      bowersj2  271:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  272:   </tr>
                    273:   <tr>
                    274: 
                    275:    <!-- Row 5 Column 1 -->
1.21      www       276:    <td bgcolor="$sidebg" valign="middle" align="left">
1.14      albertel  277:      <br />
                    278:      <table border=0 cellspacing=0 cellpadding=0>
                    279:       <tr>
1.21      www       280:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  281:         <small><b>&nbsp;&nbsp;&nbsp;Domain:&nbsp;</b></small>
                    282:        </td>
1.21      www       283:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  284:         <small><tt>&nbsp;$domain</tt></small>
                    285:        </td>
                    286:       </tr>
                    287:       <tr>
1.21      www       288:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  289:         <small><b>&nbsp;&nbsp;&nbsp;Server:&nbsp;</b></small>
                    290:        </td>
1.21      www       291:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  292:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
                    293:        </td>
                    294:       </tr>
                    295:       <tr>
1.21      www       296:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  297:         <small><b>&nbsp;&nbsp;&nbsp;Load:&nbsp;</b></small>
                    298:        </td>
1.21      www       299:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  300:         <small><tt>&nbsp;$loadpercent percent</tt></small>
                    301:        </td>
                    302:       </tr>
                    303:      </table>
                    304:      <br />
                    305:     <small>
                    306:      <b>&nbsp;&nbsp;&nbsp;System Administration:</b><br />
                    307:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$sysadm</tt><br />
                    308:      <b>&nbsp;&nbsp;&nbsp;Server Administration:</b><br />
1.19      bowersj2  309:      <tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$servadm<br />&nbsp;</tt>
1.14      albertel  310:     </small>
                    311:    </td>
                    312: 
                    313:    <!-- Row 5 Column 2 -->
1.19      bowersj2  314:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  315: 
                    316:    <!-- Row 5 Column 3 -->
1.21      www       317:    <td width="100%" valign="bottom" bgcolor="$mainbg">
1.20      www       318: $domainlogo
                    319: </td>
1.14      albertel  320: 
                    321:    <!-- Row 5 Column 4 -->
1.19      bowersj2  322:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  323:   </tr>
                    324:   <tr>
                    325: 
                    326:    <!-- Row 6 Column 1 -->
1.21      www       327:    <td bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  328: 
                    329:    <!-- Row 6 Column 2 -->
1.19      bowersj2  330:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
1.14      albertel  331: 
                    332:    <!-- Row 6 Column 3 -->
1.19      bowersj2  333:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
1.14      albertel  334: 
                    335:    <!-- Row 6 Column 4 -->
1.19      bowersj2  336:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
1.14      albertel  337:   </tr>
1.1       albertel  338:  </table>
1.25      bowersj2  339: 
                    340: <script>
                    341: // the if prevents the script error if the browser can't handle this
                    342: if ( document.client.uname ) { document.client.uname.focus(); }
                    343: </script>
1.14      albertel  344: 
1.1       albertel  345: ENDDOCUMENT
1.16      www       346: }
                    347:     $r->print('</body></html>');
1.1       albertel  348:     return OK;
                    349: } 
                    350: 
                    351: 1;
                    352: __END__

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