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

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

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