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