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