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

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

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