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