Annotation of modules/relate/lonlogin.pm, revision 1.7
1.1 raeburn 1: # The LearningOnline Network
2: # Login Screen
3: #
1.7 ! raeburn 4: # $Id: lonlogin.pm,v 1.6 2012/02/13 15:00:24 raeburn Exp $
1.1 raeburn 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:
29: package Apache::lonlogin;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::File ();
34: use Apache::lonnet;
35: use Apache::loncommon();
36: use Apache::lonauth();
37: use Apache::lonlocal;
38: use Apache::migrateuser();
39: use lib '/home/httpd/lib/perl/';
40: use LONCAPA;
41: use HTML::Entities();
42:
43: sub handler {
44: my $r = shift;
45:
46: &Apache::loncommon::get_unprocessed_cgi
47: (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
48: $ENV{'REDIRECT_QUERY_STRING'}),
49: ['username','domain','firsturl','localpath','localres',
50: 'token','role','symb']);
51: if (!defined($env{'form.firsturl'})) {
52: &Apache::lonacc::get_posted_cgi($r,['firsturl']);
53: }
54: $env{'form.firsturl'} =~ s/(`)/'/g;
55:
56: # -- check if they are a migrating user
57: if (defined($env{'form.token'})) {
58: return &Apache::migrateuser::handler($r);
59: }
60:
61: &Apache::loncommon::no_cache($r);
62: &Apache::lonlocal::get_language_handle($r);
63: &Apache::loncommon::content_type($r,'text/html');
64: $r->send_http_header;
65: return OK if $r->header_only;
66:
67: # --------------------------------------------------------- Are we re-routing?
68: my $londocroot = $r->dir_config('lonDocRoot');
69: if (-e "$londocroot/lon-status/reroute.txt") {
70: &Apache::lonauth::reroute($r);
71: return OK;
72: }
73:
74: # -------------------------------- Prevent users from attempting to login twice
75: my $handle = &Apache::lonnet::check_for_valid_session($r);
76: if ($handle ne '') {
77: my $lonidsdir=$r->dir_config('lonIDsDir');
78: if ($handle=~/^publicuser\_/) {
79: # For "public user" - remove it, we apparently really want to login
80: unlink("$lonidsdir/$handle.id");
81: } else {
82: # Indeed, a valid token is found
83: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
84: my $start_page =
85: &Apache::loncommon::start_page('Already logged in');
86: my $end_page =
87: &Apache::loncommon::end_page();
88: my $dest = '/adm/roles';
89: if ($env{'form.role'}) {
90: $dest .= '?selectrole=1&'.$env{'form.role'}.'=1';
91: }
92: if ($env{'form.symb'}) {
93: $dest .= ($dest =~ /\?/) ? '&' : '?';
94: $dest .= 'destinationurl='.
95: &HTML::Entities::encode($env{'form.symb'},'"&<>');
96: }
97: if ($env{'form.firsturl'} ne '') {
98: $dest = $env{'form.firsturl'};
99: }
100: $r->print(
101: $start_page.
102: '<h1>'.&mt('You are already logged in!').'</h1>'.
103: '<p>'.
104: &mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
105: '<a href="'.$dest.'">','</a>',
106: '<a href="/adm/logout">','</a>').
107: '</p>'.
108: $end_page
109: );
110: return OK;
111: }
112: }
113:
114: # ---------------------------------------------------- No valid token, continue
115:
116: # ---------------------------- Not possible to really login to domain "public"
117: if ($env{'form.domain'} eq 'public') {
118: $env{'form.domain'}='';
119: $env{'form.username'}='';
120: }
121: # ----------------------------------------------------------- Process Interface
122: my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
123:
124: my $iconpath=
125: &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
126:
127: # ----------------------------------------------------------------
128:
129: my $lonhost = $r->dir_config('lonHostID');
130: my $domain = &Apache::lonnet::default_login_domain();
131: if ($lonhost ne '') {
132: my $redirect = &check_loginvia($domain,$lonhost);
133: if ($redirect) {
134: $r->print($redirect);
135: return OK;
136: }
137: }
138:
139: if (($env{'form.domain'}) &&
140: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
141: $domain=$env{'form.domain'};
142: }
143:
144: my $role = $r->dir_config('lonRole');
145: my $loadlim = $r->dir_config('lonLoadLim');
146: my $uloadlim= $r->dir_config('lonUserLoadLim');
147: my $servadm = $r->dir_config('lonAdmEMail');
148: my $tabdir = $r->dir_config('lonTabDir');
149: my $include = $r->dir_config('lonIncludes');
150: my $expire = $r->dir_config('lonExpire');
151: my $version = $r->dir_config('lonVersion');
152: my $host_name = &Apache::lonnet::hostname($lonhost);
153:
154: # --------------------------------------------- Default values for login fields
155:
156: my $authusername=($env{'form.username'}?$env{'form.username'}:'');
157: my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
158:
159: # ---------------------------------------------------------- Determine own load
160: my $loadavg;
161: {
162: my $loadfile=Apache::File->new('/proc/loadavg');
163: $loadavg=<$loadfile>;
164: }
165: $loadavg =~ s/\s.*//g;
166:
167: my ($loadpercent,$userloadpercent);
168: if ($loadlim) {
169: $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
170: }
171: if ($uloadlim) {
172: $userloadpercent=&Apache::lonnet::userload();
173: }
174:
175: my $firsturl=
176: ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
177:
178: # ----------------------------------------------------------- Get announcements
179: my $announcements=&Apache::lonnet::getannounce();
180: # -------------------------------------------------------- Set login parameters
181:
182: my @hexstr=('0','1','2','3','4','5','6','7',
183: '8','9','a','b','c','d','e','f');
184: my $lkey='';
185: for (0..7) {
186: $lkey.=$hexstr[rand(15)];
187: }
188:
189: my $ukey='';
190: for (0..7) {
191: $ukey.=$hexstr[rand(15)];
192: }
193:
194: my $lextkey=hex($lkey);
195: if ($lextkey>2147483647) { $lextkey-=4294967296; }
196:
197: my $uextkey=hex($ukey);
198: if ($uextkey>2147483647) { $uextkey-=4294967296; }
199:
200: # -------------------------------------------------------- Store away log token
201: my $tokenextras;
202: if ($env{'form.role'}) {
203: $tokenextras = '&role='.&escape($env{'form.role'});
204: }
205: if ($env{'form.symb'}) {
206: if (!$tokenextras) {
207: $tokenextras = '&';
208: }
209: $tokenextras .= '&symb='.&escape($env{'form.symb'});
210: }
211: my $logtoken=Apache::lonnet::reply(
212: 'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
213: $lonhost);
214:
215: # -- If we cannot talk to ourselves, or hostID does not map to a hostname
216: # we are in serious trouble
217:
218: if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
219: if ($logtoken eq 'no_such_host') {
220: &Apache::lonnet::logthis('No valid logtoken for log-in page -- '.
221: 'unable to determine hostname for hostID: '.$lonhost.
222: '. Check entry in hosts.tab');
223: }
224: my $spares='';
225: my $last;
226: foreach my $hostid (sort
227: {
228: &Apache::lonnet::hostname($a) cmp
229: &Apache::lonnet::hostname($b);
230: }
231: keys(%Apache::lonnet::spareid)) {
232: next if ($hostid eq $lonhost);
233: my $hostname = &Apache::lonnet::hostname($hostid);
234: next if (($last eq $hostname) || ($hostname eq ''));
235: $spares.='<br /><span style="font-size: larger;"><a href="http://'.
236: $hostname.
237: '/adm/login?domain='.$authdomain.'">'.
238: $hostname.'</a>'.
239: ' '.&mt('(preferred)').'</span>'.$/;
240: $last=$hostname;
241: }
242: if ($spares) {
243: $spares.= '<br />';
244: }
245: my %all_hostnames = &Apache::lonnet::all_hostnames();
246: foreach my $hostid (sort
247: {
248: &Apache::lonnet::hostname($a) cmp
249: &Apache::lonnet::hostname($b);
250: }
251: keys(%all_hostnames)) {
252: next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
253: my $hostname = &Apache::lonnet::hostname($hostid);
254: next if (($last eq $hostname) || ($hostname eq ''));
255: $spares.='<br /><a href="http://'.
256: $hostname.
257: '/adm/login?domain='.$authdomain.'">'.
258: $hostname.'</a>';
259: $last=$hostname;
260: }
261: $r->print(
262: '<html>'
263: .'<head><title>'
264: .&mt('The LearningOnline Network with CAPA')
265: .'</title></head>'
266: .'<body bgcolor="#FFFFFF">'
267: .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
268: .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
1.5 raeburn 269: .'<h3>'.&mt("This Mechanics Online course server is temporarily not available for login.").'</h3>'
1.1 raeburn 270: .'</body>'
271: .'</html>'
272: );
273: return OK;
274: }
275:
276: # ----------------------------------------------- Apparently we are in business
277: $servadm=~s/\,/\<br \/\>/g;
278:
279: # ----------------------------------------------------------------------- Texts
1.5 raeburn 280: my $pagetitle = 'Mechanics Online Log-in'; # Do not localize.
1.1 raeburn 281: my %lt=&Apache::lonlocal::texthash(
282: 'needu' => 'You must provide a username',
283: 'needp' => 'You must provide a password',
284: 'un' => 'Username',
285: 'pw' => 'Password',
286: 'dom' => 'Domain',
287: 'perc' => 'percent',
288: 'load' => 'Server Load',
289: 'userload' => 'User Load',
290: 'catalog' => 'Course/Community Catalog',
291: 'log' => 'Log-in',
292: 'help' => 'Log-in Help',
293: 'serv' => 'Server',
294: 'servadm' => 'Server Administration',
295: 'helpdesk' => 'Contact Helpdesk',
1.5 raeburn 296: 'exist' => 'Existing user?',
1.1 raeburn 297: 'forgotpw' => 'Forgot your password?',
298: 'newuser' => 'New User?',
1.5 raeburn 299: 'click' => 'Click here to sign up',
300: 'plea' => 'Please log-in',
301: 'supp' => 'Support from NSF, NIH, Google',
302: 'note' => 'Please Note:',
303: 'jscr' => 'Javascript must be enabled in your web browser in order to use this web site.',
1.1 raeburn 304: );
305: # ----------------------------------------------------------- Front page design
306: my $font=&Apache::loncommon::designparm('login.font',$domain);
307: my $link=&Apache::loncommon::designparm('login.link',$domain);
308: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
309: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
310: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
311: my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
312:
313: my $helpdeskscript;
314: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
315: $authdomain,\$helpdeskscript);
316:
317: # -------------------------------------------------- Change password field name
318: my $now=time;
319:
320: # ---------------------------------------- Assemble Javascript to put in <head>
321:
322: my $js = (<<ENDSCRIPT);
323:
324: <script type="text/javascript" language="JavaScript">
325: // <![CDATA[
326:
327: function send(caller) {
328: if (caller == "newaccount") {
329: this.document.signup.submit();
330: return false;
331: }
332: if (document.client.uname.value == "" || !document.client.uname.value) {
333: alert("$lt{'needu'}");
334: return false;
335: }
336: if (document.client.upass$now.value == "" ||
337: !document.client.upass$now.value) {
338: alert("$lt{'needp'}");
339: return false;
340: }
341:
342: this.document.server.elements.uname.value
343: =this.document.client.elements.uname.value;
344:
345: this.document.server.elements.udom.value
346: =this.document.client.elements.udom.value;
347:
348: uextkey=this.document.client.elements.uextkey.value;
349: lextkey=this.document.client.elements.lextkey.value;
350: initkeys();
351:
352: this.document.server.elements.upass0.value
353: =crypted(this.document.client.elements.upass$now.value.substr(0,15));
354: this.document.server.elements.upass1.value
355: =crypted(this.document.client.elements.upass$now.value.substr(15,15));
356: this.document.server.elements.upass2.value
357: =crypted(this.document.client.elements.upass$now.value.substr(30,15));
358:
359: this.document.client.elements.uname.value='';
360: this.document.client.elements.upass$now.value='';
361:
362: this.document.server.submit();
363: return false;
364: }
365:
366: function enableInput() {
367: this.document.client.elements.upass$now.removeAttribute("readOnly");
368: this.document.client.elements.uname.removeAttribute("readOnly");
369: this.document.client.elements.udom.removeAttribute("readOnly");
370: return;
371: }
372:
373: // ]]>
374: </script>
375:
376: $helpdeskscript
377:
378: ENDSCRIPT
379:
380: # --------------------------------------------------- Print login screen header
381: my %add_entries = (
382: bgcolor => "$mainbg",
383: text => "$font",
384: link => "$link",
385: vlink => "$vlink",
386: alink => "$alink",
387: onload => 'javascript:enableInput();',);
388:
1.4 raeburn 389: my $css_url = "/css/relate/login.css";
1.2 raeburn 390: $js .= "\n".'<link type="text/css" rel="stylesheet" href="'.$css_url.'" />'."\n";
1.1 raeburn 391: $r->print(&Apache::loncommon::start_page($pagetitle,$js,
392: {'redirect' => [$expire,'/adm/roles'],
393: 'add_entries' => \%add_entries,
394: 'only_body' => 1,}));
395:
396: # ------------------------------------------------------------ Additional Texts
1.5 raeburn 397: $lt{'newto'} = &mt('New to the [_1]Mechanics Online[_2] site?','<i>','</i>');
398: $lt{'mech'} = &mt('Mechanics Online is a Newtonian Mechanics course developed by Professor David Pritchard and the RELATE education group at MIT. [_1]Learn more[_2]','<a href="http://relate.mit.edu/physicscourse" style="text-decoration: underline;">','</a>');
399: $lt{'runson'} = &mt('Mechanics Online runs on [_1]LON-CAPA[_2] - an open source, freeware, distributed learning content management and assessment system.',
1.2 raeburn 400: '<a href="http://loncapa.org/" style="text-decoration: underline;">',
1.7 ! raeburn 401: '</a>');
1.5 raeburn 402: $lt{'newhere'} = &mt('New to [_1]Mechanics Online[_2]:','<i>','</i>');
1.1 raeburn 403: $lt{'browser'} = &mt('Your browser must allow [_1]cookies[_2]',
1.2 raeburn 404: '<a href="http://loncapa.msu.edu/cookies.html" style="color: #ffffff; text-decoration:underline;">','</a>');
405:
406: my ($contactrow,$domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
407: $contactrow = <<"END";
408: <tr>
1.6 raeburn 409: <td align="left" colspan="2">
1.2 raeburn 410: $contactblock
411: </td>
412: </tr>
413: END
414: $domainrow = <<"END";
415: <tr>
416: <td align="left" valign="top">
417: <small><b>$lt{'dom'}: </b></small>
418: </td>
419: <td align="left" valign="top">
420: <small><tt> $domain</tt></small>
421: </td>
422: </tr>
423: END
424: $serverrow = <<"END";
425: <tr>
426: <td align="left" valign="top">
427: <small><b>$lt{'serv'}: </b></small>
428: </td>
429: <td align="left" valign="top">
430: <small><tt> $lonhost ($role)</tt></small>
431: </td>
432: </tr>
433: END
434: if ($loadlim) {
435: $loadrow = <<"END";
436: <tr>
437: <td align="left" valign="top">
438: <small><b>$lt{'load'}: </b></small>
439: </td>
440: <td align="left" valign="top">
441: <small><tt> $loadpercent $lt{'perc'}</tt></small>
442: </td>
443: </tr>
444: END
445: }
446: if ($uloadlim) {
447: $userloadrow = <<"END";
448: <tr>
449: <td align="left" valign="top">
450: <small><b>$lt{'userload'}: </b></small>
451: </td>
452: <td align="left" valign="top">
453: <small><tt> $userloadpercent $lt{'perc'}</tt></small>
454: </td>
455: </tr>
456: END
457: }
458: if (($version ne '') && ($version ne '<!-- VERSION -->')) {
459: $versionrow = <<"END";
460: <tr>
461: <td colspan="2" align="left">
1.7 ! raeburn 462: <a href="/adm/about.html">
! 463: <img src="/images/login/lclogosm.gif" width="16" height="14" alt="LC" border="0" /> <small>$version</small></a>
1.2 raeburn 464: </td>
465: </tr>
466: END
467: }
1.1 raeburn 468:
469: # -------------------------------------------- Static cid for prerequisite test
1.3 raeburn 470: my $prereqcid = 'relate_3H121116c19344ff3relatel1';
1.1 raeburn 471:
472: # ---------------------------------------------------- Warning if no Javascript
1.4 raeburn 473: my $noscript_warning = '<noscript><br /><span class="LC_warning">'.
1.2 raeburn 474: '<b>'.$lt{'note'}.'</b>'.$lt{'jscr'}.
1.1 raeburn 475: '</span></noscript>';
476:
477: # ---------------------------------------------------- Serve out DES JavaScript
478: {
479: my $jsh=Apache::File->new($include."/londes.js");
480: $r->print(<$jsh>);
481: }
482: # ---------------------------------------------------------- Serve rest of page
483:
484: $r->print(<<"ENDLOGIN");
485: <br />
486: <div align="center">
487: <table class="LC_loginbox">
488: <tr>
1.6 raeburn 489: <td align="left" valign="top" width="11"><img src="/images/login/tlc_11_ffffff_e2e2e2.gif" width="10" height="10" border="0" alt="" /></td>
1.1 raeburn 490: <td width="450" valign="top">
491: <table class="LC_loginbox_left">
492: <tr>
1.4 raeburn 493: <td width="441" align="left"><br />
494: <img src="/images/login/LCrelateheader_sm.png" width="441" height="100" alt="Relate @ MIT" align="left" /></td>
1.1 raeburn 495: </tr>
496: <tr>
497: <td>
498: <div align="left" style="display:block; margin-top:5px; margin-bottom:5px; margin-left:0px; margin-right:0px; width:440px; height:5px;">
499: <div class="divider">
500: </div>
501: </div>
502: </td>
503: </tr>
504: </table>
505: <table class="LC_loginbox_left">
506: <tr>
507: <td width="10"> </td>
508: <td valign="top" class="bodyred" width="430" align="left"><br />
1.2 raeburn 509: <span style="font-size: 18px; line-height: 22px; ">$lt{'newto'}</span>
1.5 raeburn 510: <p class="bodyred">$lt{'mech'}</p>
511: <p class="bodyred">$lt{'runson'}</p>
1.1 raeburn 512: <br />
1.3 raeburn 513: <form name="signup" method="post" action="/adm/createaccount?courseid=$prereqcid"><input type="hidden" name="process" value="signup" />
1.1 raeburn 514: <table class="LC_signup">
515: <tr>
1.3 raeburn 516: <td align="left" valign="top" width="11" height="11"><img src="/images/login/tlc_11_993333_ffffff.gif" width="10" height="10" border="0" alt="" /></td>
1.1 raeburn 517: <td> </td>
1.3 raeburn 518: <td align="right" valign="top" width="11" height="11"><img src="/images/login/tr_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 519: </tr>
520: <tr>
521: <td> </td>
1.2 raeburn 522: <td align="center" valign="middle"><span style="white-space: nowrap;"><b>$lt{'newhere'}</b> <a href="javascript:send('newaccount')" style="color: #ffffff; text-decoration:underline;">$lt{'click'}</a></span></td>
1.1 raeburn 523: <td> </td>
524: </tr>
525: <tr>
1.3 raeburn 526: <td align="left" valign="bottom" width="11" height="11"><img src="/images/login/bl_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 527: <td> </td>
1.3 raeburn 528: <td align="right" valign="bottom" width="11" height="11"><img src="/images/login/br_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 529: </tr>
530: </table>
531: </form>
532: </td>
533: </tr>
534: </table>
535: </td>
536: <td width="10"> </td>
537: <td valign="top">
1.3 raeburn 538: <form name="client" method="post" onsubmit="return(send());" action="">
1.1 raeburn 539: <table class="LC_loginbox_right">
540: <tr>
541: <td colspan="3" height="23" class="LC_loginbox_strip"> </td>
1.2 raeburn 542: </tr>
1.1 raeburn 543: <tr>
1.3 raeburn 544: <td align="left" valign="top" width="11" height="11"><img src="/images/login/tlc_11_993333_ffffff.gif" width="10" height="10" border="0" alt="" /></td>
1.1 raeburn 545: <td> </td>
1.3 raeburn 546: <td align="right" valign="top" width="11" height="11"><img src="/images/login/tr_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 547: </tr>
548: <tr>
549: <td width="10"> </td>
550: <td>
551: <table border="0" cellspacing="0" cellpadding="0">
552: <tr>
1.3 raeburn 553: <td align="right" class="bodywhite" height="50"><br />
1.1 raeburn 554: <span style="font-size: 15px; line-height: 17px; font-weight: bold;">
555: $lt{'exist'}</span>
556: <br />$lt{'plea'}<br />
1.3 raeburn 557: <hr class="login" /><br /><br />
1.1 raeburn 558: </td>
559: </tr>
560: <tr>
561: <td>
562: <table border="0" cellpadding="2" cellspacing="0">
563: <tr>
1.3 raeburn 564: <td align="right" class="bodywhite"><label>$lt{'un'}</label>:</td>
1.1 raeburn 565: <td align="right"><input type="text" name="uname" size="17" value="" /></td>
566: </tr>
567: <tr>
1.3 raeburn 568: <td align="right" class="bodywhite"><label>$lt{'pw'}</label>:</td>
1.5 raeburn 569: <td align="right"><input name="upass$now" size="17" value="" type="password" /><input type="hidden" name="udom" value="$domain" /></td>
1.1 raeburn 570: </tr>
571: <tr><td> </td></tr>
572: <tr>
573: <td colspan="2" align="right"><input name="signin" type="submit" value="$lt{'log'}" class="buttonwhite" /></td>
574: </tr>
575: </table>
576: </td>
577: </tr>
578: <tr>
579: <td align="right" valign="top" class="bodywhite">
580: <br />
581: <br />
582: <span style="font-size: smaller;">$lt{'browser'}</span><br />
583: <hr class="login" />
584: <br />
1.3 raeburn 585: <a href="/adm/resetpw" style="color: #ffffff; text-decoration:underline;">$lt{'forgotpw'}</a><br />
1.1 raeburn 586: <br />
587: </td>
588: </tr>
589: </table>
590: </td>
591: <td width="9"> </td>
592: </tr>
593: <tr>
1.3 raeburn 594: <td align="left" valign="bottom" width="11" height="11"><img src="/images/login/bl_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 595: <td> </td>
1.3 raeburn 596: <td align="right" valign="bottom" width="11" height="11"><img src="/images/login/br_11_993333_ffffff.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 597: </tr>
598: </table>
1.3 raeburn 599: <input type="hidden" name="lextkey" value="$lextkey" />
600: <input type="hidden" name="uextkey" value="$uextkey" />
601: </form>
1.1 raeburn 602: </td>
1.3 raeburn 603: <td align="right" valign="top" width="11"><img src="/images/login/tr_11_ffffff_e2e2e2.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 604: </tr>
605: <tr>
1.3 raeburn 606: <td width="10"> </td>
607: <td colspan="3">
1.2 raeburn 608: <br />
1.4 raeburn 609: $noscript_warning
1.2 raeburn 610: <hr style="clear:both;" />
611: </td>
1.3 raeburn 612: <td width="10"> </td>
1.2 raeburn 613: </tr>
614: <tr>
615: <td width="10"> </td>
1.3 raeburn 616: <td colspan="4">
1.2 raeburn 617: <div style="float: left;">
618: <table border="0" cellspacing="0" cellpadding="0">
619: $contactrow
620: $domainrow
621: $serverrow
622: $loadrow
623: $userloadrow
624: $versionrow
625: </table>
626: </div>
627: <div style="float: right;">
628: <img src="/images/login/sponsors.png" alt="$lt{'supp'}" align="right" />
629: <br style="clear:both;" />
630: </div>
1.1 raeburn 631: </td>
632: </tr>
633: <tr>
1.3 raeburn 634: <td align="left" valign="bottom" width="11"><img src="/images/login/bl_11_ffffff_e2e2e2.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 635: <td colspan="3" width="698"> </td>
1.3 raeburn 636: <td align="right" valign="bottom" width="11"><img src="/images/login/br_11_ffffff_e2e2e2.gif" width="11" height="11" border="0" alt="" /></td>
1.1 raeburn 637: </tr>
638: </table>
639: </div>
640: <p> </p>
641: <form name="server" action="/adm/authenticate" method="post" target="_top">
642: <input type="hidden" name="logtoken" value="$logtoken" />
643: <input type="hidden" name="serverid" value="$lonhost" />
644: <input type="hidden" name="uname" value="" />
645: <input type="hidden" name="upass0" value="" />
646: <input type="hidden" name="upass1" value="" />
647: <input type="hidden" name="upass2" value="" />
648: <input type="hidden" name="udom" value="" />
649: <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
650: <input type="hidden" name="localres" value="$env{'form.localres'}" />
651: </form>
652:
653: <script type="text/javascript">
654: // <![CDATA[
655: // the if prevents the script error if the browser can not handle this
656: if ( document.client.uname ) { document.client.uname.focus(); }
657: // ]]>
658: </script>
659:
660: ENDLOGIN
661:
662: # -------------------------------------------------------- Standard page ending
663: my %endargs = ( 'noredirectlink' => 1, );
664: $r->print(&Apache::loncommon::end_page(\%endargs));
665: return OK;
666: }
667:
668: sub check_loginvia {
669: my ($domain,$lonhost) = @_;
670: if ($domain eq '' || $lonhost eq '') {
671: return;
672: }
673: my %domconfhash = &Apache::loncommon::get_domainconf($domain);
674: my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
675: my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
676: my $output;
677: if ($loginvia ne '') {
678: my $noredirect;
679: my $ip = $ENV{'REMOTE_ADDR'};
680: if ($ip eq '127.0.0.1') {
681: $noredirect = 1;
682: } else {
683: if ($loginvia_exempt ne '') {
684: my @exempt = split(',',$loginvia_exempt);
685: if (grep(/^\Q$ip\E$/,@exempt)) {
686: $noredirect = 1;
687: }
688: }
689: }
690: unless ($noredirect) {
691: my ($newhost,$path);
692: if ($loginvia =~ /:/) {
693: ($newhost,$path) = split(':',$loginvia);
694: } else {
695: $newhost = $loginvia;
696: }
697: if ($newhost ne $lonhost) {
698: if (&Apache::lonnet::hostname($newhost) ne '') {
699: $output = &redirect_page($newhost,$path);
700: }
701: }
702: }
703: }
704: return $output;
705: }
706:
707: sub redirect_page {
708: my ($desthost,$path) = @_;
709: my $protocol = $Apache::lonnet::protocol{$desthost};
710: $protocol = 'http' if ($protocol ne 'https');
711: unless ($path =~ m{^/}) {
712: $path = '/'.$path;
713: }
714: my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
715: if ($env{'form.firsturl'} ne '') {
716: $url .='?firsturl='.$env{'form.firsturl'};
717: }
718: my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
719: {'redirect' => [0,$url],});
720: my $end_page = &Apache::loncommon::end_page();
721: return $start_page.$end_page;
722: }
723:
724: sub contactdisplay {
725: my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript) = @_;
726: return unless(ref($lt) eq 'HASH');
727: my $contactblock;
728: my $showhelpdesk = 0;
729: my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
730: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
731: $showhelpdesk = 1;
732: }
733: if ($servadm && $showadminmail) {
734: $contactblock .= $lt->{'servadm'}.':<br />'.
735: '<tt>'.$servadm.'</tt><br />';
736: }
737: if ($showhelpdesk) {
1.2 raeburn 738: $contactblock .= '<a href="javascript:helpdesk()" style="text-decoration:underline;">'.$lt->{'helpdesk'}.'</a><br />';
1.1 raeburn 739: my $thisurl = &escape('/adm/login');
740: $$helpdeskscript = <<"ENDSCRIPT";
741: <script type="text/javascript">
742: // <![CDATA[
743: function helpdesk() {
744: var codedom = document.client.udom.value;
745: if (codedom == '') {
746: codedom = "$authdomain";
747: }
748: var querystr = "origurl=$thisurl&codedom="+codedom;
749: document.location.href = "/adm/helpdesk?"+querystr;
750: return;
751: }
752: // ]]>
753: </script>
754: ENDSCRIPT
755: }
756: return $contactblock;
757: }
758:
759: 1;
760: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>