1: # The LearningOnline Network
2: # User Authentication Module
3: #
4: # $Id: lonauth.pm,v 1.129 2013/12/20 14:54:34 raeburn Exp $
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonauth;
30:
31: use strict;
32: use LONCAPA;
33: use Apache::Constants qw(:common);
34: use CGI qw(:standard);
35: use DynaLoader; # for Crypt::DES version
36: use Crypt::DES;
37: use Apache::loncommon();
38: use Apache::lonnet;
39: use Apache::lonmenu();
40: use Apache::createaccount;
41: use Fcntl qw(:flock);
42: use Apache::lonlocal;
43: use Apache::File();
44: use HTML::Entities;
45:
46: # ------------------------------------------------------------ Successful login
47: sub success {
48: my ($r, $username, $domain, $authhost, $lowerurl, $extra_env,
49: $form) = @_;
50:
51: # ------------------------------------------------------------ Get cookie ready
52: my $cookie =
53: &Apache::loncommon::init_user_environment($r, $username, $domain,
54: $authhost, $form,
55: {'extra_env' => $extra_env,});
56:
57: my $public=($username eq 'public' && $domain eq 'public');
58:
59: if ($public or $lowerurl eq 'noredirect') { return $cookie; }
60:
61: # -------------------------------------------------------------------- Log this
62:
63: &Apache::lonnet::log($domain,$username,$authhost,
64: "Login $ENV{'REMOTE_ADDR'}");
65:
66: # ------------------------------------------------- Check for critical messages
67:
68: my @what=&Apache::lonnet::dump('critical',$domain,$username);
69: if ($what[0]) {
70: if (($what[0] ne 'con_lost') && ($what[0]!~/^error\:/)) {
71: $lowerurl='/adm/email?critical=display';
72: }
73: }
74:
75: # ------------------------------------------------------------ Get cookie ready
76: $cookie="lonID=$cookie; path=/";
77: # -------------------------------------------------------- Menu script and info
78: my $destination = $lowerurl;
79:
80: if (defined($form->{role})) {
81: my $envkey = 'user.role.'.$form->{role};
82: my $now=time;
83: my $then=$env{'user.login.time'};
84: my $refresh=$env{'user.refresh.time'};
85: my $update=$env{'user.update.time'};
86: if (!$update) {
87: $update = $then;
88: }
89: if (exists($env{$envkey})) {
90: my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus);
91: &Apache::lonnet::role_status($envkey,$update,$refresh,$now,\$role,\$where,
92: \$trolecode,\$tstatus,\$tstart,\$tend);
93: if ($tstatus eq 'is') {
94: $destination .= ($destination =~ /\?/) ? '&' : '?';
95: my $newrole = &HTML::Entities::encode($form->{role},'"<>&');
96: $destination .= 'selectrole=1&'.$newrole.'=1';
97: }
98: }
99: }
100: if (defined($form->{symb})) {
101: my $destsymb = $form->{symb};
102: $destination .= ($destination =~ /\?/) ? '&' : '?';
103: if ($destsymb =~ /___/) {
104: # FIXME Need to deal with encrypted symbs and urls as needed.
105: my ($map,$resid,$desturl)=split(/___/,$destsymb);
106: unless ($desturl=~/^(adm|editupload|public)/) {
107: $desturl = &Apache::lonnet::clutter($desturl);
108: }
109: $desturl = &HTML::Entities::encode($desturl,'"<>&');
110: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
111: $destination .= '&destinationurl='.$desturl.
112: '&destsymb='.$destsymb;
113: } else {
114: $destsymb = &HTML::Entities::encode($destsymb,'"<>&');
115: $destination .= '&destinationurl='.$destsymb;
116: }
117: }
118: if ($destination =~ m{^/adm/roles}) {
119: $destination .= ($destination =~ /\?/) ? '&' : '?';
120: $destination .= 'source=login';
121: }
122:
123: my $windowinfo = Apache::lonhtmlcommon::scripttag('self.name="loncapaclient";');
124: my $header = '<meta HTTP-EQUIV="Refresh" CONTENT="0; url='.$destination.'" />';
125: my $brcrum = [{'href' => '',
126: 'text' => 'Successful Login'},];
127: my $start_page=&Apache::loncommon::start_page('Successful Login',
128: $header,
129: {'bread_crumbs' => $brcrum,});
130: my $end_page =&Apache::loncommon::end_page();
131:
132: my $continuelink='<a href="'.$destination.'">'.&mt('Continue').'</a>';
133: # ------------------------------------------------- Output for successful login
134:
135: &Apache::loncommon::content_type($r,'text/html');
136: $r->header_out('Set-cookie' => $cookie);
137: $r->send_http_header;
138:
139: my %lt=&Apache::lonlocal::texthash(
140: 'wel' => 'Welcome',
141: 'pro' => 'Login problems?',
142: );
143: my $loginhelp = &loginhelpdisplay($domain);
144: if ($loginhelp) {
145: $loginhelp = '<p><a href="'.$loginhelp.'">'.$lt{'pro'}.'</a></p>';
146: }
147:
148: my $welcome = &mt('Welcome to the Learning[_1]Online[_2] Network with CAPA. Please wait while your session is being set up.','<i>','</i>');
149: $r->print(<<ENDSUCCESS);
150: $start_page
151: $windowinfo
152: <h1>$lt{'wel'}</h1>
153: $welcome
154: $loginhelp
155: $continuelink
156: $end_page
157: ENDSUCCESS
158: }
159:
160: # --------------------------------------------------------------- Failed login!
161:
162: sub failed {
163: my ($r,$message,$form) = @_;
164: (undef,undef,undef,my $clientmathml,my $clientunicode) =
165: &Apache::loncommon::decode_user_agent();
166: my $args = {};
167: if ($clientunicode && !$clientmathml) {
168: $args = {'browser.unicode' => 1};
169: }
170:
171: my $start_page = &Apache::loncommon::start_page('Unsuccessful Login',undef,$args);
172: my $uname = &Apache::loncommon::cleanup_html($form->{'uname'});
173: my $udom = &Apache::loncommon::cleanup_html($form->{'udom'});
174: if (&Apache::lonnet::domain($udom,'description') eq '') {
175: undef($udom);
176: }
177: my $retry = '/adm/login';
178: if ($uname eq $form->{'uname'}) {
179: $retry .= '?username='.$uname;
180: }
181: if ($udom) {
182: $retry .= (($retry=~/\?/)?'&':'?').'domain='.$udom;
183: }
184: if (exists($form->{role})) {
185: my $role = &Apache::loncommon::cleanup_html($form->{role});
186: if ($role ne '') {
187: $retry .= (($retry=~/\?/)?'&':'?').'role='.$role;
188: }
189: }
190: if (exists($form->{symb})) {
191: my $symb = &Apache::loncommon::cleanup_html($form->{symb});
192: if ($symb ne '') {
193: $retry .= (($retry=~/\?/)?'&':'?').'symb='.$symb;
194: }
195: }
196: my $end_page = &Apache::loncommon::end_page();
197: &Apache::loncommon::content_type($r,'text/html');
198: $r->send_http_header;
199: my $loginhelp = &loginhelpdisplay($udom);
200: if ($loginhelp) {
201: $loginhelp = '<p><a href="'.$loginhelp.'">'.&mt('Login problems?').'</a></p>';
202: }
203:
204: $r->print(
205: $start_page
206: .'<h1>'.&mt('Sorry ...').'</h1>'
207: .'<p class="LC_warning">'.&mt($message).'</p>'
208: .'<p>'.&mt('Please [_1]log in again[_2].','<a href="'.$retry.'">','</a>')
209: .'</p>'
210: .$loginhelp
211: .$end_page
212: );
213: }
214:
215: # ------------------------------------------------------------------ Rerouting!
216:
217: sub reroute {
218: my ($r) = @_;
219: &Apache::loncommon::content_type($r,'text/html');
220: $r->send_http_header;
221: my $msg='<b>'.&mt('Sorry ...').'</b><br />'
222: .&mt('Please [_1]log in again[_2].');
223: &Apache::loncommon::simple_error_page($r,'Rerouting',$msg,{'no_auto_mt_msg' => 1});
224: }
225:
226: # ---------------------------------------------------------------- Main handler
227:
228: sub handler {
229: my $r = shift;
230: my $londocroot = $r->dir_config('lonDocRoot');
231: my $form;
232: # Are we re-routing?
233: if (-e "$londocroot/lon-status/reroute.txt") {
234: &reroute($r);
235: return OK;
236: }
237:
238: &Apache::lonlocal::get_language_handle($r);
239:
240: # -------------------------------- Prevent users from attempting to login twice
241: my $handle = &Apache::lonnet::check_for_valid_session($r);
242: if ($handle ne '') {
243: my $lonidsdir=$r->dir_config('lonIDsDir');
244: if ($handle=~/^publicuser\_/) {
245: # For "public user" - remove it, we apparently really want to login
246: unlink($r->dir_config('lonIDsDir')."/$handle.id");
247: } else {
248: # Indeed, a valid token is found
249: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
250: &Apache::loncommon::content_type($r,'text/html');
251: $r->send_http_header;
252: my $start_page =
253: &Apache::loncommon::start_page('Already logged in');
254: my $end_page =
255: &Apache::loncommon::end_page();
256: my $dest = '/adm/roles';
257: if ($env{'form.firsturl'} ne '') {
258: $dest = $env{'form.firsturl'};
259: }
260: $r->print(
261: $start_page
262: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
263: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].'
264: ,'<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>')
265: .'</p>'
266: .$end_page
267: );
268: return OK;
269: }
270: }
271:
272: # ---------------------------------------------------- No valid token, continue
273:
274:
275: my $buffer;
276: if ($r->header_in('Content-length') > 0) {
277: $r->read($buffer,$r->header_in('Content-length'),0);
278: }
279: my %form;
280: foreach my $pair (split(/&/,$buffer)) {
281: my ($name,$value) = split(/=/,$pair);
282: $value =~ tr/+/ /;
283: $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
284: $form{$name}=$value;
285: }
286:
287: if ((!$form{'uname'}) || (!$form{'upass0'}) || (!$form{'udom'})) {
288: &failed($r,'Username, password and domain need to be specified.',
289: \%form);
290: return OK;
291: }
292:
293: # split user logging in and "su"-user
294:
295: ($form{'uname'},$form{'suname'})=split(/\:/,$form{'uname'});
296: $form{'uname'} = &LONCAPA::clean_username($form{'uname'});
297: $form{'suname'}= &LONCAPA::clean_username($form{'suname'});
298: $form{'udom'} = &LONCAPA::clean_domain( $form{'udom'});
299:
300: my $role = $r->dir_config('lonRole');
301: my $domain = $r->dir_config('lonDefDomain');
302: my $prodir = $r->dir_config('lonUsersDir');
303: my $contact_name = &mt('LON-CAPA helpdesk');
304:
305: # ---------------------------------------- Get the information from login token
306:
307: my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'},
308: $form{'serverid'});
309:
310: my %sessiondata;
311: if ($form{'iptoken'}) {
312: %sessiondata = &Apache::lonnet::tmpget($form{'iptoken'});
313: my $delete = &Apache::lonnet::tmpdel($form{'token'});
314: }
315:
316: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') ||
317: ($tmpinfo eq 'no_such_host')) {
318: &failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form);
319: return OK;
320: } else {
321: my $reply = &Apache::lonnet::reply('tmpdel:'.$form{'logtoken'},
322: $form{'serverid'});
323: if ( $reply ne 'ok' ) {
324: &failed($r,'Session could not be opened.',\%form);
325: &Apache::lonnet::logthis("ERROR got a reply of $reply when trying to contact ". $form{'serverid'}." to get login token");
326: return OK;
327: }
328: }
329:
330: if (!&Apache::lonnet::domain($form{'udom'})) {
331: &failed($r,'The domain you provided is not a valid LON-CAPA domain.',\%form);
332: return OK;
333: }
334:
335: my ($key,$firsturl,$rolestr,$symbstr)=split(/&/,$tmpinfo);
336: if ($rolestr) {
337: $rolestr = &unescape($rolestr);
338: }
339: if ($symbstr) {
340: $symbstr= &unescape($symbstr);
341: }
342: if ($rolestr =~ /^role=/) {
343: (undef,$form{'role'}) = split('=',$rolestr);
344: }
345: if ($symbstr =~ /^symb=/) {
346: (undef,$form{'symb'}) = split('=',$symbstr);
347: }
348:
349: my $keybin=pack("H16",$key);
350:
351: my $cipher;
352: if ($Crypt::DES::VERSION>=2.03) {
353: $cipher=new Crypt::DES $keybin;
354: }
355: else {
356: $cipher=new DES $keybin;
357: }
358: my $upass='';
359: for (my $i=0;$i<=2;$i++) {
360: my $chunk=
361: $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},0,16))));
362:
363: $chunk.=
364: $cipher->decrypt(unpack("a8",pack("H16",substr($form{'upass'.$i},16,16))));
365:
366: $chunk=substr($chunk,1,ord(substr($chunk,0,1)));
367: $upass.=$chunk;
368: }
369:
370: # ---------------------------------------------------------------- Authenticate
371:
372: my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'});
373: my ($cancreate,$statustocreate) =
374: &Apache::createaccount::get_creation_controls($form{'udom'},$domconfig{'usercreation'});
375: my $defaultauth;
376: if (ref($cancreate) eq 'ARRAY') {
377: if (grep(/^login$/,@{$cancreate})) {
378: $defaultauth = 1;
379: }
380: }
381: my $clientcancheckhost = 1;
382: my $authhost=Apache::lonnet::authenticate($form{'uname'},$upass,
383: $form{'udom'},$defaultauth,
384: $clientcancheckhost);
385:
386: # --------------------------------------------------------------------- Failed?
387:
388: if ($authhost eq 'no_host') {
389: &failed($r,'Username and/or password could not be authenticated.',
390: \%form);
391: return OK;
392: } elsif ($authhost eq 'no_account_on_host') {
393: if ($defaultauth) {
394: my $domdesc = &Apache::lonnet::domain($form{'udom'},'description');
395: unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) {
396: return OK;
397: }
398: my $start_page =
399: &Apache::loncommon::start_page('Create a user account in LON-CAPA');
400: my $lonhost = $r->dir_config('lonHostID');
401: my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
402: my $contacts =
403: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
404: $form{'udom'},$origmail);
405: my ($contact_email) = split(',',$contacts);
406: my $output =
407: &Apache::createaccount::username_check($form{'uname'},$form{'udom'},
408: $domdesc,'',$lonhost,
409: $contact_email,$contact_name,
410: undef,$statustocreate);
411: &Apache::loncommon::content_type($r,'text/html');
412: $r->send_http_header;
413: &Apache::createaccount::print_header($r,$start_page);
414: $r->print('<h3>'.&mt('Account creation').'</h3>'.
415: &mt('Although your username and password were authenticated, you do not currently have a LON-CAPA account at this institution.').'<br />'.
416: $output.&Apache::loncommon::end_page());
417: return OK;
418: } else {
419: &failed($r,'Although your username and password were authenticated, you do not currently have a LON-CAPA account in this domain, and you are not permitted to create one.',\%form);
420: return OK;
421: }
422: }
423:
424: if (($firsturl eq '') ||
425: ($firsturl=~/^\/adm\/(logout|remote)/)) {
426: $firsturl='/adm/roles';
427: }
428:
429: my $hosthere;
430: if ($form{'iptoken'}) {
431: if (($sessiondata{'domain'} eq $form{'udom'}) &&
432: ($sessiondata{'username'} eq $form{'uname'})) {
433: $hosthere = 1;
434: }
435: }
436:
437: # --------------------------------- Are we attempting to login as somebody else?
438: if ($form{'suname'}) {
439: # ------------ see if the original user has enough privileges to pull this stunt
440: if (&Apache::lonnet::privileged($form{'uname'},$form{'udom'})) {
441: # ---------------------------------------------------- see if the su-user exists
442: unless (&Apache::lonnet::homeserver($form{'suname'},$form{'udom'})
443: eq 'no_host') {
444: &Apache::lonnet::logthis(&Apache::lonnet::homeserver($form{'suname'},$form{'udom'}));
445: # ------------------------------ see if the su-user is not too highly privileged
446: unless (&Apache::lonnet::privileged($form{'suname'},$form{'udom'})) {
447: # -------------------------------------------------------- actually switch users
448: &Apache::lonnet::logperm('User '.$form{'uname'}.' at '.$form{'udom'}.
449: ' logging in as '.$form{'suname'});
450: $form{'uname'}=$form{'suname'};
451: } else {
452: &Apache::lonnet::logthis('Attempted switch user to privileged user');
453: }
454: }
455: } else {
456: &Apache::lonnet::logthis('Non-privileged user attempting switch user');
457: }
458: }
459:
460: my ($is_balancer,$otherserver);
461:
462: unless ($hosthere) {
463: ($is_balancer,$otherserver) =
464: &Apache::lonnet::check_loadbalancing($form{'uname'},$form{'udom'});
465: }
466:
467: if ($is_balancer) {
468: if (!$otherserver) {
469: ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
470: }
471: if ($otherserver) {
472: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
473: \%form);
474: $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);
475: } else {
476: $r->print(&noswitch());
477: }
478: return OK;
479: } else {
480: if (!&check_can_host($r,\%form,$authhost)) {
481: my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'});
482: if ($otherserver) {
483: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef,
484: \%form);
485: $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl);
486: } else {
487: $r->print(&noswitch());
488: }
489: return OK;
490: }
491:
492: # ------------------------------------------------------- Do the load balancing
493:
494: # ---------------------------------------------------------- Determine own load
495: my $loadlim = $r->dir_config('lonLoadLim');
496: my $loadavg;
497: {
498: my $loadfile=Apache::File->new('/proc/loadavg');
499: $loadavg=<$loadfile>;
500: }
501: $loadavg =~ s/\s.*//g;
502: my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
503: my $userloadpercent=&Apache::lonnet::userload();
504:
505: # ---------------------------------------------------------- Are we overloaded?
506: if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
507: my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'});
508: if (!$unloaded) {
509: ($unloaded) = &Apache::lonnet::choose_server($form{'udom'});
510: }
511: if ($unloaded) {
512: &success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',
513: undef,\%form);
514: $r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl);
515: return OK;
516: }
517: }
518: &success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef,
519: \%form);
520: return OK;
521: }
522: }
523:
524: sub check_can_host {
525: my ($r,$form,$authhost,$domdesc) = @_;
526: return unless (ref($form) eq 'HASH');
527: my $canhost = 1;
528: my $lonhost = $r->dir_config('lonHostID');
529: my $udom = $form->{'udom'};
530: my @intdoms;
531: my $internet_names = &Apache::lonnet::get_internet_names($lonhost);
532: if (ref($internet_names) eq 'ARRAY') {
533: @intdoms = @{$internet_names};
534: }
535: my $uprimary_id = &Apache::lonnet::domain($udom,'primary');
536: my $uint_dom = &Apache::lonnet::internet_dom($uprimary_id);
537: unless ($uint_dom ne '' && grep(/^\Q$uint_dom\E$/,@intdoms)) {
538: my $machine_dom = &Apache::lonnet::host_domain($lonhost);
539: my $hostname = &Apache::lonnet::hostname($lonhost);
540: my $serverhomeID = &Apache::lonnet::get_server_homeID($hostname);
541: my $serverhomedom = &Apache::lonnet::host_domain($serverhomeID);
542: my %defdomdefaults = &Apache::lonnet::get_domain_defaults($serverhomedom);
543: my %udomdefaults = &Apache::lonnet::get_domain_defaults($udom);
544: my $loncaparev;
545: if ($authhost eq 'no_account_on_host') {
546: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom);
547: } else {
548: $loncaparev = &Apache::lonnet::get_server_loncaparev($machine_dom,$lonhost);
549: }
550: $canhost = &Apache::lonnet::can_host_session($udom,$lonhost,$loncaparev,
551: $udomdefaults{'remotesessions'},
552: $defdomdefaults{'hostedsessions'});
553: }
554: unless ($canhost) {
555: if ($authhost eq 'no_account_on_host') {
556: my $checkloginvia = 1;
557: my ($login_host,$hostname) =
558: &Apache::lonnet::choose_server($udom,$checkloginvia);
559: &Apache::loncommon::content_type($r,'text/html');
560: $r->send_http_header;
561: if ($login_host ne '') {
562: my $protocol = $Apache::lonnet::protocol{$login_host};
563: $protocol = 'http' if ($protocol ne 'https');
564: my $newurl = $protocol.'://'.$hostname.'/adm/createaccount';
565: $r->print(&Apache::loncommon::start_page('Create a user account in LON-CAPA').
566: '<h3>'.&mt('Account creation').'</h3>'.
567: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
568: '<p>'.&mt('You will be able to create one by logging into a LON-CAPA server within the [_1] domain.',$domdesc).'</p>'.
569: '<p>'.&mt('[_1]Log in[_2]','<a href="'.$newurl.'">','</a>').
570: &Apache::loncommon::end_page());
571: } else {
572: $r->print(&Apache::loncommon::start_page('Access to LON-CAPA unavailable').
573: '<h3>'.&mt('Account creation unavailable').'</h3>'.
574: &mt('You do not currently have a LON-CAPA account at this institution.').'<br />'.
575: '<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'.
576: &Apache::loncommon::end_page());
577: }
578: } else {
579: &success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef,
580: $form);
581: my ($otherserver) = &Apache::lonnet::choose_server($udom);
582: $r->internal_redirect('/adm/switchserver?otherserver='.$otherserver);
583: }
584: }
585: return $canhost;
586: }
587:
588: sub noswitch {
589: my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable').
590: '<h3>'.&mt('Session unavailable').'</h3>'.
591: &mt('This LON-CAPA server is unable to host your session.').'<br />'.
592: '<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'.
593: &Apache::loncommon::end_page();
594: return $result;
595: }
596:
597: sub loginhelpdisplay {
598: my ($authdomain) = @_;
599: my $login_help = 1;
600: my $lang = &Apache::lonlocal::current_language();
601: if ($login_help) {
602: my $dom = $authdomain;
603: if ($dom eq '') {
604: $dom = &Apache::lonnet::default_login_domain();
605: }
606: my %domconfhash = &Apache::loncommon::get_domainconf($dom);
607: my $loginhelp_url;
608: if ($lang) {
609: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_'.$lang};
610: if ($loginhelp_url ne '') {
611: return $loginhelp_url;
612: }
613: }
614: $loginhelp_url = $domconfhash{$dom.'.login.helpurl_nolang'};
615: if ($loginhelp_url ne '') {
616: return $loginhelp_url;
617: } else {
618: return '/adm/loginproblems.html';
619: }
620: }
621: return;
622: }
623:
624: 1;
625: __END__
626:
627:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>