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