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