1: # The LearningOnline Network
2: # Login Screen
3: #
4: # $Id: lonlogin.pm,v 1.158 2013/11/26 03:17:09 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::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:
42: sub handler {
43: my $r = shift;
44:
45: &Apache::loncommon::get_unprocessed_cgi
46: (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
47: $ENV{'REDIRECT_QUERY_STRING'}),
48: ['interface','username','domain','firsturl','localpath','localres',
49: 'token','role','symb','iptoken']);
50: if (!defined($env{'form.firsturl'})) {
51: &Apache::lonacc::get_posted_cgi($r,['firsturl']);
52: }
53:
54: # -- check if they are a migrating user
55: if (defined($env{'form.token'})) {
56: return &Apache::migrateuser::handler($r);
57: }
58:
59: &Apache::loncommon::no_cache($r);
60: &Apache::lonlocal::get_language_handle($r);
61: &Apache::loncommon::content_type($r,'text/html');
62: $r->send_http_header;
63: return OK if $r->header_only;
64:
65:
66: # Are we re-routing?
67: my $londocroot = $r->dir_config('lonDocRoot');
68: if (-e "$londocroot/lon-status/reroute.txt") {
69: &Apache::lonauth::reroute($r);
70: return OK;
71: }
72:
73: $env{'form.firsturl'} =~ s/(`)/'/g;
74:
75: # -------------------------------- Prevent users from attempting to login twice
76: my $handle = &Apache::lonnet::check_for_valid_session($r);
77: if ($handle ne '') {
78: my $lonidsdir=$r->dir_config('lonIDsDir');
79: if ($handle=~/^publicuser\_/) {
80: # For "public user" - remove it, we apparently really want to login
81: unlink($r->dir_config('lonIDsDir')."/$handle.id");
82: } else {
83: # Indeed, a valid token is found
84: &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle);
85: my $start_page =
86: &Apache::loncommon::start_page('Already logged in');
87: my $end_page =
88: &Apache::loncommon::end_page();
89: my $dest = '/adm/roles';
90: if ($env{'form.firsturl'} ne '') {
91: $dest = $env{'form.firsturl'};
92: }
93: $r->print(
94: $start_page
95: .'<p class="LC_warning">'.&mt('You are already logged in!').'</p>'
96: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
97: '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
98: .$end_page
99: );
100: return OK;
101: }
102: }
103:
104: # ---------------------------------------------------- No valid token, continue
105:
106: # ---------------------------- Not possible to really login to domain "public"
107: if ($env{'form.domain'} eq 'public') {
108: $env{'form.domain'}='';
109: $env{'form.username'}='';
110: }
111:
112: # ------ Is this page requested because /adm/migrateuser detected an IP change?
113: my %sessiondata;
114: if ($env{'form.iptoken'}) {
115: %sessiondata = &Apache::lonnet::tmpget($env{'form.iptoken'});
116: my $delete = &Apache::lonnet::tmpdel($env{'form.token'});
117: }
118: # ----------------------------------------------------------- Process Interface
119: $env{'form.interface'}=~s/\W//g;
120:
121: (undef,undef,undef,undef,undef,undef,my $clientmobile) =
122: &Apache::loncommon::decode_user_agent();
123:
124: my $iconpath=
125: &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
126:
127: my $lonhost = $r->dir_config('lonHostID');
128: my $domain = &Apache::lonnet::default_login_domain();
129: if ($lonhost ne '') {
130: unless ($sessiondata{'sessionserver'}) {
131: my $redirect = &check_loginvia($domain,$lonhost);
132: if ($redirect) {
133: $r->print($redirect);
134: return OK;
135: }
136: }
137: }
138:
139: if (($sessiondata{'domain'}) &&
140: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
141: $domain=$sessiondata{'domain'};
142: } elsif (($env{'form.domain'}) &&
143: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
144: $domain=$env{'form.domain'};
145: }
146:
147: my $role = $r->dir_config('lonRole');
148: my $loadlim = $r->dir_config('lonLoadLim');
149: my $uloadlim= $r->dir_config('lonUserLoadLim');
150: my $servadm = $r->dir_config('lonAdmEMail');
151: my $tabdir = $r->dir_config('lonTabDir');
152: my $include = $r->dir_config('lonIncludes');
153: my $expire = $r->dir_config('lonExpire');
154: my $version = $r->dir_config('lonVersion');
155: my $host_name = &Apache::lonnet::hostname($lonhost);
156:
157: # --------------------------------------------- Default values for login fields
158:
159: my ($authusername,$authdomain);
160: if ($sessiondata{'username'}) {
161: $authusername=$sessiondata{'username'};
162: } else {
163: $env{'form.username'} = &Apache::loncommon::cleanup_html($env{'form.username'});
164: $authusername=($env{'form.username'}?$env{'form.username'}:'');
165: }
166: if ($sessiondata{'domain'}) {
167: $authdomain=$sessiondata{'domain'};
168: } else {
169: $env{'form.domain'} = &Apache::loncommon::cleanup_html($env{'form.domain'});
170: $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
171: }
172:
173: # ---------------------------------------------------------- Determine own load
174: my $loadavg;
175: {
176: my $loadfile=Apache::File->new('/proc/loadavg');
177: $loadavg=<$loadfile>;
178: }
179: $loadavg =~ s/\s.*//g;
180:
181: my ($loadpercent,$userloadpercent);
182: if ($loadlim) {
183: $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
184: }
185: if ($uloadlim) {
186: $userloadpercent=&Apache::lonnet::userload();
187: }
188:
189: my $firsturl=
190: ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
191:
192: # ----------------------------------------------------------- Get announcements
193: my $announcements=&Apache::lonnet::getannounce();
194: # -------------------------------------------------------- Set login parameters
195:
196: my @hexstr=('0','1','2','3','4','5','6','7',
197: '8','9','a','b','c','d','e','f');
198: my $lkey='';
199: for (0..7) {
200: $lkey.=$hexstr[rand(15)];
201: }
202:
203: my $ukey='';
204: for (0..7) {
205: $ukey.=$hexstr[rand(15)];
206: }
207:
208: my $lextkey=hex($lkey);
209: if ($lextkey>2147483647) { $lextkey-=4294967296; }
210:
211: my $uextkey=hex($ukey);
212: if ($uextkey>2147483647) { $uextkey-=4294967296; }
213:
214: # -------------------------------------------------------- Store away log token
215: my $tokenextras;
216: if ($env{'form.role'}) {
217: $tokenextras = '&role='.&escape($env{'form.role'});
218: }
219: if ($env{'form.symb'}) {
220: if (!$tokenextras) {
221: $tokenextras = '&';
222: }
223: $tokenextras .= '&symb='.&escape($env{'form.symb'});
224: }
225: my $logtoken=Apache::lonnet::reply(
226: 'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
227: $lonhost);
228:
229: # -- If we cannot talk to ourselves, or hostID does not map to a hostname
230: # we are in serious trouble
231:
232: if (($logtoken eq 'con_lost') || ($logtoken eq 'no_such_host')) {
233: if ($logtoken eq 'no_such_host') {
234: &Apache::lonnet::logthis('No valid logtoken for log-in page -- unable to determine hostname for hostID: '.$lonhost.'. Check entry in hosts.tab');
235: }
236: my $spares='';
237: my $last;
238: foreach my $hostid (sort
239: {
240: &Apache::lonnet::hostname($a) cmp
241: &Apache::lonnet::hostname($b);
242: }
243: keys(%Apache::lonnet::spareid)) {
244: next if ($hostid eq $lonhost);
245: my $hostname = &Apache::lonnet::hostname($hostid);
246: next if (($last eq $hostname) || ($hostname eq ''));
247: $spares.='<br /><font size="+1"><a href="http://'.
248: $hostname.
249: '/adm/login?domain='.$authdomain.'">'.
250: $hostname.'</a>'.
251: ' '.&mt('(preferred)').'</font>'.$/;
252: $last=$hostname;
253: }
254: if ($spares) {
255: $spares.= '<br />';
256: }
257: my %all_hostnames = &Apache::lonnet::all_hostnames();
258: foreach my $hostid (sort
259: {
260: &Apache::lonnet::hostname($a) cmp
261: &Apache::lonnet::hostname($b);
262: }
263: keys(%all_hostnames)) {
264: next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
265: my $hostname = &Apache::lonnet::hostname($hostid);
266: next if (($last eq $hostname) || ($hostname eq ''));
267: $spares.='<br /><a href="http://'.
268: $hostname.
269: '/adm/login?domain='.$authdomain.'">'.
270: $hostname.'</a>';
271: $last=$hostname;
272: }
273: $r->print(
274: '<html>'
275: .'<head><title>'
276: .&mt('The LearningOnline Network with CAPA')
277: .'</title></head>'
278: .'<body bgcolor="#FFFFFF">'
279: .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
280: .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
281: .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>');
282: if ($spares) {
283: $r->print('<p>'.&mt('Please attempt to login to one of the following servers:')
284: .'</p>'
285: .$spares);
286: }
287: $r->print('</body>'
288: .'</html>'
289: );
290: return OK;
291: }
292:
293: # ----------------------------------------------- Apparently we are in business
294: $servadm=~s/\,/\<br \/\>/g;
295:
296: # ----------------------------------------------------------- Front page design
297: my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
298: my $font=&Apache::loncommon::designparm('login.font',$domain);
299: my $link=&Apache::loncommon::designparm('login.link',$domain);
300: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
301: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
302: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
303: my $loginbox_bg=&Apache::loncommon::designparm('login.sidebg',$domain);
304: my $loginbox_header_bgcol=&Apache::loncommon::designparm('login.bgcol',$domain);
305: my $loginbox_header_textcol=&Apache::loncommon::designparm('login.textcol',$domain);
306: my $logo=&Apache::loncommon::designparm('login.logo',$domain);
307: my $img=&Apache::loncommon::designparm('login.img',$domain);
308: my $domainlogo=&Apache::loncommon::domainlogo($domain);
309: my $showbanner = 1;
310: my $showmainlogo = 1;
311: if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
312: $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
313: }
314: if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
315: $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
316: }
317: my $showadminmail;
318: my @possdoms = &Apache::lonnet::current_machine_domains();
319: if (grep(/^\Q$domain\E$/,@possdoms)) {
320: $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
321: }
322: my $showcoursecat =
323: &Apache::loncommon::designparm('login.coursecatalog',$domain);
324: my $shownewuserlink =
325: &Apache::loncommon::designparm('login.newuser',$domain);
326: my $showhelpdesk =
327: &Apache::loncommon::designparm('login.helpdesk',$domain);
328: my $now=time;
329: my $js = (<<ENDSCRIPT);
330:
331: <script type="text/javascript" language="JavaScript">
332: // <![CDATA[
333: function send()
334: {
335: this.document.server.elements.uname.value
336: =this.document.client.elements.uname.value;
337:
338: this.document.server.elements.udom.value
339: =this.document.client.elements.udom.value;
340:
341: uextkey=this.document.client.elements.uextkey.value;
342: lextkey=this.document.client.elements.lextkey.value;
343: initkeys();
344:
345: this.document.server.elements.upass0.value
346: =crypted(this.document.client.elements.upass$now.value.substr(0,15));
347: this.document.server.elements.upass1.value
348: =crypted(this.document.client.elements.upass$now.value.substr(15,15));
349: this.document.server.elements.upass2.value
350: =crypted(this.document.client.elements.upass$now.value.substr(30,15));
351:
352: this.document.client.elements.uname.value='';
353: this.document.client.elements.upass$now.value='';
354:
355: this.document.server.submit();
356: return false;
357: }
358:
359: function enableInput() {
360: this.document.client.elements.upass$now.removeAttribute("readOnly");
361: this.document.client.elements.uname.removeAttribute("readOnly");
362: this.document.client.elements.udom.removeAttribute("readOnly");
363: return;
364: }
365:
366: // ]]>
367: </script>
368:
369: ENDSCRIPT
370:
371: # --------------------------------------------------- Print login screen header
372:
373: my %add_entries = (
374: bgcolor => "$mainbg",
375: text => "$font",
376: link => "$link",
377: vlink => "$vlink",
378: alink => "$alink",
379: onload => 'javascript:enableInput();',);
380:
381: $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
382: { 'redirect' => [$expire,'/adm/roles'],
383: 'add_entries' => \%add_entries,
384: 'only_body' => 1,}));
385:
386: # ----------------------------------------------------------------------- Texts
387:
388: my %lt=&Apache::lonlocal::texthash(
389: 'un' => 'Username',
390: 'pw' => 'Password',
391: 'dom' => 'Domain',
392: 'perc' => 'percent',
393: 'load' => 'Server Load',
394: 'userload' => 'User Load',
395: 'catalog' => 'Course/Community Catalog',
396: 'log' => 'Log in',
397: 'help' => 'Log-in Help',
398: 'serv' => 'Server',
399: 'servadm' => 'Server Administration',
400: 'helpdesk' => 'Contact Helpdesk',
401: 'forgotpw' => 'Forgot password?',
402: 'newuser' => 'New User?',
403: );
404: # -------------------------------------------------- Change password field name
405:
406: my $forgotpw = &forgotpwdisplay(%lt);
407: $forgotpw .= '<br />' if $forgotpw;
408: my $loginhelp = &Apache::lonauth::loginhelpdisplay($authdomain);
409: if ($loginhelp) {
410: $loginhelp = '<a href="'.$loginhelp.'">'.$lt{'help'}.'</a><br />';
411: }
412:
413: # ---------------------------------------------------- Serve out DES JavaScript
414: {
415: my $jsh=Apache::File->new($include."/londes.js");
416: $r->print(<$jsh>);
417: }
418: # ---------------------------------------------------------- Serve rest of page
419:
420: $r->print(
421: '<div class="LC_Box"'
422: .' style="margin:0 auto; padding:10px; width:90%; height: auto; background-color:#FFFFFF;">'
423: );
424:
425: $r->print(<<ENDSERVERFORM);
426: <form name="server" action="/adm/authenticate" method="post" target="_top">
427: <input type="hidden" name="logtoken" value="$logtoken" />
428: <input type="hidden" name="serverid" value="$lonhost" />
429: <input type="hidden" name="uname" value="" />
430: <input type="hidden" name="upass0" value="" />
431: <input type="hidden" name="upass1" value="" />
432: <input type="hidden" name="upass2" value="" />
433: <input type="hidden" name="udom" value="" />
434: <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
435: <input type="hidden" name="localres" value="$env{'form.localres'}" />
436: </form>
437: ENDSERVERFORM
438: my $coursecatalog;
439: if (($showcoursecat eq '') || ($showcoursecat)) {
440: $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
441: }
442: my $newuserlink;
443: if ($shownewuserlink) {
444: $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
445: }
446: my $logintitle =
447: '<h2 class="LC_hcell"'
448: .' style="background:'.$loginbox_header_bgcol.';'
449: .' color:'.$loginbox_header_textcol.'">'
450: .$lt{'log'}
451: .'</h2>';
452:
453: my $noscript_warning='<noscript><span class="LC_warning"><b>'
454: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
455: .'</b></span></noscript>';
456: my $helpdeskscript;
457: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
458: $authdomain,\$helpdeskscript,
459: $showhelpdesk,\@possdoms);
460:
461: my $mobileargs;
462: if ($clientmobile) {
463: $mobileargs = 'autocapitalize="off" autocorrect="off"';
464: }
465: my $loginform=(<<LFORM);
466: <form name="client" action="" onsubmit="return(send())">
467: <input type="hidden" name="lextkey" value="$lextkey" />
468: <input type="hidden" name="uextkey" value="$uextkey" />
469: <b><label for="uname">$lt{'un'}</label>:</b><br />
470: <input type="text" name="uname" id="uname" size="15" value="$authusername" readonly="readonly" $mobileargs /><br />
471: <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
472: <input type="password" name="upass$now" id="upass$now" size="15" readonly="readonly" /><br />
473: <b><label for="udom">$lt{'dom'}</label>:</b><br />
474: <input type="text" name="udom" id="udom" size="15" value="$authdomain" readonly="readonly" $mobileargs /><br />
475: <input type="submit" value="$lt{'log'}" />
476: </form>
477: LFORM
478:
479: if ($showbanner) {
480: $r->print(<<HEADER);
481: <!-- The LON-CAPA Header -->
482: <div style="background:$pgbg;margin:0;width:100%;">
483: <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
484: </div>
485: HEADER
486: }
487: $r->print(<<ENDTOP);
488: <div style="float:left;margin-top:0;">
489: <div class="LC_Box" style="background:$loginbox_bg;">
490: $logintitle
491: $loginform
492: $noscript_warning
493: </div>
494:
495: <div class="LC_Box" style="padding-top: 10px;">
496: $loginhelp
497: $forgotpw
498: $contactblock
499: $newuserlink
500: $coursecatalog
501: </div>
502: </div>
503:
504: <div>
505: ENDTOP
506: if ($showmainlogo) {
507: $r->print(' <img src="'.$logo.'" alt="" />'."\n");
508: }
509: $r->print(<<ENDTOP);
510: $announcements
511: </div>
512: <hr style="clear:both;" />
513: ENDTOP
514: my ($domainrow,$serverrow,$loadrow,$userloadrow,$versionrow);
515: $domainrow = <<"END";
516: <tr>
517: <td align="left" valign="top">
518: <small><b>$lt{'dom'}: </b></small>
519: </td>
520: <td align="left" valign="top">
521: <small><tt> $domain</tt></small>
522: </td>
523: </tr>
524: END
525: $serverrow = <<"END";
526: <tr>
527: <td align="left" valign="top">
528: <small><b>$lt{'serv'}: </b></small>
529: </td>
530: <td align="left" valign="top">
531: <small><tt> $lonhost ($role)</tt></small>
532: </td>
533: </tr>
534: END
535: if ($loadlim) {
536: $loadrow = <<"END";
537: <tr>
538: <td align="left" valign="top">
539: <small><b>$lt{'load'}: </b></small>
540: </td>
541: <td align="left" valign="top">
542: <small><tt> $loadpercent $lt{'perc'}</tt></small>
543: </td>
544: </tr>
545: END
546: }
547: if ($uloadlim) {
548: $userloadrow = <<"END";
549: <tr>
550: <td align="left" valign="top">
551: <small><b>$lt{'userload'}: </b></small>
552: </td>
553: <td align="left" valign="top">
554: <small><tt> $userloadpercent $lt{'perc'}</tt></small>
555: </td>
556: </tr>
557: END
558: }
559: if (($version ne '') && ($version ne '<!-- VERSION -->')) {
560: $versionrow = <<"END";
561: <tr>
562: <td colspan="2" align="left">
563: <small>$version</small>
564: </td>
565: </tr>
566: END
567: }
568:
569: $r->print(<<ENDDOCUMENT);
570: <div style="float: left;">
571: <table border="0" cellspacing="0" cellpadding="0">
572: $domainrow
573: $serverrow
574: $loadrow
575: $userloadrow
576: $versionrow
577: </table>
578: </div>
579: <div style="float: right;">
580: $domainlogo
581: </div>
582: <br style="clear:both;" />
583: </div>
584:
585: <script type="text/javascript">
586: // <![CDATA[
587: // the if prevents the script error if the browser can not handle this
588: if ( document.client.uname ) { document.client.uname.focus(); }
589: // ]]>
590: </script>
591: $helpdeskscript
592:
593: ENDDOCUMENT
594: my %endargs = ( 'noredirectlink' => 1, );
595: $r->print(&Apache::loncommon::end_page(\%endargs));
596: return OK;
597: }
598:
599: sub check_loginvia {
600: my ($domain,$lonhost) = @_;
601: if ($domain eq '' || $lonhost eq '') {
602: return;
603: }
604: my %domconfhash = &Apache::loncommon::get_domainconf($domain);
605: my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
606: my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
607: my $output;
608: if ($loginvia ne '') {
609: my $noredirect;
610: my $ip = $ENV{'REMOTE_ADDR'};
611: if ($ip eq '127.0.0.1') {
612: $noredirect = 1;
613: } else {
614: if ($loginvia_exempt ne '') {
615: my @exempt = split(',',$loginvia_exempt);
616: if (grep(/^\Q$ip\E$/,@exempt)) {
617: $noredirect = 1;
618: }
619: }
620: }
621: unless ($noredirect) {
622: my ($newhost,$path);
623: if ($loginvia =~ /:/) {
624: ($newhost,$path) = split(':',$loginvia);
625: } else {
626: $newhost = $loginvia;
627: }
628: if ($newhost ne $lonhost) {
629: if (&Apache::lonnet::hostname($newhost) ne '') {
630: $output = &redirect_page($newhost,$path);
631: }
632: }
633: }
634: }
635: return $output;
636: }
637:
638: sub redirect_page {
639: my ($desthost,$path) = @_;
640: my $protocol = $Apache::lonnet::protocol{$desthost};
641: $protocol = 'http' if ($protocol ne 'https');
642: unless ($path =~ m{^/}) {
643: $path = '/'.$path;
644: }
645: my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
646: if ($env{'form.firsturl'} ne '') {
647: $url .='?firsturl='.$env{'form.firsturl'};
648: }
649: my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
650: {'redirect' => [0,$url],});
651: my $end_page = &Apache::loncommon::end_page();
652: return $start_page.$end_page;
653: }
654:
655: sub contactdisplay {
656: my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript,$showhelpdesk,
657: $possdoms) = @_;
658: my $contactblock;
659: my $origmail;
660: if (ref($possdoms) eq 'ARRAY') {
661: if (grep(/^\Q$authdomain\E$/,@{$possdoms})) {
662: $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
663: }
664: }
665: my $requestmail =
666: &Apache::loncommon::build_recipient_list(undef,'helpdeskmail',
667: $authdomain,$origmail);
668: unless ($showhelpdesk eq '0') {
669: if ($requestmail =~ m/[^\@]+\@[^\@]+/) {
670: $showhelpdesk = 1;
671: } else {
672: $showhelpdesk = 0;
673: }
674: }
675: if ($servadm && $showadminmail) {
676: $contactblock .= $$lt{'servadm'}.':<br />'.
677: '<tt>'.$servadm.'</tt><br />';
678: }
679: if ($showhelpdesk) {
680: $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
681: my $thisurl = &escape('/adm/login');
682: $$helpdeskscript = <<"ENDSCRIPT";
683: <script type="text/javascript">
684: // <![CDATA[
685: function helpdesk() {
686: var possdom = document.client.udom.value;
687: var codedom = possdom.replace( new RegExp("[^A-Za-z0-9.\\-]","g"),'');
688: if (codedom == '') {
689: codedom = "$authdomain";
690: }
691: var querystr = "origurl=$thisurl&codedom="+codedom;
692: document.location.href = "/adm/helpdesk?"+querystr;
693: return;
694: }
695: // ]]>
696: </script>
697: ENDSCRIPT
698: }
699: return $contactblock;
700: }
701:
702: sub forgotpwdisplay {
703: my (%lt) = @_;
704: my $prompt_for_resetpw = 1;
705: if ($prompt_for_resetpw) {
706: return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
707: }
708: return;
709: }
710:
711: sub coursecatalog_link {
712: my ($linkname) = @_;
713: return <<"END";
714: <a href="/adm/coursecatalog">$linkname</a>
715: END
716: }
717:
718: sub newuser_link {
719: my ($linkname) = @_;
720: return '<a href="/adm/createaccount">'.$linkname.'</a>';
721: }
722:
723: 1;
724: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>