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