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