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