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