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