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