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