Annotation of loncom/auth/lonlogin.pm, revision 1.191
1.160 kruse 1: # The LearningOnline Network
2: # Login Screen
3: #
1.191 ! raeburn 4: # $Id: lonlogin.pm,v 1.190 2021/10/08 14:45:45 raeburn Exp $
1.160 kruse 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/';
1.176 raeburn 40: use LONCAPA qw(:DEFAULT :match);
1.188 raeburn 41: use URI::Escape;
42: use HTML::Entities();
1.169 raeburn 43: use CGI::Cookie();
1.160 kruse 44:
45: sub handler {
46: my $r = shift;
47:
48: &Apache::loncommon::get_unprocessed_cgi
49: (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
50: $ENV{'REDIRECT_QUERY_STRING'}),
51: ['interface','username','domain','firsturl','localpath','localres',
1.184 raeburn 52: 'token','role','symb','iptoken','btoken','ltoken','linkkey','saml']);
1.160 kruse 53: if (!defined($env{'form.firsturl'})) {
54: &Apache::lonacc::get_posted_cgi($r,['firsturl']);
55: }
1.172 raeburn 56: if (!defined($env{'form.firsturl'})) {
57: if ($ENV{'REDIRECT_URL'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) {
58: $env{'form.firsturl'} = $ENV{'REDIRECT_URL'};
59: }
60: }
1.179 raeburn 61: if (($env{'form.firsturl'} =~ m{^/+tiny/+$LONCAPA::match_domain/+\w+$}) &&
62: (!$env{'form.ltoken'}) && (!$env{'form.linkkey'})) {
63: &Apache::lonacc::get_posted_cgi($r,['linkkey']);
64: }
1.189 raeburn 65: if ($env{'form.firsturl'} eq '/adm/logout') {
66: delete($env{'form.firsturl'});
67: }
1.160 kruse 68:
69: # -- check if they are a migrating user
70: if (defined($env{'form.token'})) {
71: return &Apache::migrateuser::handler($r);
72: }
73:
1.169 raeburn 74: # For "public user" - remove any exising "public" cookie, as user really wants to log-in
1.171 raeburn 75: my ($handle,$lonidsdir,$expirepub,$userdom);
1.176 raeburn 76: $lonidsdir=$r->dir_config('lonIDsDir');
1.169 raeburn 77: unless ($r->header_only) {
1.171 raeburn 78: $handle = &Apache::lonnet::check_for_valid_session($r,'lonID',undef,\$userdom);
1.169 raeburn 79: if ($handle ne '') {
80: if ($handle=~/^publicuser\_/) {
81: unlink($r->dir_config('lonIDsDir')."/$handle.id");
82: undef($handle);
1.171 raeburn 83: undef($userdom);
84: $expirepub = 1;
1.169 raeburn 85: }
86: }
87: }
88:
1.160 kruse 89: &Apache::loncommon::no_cache($r);
90: &Apache::lonlocal::get_language_handle($r);
91: &Apache::loncommon::content_type($r,'text/html');
1.171 raeburn 92: if ($expirepub) {
1.170 raeburn 93: my $c = new CGI::Cookie(-name => 'lonPubID',
1.169 raeburn 94: -value => '',
95: -expires => '-10y',);
96: $r->header_out('Set-cookie' => $c);
1.171 raeburn 97: } elsif (($handle eq '') && ($userdom ne '')) {
1.173 raeburn 98: my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
99: foreach my $name (keys(%cookies)) {
100: next unless ($name =~ /^lon(|S|Link|Pub)ID$/);
101: my $c = new CGI::Cookie(-name => $name,
102: -value => '',
103: -expires => '-10y',);
104: $r->headers_out->add('Set-cookie' => $c);
105: }
1.169 raeburn 106: }
1.160 kruse 107: $r->send_http_header;
108: return OK if $r->header_only;
109:
110:
111: # Are we re-routing?
112: my $londocroot = $r->dir_config('lonDocRoot');
113: if (-e "$londocroot/lon-status/reroute.txt") {
114: &Apache::lonauth::reroute($r);
115: return OK;
116: }
117:
1.176 raeburn 118: my $lonhost = $r->dir_config('lonHostID');
1.174 raeburn 119:
120: # Check if browser sent a LON-CAPA load balancer cookie (and this is a balancer)
121:
122: my ($found_server,$balancer_cookie) = &Apache::lonnet::check_for_balancer_cookie($r,1);
123: if ($found_server) {
124: my $hostname = &Apache::lonnet::hostname($found_server);
125: if ($hostname ne '') {
126: my $protocol = $Apache::lonnet::protocol{$found_server};
127: $protocol = 'http' if ($protocol ne 'https');
128: my $dest = '/adm/roles';
129: if ($env{'form.firsturl'} ne '') {
1.188 raeburn 130: if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
131: $dest = &uri_escape_utf8($env{'form.firsturl'});
132: } else {
133: $dest = &uri_escape($env{'form.firsturl'});
134: }
135: $dest = &HTML::Entities::encode($dest,"'");
1.174 raeburn 136: }
1.176 raeburn 137: my %info = (
138: balcookie => $lonhost.':'.$balancer_cookie,
139: );
1.177 raeburn 140: if ($env{'form.ltoken'}) {
141: my %link_info = &Apache::lonnet::tmpget($env{'form.ltoken'});
142: if ($link_info{'linkprot'}) {
143: $info{'linkprot'} = $link_info{'linkprot'};
144: }
145: &Apache::lonnet::tmpdel($env{'form.ltoken'});
146: delete($env{'form.ltoken'});
1.179 raeburn 147: } elsif ($env{'form.linkkey'}) {
148: $info{'linkkey'} = $env{'form.linkkey'};
149: delete($env{'form.linkkey'});
1.177 raeburn 150: }
1.176 raeburn 151: my $balancer_token = &Apache::lonnet::tmpput(\%info,$found_server);
152: if ($balancer_token) {
1.187 raeburn 153: $dest .= (($dest=~/\?/)?'&':'?') . 'btoken='.$balancer_token;
1.176 raeburn 154: }
1.183 raeburn 155: unless ($found_server eq $lonhost) {
156: my $alias = &Apache::lonnet::use_proxy_alias($r,$found_server);
157: $hostname = $alias if ($alias ne '');
158: }
1.174 raeburn 159: my $url = $protocol.'://'.$hostname.$dest;
160: my $start_page =
161: &Apache::loncommon::start_page('Switching Server ...',undef,
162: {'redirect' => [0,$url],});
163: my $end_page = &Apache::loncommon::end_page();
164: $r->print($start_page.$end_page);
165: return OK;
166: }
167: }
168:
1.171 raeburn 169: #
1.176 raeburn 170: # Check if a LON-CAPA load balancer sent user here because user's browser sent
171: # it a balancer cookie for an active session on this server.
172: #
173:
1.179 raeburn 174: my ($balcookie,$linkprot,$linkkey);
1.176 raeburn 175: if ($env{'form.btoken'}) {
176: my %info = &Apache::lonnet::tmpget($env{'form.btoken'});
177: $balcookie = $info{'balcookie'};
1.177 raeburn 178: if ($balcookie) {
179: if ($info{'linkprot'}) {
180: $linkprot = $info{'linkprot'};
1.179 raeburn 181: } elsif ($info{'linkkey'}) {
182: $linkkey = $info{'linkkey'};
1.177 raeburn 183: }
184: }
1.176 raeburn 185: &Apache::lonnet::tmpdel($env{'form.btoken'});
186: delete($env{'form.btoken'});
187: }
188:
189: #
1.171 raeburn 190: # If browser sent an old cookie for which the session file had been removed
191: # check if configuration for user's domain has a portal URL set. If so
192: # switch user's log-in to the portal.
193: #
194:
195: if (($handle eq '') && ($userdom ne '')) {
196: my %domdefaults = &Apache::lonnet::get_domain_defaults($userdom);
197: if ($domdefaults{'portal_def'} =~ /^https?\:/) {
198: my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
199: {'redirect' => [0,$domdefaults{'portal_def'}],});
200: my $end_page = &Apache::loncommon::end_page();
201: $r->print($start_page.$end_page);
202: return OK;
203: }
204: }
205:
1.160 kruse 206: # -------------------------------- Prevent users from attempting to login twice
207: if ($handle ne '') {
1.169 raeburn 208: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
209: my $start_page =
210: &Apache::loncommon::start_page('Already logged in');
211: my $end_page =
212: &Apache::loncommon::end_page();
213: my $dest = '/adm/roles';
214: if ($env{'form.firsturl'} ne '') {
1.188 raeburn 215: if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
216: $dest = &uri_escape_utf8($env{'form.firsturl'});
217: } else {
218: $dest = &uri_escape($env{'form.firsturl'});
219: }
220: $dest = &HTML::Entities::encode($dest,"'");
1.169 raeburn 221: }
1.177 raeburn 222: if (($env{'form.ltoken'}) || ($linkprot)) {
223: unless ($linkprot) {
224: my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
225: $linkprot = $info{'linkprot'};
226: my $delete = &Apache::lonnet::tmpdel($env{'form.ltoken'});
227: delete($env{'form.ltoken'});
228: }
229: if ($linkprot) {
230: my ($linkprotector,$deeplink) = split(/:/,$linkprot,2);
231: if ($env{'user.linkprotector'}) {
232: my @protectors = split(/,/,$env{'user.linkprotector'});
233: unless (grep(/^\Q$linkprotector\E$/,@protectors)) {
234: push(@protectors,$linkprotector);
235: @protectors = sort { $a <=> $b } @protectors;
236: &Apache::lonnet::appenv({'user.linkprotector' => join(',',@protectors)});
237: }
238: } else {
239: &Apache::lonnet::appenv({'user.linkprotector' => $linkprotector });
240: }
241: if ($env{'user.linkproturi'}) {
242: my @proturis = split(/,/,$env{'user.linkproturi'});
1.179 raeburn 243: unless (grep(/^\Q$deeplink\E$/,@proturis)) {
1.177 raeburn 244: push(@proturis,$deeplink);
245: @proturis = sort @proturis;
246: &Apache::lonnet::appenv({'user.linkproturi' => join(',',@proturis)});
247: }
248: } else {
249: &Apache::lonnet::appenv({'user.linkproturi' => $deeplink});
250: }
251: }
1.179 raeburn 252: } elsif (($env{'form.linkkey'}) || ($linkkey)) {
253: if ($env{'form.firsturl'} =~ m{^/tiny/$match_domain/\w+$}) {
254: if ($linkkey eq '') {
255: $linkkey = $env{'form.linkkey'};
256: }
257: if ($env{'user.deeplinkkey'}) {
258: my @linkkeys = split(/,/,$env{'user.deeplinkkey'});
259: unless (grep(/^\Q$linkkey\E$/,@linkkeys)) {
260: push(@linkkeys,$linkkey);
261: &Apache::lonnet::appenv({'user.deeplinkkey' => join(',',sort(@linkkeys))});
262: }
263: } else {
264: &Apache::lonnet::appenv({'user.deeplinkkey' => $linkkey});
265: }
266: my $deeplink = $env{'form.firsturl'};
267: if ($env{'user.keyedlinkuri'}) {
268: my @keyeduris = split(/,/,$env{'user.keyedlinkuri'});
269: unless (grep(/^\Q$deeplink\E$/,@keyeduris)) {
270: push(@keyeduris,$deeplink);
271: &Apache::lonnet::appenv({'user.keyedlinkuri' => join(',',sort(@keyeduris))});
272: }
273: } else {
274: &Apache::lonnet::appenv({'user.keyedlinkuri' => $deeplink});
275: }
276: }
1.177 raeburn 277: }
1.169 raeburn 278: $r->print(
1.160 kruse 279: $start_page
280: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
281: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
282: '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
283: .$end_page
284: );
1.169 raeburn 285: return OK;
1.160 kruse 286: }
287:
288: # ---------------------------------------------------- No valid token, continue
289:
290: # ---------------------------- Not possible to really login to domain "public"
291: if ($env{'form.domain'} eq 'public') {
292: $env{'form.domain'}='';
293: $env{'form.username'}='';
294: }
295:
296: # ------ Is this page requested because /adm/migrateuser detected an IP change?
297: my %sessiondata;
298: if ($env{'form.iptoken'}) {
299: %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
1.162 raeburn 300: unless ($sessiondata{'sessionserver'}) {
301: my $delete = &Apache::lonnet::tmpdel($env{'form.iptoken'});
302: delete($env{'form.iptoken'});
303: }
1.160 kruse 304: }
305: # ----------------------------------------------------------- Process Interface
306: $env{'form.interface'}=~s/\W//g;
307:
308: (undef,undef,undef,undef,undef,undef,my $clientmobile) =
309: &Apache::loncommon::decode_user_agent();
310:
311: my $iconpath=
312: &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
313:
314: my $domain = &Apache::lonnet::default_login_domain();
1.161 raeburn 315: my $defdom = $domain;
1.160 kruse 316: if ($lonhost ne '') {
317: unless ($sessiondata{'sessionserver'}) {
1.177 raeburn 318: my $redirect = &check_loginvia($domain,$lonhost,$lonidsdir,$balcookie,$linkprot);
1.160 kruse 319: if ($redirect) {
320: $r->print($redirect);
321: return OK;
322: }
323: }
324: }
325:
326: if (($sessiondata{'domain'}) &&
1.175 raeburn 327: (&Apache::lonnet::domain($sessiondata{'domain'},'description'))) {
1.160 kruse 328: $domain=$sessiondata{'domain'};
329: } elsif (($env{'form.domain'}) &&
330: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
331: $domain=$env{'form.domain'};
332: }
333:
334: my $role = $r->dir_config('lonRole');
335: my $loadlim = $r->dir_config('lonLoadLim');
336: my $uloadlim= $r->dir_config('lonUserLoadLim');
337: my $servadm = $r->dir_config('lonAdmEMail');
338: my $tabdir = $r->dir_config('lonTabDir');
339: my $include = $r->dir_config('lonIncludes');
340: my $expire = $r->dir_config('lonExpire');
341: my $version = $r->dir_config('lonVersion');
342: my $host_name = &Apache::lonnet::hostname($lonhost);
343:
344: # --------------------------------------------- Default values for login fields
345:
346: my ($authusername,$authdomain);
347: if ($sessiondata{'username'}) {
348: $authusername=$sessiondata{'username'};
349: } else {
350: $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
351: $authusername=($env{'form.username'}?$env{'form.username'}:'');
352: }
353: if ($sessiondata{'domain'}) {
354: $authdomain=$sessiondata{'domain'};
355: } else {
356: $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
357: $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
358: }
359:
360: # ---------------------------------------------------------- Determine own load
361: my $loadavg;
362: {
363: my $loadfile=Apache::File->new('/proc/loadavg');
364: $loadavg=<$loadfile>;
365: }
366: $loadavg =~ s/\s.*//g;
367:
368: my ($loadpercent,$userloadpercent);
369: if ($loadlim) {
370: $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
371: }
372: if ($uloadlim) {
373: $userloadpercent=&Apache::lonnet::userload();
374: }
375:
376: my $firsturl=
377: ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
378:
379: # ----------------------------------------------------------- Get announcements
380: my $announcements=&Apache::lonnet::getannounce();
381: # -------------------------------------------------------- Set login parameters
382:
383: my @hexstr=('0','1','2','3','4','5','6','7',
384: '8','9','a','b','c','d','e','f');
385: my $lkey='';
386: for (0..7) {
387: $lkey.=$hexstr[rand(15)];
388: }
389:
390: my $ukey='';
391: for (0..7) {
392: $ukey.=$hexstr[rand(15)];
393: }
394:
395: my $lextkey=hex($lkey);
396: if ($lextkey>2147483647) { $lextkey-=4294967296; }
397:
398: my $uextkey=hex($ukey);
399: if ($uextkey>2147483647) { $uextkey-=4294967296; }
400:
401: # -------------------------------------------------------- Store away log token
402: my $tokenextras;
403: if ($env{'form.role'}) {
404: $tokenextras = '&role='.&escape($env{'form.role'});
405: }
406: if ($env{'form.symb'}) {
407: if (!$tokenextras) {
408: $tokenextras = '&';
409: }
410: $tokenextras .= '&symb='.&escape($env{'form.symb'});
411: }
1.162 raeburn 412: if ($env{'form.iptoken'}) {
413: if (!$tokenextras) {
414: $tokenextras = '&&';
415: }
416: $tokenextras .= '&iptoken='.&escape($env{'form.iptoken'});
417: }
1.177 raeburn 418: if ($env{'form.ltoken'}) {
419: my %info = &Apache::lonnet::tmpget($env{'form.ltoken'});
420: if ($info{'linkprot'}) {
421: if (!$tokenextras) {
422: $tokenextras = '&&&';
423: }
424: $tokenextras .= '&linkprot='.&escape($info{'linkprot'});
425: }
1.179 raeburn 426: } elsif ($env{'form.linkkey'}) {
427: if (!$tokenextras) {
428: $tokenextras = '&&&';
429: }
430: $tokenextras .= '&linkkey='.&escape($env{'form.linkkey'});
1.177 raeburn 431: }
1.160 kruse 432: my $logtoken=Apache::lonnet::reply(
433: 'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
434: $lonhost);
435:
436: # -- If we cannot talk to ourselves, or hostID does not map to a hostname
437: # we are in serious trouble
438:
439: if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
440: if ($logtoken eq 'no_such_host') {
441: &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
442: }
1.191 ! raeburn 443: if ($env{'form.ltoken'}) {
! 444: &Apache::lonnet::tmpdel($env{'form.ltoken'});
! 445: delete($env{'form.ltoken'});
! 446: }
1.160 kruse 447: my $spares='';
1.180 raeburn 448: my (@sparehosts,%spareservers);
449: my $sparesref = &Apache::lonnet::this_host_spares($defdom);
450: if (ref($sparesref) eq 'HASH') {
451: foreach my $key (keys(%{$sparesref})) {
452: if (ref($sparesref->{$key}) eq 'ARRAY') {
453: my @sorted = sort { &Apache::lonnet::hostname($a) cmp
454: &Apache::lonnet::hostname($b);
455: } @{$sparesref->{$key}};
456: if (@sorted) {
457: if ($key eq 'primary') {
458: unshift(@sparehosts,@sorted);
459: } elsif ($key eq 'default') {
460: push(@sparehosts,@sorted);
461: }
462: }
463: }
464: }
465: }
466: foreach my $hostid (@sparehosts) {
1.160 kruse 467: next if ($hostid eq $lonhost);
468: my $hostname = &Apache::lonnet::hostname($hostid);
1.180 raeburn 469: next if (($hostname eq '') || ($spareservers{$hostname}));
470: $spareservers{$hostname} = 1;
471: my $protocol = $Apache::lonnet::protocol{$hostid};
472: $protocol = 'http' if ($protocol ne 'https');
473: $spares.='<br /><span style="font-size: larger;"><a href="'.$protocol.'://'.
1.160 kruse 474: $hostname.
475: '/adm/login?domain='.$authdomain.'">'.
476: $hostname.'</a>'.
1.180 raeburn 477: ' '.&mt('(preferred)').'</span>'.$/;
1.160 kruse 478: }
479: if ($spares) {
480: $spares.= '<br />';
481: }
482: my %all_hostnames = &Apache::lonnet::all_hostnames();
483: foreach my $hostid (sort
484: {
485: &Apache::lonnet::hostname($a) cmp
486: &Apache::lonnet::hostname($b);
487: }
488: keys(%all_hostnames)) {
1.180 raeburn 489: next if ($hostid eq $lonhost);
1.160 kruse 490: my $hostname = &Apache::lonnet::hostname($hostid);
1.180 raeburn 491: next if (($hostname eq '') || ($spareservers{$hostname}));
1.181 raeburn 492: $spareservers{$hostname} = 1;
1.180 raeburn 493: my $protocol = $Apache::lonnet::protocol{$hostid};
494: $protocol = 'http' if ($protocol ne 'https');
495: $spares.='<br /><a href="'.$protocol.'://'.
1.160 kruse 496: $hostname.
497: '/adm/login?domain='.$authdomain.'">'.
498: $hostname.'</a>';
499: }
500: $r->print(
1.180 raeburn 501: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
502: .'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'
503: .'<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>'
1.160 kruse 504: .&mt('The LearningOnline Network with CAPA')
505: .'</title></head>'
506: .'<body bgcolor="#FFFFFF">'
507: .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
1.180 raeburn 508: .'<img src="/adm/lonKaputt/lonlogo_broken.gif" alt="broken icon" align="right" />'
1.160 kruse 509: .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
510: if ($spares) {
511: $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
512: .'</p>'
513: .$spares);
514: }
515: $r->print('</body>'
516: .'</html>'
517: );
518: return OK;
519: }
520:
521: # ----------------------------------------------- Apparently we are in business
522: $servadm=~s/\,/\<br \/\>/g;
523:
524: # ----------------------------------------------------------- Front page design
525: my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
526: my $font=&Apache::loncommon::designparm('login.font',$domain);
527: my $link=&Apache::loncommon::designparm('login.link',$domain);
528: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
529: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
530: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
531: my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
532: my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
533: my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
534: my $logo=&Apache::loncommon::designparm('login.logo',$domain);
535: my $img=&Apache::loncommon::designparm('login.img',$domain);
536: my $domainlogo=&Apache::loncommon::domainlogo($domain);
537: my $showbanner = 1;
538: my $showmainlogo = 1;
539: if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
540: $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
541: }
542: if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
543: $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
544: }
545: my $showadminmail;
546: my @possdoms = &Apache::lonnet::current_machine_domains();
547: if (grep(/^\Q$domain\E$/,@possdoms)) {
548: $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
549: }
550: my $showcoursecat =
551: &Apache::loncommon::designparm('login.coursecatalog',$domain);
552: my $shownewuserlink =
553: &Apache::loncommon::designparm('login.newuser',$domain);
554: my $showhelpdesk =
555: &Apache::loncommon::designparm('login.helpdesk',$domain);
556: my $now=time;
557: my $js = (<<ENDSCRIPT);
558:
559: <script type="text/javascript" language="JavaScript">
560: // <![CDATA[
561: function send()
562: {
563: this.document.server.elements.uname.value
564: =this.document.client.elements.uname.value;
565:
566: this.document.server.elements.udom.value
567: =this.document.client.elements.udom.value;
568:
569: uextkey=this.document.client.elements.uextkey.value;
570: lextkey=this.document.client.elements.lextkey.value;
571: initkeys();
572:
573: if(this.document.server.action.substr(0,5) === 'http:'){
1.165 raeburn 574: this.document.server.elements.upass0.value
575: =getCrypted(this.document.client.elements.upass$now.value);
1.166 raeburn 576: } else {
577: this.document.server.elements.upass0.value
578: =this.document.client.elements.upass$now.value;
1.167 raeburn 579: }
1.160 kruse 580:
581: this.document.client.elements.uname.value='';
582: this.document.client.elements.upass$now.value='';
583:
584: this.document.server.submit();
585: return false;
586: }
587:
588: function enableInput() {
589: this.document.client.elements.upass$now.removeAttribute("readOnly");
590: this.document.client.elements.uname.removeAttribute("readOnly");
591: this.document.client.elements.udom.removeAttribute("readOnly");
592: return;
593: }
594:
595: // ]]>
596: </script>
597:
598: ENDSCRIPT
599:
1.184 raeburn 600: my ($lonhost_in_use,@hosts,%defaultdomconf,$saml_prefix,$saml_landing,
601: $samlssotext,$samlnonsso,$samlssoimg,$samlssoalt,$samlssourl,$samltooltip);
602: %defaultdomconf = &Apache::loncommon::get_domainconf($defdom);
603: @hosts = &Apache::lonnet::current_machine_ids();
604: $lonhost_in_use = $lonhost;
605: if (@hosts > 1) {
606: foreach my $hostid (@hosts) {
607: if (&Apache::lonnet::host_domain($hostid) eq $defdom) {
608: $lonhost_in_use = $hostid;
609: last;
610: }
611: }
612: }
613: $saml_prefix = $defdom.'.login.saml_';
614: if ($defaultdomconf{$saml_prefix.$lonhost_in_use}) {
615: $saml_landing = 1;
616: $samlssotext = $defaultdomconf{$saml_prefix.'text_'.$lonhost_in_use};
617: $samlnonsso = $defaultdomconf{$saml_prefix.'notsso_'.$lonhost_in_use};
618: $samlssoimg = $defaultdomconf{$saml_prefix.'img_'.$lonhost_in_use};
619: $samlssoalt = $defaultdomconf{$saml_prefix.'alt_'.$lonhost_in_use};
620: $samlssourl = $defaultdomconf{$saml_prefix.'url_'.$lonhost_in_use};
621: $samltooltip = $defaultdomconf{$saml_prefix.'title_'.$lonhost_in_use};
622: }
623: if ($saml_landing) {
624: if ($samlssotext eq '') {
625: $samlssotext = 'SSO Login';
626: }
627: if ($samlnonsso eq '') {
628: $samlnonsso = 'Non-SSO Login';
629: }
630: $js .= <<"ENDSAMLJS";
631:
632: <script type="text/javascript">
633: // <![CDATA[
634: function toggleLClogin() {
635: if (document.getElementById('LC_standard_login')) {
636: if (document.getElementById('LC_standard_login').style.display == 'none') {
637: document.getElementById('LC_standard_login').style.display = 'inline-block';
638: if (document.getElementById('LC_login_text')) {
639: document.getElementById('LC_login_text').innerHTML = '$samlnonsso';
640: }
641: if (document.getElementById('LC_SSO_login')) {
642: document.getElementById('LC_SSO_login').style.display = 'none';
643: }
644: } else {
645: document.getElementById('LC_standard_login').style.display = 'none';
646: if (document.getElementById('LC_login_text')) {
647: document.getElementById('LC_login_text').innerHTML = '$samlssotext';
648: }
649: if (document.getElementById('LC_SSO_login')) {
650: document.getElementById('LC_SSO_login').style.display = 'inline-block';
651: }
652: }
653: }
654: return;
655: }
656:
657: // ]]>
658: </script>
659:
660: ENDSAMLJS
661: }
662:
1.160 kruse 663: # --------------------------------------------------- Print login screen header
664:
665: my %add_entries = (
666: bgcolor => "$mainbg",
667: text => "$font",
668: link => "$link",
669: vlink => "$vlink",
670: alink => "$alink",
671: onload => 'javascript:enableInput();',);
672:
1.186 raeburn 673: my ($headextra,$headextra_exempt);
1.164 raeburn 674: $headextra = $defaultdomconf{$defdom.'.login.headtag_'.$lonhost_in_use};
675: $headextra_exempt = $defaultdomconf{$domain.'.login.headtag_exempt_'.$lonhost_in_use};
1.161 raeburn 676: if ($headextra) {
677: my $omitextra;
678: if ($headextra_exempt ne '') {
679: my @exempt = split(',',$headextra_exempt);
1.182 raeburn 680: my $ip = &Apache::lonnet::get_requestor_ip();
1.161 raeburn 681: if (grep(/^\Q$ip\E$/,@exempt)) {
682: $omitextra = 1;
683: }
684: }
685: unless ($omitextra) {
686: my $confname = $defdom.'-domainconfig';
1.163 raeburn 687: if ($headextra =~ m{^\Q/res/$defdom/$confname/login/headtag/$lonhost_in_use/\E}) {
1.161 raeburn 688: my $extra = &Apache::lonnet::getfile(&Apache::lonnet::filelocation("",$headextra));
689: unless ($extra eq '-1') {
690: $js .= "\n".$extra."\n";
691: }
692: }
693: }
694: }
695:
1.160 kruse 696: $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
697: { 'redirect' => [$expire,'/adm/roles'],
698: 'add_entries' => \%add_entries,
699: 'only_body' => 1,}));
700:
701: # ----------------------------------------------------------------------- Texts
702:
703: my %lt=&Apache::lonlocal::texthash(
704: 'un' => 'Username',
705: 'pw' => 'Password',
706: 'dom' => 'Domain',
707: 'perc' => 'percent',
708: 'load' => 'Server Load',
709: 'userload' => 'User Load',
710: 'catalog' => 'Course/Community Catalog',
711: 'log' => 'Log in',
712: 'help' => 'Log-in Help',
713: 'serv' => 'Server',
714: 'servadm' => 'Server Administration',
715: 'helpdesk' => 'Contact Helpdesk',
716: 'forgotpw' => 'Forgot password?',
717: 'newuser' => 'New User?',
1.184 raeburn 718: 'change' => 'Change?',
1.160 kruse 719: );
720: # -------------------------------------------------- Change password field name
721:
722: my $forgotpw = &forgotpwdisplay(%lt);
723: $forgotpw .= '<br />' if $forgotpw;
724: my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
725: if ($loginhelp) {
726: $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
727: }
728:
729: # ---------------------------------------------------- Serve out DES JavaScript
730: {
731: my $jsh=Apache::File->new($include."/londes.js");
732: $r->print(<$jsh>);
733: }
734: # ---------------------------------------------------------- Serve rest of page
735:
736: $r->print(
737: '<div class="LC_Box"'
738: .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
739: );
740:
741: $r->print(<<ENDSERVERFORM);
742: <form name="server" action="/adm/authenticate" method="post" target="_top">
743: <input type="hidden" name="logtoken" value="$logtoken" />
744: <input type="hidden" name="serverid" value="$lonhost" />
745: <input type="hidden" name="uname" value="" />
746: <input type="hidden" name="upass0" value="" />
747: <input type="hidden" name="udom" value="" />
748: <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
749: <input type="hidden" name="localres" value="$env{'form.localres'}" />
750: </form>
751: ENDSERVERFORM
752: my $coursecatalog;
753: if (($showcoursecat eq '') || ($showcoursecat)) {
754: $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
755: }
756: my $newuserlink;
757: if ($shownewuserlink) {
758: $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
759: }
760: my $logintitle =
761: '<h2 class="LC_hcell"'
762: .' style="background:'.$loginbox_header_bgcol.';'
763: .' color:'.$loginbox_header_textcol.'">'
764: .$lt{'log'}
765: .'</h2>';
766:
767: my $noscript_warning='<noscript><span class="LC_warning"><b>'
768: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
769: .'</b></span></noscript>';
770: my $helpdeskscript;
771: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
772: $authdomain,\$helpdeskscript,
773: $showhelpdesk,\@possdoms);
774:
775: my $mobileargs;
776: if ($clientmobile) {
777: $mobileargs = 'autocapitalize="off" autocorrect="off"';
778: }
779: my $loginform=(<<LFORM);
1.184 raeburn 780: <form name="client" action="" onsubmit="return(send())" id="lclogin">
1.160 kruse 781: <input type="hidden" name="lextkey" value="$lextkey" />
782: <input type="hidden" name="uextkey" value="$uextkey" />
783: <b><label for="uname">$lt{'un'}</label>:</b><br />
784: <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
785: <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
786: <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
787: <b><label for="udom">$lt{'dom'}</label>:</b><br />
788: <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
789: <input type="submit" value="$lt{'log'}" />
790: </form>
791: LFORM
792:
793: if ($showbanner) {
794: $r->print(<<HEADER);
795: <!-- The LON-CAPA Header -->
796: <div style="background:$pgbg;margin:0;width:100%;">
1.168 raeburn 797: <img src="$img" border="0" alt="The Learning Online Network with CAPA" class="LC_maxwidth" />
1.160 kruse 798: </div>
799: HEADER
800: }
1.184 raeburn 801:
802: my $stdauthformstyle = 'inline-block';
803: my $ssoauthstyle = 'none';
804: my $logintype;
805: $r->print('<div style="float:left;margin-top:0;">');
806: if ($saml_landing) {
807: $ssoauthstyle = 'inline-block';
808: $stdauthformstyle = 'none';
809: $logintype = $samlssotext;
810: my $ssologin = '/adm/sso';
811: if ($samlssourl ne '') {
812: $ssologin = $samlssourl;
813: }
1.187 raeburn 814: if ($env{'form.firsturl'} ne '') {
1.190 raeburn 815: my $querystring = 'origurl=';
1.188 raeburn 816: if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
1.190 raeburn 817: $querystring .= &uri_escape_utf8($env{'form.firsturl'});
1.188 raeburn 818: } else {
1.190 raeburn 819: $querystring .= &uri_escape($env{'form.firsturl'});
1.188 raeburn 820: }
821: $querystring = &HTML::Entities::encode($querystring,"'");
822: $ssologin .= (($ssologin=~/\?/)?'&':'?') . $querystring;
1.187 raeburn 823: }
1.191 ! raeburn 824: if ($env{'form.ltoken'} ne '') {
! 825: $querystring .= (($querystring eq '')?'':'&') . 'ltoken='.
! 826: &HTML::Entities::encode(&uri_escape($env{'form.ltoken'}));
! 827: } elsif ($env{'form.linkkey'}) {
! 828: $querystring .= (($querystring eq '')?'':'&') . 'linkkey='.
! 829: &HTML::Entities::encode(&uri_escape($env{'form.linkkey'}));
! 830: }
1.184 raeburn 831: my $ssohref;
832: if ($samlssoimg ne '') {
833: $ssohref = '<a href="'.$ssologin.'" title="'.$samltooltip.'"><img src="'.$samlssoimg.'" alt="'.$samlssoalt.'" /></a>';
834: } else {
835: $ssohref = '<a href="'.$ssologin.'">'.$samlssotext.'</a>';
836: }
837: if (($env{'form.saml'} eq 'no') ||
838: (($env{'form.username'} ne '') && ($env{'form.domain'} ne ''))) {
839: $ssoauthstyle = 'none';
840: $stdauthformstyle = 'inline-block';
841: $logintype = $samlnonsso;
842: }
843: $r->print(<<ENDSAML);
844: <p>
845: Log-in type:
846: <span style="font-weight:bold" id="LC_login_text">$logintype</span><br />
847: <span><a href="javascript:toggleLClogin();" style="color:#000000">$lt{'change'}</a></span>
848: </p>
849: <div style="display:$ssoauthstyle" id="LC_SSO_login">
850: <div class="LC_Box" style="padding-top: 10px;">
851: $ssohref
852: $noscript_warning
853: </div>
854: <div class="LC_Box" style="padding-top: 10px;">
855: $loginhelp
856: $contactblock
857: $coursecatalog
858: </div>
859: </div>
860: ENDSAML
1.191 ! raeburn 861: } else {
! 862: if ($env{'form.ltoken'}) {
! 863: &Apache::lonnet::tmpdel($env{'form.ltoken'});
! 864: delete($env{'form.ltoken'});
! 865: }
1.184 raeburn 866: }
867:
868: $r->print(<<ENDLOGIN);
869: <div style="display:$stdauthformstyle;" id="LC_standard_login">
1.160 kruse 870: <div class="LC_Box" style="background:$loginbox_bg;">
871: $logintitle
872: $loginform
873: $noscript_warning
874: </div>
875:
876: <div class="LC_Box" style="padding-top: 10px;">
877: $loginhelp
878: $forgotpw
879: $contactblock
880: $newuserlink
881: $coursecatalog
882: </div>
883: </div>
884:
1.184 raeburn 885: ENDLOGIN
886: $r->print('</div><div>'."\n");
1.160 kruse 887: if ($showmainlogo) {
1.168 raeburn 888: $r->print(' <img src="'.$logo.'" alt="" class="LC_maxwidth" />'."\n");
1.160 kruse 889: }
890: $r->print(<<ENDTOP);
891: $announcements
892: </div>
893: <hr style="clear:both;" />
894: ENDTOP
895: my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
896: $domainrow = <<"END";
897: <tr>
898: <td align="left" valign="top">
899: <small><b>$lt{'dom'}: </b></small>
900: </td>
901: <td align="left" valign="top">
902: <small><tt> $domain</tt></small>
903: </td>
904: </tr>
905: END
906: $serverrow = <<"END";
907: <tr>
908: <td align="left" valign="top">
909: <small><b>$lt{'serv'}: </b></small>
910: </td>
911: <td align="left" valign="top">
912: <small><tt> $lonhost ($role)</tt></small>
913: </td>
914: </tr>
915: END
916: if ($loadlim) {
917: $loadrow = <<"END";
918: <tr>
919: <td align="left" valign="top">
920: <small><b>$lt{'load'}: </b></small>
921: </td>
922: <td align="left" valign="top">
923: <small><tt> $loadpercent $lt{'perc'}</tt></small>
924: </td>
925: </tr>
926: END
927: }
928: if ($uloadlim) {
929: $userloadrow = <<"END";
930: <tr>
931: <td align="left" valign="top">
932: <small><b>$lt{'userload'}: </b></small>
933: </td>
934: <td align="left" valign="top">
935: <small><tt> $userloadpercent $lt{'perc'}</tt></small>
936: </td>
937: </tr>
938: END
939: }
940: if (($version ne '') && ($version ne '<!-- VERSION -->')) {
941: $versionrow = <<"END";
942: <tr>
943: <td colspan="2" align="left">
944: <small>$version</small>
945: </td>
946: </tr>
947: END
948: }
949:
950: $r->print(<<ENDDOCUMENT);
951: <div style="float: left;">
952: <table border="0" cellspacing="0" cellpadding="0">
953: $domainrow
954: $serverrow
955: $loadrow
956: $userloadrow
957: $versionrow
958: </table>
959: </div>
960: <div style="float: right;">
961: $domainlogo
962: </div>
963: <br style="clear:both;" />
964: </div>
965:
966: <script type="text/javascript">
967: // <![CDATA[
968: // the if prevents the script error if the browser can not handle this
969: if ( document.client.uname ) { document.client.uname.focus(); }
970: // ]]>
971: </script>
972: $helpdeskscript
973:
974: ENDDOCUMENT
975: my %endargs = ( 'noredirectlink' => 1, );
976: $r->print(&Apache::loncommon::end_page(\%endargs));
977: return OK;
978: }
979:
980: sub check_loginvia {
1.177 raeburn 981: my ($domain,$lonhost,$lonidsdir,$balcookie,$linkprot) = @_;
1.176 raeburn 982: if ($domain eq '' || $lonhost eq '' || $lonidsdir eq '') {
1.160 kruse 983: return;
984: }
985: my %domconfhash = &Apache::loncommon::get_domainconf($domain);
986: my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
987: my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
988: my $output;
989: if ($loginvia ne '') {
990: my $noredirect;
1.182 raeburn 991: my $ip = &Apache::lonnet::get_requestor_ip();
1.160 kruse 992: if ($ip eq '127.0.0.1') {
993: $noredirect = 1;
994: } else {
995: if ($loginvia_exempt ne '') {
996: my @exempt = split(',',$loginvia_exempt);
997: if (grep(/^\Q$ip\E$/,@exempt)) {
998: $noredirect = 1;
999: }
1000: }
1001: }
1002: unless ($noredirect) {
1003: my ($newhost,$path);
1004: if ($loginvia =~ /:/) {
1005: ($newhost,$path) = split(':',$loginvia);
1006: } else {
1007: $newhost = $loginvia;
1008: }
1009: if ($newhost ne $lonhost) {
1010: if (&Apache::lonnet::hostname($newhost) ne '') {
1.176 raeburn 1011: if ($balcookie) {
1012: my ($balancer,$cookie) = split(/:/,$balcookie);
1013: if ($cookie =~ /^($match_domain)_($match_username)_([a-f0-9]+)$/) {
1014: my ($udom,$uname,$cookieid) = ($1,$2,$3);
1015: unless (&Apache::lonnet::delbalcookie($cookie,$balancer) eq 'ok') {
1016: if ((-d $lonidsdir) && (opendir(my $dh,$lonidsdir))) {
1017: while (my $filename=readdir($dh)) {
1018: if ($filename=~/^(\Q$uname\E_\d+_\Q$udom\E_$match_lonid)\.id$/) {
1019: my $handle = $1;
1020: my %hash =
1021: &Apache::lonnet::get_sessionfile_vars($handle,$lonidsdir,
1022: ['request.balancercookie',
1023: 'user.linkedenv']);
1024: if ($hash{'request.balancercookie'} eq "$balancer:$cookieid") {
1025: if (unlink("$lonidsdir/$filename")) {
1026: if (($hash{'user.linkedenv'} =~ /^[a-f0-9]+_linked$/) &&
1027: (-l "$lonidsdir/$hash{'user.linkedenv'}.id") &&
1028: (readlink("$lonidsdir/$hash{'user.linkedenv'}.id") eq "$lonidsdir/$filename")) {
1029: unlink("$lonidsdir/$hash{'user.linkedenv'}.id");
1030: }
1031: }
1032: }
1033: last;
1034: }
1035: }
1036: closedir($dh);
1037: }
1038: }
1039: }
1040: }
1.177 raeburn 1041: $output = &redirect_page($newhost,$path,$linkprot);
1.160 kruse 1042: }
1043: }
1044: }
1045: }
1046: return $output;
1047: }
1048:
1049: sub redirect_page {
1.177 raeburn 1050: my ($desthost,$path,$linkprot) = @_;
1.178 raeburn 1051: my $hostname = &Apache::lonnet::hostname($desthost);
1.160 kruse 1052: my $protocol = $Apache::lonnet::protocol{$desthost};
1053: $protocol = 'http' if ($protocol ne 'https');
1054: unless ($path =~ m{^/}) {
1055: $path = '/'.$path;
1056: }
1.178 raeburn 1057: my $url = $protocol.'://'.$hostname.$path;
1.160 kruse 1058: if ($env{'form.firsturl'} ne '') {
1.188 raeburn 1059: my $querystring;
1060: if ($env{'form.firsturl'} =~ /[^\x00-\xFF]/) {
1061: $querystring = &uri_escape_utf8($env{'form.firsturl'});
1062: } else {
1063: $querystring = &uri_escape($env{'form.firsturl'});
1064: }
1065: $querystring = &HTML::Entities::encode($querystring,"'");
1066: $url .='?firsturl='.$querystring
1.160 kruse 1067: }
1.177 raeburn 1068: if ($linkprot) {
1069: my $ltoken = &Apache::lonnet::tmpput({linkprot => $linkprot},$desthost);
1070: if ($ltoken) {
1.187 raeburn 1071: $url .= (($url =~ /\?/) ? '&' : '?').'ltoken='.$ltoken;
1.177 raeburn 1072: }
1073: }
1.160 kruse 1074: my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
1075: {'redirect' => [0,$url],});
1076: my $end_page = &Apache::loncommon::end_page();
1077: return $start_page.$end_page;
1078: }
1079:
1080: sub contactdisplay {
1081: my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
1082: $possdoms) = @_;
1083: my $contactblock;
1084: my $origmail;
1085: if (ref($possdoms) eq 'ARRAY') {
1086: if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
1087: $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
1088: }
1089: }
1090: my $requestmail =
1091: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
1092: $authdomain,$origmail);
1093: unless ($showhelpdesk eq '0') {
1094: if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
1095: $showhelpdesk = 1;
1096: } else {
1097: $showhelpdesk = 0;
1098: }
1099: }
1100: if ($servadm && $showadminmail) {
1101: $contactblock .= $$lt{'servadm'}.':<br />'.
1102: '<tt>'.$servadm.'</tt><br />';
1103: }
1104: if ($showhelpdesk) {
1105: $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
1106: my $thisurl = &escape('/adm/login');
1107: $$helpdeskscript = <<"ENDSCRIPT";
1108: <script type="text/javascript">
1109: // <![CDATA[
1110: function helpdesk() {
1111: var possdom = document.client.udom.value;
1112: var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
1113: if (codedom == '') {
1114: codedom = "$authdomain";
1115: }
1116: var querystr = "origurl=$thisurl&codedom="+codedom;
1117: document.location.href = "/adm/helpdesk?"+querystr;
1118: return;
1119: }
1120: // ]]>
1121: </script>
1122: ENDSCRIPT
1123: }
1124: return $contactblock;
1125: }
1126:
1127: sub forgotpwdisplay {
1128: my (%lt) = @_;
1129: my $prompt_for_resetpw = 1;
1130: if ($prompt_for_resetpw) {
1131: return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
1132: }
1133: return;
1134: }
1135:
1136: sub coursecatalog_link {
1137: my ($linkname) = @_;
1138: return <<"END";
1139: <a href="/adm/coursecatalog">$linkname</a>
1140: END
1141: }
1142:
1143: sub newuser_link {
1144: my ($linkname) = @_;
1145: return '<a href="/adm/createaccount">'.$linkname.'</a>';
1146: }
1147:
1148: 1;
1149: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>