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