Annotation of loncom/auth/lonlogin.pm, revision 1.132
1.1 albertel 1: # The LearningOnline Network
2: # Login Screen
1.11 www 3: #
1.132 ! bisitz 4: # $Id: lonlogin.pm,v 1.131 2009/12/04 13:50:48 jms Exp $
1.11 www 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: #
1.14 albertel 28:
1.1 albertel 29: package Apache::lonlogin;
30:
31: use strict;
32: use Apache::Constants qw(:common);
33: use Apache::File ();
1.63 albertel 34: use Apache::lonnet;
1.12 albertel 35: use Apache::loncommon();
1.49 www 36: use Apache::lonauth();
1.50 www 37: use Apache::lonlocal;
1.71 albertel 38: use Apache::migrateuser();
1.75 www 39: use lib '/home/httpd/lib/perl/';
40: use LONCAPA;
41:
1.1 albertel 42: sub handler {
43: my $r = shift;
1.71 albertel 44:
45: &Apache::loncommon::get_unprocessed_cgi
1.79 albertel 46: (join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
47: $ENV{'REDIRECT_QUERY_STRING'}),
1.71 albertel 48: ['interface','username','domain','firsturl','localpath','localres',
1.123 raeburn 49: 'token','role','symb']);
1.102 raeburn 50: if (!defined($env{'form.firsturl'})) {
51: &Apache::lonacc::get_posted_cgi($r,['firsturl']);
52: }
1.71 albertel 53:
54: # -- check if they are a migrating user
55: if (defined($env{'form.token'})) {
56: return &Apache::migrateuser::handler($r);
57: }
58:
1.53 www 59: &Apache::loncommon::no_cache($r);
60: &Apache::lonlocal::get_language_handle($r);
1.54 www 61: &Apache::loncommon::content_type($r,'text/html');
1.1 albertel 62: $r->send_http_header;
63: return OK if $r->header_only;
64:
1.49 www 65:
66: # Are we re-routing?
67: if (-e '/home/httpd/html/lon-status/reroute.txt') {
68: &Apache::lonauth::reroute($r);
69: return OK;
70: }
1.55 www 71:
1.71 albertel 72:
1.55 www 73: # -------------------------------- Prevent users from attempting to login twice
1.95 albertel 74: my $handle = &Apache::lonnet::check_for_valid_session($r);
75: if ($handle=~/^publicuser\_/) {
1.70 www 76: # For "public user" - remove it, we apparently really want to login
1.95 albertel 77: unlink($r->dir_config('lonIDsDir')."/$handle.id");
78: } elsif ($handle ne '') {
1.55 www 79: # Indeed, a valid token is found
1.95 albertel 80: my $start_page =
81: &Apache::loncommon::start_page('Already logged in');
82: my $end_page =
83: &Apache::loncommon::end_page();
1.125 raeburn 84: my $dest = '/adm/roles';
85: if ($env{'form.firsturl'} ne '') {
86: $dest = $env{'form.firsturl'};
87: }
1.131 jms 88:
89: my $dom = &Apache::lonnet::default_login_domain();
90: my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
91:
92: my $loginhelp_page = $helpconfig{'helpsettings'}{'loginhelpurl'};
93: if ($loginhelp_page eq '') {
94: $loginhelp_page = '/adm/loginproblems.html';
95: }
1.100 bisitz 96: $r->print(
97: $start_page
1.103 bisitz 98: .'<h1>'.&mt('You are already logged in!').'</h1>'
1.117 hauer 99: .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
1.125 raeburn 100: '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
1.131 jms 101: .'<p><a href="'.$loginhelp_page.'">'.&mt('Login problems?').'</a></p>'
102: .$dom.' '.$end_page
1.100 bisitz 103: );
1.95 albertel 104: return OK;
1.55 www 105: }
106:
107: # ---------------------------------------------------- No valid token, continue
1.16 www 108:
1.70 www 109: # ---------------------------- Not possible to really login to domain "public"
110: if ($env{'form.domain'} eq 'public') {
111: $env{'form.domain'}='';
112: $env{'form.username'}='';
113: }
1.32 www 114: # ----------------------------------------------------------- Process Interface
1.63 albertel 115: $env{'form.interface'}=~s/\W//g;
1.16 www 116:
1.32 www 117: my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
1.94 albertel 118:
119: my $iconpath=
120: &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
121:
1.126 raeburn 122: my $lonhost = $r->dir_config('lonHostID');
1.87 raeburn 123: my $domain = &Apache::lonnet::default_login_domain();
1.127 raeburn 124: my %domconfhash = &Apache::loncommon::get_domainconf($domain);
1.126 raeburn 125: if ($lonhost ne '') {
1.127 raeburn 126: my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
127: if (($loginvia ne '') && ($loginvia ne $lonhost)) {
1.128 raeburn 128: if (&Apache::lonnet::hostname($loginvia) ne '') {
1.127 raeburn 129: $r->print(&redirect_page($loginvia));
130: return OK;
1.126 raeburn 131: }
132: }
133: }
134:
1.63 albertel 135: if (($env{'form.domain'}) &&
1.89 albertel 136: (&Apache::lonnet::domain($env{'form.domain'},'description'))) {
1.63 albertel 137: $domain=$env{'form.domain'};
1.46 www 138: }
1.1 albertel 139: my $role = $r->dir_config('lonRole');
140: my $loadlim = $r->dir_config('lonLoadLim');
1.90 raeburn 141: my $servadm = $r->dir_config('lonAdmEMail');
1.1 albertel 142: my $tabdir = $r->dir_config('lonTabDir');
1.6 www 143: my $include = $r->dir_config('lonIncludes');
1.37 www 144: my $expire = $r->dir_config('lonExpire');
1.44 www 145: my $version = $r->dir_config('lonVersion');
1.88 albertel 146: my $host_name = &Apache::lonnet::hostname($lonhost);
1.1 albertel 147:
1.30 www 148: # --------------------------------------------- Default values for login fields
149:
1.63 albertel 150: my $authusername=($env{'form.username'}?$env{'form.username'}:'');
151: my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
1.30 www 152:
153: # ---------------------------------------------------------- Determine own load
1.1 albertel 154: my $loadavg;
1.41 albertel 155: {
156: my $loadfile=Apache::File->new('/proc/loadavg');
157: $loadavg=<$loadfile>;
158: }
1.1 albertel 159: $loadavg =~ s/\s.*//g;
1.57 matthew 160: my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
1.41 albertel 161: my $userloadpercent=&Apache::lonnet::userload();
1.1 albertel 162:
1.30 www 163: # ------------------------------------------------------- Do the load balancing
1.80 albertel 164: my $otherserver= &Apache::lonnet::absolute_url($host_name);
1.31 www 165: my $firsturl=
1.63 albertel 166: ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
1.97 albertel 167: # ---------------------------------------------------------- Are we overloaded?
168: if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
1.47 albertel 169: my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
170: if ($unloaded) { $otherserver=$unloaded; }
1.1 albertel 171: }
1.6 www 172:
1.45 www 173: # ----------------------------------------------------------- Get announcements
174: my $announcements=&Apache::lonnet::getannounce();
1.6 www 175: # -------------------------------------------------------- Set login parameters
176:
177: my @hexstr=('0','1','2','3','4','5','6','7',
178: '8','9','a','b','c','d','e','f');
179: my $lkey='';
180: for (0..7) {
181: $lkey.=$hexstr[rand(15)];
182: }
183:
184: my $ukey='';
185: for (0..7) {
186: $ukey.=$hexstr[rand(15)];
187: }
188:
189: my $lextkey=hex($lkey);
1.15 www 190: if ($lextkey>2147483647) { $lextkey-=4294967296; }
191:
1.6 www 192: my $uextkey=hex($ukey);
1.15 www 193: if ($uextkey>2147483647) { $uextkey-=4294967296; }
194:
1.31 www 195: # -------------------------------------------------------- Store away log token
1.123 raeburn 196: my $tokenextras;
197: if ($env{'form.role'}) {
198: $tokenextras = '&role='.&escape($env{'form.role'});
199: }
200: if ($env{'form.symb'}) {
1.124 raeburn 201: if (!$tokenextras) {
202: $tokenextras = '&';
203: }
1.123 raeburn 204: $tokenextras .= '&symb='.&escape($env{'form.symb'});
205: }
1.6 www 206: my $logtoken=Apache::lonnet::reply(
1.123 raeburn 207: 'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
1.6 www 208: $lonhost);
1.31 www 209:
210: # ------------------- If we cannot talk to ourselves, we are in serious trouble
211:
212: if ($logtoken eq 'con_lost') {
213: my $spares='';
1.64 albertel 214: my $last;
215: foreach my $hostid (sort
216: {
1.88 albertel 217: &Apache::lonnet::hostname($a) cmp
218: &Apache::lonnet::hostname($b);
1.64 albertel 219: }
220: keys(%Apache::lonnet::spareid)) {
1.58 matthew 221: next if ($hostid eq $lonhost);
1.88 albertel 222: my $hostname = &Apache::lonnet::hostname($hostid);
223: next if ($last eq $hostname);
1.58 matthew 224: $spares.='<br /><font size="+1"><a href="http://'.
1.88 albertel 225: $hostname.
1.58 matthew 226: '/adm/login?domain='.$authdomain.'">'.
1.88 albertel 227: $hostname.'</a>'.
1.106 bisitz 228: ' '.&mt('(preferred)').'</font>'.$/;
1.88 albertel 229: $last=$hostname;
1.58 matthew 230: }
1.107 tempelho 231: $spares.= '<br />';
232: my %all_hostnames = &Apache::lonnet::all_hostnames();
233: foreach my $hostid (sort
234: {
235: &Apache::lonnet::hostname($a) cmp
236: &Apache::lonnet::hostname($b);
237: }
238: keys(%all_hostnames)) {
239: next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
240: my $hostname = &Apache::lonnet::hostname($hostid);
241: next if ($last eq $hostname);
242: $spares.='<br /><a href="http://'.
243: $hostname.
244: '/adm/login?domain='.$authdomain.'">'.
245: $hostname.'</a>';
246: $last=$hostname;
247: }
248: $r->print(
249: '<html>'
250: .'<head><title>'
251: .&mt('The LearningOnline Network with CAPA')
252: .'</title></head>'
253: .'<body bgcolor="#FFFFFF">'
254: .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
255: .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
256: .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>'
257: .'<p>'.&mt('Please attempt to login to one of the following servers:').'</p>'
258: .$spares
259: .'</body>'
260: .'</html>'
261: );
262: return OK;
263: }
1.31 www 264:
265: # ----------------------------------------------- Apparently we are in business
1.107 tempelho 266: $servadm=~s/\,/\<br \/\>/g;
1.38 www 267:
1.21 www 268: # ----------------------------------------------------------- Front page design
1.119 tempelho 269: my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
270: my $font=&Apache::loncommon::designparm('login.font',$domain);
271: my $link=&Apache::loncommon::designparm('login.link',$domain);
272: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
1.107 tempelho 273: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
1.119 tempelho 274: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
1.107 tempelho 275: my $logo=&Apache::loncommon::designparm('login.logo',$domain);
276: my $img=&Apache::loncommon::designparm('login.img',$domain);
1.132 ! bisitz 277: my $domainlogo='<div>'.&Apache::loncommon::domainlogo($domain).'</div>';
1.107 tempelho 278: my $login=&Apache::loncommon::designparm('login.login',$domain);
279: if ($login eq '') {
280: $login = $iconpath.'/'.&mt('userauthentication.gif');
281: }
1.109 raeburn 282: my $showbanner = 1;
283: my $showmainlogo = 1;
284: if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
285: $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
286: }
287: if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
288: $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
289: }
1.107 tempelho 290: my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
291: my $showcoursecat =
292: &Apache::loncommon::designparm('login.coursecatalog',$domain);
293: my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
294: my $shownewuserlink =
295: &Apache::loncommon::designparm('login.newuser',$domain);
296: my $now=time;
297: my $js = (<<ENDSCRIPT);
298:
1.116 bisitz 299: <script type="text/javascript" language="JavaScript">
1.122 bisitz 300: // <![CDATA[
1.107 tempelho 301: function send()
302: {
303: this.document.server.elements.uname.value
304: =this.document.client.elements.uname.value;
305:
306: this.document.server.elements.udom.value
307: =this.document.client.elements.udom.value;
308:
309: uextkey=this.document.client.elements.uextkey.value;
310: lextkey=this.document.client.elements.lextkey.value;
311: initkeys();
312:
313: this.document.server.elements.upass0.value
314: =crypted(this.document.client.elements.upass$now.value.substr(0,15));
315: this.document.server.elements.upass1.value
316: =crypted(this.document.client.elements.upass$now.value.substr(15,15));
317: this.document.server.elements.upass2.value
318: =crypted(this.document.client.elements.upass$now.value.substr(30,15));
1.6 www 319:
1.107 tempelho 320: this.document.client.elements.uname.value='';
321: this.document.client.elements.upass$now.value='';
1.6 www 322:
1.107 tempelho 323: this.document.server.submit();
324: return false;
325: }
1.122 bisitz 326: // ]]>
1.107 tempelho 327: </script>
1.98 raeburn 328:
1.16 www 329: ENDSCRIPT
1.6 www 330:
1.98 raeburn 331: # --------------------------------------------------- Print login screen header
332:
1.118 tempelho 333: my %add_entries = (
1.108 tempelho 334: bgcolor => "$mainbg",
1.107 tempelho 335: text => "$font",
336: link => "$link",
337: vlink => "$vlink",
338: alink => "$alink",);
339:
340: $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
341: { 'redirect' => [$expire,'/adm/roles'],
342: 'add_entries' => \%add_entries,
343: 'only_body' => 1,}));
1.98 raeburn 344:
345: # ----------------------------------------------------------------------- Texts
346:
347: my %lt=&Apache::lonlocal::texthash(
1.129 bisitz 348: 'un' => 'Username',
349: 'pw' => 'Password',
350: 'dom' => 'Domain',
351: 'perc' => 'percent',
352: 'load' => 'Server Load',
353: 'userload' => 'User Load',
354: 'catalog' => 'Course/Community Catalog',
355: 'log' => 'Log in',
356: 'help' => 'Log-in Help',
357: 'serv' => 'Server',
358: 'servadm' => 'Server Administration',
359: 'helpdesk' => 'Contact Helpdesk',
360: 'forgotpw' => 'Forgot password?',
361: 'newuser' => 'New User?',
362: );
1.98 raeburn 363: # -------------------------------------------------- Change password field name
1.131 jms 364:
1.107 tempelho 365: my $forgotpw = &forgotpwdisplay(%lt);
1.132 ! bisitz 366: $forgotpw .= '<br />' if $forgotpw;
1.107 tempelho 367: my $loginhelp = &loginhelpdisplay(%lt);
1.132 ! bisitz 368: $loginhelp .= '<br />' if $loginhelp;
1.98 raeburn 369:
370: # ---------------------------------------------------- Serve out DES JavaScript
1.107 tempelho 371: {
372: my $jsh=Apache::File->new($include."/londes.js");
373: $r->print(<$jsh>);
374: }
1.98 raeburn 375: # ---------------------------------------------------------- Serve rest of page
376:
1.107 tempelho 377: $r->print(
378: '<div class="LC_loginpage_container">');
1.6 www 379:
1.120 foxr 380: #
381: # If the loadbalancing yielded just http:// because perhaps there's no loadbalancing?
382: # then just us a relative link to authenticate:
383: #
384:
1.107 tempelho 385: $r->print(<<ENDSERVERFORM);
386: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33 www 387: <input type="hidden" name="logtoken" value="$logtoken" />
388: <input type="hidden" name="serverid" value="$lonhost" />
389: <input type="hidden" name="uname" value="" />
1.65 www 390: <input type="hidden" name="upass0" value="" />
391: <input type="hidden" name="upass1" value="" />
392: <input type="hidden" name="upass2" value="" />
1.33 www 393: <input type="hidden" name="udom" value="" />
1.63 albertel 394: <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
395: <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14 albertel 396: </form>
1.16 www 397: ENDSERVERFORM
1.108 tempelho 398: my $coursecatalog;
399: if (($showcoursecat eq '') || ($showcoursecat)) {
1.132 ! bisitz 400: $coursecatalog = &coursecatalog_link($lt{'catalog'}).'<br />';
1.108 tempelho 401: }
402: my $newuserlink;
403: if ($shownewuserlink) {
1.132 ! bisitz 404: $newuserlink = &newuser_link($lt{'newuser'}).'<br />';
1.108 tempelho 405: }
406: my $logintitle;
407: if ($loginheader eq 'text') {
1.113 tempelho 408: $logintitle ='<h2>'.$lt{'log'}.'</h2>';
1.108 tempelho 409: } else {
410: $logintitle = '<img src="'.$login.'" alt="'.
411: &mt('User Authentication').'" />';
412: }
413:
414: my $noscript_warning='<noscript><span class="LC_warning"><b>'
415: .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
416: .'</b></span></noscript>';
417: my $helpdeskscript;
418: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
1.132 ! bisitz 419: $authdomain,\$helpdeskscript);
1.107 tempelho 420:
1.108 tempelho 421: my $loginform=(<<LFORM);
1.122 bisitz 422: <form name="client" action="" onsubmit="return(send())">
1.115 bisitz 423: <input type="hidden" name="lextkey" value="$lextkey" />
424: <input type="hidden" name="uextkey" value="$uextkey" />
1.108 tempelho 425: <b><label for="uname">$lt{'un'}</label>:</b><br />
1.130 bisitz 426: <input type="text" name="uname" id="uname" size="15" value="$authusername" /><br />
1.108 tempelho 427: <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
1.130 bisitz 428: <input type="password" name="upass$now" id="upass$now" size="15" /><br />
1.108 tempelho 429: <b><label for="udom">$lt{'dom'}</label>:</b><br />
1.130 bisitz 430: <input type="text" name="udom" id="udom" size="15" value="$authdomain" /><br />
1.108 tempelho 431: <input type="submit" value="$lt{'log'}" />
432: </form>
433: LFORM
434:
1.109 raeburn 435: if ($showbanner) {
436: $r->print(<<HEADER);
437: <!-- The LON-CAPA Header -->
1.132 ! bisitz 438: <div style="background:$pgbg;margin:0;width:100%;">
! 439: <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
! 440: </div>
1.109 raeburn 441: HEADER
442: }
443: $r->print(<<ENDTOP);
1.118 tempelho 444: <div class="LC_loginpage_space"> </div>
445: <div class="LC_loginpage_floatLeft">
1.108 tempelho 446: <div class="LC_loginpage_loginContainer">
1.112 muellerd 447: $logintitle
448: <table border="0" align="left" cellspacing="1" cellpadding="2" width="100%">
1.108 tempelho 449: <tr>
450: <td>
451: $loginform
452: </td>
453: </tr>
454: </table>
455: $noscript_warning
456: </div>
1.107 tempelho 457:
458: <div class="LC_loginpage_loginInfo">
1.132 ! bisitz 459: $loginhelp
! 460: $forgotpw
! 461: $contactblock
! 462: $newuserlink
1.130 bisitz 463: $coursecatalog
1.107 tempelho 464: </div>
1.118 tempelho 465: </div>
466: ENDTOP
467: if ($showmainlogo) {
468: $r->print(' <img src="'.$logo.'" alt="" />'."\n");
469: }
470: $r->print(<<ENDTOP);
471: $announcements
472: $domainlogo
1.107 tempelho 473: <div class="LC_loginpage_space"> </div>
1.108 tempelho 474: ENDTOP
475:
476: $r->print(<<ENDDOCUMENT);
1.115 bisitz 477: <table border="0" cellspacing="0" cellpadding="0">
1.14 albertel 478: <tr>
1.110 muellerd 479: <td align="left" valign="top">
1.132 ! bisitz 480: <small><b>$lt{'dom'}: </b></small>
1.14 albertel 481: </td>
1.110 muellerd 482: <td align="left" valign="top">
1.14 albertel 483: <small><tt> $domain</tt></small>
484: </td>
485: </tr>
486: <tr>
1.110 muellerd 487: <td align="left" valign="top">
1.132 ! bisitz 488: <small><b>$lt{'serv'}: </b></small>
1.14 albertel 489: </td>
1.110 muellerd 490: <td align="left" valign="top">
1.14 albertel 491: <small><tt> $lonhost ($role)</tt></small>
492: </td>
493: </tr>
494: <tr>
1.110 muellerd 495: <td align="left" valign="top">
1.132 ! bisitz 496: <small><b>$lt{'load'}: </b></small>
1.14 albertel 497: </td>
1.110 muellerd 498: <td align="left" valign="top">
1.51 www 499: <small><tt> $loadpercent $lt{'perc'}</tt></small>
1.42 albertel 500: </td>
501: </tr>
502: <tr>
1.110 muellerd 503: <td align="left" valign="top">
1.132 ! bisitz 504: <small><b>$lt{'userload'}: </b></small>
1.42 albertel 505: </td>
1.110 muellerd 506: <td align="left" valign="top">
1.51 www 507: <small><tt> $userloadpercent $lt{'perc'}</tt></small>
1.14 albertel 508: </td>
509: </tr>
1.132 ! bisitz 510: <tr>
! 511: <td colspan="2" align="left">
! 512: <small>$version</small>
! 513: </td>
! 514: </tr>
1.14 albertel 515: </table>
1.107 tempelho 516: </div>
1.25 bowersj2 517:
1.59 albertel 518: <script type="text/javascript">
1.122 bisitz 519: // <![CDATA[
1.59 albertel 520: // the if prevents the script error if the browser can not handle this
1.25 bowersj2 521: if ( document.client.uname ) { document.client.uname.focus(); }
1.122 bisitz 522: // ]]>
1.25 bowersj2 523: </script>
1.62 raeburn 524: $helpdeskscript
1.14 albertel 525:
1.1 albertel 526: ENDDOCUMENT
1.98 raeburn 527: my %endargs = ( 'noredirectlink' => 1, );
528: $r->print(&Apache::loncommon::end_page(\%endargs));
1.1 albertel 529: return OK;
1.60 raeburn 530: }
531:
1.126 raeburn 532: sub redirect_page {
533: my ($desthost) = @_;
534: my $protocol = $Apache::lonnet::protocol{$desthost};
535: $protocol = 'http' if ($protocol ne 'https');
536: my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).'/';
537: if ($env{'form.firsturl'} ne '') {
538: $url .='?firsturl='.$env{'form.firsturl'};
539: }
540: my $start_page = &Apache::loncommon::start_page('Switching Server',undef,
541: {'redirect' => [0,$url],});
542: my $end_page = &Apache::loncommon::end_page();
543: return $start_page.$end_page;
544: }
545:
1.60 raeburn 546: sub contactdisplay {
1.132 ! bisitz 547: my ($lt,$servadm,$showadminmail,$authdomain,$helpdeskscript) = @_;
1.60 raeburn 548: my $contactblock;
1.62 raeburn 549: my $showhelpdesk = 0;
550: my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
551: if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
552: $showhelpdesk = 1;
553: }
1.90 raeburn 554: if ($servadm && $showadminmail) {
1.130 bisitz 555: $contactblock .= $$lt{'servadm'}.':<br />'.
556: '<tt>'.$servadm.'</tt><br />';
1.90 raeburn 557: }
1.60 raeburn 558: if ($showhelpdesk) {
1.114 tempelho 559: $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
1.75 www 560: my $thisurl = &escape('/adm/login');
1.62 raeburn 561: $$helpdeskscript = <<"ENDSCRIPT";
562: <script type="text/javascript">
1.122 bisitz 563: // <![CDATA[
1.62 raeburn 564: function helpdesk() {
565: var codedom = document.client.udom.value;
566: if (codedom == '') {
567: codedom = "$authdomain";
568: }
569: var querystr = "origurl=$thisurl&codedom="+codedom;
570: document.location.href = "/adm/helpdesk?"+querystr;
571: return;
572: }
1.122 bisitz 573: // ]]>
1.62 raeburn 574: </script>
575: ENDSCRIPT
1.60 raeburn 576: }
577: return $contactblock;
578: }
1.83 raeburn 579:
580: sub forgotpwdisplay {
1.84 raeburn 581: my (%lt) = @_;
1.83 raeburn 582: my $prompt_for_resetpw = 1;
583: if ($prompt_for_resetpw) {
1.107 tempelho 584: return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
1.84 raeburn 585: }
586: return;
587: }
588:
589: sub loginhelpdisplay {
590: my (%lt) = @_;
591: my $login_help = 1;
592: if ($login_help) {
1.131 jms 593: my $dom = &Apache::lonnet::default_login_domain();
594: my %helpconfig = &Apache::lonnet::get_dom('configuration',['helpsettings'],$dom);
595: my $loginhelp_url = $helpconfig{'helpsettings'}{'loginhelpurl'};
596: if ($loginhelp_url ne '') {
597: return '<a href="'.$loginhelp_url.'">'.$lt{'help'}.'</a>';
598: } else {
599: return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';
600: }
1.83 raeburn 601: }
602: return;
603: }
1.1 albertel 604:
1.90 raeburn 605: sub coursecatalog_link {
606: my ($linkname) = @_;
607: return <<"END";
1.107 tempelho 608: <a href="/adm/coursecatalog">$linkname</a>
1.90 raeburn 609: END
610: }
611:
1.101 raeburn 612: sub newuser_link {
613: my ($linkname) = @_;
1.130 bisitz 614: return '<a href="/adm/createaccount">'.$linkname.'</a>';
1.101 raeburn 615: }
616:
1.1 albertel 617: 1;
618: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>