Annotation of loncom/auth/lonlogin.pm, revision 1.16
1.1 albertel 1: # The LearningOnline Network
2: # Login Screen
1.11 www 3: #
1.16 ! www 4: # $Id: lonlogin.pm,v 1.15 2002/03/23 21:06:54 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
33:
1.1 albertel 34: package Apache::lonlogin;
35:
36: use strict;
37: use Apache::Constants qw(:common);
38: use Apache::File ();
39: use Apache::lonnet();
1.12 albertel 40: use Apache::loncommon();
1.1 albertel 41:
42: sub handler {
43: my $r = shift;
44: $r->content_type('text/html');
1.12 albertel 45: &Apache::loncommon::no_cache($r);
1.1 albertel 46: $r->send_http_header;
47: return OK if $r->header_only;
48:
1.16 ! www 49:
! 50: &Apache::loncommon::get_unprocessed_cgi
! 51: ($ENV{'QUERY_STRING'},['interface']);
! 52:
! 53: my $fullgraph=($ENV{'form.interface'} ne 'textual');
! 54:
1.1 albertel 55: my $iconpath= $r->dir_config('lonIconsURL');
56: my $domain = $r->dir_config('lonDefDomain');
57: my $role = $r->dir_config('lonRole');
58: my $loadlim = $r->dir_config('lonLoadLim');
59: my $servadm = $r->dir_config('lonAdmEMail');
60: my $sysadm = $r->dir_config('lonSysEMail');
61: my $lonhost = $r->dir_config('lonHostID');
62: my $tabdir = $r->dir_config('lonTabDir');
1.6 www 63: my $include = $r->dir_config('lonIncludes');
1.1 albertel 64:
65: my $loadavg;
66: {
67: my $loadfile=Apache::File->new('/proc/loadavg');
68: $loadavg=<$loadfile>;
69: }
70: $loadavg =~ s/\s.*//g;
71: my $loadpercent=100*$loadavg/$loadlim;
72:
1.10 www 73: my $otherserver='http://'.$ENV{'SERVER_NAME'};
1.5 www 74: my $firsturl=$ENV{'request.firsturl'};
1.1 albertel 75: # ---------------------------------------- Are we access server and overloaded?
76: if (($role eq 'access') && ($loadpercent>100.0)) {
77: $otherserver=Apache::lonnet::spareserver();
78: }
1.6 www 79:
80: # -------------------------------------------------------- Set login parameters
81:
82: my @hexstr=('0','1','2','3','4','5','6','7',
83: '8','9','a','b','c','d','e','f');
84: my $lkey='';
85: for (0..7) {
86: $lkey.=$hexstr[rand(15)];
87: }
88:
89: my $ukey='';
90: for (0..7) {
91: $ukey.=$hexstr[rand(15)];
92: }
93:
94: my $lextkey=hex($lkey);
1.15 www 95: if ($lextkey>2147483647) { $lextkey-=4294967296; }
96:
1.6 www 97: my $uextkey=hex($ukey);
1.15 www 98: if ($uextkey>2147483647) { $uextkey-=4294967296; }
99:
1.6 www 100: my $logtoken=Apache::lonnet::reply(
1.7 www 101: 'tmpput:'.$ukey.$lkey.'&'.$firsturl,
1.6 www 102: $lonhost);
103:
104: # --------------------------------------------------- Print login screen header
105: $r->print(<<ENDHEADER);
1.1 albertel 106: <html>
107: <head>
1.2 www 108: <title>The LearningOnline Network with CAPA Login</title>
1.1 albertel 109: </head>
1.6 www 110: ENDHEADER
111: # ---------------------------------------------------- Serve out DES JavaScript
112: {
113: my $jsh=Apache::File->new($include."/londes.js");
114: $r->print(<$jsh>);
115: }
116: # ---------------------------------------------------------- Serve rest of page
1.16 ! www 117: $r->print(<<ENDSCRIPT);
1.6 www 118:
1.14 albertel 119: <body bgcolor="#006600" text="#000000" link="#999999" vlink="#999999"
120: onLoad="init();" topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
1.6 www 121:
1.14 albertel 122: <script language="JavaScript">
123: function send()
124: {
1.6 www 125: this.document.server.elements.uname.value
126: =this.document.client.elements.uname.value;
127:
128: this.document.server.elements.udom.value
129: =this.document.client.elements.udom.value;
130:
131: uextkey=this.document.client.elements.uextkey.value;
132: lextkey=this.document.client.elements.lextkey.value;
133: initkeys();
134:
135: this.document.server.elements.upass.value
136: =crypted(this.document.client.elements.upass.value);
137:
138: this.document.server.submit();
139: }
1.14 albertel 140: </script>
1.16 ! www 141: ENDSCRIPT
1.6 www 142:
1.16 ! www 143: if ($fullgraph) {
! 144: $r->print(
! 145: '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
! 146: }
1.6 www 147:
1.16 ! www 148: $r->print(<<ENDSERVERFORM);
1.14 albertel 149: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
150: <input type=hidden name=logtoken value="$logtoken">
151: <input type=hidden name=serverid value="$lonhost">
152: <input type=hidden name=uname value="">
153: <input type=hidden name=upass value="">
154: <input type=hidden name=udom value="">
155: </form>
1.16 ! www 156: ENDSERVERFORM
! 157: if ($fullgraph) { $r->print(<<ENDTOP);
1.14 albertel 158: <!-- The LON-CAPA Header -->
159: <tr>
160:
161: <!-- Row 1 Columns 2-4 -->
162: <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="#006600"><img src="$iconpath/header.gif" border=0 /></td>
163: </tr>
164:
165: <!-- The gray bar that starts the two table frames -->
166: <tr>
167:
168: <!-- Row 2 Column 1 -->
169: <td width=182 height=27 bgcolor="#cccccc"> </td>
170:
171: <!-- Row 2 Column 2 -->
172: <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 /></td>
173:
174: <!-- Row 2 Column 3 -->
175: <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" /></td>
176:
177: <!-- Row 2 Column 4 -->
178: <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 /></td>
179: </tr>
180: <tr>
181:
182: <!-- A cell that will hold the 'access' and 'about' buttons -->
183: <!-- Row 3 Column 1 -->
184: <td valign="top" height=60 align="center" bgcolor="#cccccc">
1.16 ! www 185: <a href="/adm/login?interface=textual"><img src="$iconpath/accessbutton.gif" border=0 /></a>
1.14 albertel 186: <br />
187: <a href="/adm/about.html"><img src="$iconpath/aboutlon.gif" border=0 /></a>
188: </td>
189:
190: <!-- The shaded space between the two main columns -->
191: <!-- Row 3 Column 2 -->
192: <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
193:
194: <!-- The right main column holding the large LON-CAPA logo-->
195: <!-- Rows 3-4 Column 3 -->
196: <td align="center" valign="top" width="100%" height="100%" rowspan=2 bgcolor="#ffffff">
197: <center>
198: <img src="$iconpath/loncapalogo.gif" />
199: </center>
200: </td>
201:
202: <!-- Row 3 Column 4 -->
203: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
204: </tr>
205: <tr>
206:
207: <!-- The entry form -->
208: <!-- Row 4 Column 1 -->
209: <td align="center" valign="middle" bgcolor="#cccccc">
1.16 ! www 210: ENDTOP
! 211: }
! 212: $r->print(<<ENDLOGIN);
1.14 albertel 213: <form name="client">
214: <input type="hidden" name="lextkey" value="$lextkey">
215: <input type="hidden" name="uextkey" value="$uextkey">
216:
217: <!-- Start the sub-table for text and input alignment -->
218: <table border=0 cellspacing=0 cellpadding=0>
219: <tr><td bgcolor="#cccccc" colspan=2><img src="$iconpath/userauthentication.gif" /></td></tr>
220: <tr>
221: <td bgcolor="#ffffff"><br /><font size=-1><b> User Name:</b></font></td>
222: <td bgcolor="#ffffff"><br /><input type="text" name="uname" size="10" /></td>
223: </tr>
224: <tr>
225: <td bgcolor="#ffffff"><font size=-1><b> Password:</b></font></td>
226: <td bgcolor="#ffffff"><input type="password" name="upass" size="10" /></td>
227: </tr>
228: <tr>
229: <td bgcolor="#ffffff"><font size=-1><b> Domain:</b></font></td>
230: <td bgcolor="#ffffff"><input type="text" name="udom" size="10" value=$domain /></td>
231: </tr>
232: <tr>
233: <td bgcolor="#ffffff" valign="bottom" align="center" colspan=2>
234: <br />
235: <input type="button" value="Log In" onClick="send();" />
236: </td>
237: </tr>
238: </table>
239: <!-- End sub-table -->
240: </form>
1.16 ! www 241: ENDLOGIN
! 242: if ($fullgraph) {
! 243: $r->print(<<ENDDOCUMENT);
1.14 albertel 244: </td>
245:
246: <!-- Row 4 Column 2 -->
247: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
248:
249: <!-- Row 4 Column 4 -->
250: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
251: </tr>
252: <tr>
253:
254: <!-- Row 5 Column 1 -->
255: <td bgcolor="#cccccc" valign="middle" align="left">
256: <br />
257: <table border=0 cellspacing=0 cellpadding=0>
258: <tr>
259: <td bgcolor="#cccccc" align="left" valign="top">
260: <small><b> Domain: </b></small>
261: </td>
262: <td bgcolor="#cccccc" align="left" valign="top">
263: <small><tt> $domain</tt></small>
264: </td>
265: </tr>
266: <tr>
267: <td bgcolor="#cccccc" align="left" valign="top">
268: <small><b> Server: </b></small>
269: </td>
270: <td bgcolor="#cccccc" align="left" valign="top">
271: <small><tt> $lonhost ($role)</tt></small>
272: </td>
273: </tr>
274: <tr>
275: <td bgcolor="#cccccc" align="left" valign="top">
276: <small><b> Load: </b></small>
277: </td>
278: <td bgcolor="#cccccc" align="left" valign="top">
279: <small><tt> $loadpercent percent</tt></small>
280: </td>
281: </tr>
282: </table>
283: <br />
284: <small>
285: <b> System Administration:</b><br />
286: <tt> $sysadm</tt><br />
287: <b> Server Administration:</b><br />
288: <tt> $servadm</tt>
289: </small>
290: </td>
291:
292: <!-- Row 5 Column 2 -->
293: <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" /></td>
294:
295: <!-- Row 5 Column 3 -->
296: <td width="100%" valign="bottom" bgcolor="#ffffff"><img src="$iconpath/litetext.gif" /><img src="$iconpath/lite.gif" /></td>
297:
298: <!-- Row 5 Column 4 -->
299: <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" /></td>
300: </tr>
301: <tr>
302:
303: <!-- Row 6 Column 1 -->
304: <td bgcolor="#cccccc"> </td>
305:
306: <!-- Row 6 Column 2 -->
307: <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" /></td>
308:
309: <!-- Row 6 Column 3 -->
310: <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" /></td>
311:
312: <!-- Row 6 Column 4 -->
313: <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" /></td>
314: </tr>
1.1 albertel 315: </table>
1.14 albertel 316:
1.1 albertel 317: ENDDOCUMENT
1.16 ! www 318: }
! 319: $r->print('</body></html>');
1.1 albertel 320: return OK;
321: }
322:
323: 1;
324: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>