File:
[LON-CAPA] /
loncom /
auth /
lonlogin.pm
Revision
1.30:
download - view:
text,
annotated -
select for diffs
Tue Feb 4 15:11:44 2003 UTC (21 years, 5 months ago) by
www
Branches:
MAIN
CVS tags:
HEAD
The plan was to be able to pass username and domain (NOT PASSWORD!!!) in the
query string to support "Switch Server" better. Unfortunately, as expected,
the query string is not available to this module if it is called by
"/priv/username/..." as an error document.
1: # The LearningOnline Network
2: # Login Screen
3: #
4: # $Id: lonlogin.pm,v 1.30 2003/02/04 15:11:44 www Exp $
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'},['interface','username','domain']);
54:
55: $ENV{'form.interface'}=~s/\W//g;
56:
57: my $fullgraph=($ENV{'form.interface'} ne 'textual');
58:
59: my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':8080'.
60: $r->dir_config('lonIconsURL');
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');
68: my $include = $r->dir_config('lonIncludes');
69:
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
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:
84: # ------------------------------------------------------- Do the load balancing
85: my $otherserver='http://'.$ENV{'SERVER_NAME'};
86: my $firsturl=$ENV{'request.firsturl'};
87: # ---------------------------------------- Are we access server and overloaded?
88: if (($role eq 'access') && ($loadpercent>100.0)) {
89: $otherserver=Apache::lonnet::spareserver($loadpercent);
90: }
91:
92: # -------------------------------------------------------- Set login parameters
93:
94: my @hexstr=('0','1','2','3','4','5','6','7',
95: '8','9','a','b','c','d','e','f');
96: my $lkey='';
97: for (0..7) {
98: $lkey.=$hexstr[rand(15)];
99: }
100:
101: my $ukey='';
102: for (0..7) {
103: $ukey.=$hexstr[rand(15)];
104: }
105:
106: my $lextkey=hex($lkey);
107: if ($lextkey>2147483647) { $lextkey-=4294967296; }
108:
109: my $uextkey=hex($ukey);
110: if ($uextkey>2147483647) { $uextkey-=4294967296; }
111:
112: my $logtoken=Apache::lonnet::reply(
113: 'tmpput:'.$ukey.$lkey.'&'.$firsturl,
114: $lonhost);
115: my $domainlogo=&Apache::loncommon::domainlogo();
116: # --------------------------------------------------- Print login screen header
117: $r->print(<<ENDHEADER);
118: <html>
119: <head>
120: <title>The LearningOnline Network with CAPA Login</title>
121: </head>
122: ENDHEADER
123: # ---------------------------------------------------- Serve out DES JavaScript
124: {
125: my $jsh=Apache::File->new($include."/londes.js");
126: $r->print(<$jsh>);
127: }
128:
129: # ----------------------------------------------------------- Front page design
130: my $pgbg=&Apache::loncommon::designparm('login.pgbg');
131: my $font=&Apache::loncommon::designparm('login.font');
132: my $link=&Apache::loncommon::designparm('login.link');
133: my $vlink=&Apache::loncommon::designparm('login.vlink');
134: my $alink=&Apache::loncommon::designparm('login.alink');
135: my $mainbg=&Apache::loncommon::designparm('login.mainbg');
136: my $sidebg=&Apache::loncommon::designparm('login.sidebg');
137: my $logo=&Apache::loncommon::designparm('login.logo');
138: my $img=&Apache::loncommon::designparm('login.img');
139:
140:
141: # ---------------------------------------------------------- Serve rest of page
142: $r->print(<<ENDSCRIPT);
143:
144: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
145: topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
146:
147: <script language="JavaScript">
148: function send()
149: {
150: this.document.server.elements.uname.value
151: =this.document.client.elements.uname.value;
152:
153: this.document.server.elements.udom.value
154: =this.document.client.elements.udom.value;
155:
156: uextkey=this.document.client.elements.uextkey.value;
157: lextkey=this.document.client.elements.lextkey.value;
158: initkeys();
159:
160: this.document.server.elements.upass.value
161: =crypted(this.document.client.elements.upass.value);
162:
163: this.document.server.submit();
164: return false;
165: }
166: </script>
167: ENDSCRIPT
168:
169: if ($fullgraph) {
170: $r->print(
171: '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
172: }
173:
174: $r->print(<<ENDSERVERFORM);
175: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
176: <input type=hidden name=logtoken value="$logtoken">
177: <input type=hidden name=serverid value="$lonhost">
178: <input type=hidden name=interface value="$ENV{'form.interface'}">
179: <input type=hidden name=uname value="">
180: <input type=hidden name=upass value="">
181: <input type=hidden name=udom value="">
182: </form>
183: ENDSERVERFORM
184: if ($fullgraph) { $r->print(<<ENDTOP);
185: <!-- The LON-CAPA Header -->
186: <tr>
187:
188: <!-- Row 1 Columns 2-4 -->
189: <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>
190: </tr>
191:
192: <!-- The gray bar that starts the two table frames -->
193: <tr>
194:
195: <!-- Row 2 Column 1 -->
196: <td width=182 height=27 bgcolor="$sidebg"> </td>
197:
198: <!-- Row 2 Column 2 -->
199: <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
200:
201: <!-- Row 2 Column 3 -->
202: <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
203:
204: <!-- Row 2 Column 4 -->
205: <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
206: </tr>
207: <tr>
208:
209: <!-- A cell that will hold the 'access' and 'about' buttons -->
210: <!-- Row 3 Column 1 -->
211: <td valign="top" height=60 align="center" bgcolor="$sidebg">
212: <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 alt="Accessibility Options" /></a>
213: <br />
214: <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 alt="About LON-CAPA" /></a>
215: </td>
216:
217: <!-- The shaded space between the two main columns -->
218: <!-- Row 3 Column 2 -->
219: <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
220:
221: <!-- The right main column holding the large LON-CAPA logo-->
222: <!-- Rows 3-4 Column 3 -->
223: <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="$mainbg">
224: <center>
225: <img src="$logo" alt="" />
226: </center>
227: </td>
228:
229: <!-- Row 3 Column 4 -->
230: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
231: </tr>
232: <tr>
233:
234: <!-- The entry form -->
235: <!-- Row 4 Column 1 -->
236: <td align="center" valign="middle" bgcolor="$sidebg">
237: ENDTOP
238: }
239: $r->print(<<ENDLOGIN);
240: <form name="client" onsubmit="return(send())">
241: <input type="hidden" name="lextkey" value="$lextkey">
242: <input type="hidden" name="uextkey" value="$uextkey">
243:
244: <!-- Start the sub-table for text and input alignment -->
245: <table border=0 cellspacing=0 cellpadding=0>
246: <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/userauthentication.gif" alt="User Authentication" /></td></tr>
247: <tr>
248: <td bgcolor="$mainbg"><br /><font size=-1><b> User Name:</b></font></td>
249: <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
250: </tr>
251: <tr>
252: <td bgcolor="$mainbg"><font size=-1><b> Password:</b></font></td>
253: <td bgcolor="$mainbg"><input type="password" name="upass" size="10" /></td>
254: </tr>
255: <tr>
256: <td bgcolor="$mainbg"><font size=-1><b> Domain:</b></font></td>
257: <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
258: </tr>
259: <tr>
260: <td bgcolor="$mainbg"> <a href="/adm/loginproblems.html">Help</a></td>
261: <td bgcolor="$mainbg" valign="bottom" align="center">
262: <br />
263: <input type="submit" value="Log In" />
264: </td>
265: </tr>
266: </table>
267: <!-- End sub-table -->
268: </form>
269: ENDLOGIN
270: if ($fullgraph) {
271: $r->print(<<ENDDOCUMENT);
272: </td>
273:
274: <!-- Row 4 Column 2 -->
275: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
276:
277: <!-- Row 4 Column 4 -->
278: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
279: </tr>
280: <tr>
281:
282: <!-- Row 5 Column 1 -->
283: <td bgcolor="$sidebg" valign="middle" align="left">
284: <br />
285: <table border=0 cellspacing=0 cellpadding=0>
286: <tr>
287: <td bgcolor="$sidebg" align="left" valign="top">
288: <small><b> Domain: </b></small>
289: </td>
290: <td bgcolor="$sidebg" align="left" valign="top">
291: <small><tt> $domain</tt></small>
292: </td>
293: </tr>
294: <tr>
295: <td bgcolor="$sidebg" align="left" valign="top">
296: <small><b> Server: </b></small>
297: </td>
298: <td bgcolor="$sidebg" align="left" valign="top">
299: <small><tt> $lonhost ($role)</tt></small>
300: </td>
301: </tr>
302: <tr>
303: <td bgcolor="$sidebg" align="left" valign="top">
304: <small><b> Load: </b></small>
305: </td>
306: <td bgcolor="$sidebg" align="left" valign="top">
307: <small><tt> $loadpercent percent</tt></small>
308: </td>
309: </tr>
310: </table>
311: <br />
312: <small>
313: <b> System Administration:</b><br />
314: <tt> $sysadm</tt><br />
315: <b> Server Administration:</b><br />
316: <tt> $servadm<br /> </tt>
317: </small>
318: </td>
319:
320: <!-- Row 5 Column 2 -->
321: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
322:
323: <!-- Row 5 Column 3 -->
324: <td width="100%" valign="bottom" bgcolor="$mainbg">
325: $domainlogo
326: </td>
327:
328: <!-- Row 5 Column 4 -->
329: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
330: </tr>
331: <tr>
332:
333: <!-- Row 6 Column 1 -->
334: <td bgcolor="$sidebg"> </td>
335:
336: <!-- Row 6 Column 2 -->
337: <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
338:
339: <!-- Row 6 Column 3 -->
340: <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
341:
342: <!-- Row 6 Column 4 -->
343: <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
344: </tr>
345: </table>
346:
347: <script>
348: // the if prevents the script error if the browser can't handle this
349: if ( document.client.uname ) { document.client.uname.focus(); }
350: </script>
351:
352: ENDDOCUMENT
353: }
354: $r->print('</body></html>');
355: return OK;
356: }
357:
358: 1;
359: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>