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