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