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