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