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

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

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