Annotation of loncom/auth/lonlogin.pm, revision 1.38
1.1 albertel 1: # The LearningOnline Network
2: # Login Screen
1.11 www 3: #
1.38 ! www 4: # $Id: lonlogin.pm,v 1.37 2003/03/02 02:16:53 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:
1.32 www 55: # ----------------------------------------------------------- Process Interface
1.18 www 56: $ENV{'form.interface'}=~s/\W//g;
1.16 www 57:
1.32 www 58: my $textbrowsers=$r->dir_config('lonTextBrowsers');
59: my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
60:
61: foreach (split(/\:/,$textbrowsers)) {
62: if ($httpbrowser=~/$_/i) {
63: $ENV{'form.interface'}='textual';
64: }
65: }
66:
1.16 www 67: my $fullgraph=($ENV{'form.interface'} ne 'textual');
68:
1.26 www 69: my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':8080'.
70: $r->dir_config('lonIconsURL');
1.1 albertel 71: my $domain = $r->dir_config('lonDefDomain');
72: my $role = $r->dir_config('lonRole');
73: my $loadlim = $r->dir_config('lonLoadLim');
74: my $servadm = $r->dir_config('lonAdmEMail');
75: my $sysadm = $r->dir_config('lonSysEMail');
76: my $lonhost = $r->dir_config('lonHostID');
77: my $tabdir = $r->dir_config('lonTabDir');
1.6 www 78: my $include = $r->dir_config('lonIncludes');
1.37 www 79: my $expire = $r->dir_config('lonExpire');
1.1 albertel 80:
1.30 www 81: # --------------------------------------------- Default values for login fields
82:
83: my $authusername=($ENV{'form.username'}?$ENV{'form.username'}:'');
84: my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain);
85:
86: # ---------------------------------------------------------- Determine own load
1.1 albertel 87: my $loadavg;
88: {
89: my $loadfile=Apache::File->new('/proc/loadavg');
90: $loadavg=<$loadfile>;
91: }
92: $loadavg =~ s/\s.*//g;
93: my $loadpercent=100*$loadavg/$loadlim;
94:
1.30 www 95: # ------------------------------------------------------- Do the load balancing
1.10 www 96: my $otherserver='http://'.$ENV{'SERVER_NAME'};
1.31 www 97: my $firsturl=
98: ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'});
1.1 albertel 99: # ---------------------------------------- Are we access server and overloaded?
1.24 matthew 100: if (($role eq 'access') && ($loadpercent>100.0)) {
1.22 matthew 101: $otherserver=Apache::lonnet::spareserver($loadpercent);
1.1 albertel 102: }
1.6 www 103:
104: # -------------------------------------------------------- Set login parameters
105:
106: my @hexstr=('0','1','2','3','4','5','6','7',
107: '8','9','a','b','c','d','e','f');
108: my $lkey='';
109: for (0..7) {
110: $lkey.=$hexstr[rand(15)];
111: }
112:
113: my $ukey='';
114: for (0..7) {
115: $ukey.=$hexstr[rand(15)];
116: }
117:
118: my $lextkey=hex($lkey);
1.15 www 119: if ($lextkey>2147483647) { $lextkey-=4294967296; }
120:
1.6 www 121: my $uextkey=hex($ukey);
1.15 www 122: if ($uextkey>2147483647) { $uextkey-=4294967296; }
123:
1.31 www 124: # -------------------------------------------------------- Store away log token
1.6 www 125: my $logtoken=Apache::lonnet::reply(
1.7 www 126: 'tmpput:'.$ukey.$lkey.'&'.$firsturl,
1.6 www 127: $lonhost);
1.31 www 128:
129: # ------------------- If we cannot talk to ourselves, we are in serious trouble
130:
131: if ($logtoken eq 'con_lost') {
132: my $spares='';
133: foreach (keys %Apache::lonnet::hostname) {
134: if ($_ ne $lonhost) {
135: $spares.='<br /><a href="http://'.$Apache::lonnet::hostname{$_}.
136: '/adm/login?domain='.$authdomain.'">'.
137: $Apache::lonnet::hostname{$_}.'</a>';
138: if ($Apache::lonnet::spareid{$_}) {
139: $spares.=' (preferred)';
140: }
141: }
142: }
143: $r->print(<<ENDTROUBLE);
144: <html>
145: <head><title>The LearningOnline Network with CAPA</title></head>
146: <body bgcolor="#FFFFFF">
147: <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />
148: <h3>This LON-CAPA server is temporarily not available for login</h3>
149: <p>Please attempt to login to one of the following servers:</p>$spares
150: <p>If the problem persists, please contact <tt>$servadm</tt>.</p>
151: </body>
152: </html>
153: ENDTROUBLE
154: return OK;
155: }
156:
157: # ----------------------------------------------- Apparently we are in business
158:
1.20 www 159: my $domainlogo=&Apache::loncommon::domainlogo();
1.38 ! www 160: $servadm=~s/\,/\<br \/\>/g;
! 161: $sysadm=~s/\,/\<br \/\>/g;
! 162:
1.6 www 163: # --------------------------------------------------- Print login screen header
164: $r->print(<<ENDHEADER);
1.1 albertel 165: <html>
166: <head>
1.37 www 167: <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />
1.2 www 168: <title>The LearningOnline Network with CAPA Login</title>
1.1 albertel 169: </head>
1.6 www 170: ENDHEADER
171: # ---------------------------------------------------- Serve out DES JavaScript
172: {
173: my $jsh=Apache::File->new($include."/londes.js");
174: $r->print(<$jsh>);
175: }
1.21 www 176:
177: # ----------------------------------------------------------- Front page design
1.35 www 178: my $pgbg=
179: ($fullgraph?&Apache::loncommon::designparm('login.pgbg'):'#FFFFFF');
180: my $font=
181: ($fullgraph?&Apache::loncommon::designparm('login.font'):'#000000');
182: my $link=
183: ($fullgraph?&Apache::loncommon::designparm('login.link'):'#0000FF');
184: my $vlink=
185: ($fullgraph?&Apache::loncommon::designparm('login.vlink'):'#0000FF');
1.21 www 186: my $alink=&Apache::loncommon::designparm('login.alink');
1.35 www 187: my $mainbg=
188: ($fullgraph?&Apache::loncommon::designparm('login.mainbg'):'#FFFFFF');
189: my $sidebg=
190: ($fullgraph?&Apache::loncommon::designparm('login.sidebg'):'#FFFFFF');
1.21 www 191: my $logo=&Apache::loncommon::designparm('login.logo');
192: my $img=&Apache::loncommon::designparm('login.img');
193:
194:
1.6 www 195: # ---------------------------------------------------------- Serve rest of page
1.16 www 196: $r->print(<<ENDSCRIPT);
1.6 www 197:
1.21 www 198: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
1.27 albertel 199: topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
1.6 www 200:
1.14 albertel 201: <script language="JavaScript">
202: function send()
203: {
1.6 www 204: this.document.server.elements.uname.value
205: =this.document.client.elements.uname.value;
206:
207: this.document.server.elements.udom.value
208: =this.document.client.elements.udom.value;
209:
1.33 www 210: this.document.server.elements.imagesuppress.value
1.36 www 211: =this.document.client.elements.imagesuppress.checked;
1.33 www 212:
213: this.document.server.elements.embedsuppress.value
1.36 www 214: =this.document.client.elements.embedsuppress.checked;
1.33 www 215:
1.34 www 216: this.document.server.elements.appletsuppress.value
1.36 www 217: =this.document.client.elements.appletsuppress.checked;
1.34 www 218:
1.33 www 219: this.document.server.elements.fontenhance.value
1.36 www 220: =this.document.client.elements.fontenhance.checked;
1.33 www 221:
222: this.document.server.elements.blackwhite.value
1.36 www 223: =this.document.client.elements.blackwhite.checked;
1.33 www 224:
1.35 www 225: this.document.server.elements.remember.value
1.36 www 226: =this.document.client.elements.remember.checked;
1.35 www 227:
1.6 www 228: uextkey=this.document.client.elements.uextkey.value;
229: lextkey=this.document.client.elements.lextkey.value;
230: initkeys();
231:
232: this.document.server.elements.upass.value
233: =crypted(this.document.client.elements.upass.value);
234:
235: this.document.server.submit();
1.19 bowersj2 236: return false;
1.6 www 237: }
1.14 albertel 238: </script>
1.16 www 239: ENDSCRIPT
1.6 www 240:
1.16 www 241: if ($fullgraph) {
242: $r->print(
243: '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
244: }
1.6 www 245:
1.16 www 246: $r->print(<<ENDSERVERFORM);
1.14 albertel 247: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33 www 248: <input type="hidden" name="logtoken" value="$logtoken" />
249: <input type="hidden" name="serverid" value="$lonhost" />
250: <input type="hidden" name="interface" value="$ENV{'form.interface'}" />
251: <input type="hidden" name="uname" value="" />
252: <input type="hidden" name="upass" value="" />
253: <input type="hidden" name="udom" value="" />
254: <input type="hidden" name="imagesuppress" value="" />
1.34 www 255: <input type="hidden" name="appletsuppress" value="" />
1.33 www 256: <input type="hidden" name="embedsuppress" value="" />
257: <input type="hidden" name="fontenhance" value="" />
258: <input type="hidden" name="blackwhite" value="" />
1.35 www 259: <input type="hidden" name="remember" value="" />
1.14 albertel 260: </form>
1.16 www 261: ENDSERVERFORM
262: if ($fullgraph) { $r->print(<<ENDTOP);
1.14 albertel 263: <!-- The LON-CAPA Header -->
264: <tr>
265:
266: <!-- Row 1 Columns 2-4 -->
1.29 www 267: <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 268: </tr>
269:
270: <!-- The gray bar that starts the two table frames -->
271: <tr>
272:
273: <!-- Row 2 Column 1 -->
1.21 www 274: <td width=182 height=27 bgcolor="$sidebg"> </td>
1.14 albertel 275:
276: <!-- Row 2 Column 2 -->
1.19 bowersj2 277: <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
1.14 albertel 278:
279: <!-- Row 2 Column 3 -->
1.19 bowersj2 280: <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
1.14 albertel 281:
282: <!-- Row 2 Column 4 -->
1.19 bowersj2 283: <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
1.14 albertel 284: </tr>
285: <tr>
286:
287: <!-- A cell that will hold the 'access' and 'about' buttons -->
288: <!-- Row 3 Column 1 -->
1.21 www 289: <td valign="top" height=60 align="center" bgcolor="$sidebg">
1.19 bowersj2 290: <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
1.14 albertel 291: <br />
1.19 bowersj2 292: <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
1.14 albertel 293: </td>
294:
295: <!-- The shaded space between the two main columns -->
296: <!-- Row 3 Column 2 -->
1.19 bowersj2 297: <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14 albertel 298:
299: <!-- The right main column holding the large LON-CAPA logo-->
300: <!-- Rows 3-4 Column 3 -->
1.21 www 301: <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
1.14 albertel 302: <center>
1.21 www 303: <img src="$logo" alt="" />
1.14 albertel 304: </center>
305: </td>
306:
307: <!-- Row 3 Column 4 -->
1.19 bowersj2 308: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14 albertel 309: </tr>
310: <tr>
311:
312: <!-- The entry form -->
313: <!-- Row 4 Column 1 -->
1.21 www 314: <td align="center" valign="middle" bgcolor="$sidebg">
1.16 www 315: ENDTOP
1.32 www 316: } else {
1.35 www 317: $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>');
1.33 www 318: }
319: $r->print('<form name="client" onsubmit="return(send())">');
320: unless ($fullgraph) {
321: $r->print(<<ENDACCESSOPTIONS);
1.35 www 322: <h3>Select Accessibility Options</h3>
1.33 www 323: <input type="checkbox" name="imagesuppress" /> Suppress rendering of images<br />
1.34 www 324: <input type="checkbox" name="appletsuppress" /> Suppress Java applets<br />
1.33 www 325: <input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia<br />
326: <input type="checkbox" name="fontenhance" /> Increase font size<br />
1.35 www 327: <input type="checkbox" name="blackwhite" /> Switch to black and white mode<br />
328: <p>If you have accessibility needs that are not addressed by this interface,
329: please
330: contact the system administrator at <tt>$sysadm</tt>.</p><br />
331: <input type="checkbox" name="remember" /> Remember these settings for next login<hr />
1.33 www 332: ENDACCESSOPTIONS
333: } else {
334: $r->print(<<ENDNOOPT);
335: <input type="hidden" name="imagesuppress" value="" />
336: <input type="hidden" name="embedsuppress" value="" />
1.34 www 337: <input type="hidden" name="appletsuppress" value="" />
1.33 www 338: <input type="hidden" name="fontenhance" value="" />
339: <input type="hidden" name="blackwhite" value="" />
1.35 www 340: <input type="hidden" name="remember" value="" />
1.33 www 341: ENDNOOPT
1.16 www 342: }
343: $r->print(<<ENDLOGIN);
1.14 albertel 344: <input type="hidden" name="lextkey" value="$lextkey">
345: <input type="hidden" name="uextkey" value="$uextkey">
346:
347: <!-- Start the sub-table for text and input alignment -->
348: <table border=0 cellspacing=0 cellpadding=0>
1.21 www 349: <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
1.14 albertel 350: <tr>
1.21 www 351: <td bgcolor="$mainbg"><br /><font size=-1><b> User Name:</b></font></td>
1.30 www 352: <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
1.14 albertel 353: </tr>
354: <tr>
1.21 www 355: <td bgcolor="$mainbg"><font size=-1><b> Password:</b></font></td>
356: <td bgcolor="$mainbg"><input type="password" name="upass" size="10" /></td>
1.14 albertel 357: </tr>
358: <tr>
1.21 www 359: <td bgcolor="$mainbg"><font size=-1><b> Domain:</b></font></td>
1.30 www 360: <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
1.14 albertel 361: </tr>
362: <tr>
1.28 www 363: <td bgcolor="$mainbg"> <a href="/adm/loginproblems.html">Help</a></td>
364: <td bgcolor="$mainbg" valign="bottom" align="center">
1.14 albertel 365: <br />
1.19 bowersj2 366: <input type="submit" value="Log In" />
1.14 albertel 367: </td>
368: </tr>
369: </table>
370: <!-- End sub-table -->
371: </form>
1.16 www 372: ENDLOGIN
373: if ($fullgraph) {
374: $r->print(<<ENDDOCUMENT);
1.14 albertel 375: </td>
376:
377: <!-- Row 4 Column 2 -->
1.19 bowersj2 378: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14 albertel 379:
380: <!-- Row 4 Column 4 -->
1.19 bowersj2 381: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14 albertel 382: </tr>
383: <tr>
384:
385: <!-- Row 5 Column 1 -->
1.21 www 386: <td bgcolor="$sidebg" valign="middle" align="left">
1.14 albertel 387: <br />
388: <table border=0 cellspacing=0 cellpadding=0>
389: <tr>
1.21 www 390: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 391: <small><b> Domain: </b></small>
392: </td>
1.21 www 393: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 394: <small><tt> $domain</tt></small>
395: </td>
396: </tr>
397: <tr>
1.21 www 398: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 399: <small><b> Server: </b></small>
400: </td>
1.21 www 401: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 402: <small><tt> $lonhost ($role)</tt></small>
403: </td>
404: </tr>
405: <tr>
1.21 www 406: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 407: <small><b> Load: </b></small>
408: </td>
1.21 www 409: <td bgcolor="$sidebg" align="left" valign="top">
1.14 albertel 410: <small><tt> $loadpercent percent</tt></small>
411: </td>
412: </tr>
413: </table>
414: <br />
415: <small>
416: <b> System Administration:</b><br />
417: <tt> $sysadm</tt><br />
418: <b> Server Administration:</b><br />
1.19 bowersj2 419: <tt> $servadm<br /> </tt>
1.14 albertel 420: </small>
421: </td>
422:
423: <!-- Row 5 Column 2 -->
1.19 bowersj2 424: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14 albertel 425:
426: <!-- Row 5 Column 3 -->
1.21 www 427: <td width="100%" valign="bottom" bgcolor="$mainbg">
1.20 www 428: $domainlogo
429: </td>
1.14 albertel 430:
431: <!-- Row 5 Column 4 -->
1.19 bowersj2 432: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14 albertel 433: </tr>
434: <tr>
435:
436: <!-- Row 6 Column 1 -->
1.21 www 437: <td bgcolor="$sidebg"> </td>
1.14 albertel 438:
439: <!-- Row 6 Column 2 -->
1.19 bowersj2 440: <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
1.14 albertel 441:
442: <!-- Row 6 Column 3 -->
1.19 bowersj2 443: <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
1.14 albertel 444:
445: <!-- Row 6 Column 4 -->
1.19 bowersj2 446: <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
1.14 albertel 447: </tr>
1.1 albertel 448: </table>
1.25 bowersj2 449:
450: <script>
451: // the if prevents the script error if the browser can't handle this
452: if ( document.client.uname ) { document.client.uname.focus(); }
453: </script>
1.14 albertel 454:
1.1 albertel 455: ENDDOCUMENT
1.16 www 456: }
457: $r->print('</body></html>');
1.1 albertel 458: return OK;
459: }
460:
461: 1;
462: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>