Annotation of loncom/auth/lonlogin.pm, revision 1.130

1.1       albertel    1: # The LearningOnline Network
                      2: # Login Screen
1.11      www         3: #
1.130   ! bisitz      4: # $Id: lonlogin.pm,v 1.129 2009/10/23 16:14:36 bisitz 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?
                     67:     if (-e '/home/httpd/html/lon-status/reroute.txt') {
                     68: 	&Apache::lonauth::reroute($r);
                     69: 	return OK;
                     70:     }
1.55      www        71: 
1.71      albertel   72: 
1.55      www        73: # -------------------------------- Prevent users from attempting to login twice
1.95      albertel   74:     my $handle = &Apache::lonnet::check_for_valid_session($r);
                     75:     if ($handle=~/^publicuser\_/) {
1.70      www        76: # For "public user" - remove it, we apparently really want to login
1.95      albertel   77: 	unlink($r->dir_config('lonIDsDir')."/$handle.id");
                     78:     } elsif ($handle ne '') {
1.55      www        79: # Indeed, a valid token is found
1.95      albertel   80: 	my $start_page = 
                     81: 	    &Apache::loncommon::start_page('Already logged in');
                     82: 	my $end_page = 
                     83: 	    &Apache::loncommon::end_page();
1.125     raeburn    84:         my $dest = '/adm/roles';
                     85:         if ($env{'form.firsturl'} ne '') {
                     86:             $dest = $env{'form.firsturl'}; 
                     87:         }
1.100     bisitz     88: 	$r->print(
                     89:                   $start_page
1.103     bisitz     90:                  .'<h1>'.&mt('You are already logged in!').'</h1>'
1.117     hauer      91:                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
1.125     raeburn    92:                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
1.100     bisitz     93:                  .'<p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'
                     94:                  .$end_page
                     95:                  );
1.95      albertel   96:         return OK;
1.55      www        97:     }
                     98: 
                     99: # ---------------------------------------------------- No valid token, continue
1.16      www       100: 
1.70      www       101:  # ---------------------------- Not possible to really login to domain "public"
                    102:     if ($env{'form.domain'} eq 'public') {
                    103: 	$env{'form.domain'}='';
                    104: 	$env{'form.username'}='';
                    105:     }
1.32      www       106: # ----------------------------------------------------------- Process Interface
1.63      albertel  107:     $env{'form.interface'}=~s/\W//g;
1.16      www       108: 
1.32      www       109:     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
1.94      albertel  110: 
                    111:     my $iconpath= 
                    112: 	&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
                    113: 
1.126     raeburn   114:     my $lonhost = $r->dir_config('lonHostID');
1.87      raeburn   115:     my $domain = &Apache::lonnet::default_login_domain();
1.127     raeburn   116:     my %domconfhash = &Apache::loncommon::get_domainconf($domain);
1.126     raeburn   117:     if ($lonhost ne '') {
1.127     raeburn   118:         my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
                    119:         if (($loginvia ne '') && ($loginvia ne $lonhost)) {
1.128     raeburn   120:             if (&Apache::lonnet::hostname($loginvia) ne '') {
1.127     raeburn   121:                 $r->print(&redirect_page($loginvia));
                    122:                 return OK;
1.126     raeburn   123:             }
                    124:         }
                    125:     }
                    126: 
1.63      albertel  127:     if (($env{'form.domain'}) && 
1.89      albertel  128: 	(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
1.63      albertel  129: 	$domain=$env{'form.domain'};
1.46      www       130:     }
1.1       albertel  131:     my $role    = $r->dir_config('lonRole');
                    132:     my $loadlim = $r->dir_config('lonLoadLim');
1.90      raeburn   133:     my $servadm = $r->dir_config('lonAdmEMail');
1.1       albertel  134:     my $tabdir  = $r->dir_config('lonTabDir');
1.6       www       135:     my $include = $r->dir_config('lonIncludes');
1.37      www       136:     my $expire  = $r->dir_config('lonExpire');
1.44      www       137:     my $version = $r->dir_config('lonVersion');
1.88      albertel  138:     my $host_name = &Apache::lonnet::hostname($lonhost);
1.1       albertel  139: 
1.30      www       140: # --------------------------------------------- Default values for login fields
                    141: 
1.63      albertel  142:     my $authusername=($env{'form.username'}?$env{'form.username'}:'');
                    143:     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
1.30      www       144: 
                    145: # ---------------------------------------------------------- Determine own load
1.1       albertel  146:     my $loadavg;
1.41      albertel  147:     {
                    148: 	my $loadfile=Apache::File->new('/proc/loadavg');
                    149: 	$loadavg=<$loadfile>;
                    150:     }
1.1       albertel  151:     $loadavg =~ s/\s.*//g;
1.57      matthew   152:     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
1.41      albertel  153:     my $userloadpercent=&Apache::lonnet::userload();
1.1       albertel  154: 
1.30      www       155: # ------------------------------------------------------- Do the load balancing
1.80      albertel  156:     my $otherserver= &Apache::lonnet::absolute_url($host_name);
1.31      www       157:     my $firsturl=
1.63      albertel  158:     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
1.97      albertel  159: # ---------------------------------------------------------- Are we overloaded?
                    160:     if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
1.47      albertel  161:         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
                    162: 	if ($unloaded) { $otherserver=$unloaded; }
1.1       albertel  163:     }
1.6       www       164: 
1.45      www       165: # ----------------------------------------------------------- Get announcements
                    166:     my $announcements=&Apache::lonnet::getannounce();
1.6       www       167: # -------------------------------------------------------- Set login parameters
                    168: 
                    169:     my @hexstr=('0','1','2','3','4','5','6','7',
                    170:                 '8','9','a','b','c','d','e','f');
                    171:     my $lkey='';
                    172:     for (0..7) {
                    173:         $lkey.=$hexstr[rand(15)];
                    174:     }
                    175: 
                    176:     my $ukey='';
                    177:     for (0..7) {
                    178:         $ukey.=$hexstr[rand(15)];
                    179:     }
                    180: 
                    181:     my $lextkey=hex($lkey);
1.15      www       182:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
                    183: 
1.6       www       184:     my $uextkey=hex($ukey);
1.15      www       185:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
                    186: 
1.31      www       187: # -------------------------------------------------------- Store away log token
1.123     raeburn   188:     my $tokenextras;
                    189:     if ($env{'form.role'}) {
                    190:         $tokenextras = '&role='.&escape($env{'form.role'});
                    191:     }
                    192:     if ($env{'form.symb'}) {
1.124     raeburn   193:         if (!$tokenextras) {
                    194:             $tokenextras = '&';
                    195:         }
1.123     raeburn   196:         $tokenextras .= '&symb='.&escape($env{'form.symb'});
                    197:     }
1.6       www       198:     my $logtoken=Apache::lonnet::reply(
1.123     raeburn   199:        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
1.6       www       200:        $lonhost);
1.31      www       201: 
                    202: # ------------------- If we cannot talk to ourselves, we are in serious trouble
                    203: 
                    204:     if ($logtoken eq 'con_lost') {
                    205:         my $spares='';
1.64      albertel  206: 	my $last;
                    207:         foreach my $hostid (sort
                    208: 			    {
1.88      albertel  209: 				&Apache::lonnet::hostname($a) cmp
                    210: 				    &Apache::lonnet::hostname($b);
1.64      albertel  211: 			    }
                    212: 			    keys(%Apache::lonnet::spareid)) {
1.58      matthew   213:             next if ($hostid eq $lonhost);
1.88      albertel  214: 	    my $hostname = &Apache::lonnet::hostname($hostid);
                    215: 	    next if ($last eq $hostname);
1.58      matthew   216:             $spares.='<br /><font size="+1"><a href="http://'.
1.88      albertel  217:                 $hostname.
1.58      matthew   218:                 '/adm/login?domain='.$authdomain.'">'.
1.88      albertel  219:                 $hostname.'</a>'.
1.106     bisitz    220:                 ' '.&mt('(preferred)').'</font>'.$/;
1.88      albertel  221: 	    $last=$hostname;
1.58      matthew   222:         }
1.107     tempelho  223: $spares.= '<br />';
                    224: my %all_hostnames = &Apache::lonnet::all_hostnames();
                    225: foreach my $hostid (sort
                    226: 		    {
                    227: 			&Apache::lonnet::hostname($a) cmp
                    228: 			    &Apache::lonnet::hostname($b);
                    229: 		    }
                    230: 		    keys(%all_hostnames)) {
                    231:     next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
                    232:     my $hostname = &Apache::lonnet::hostname($hostid);
                    233:     next if ($last eq $hostname);
                    234:     $spares.='<br /><a href="http://'.
                    235: 	$hostname.
                    236: 	'/adm/login?domain='.$authdomain.'">'.
                    237: 	$hostname.'</a>';
                    238:     $last=$hostname;
                    239: }
                    240: $r->print(
                    241:    '<html>'
                    242:   .'<head><title>'
                    243:   .&mt('The LearningOnline Network with CAPA')
                    244:   .'</title></head>'
                    245:   .'<body bgcolor="#FFFFFF">'
                    246:   .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
                    247:   .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
                    248:   .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>'
                    249:   .'<p>'.&mt('Please attempt to login to one of the following servers:').'</p>'
                    250:   .$spares
                    251:   .'</body>'
                    252:   .'</html>'
                    253: );
                    254: return OK;
                    255: }
1.31      www       256: 
                    257: # ----------------------------------------------- Apparently we are in business
1.107     tempelho  258: $servadm=~s/\,/\<br \/\>/g;
1.38      www       259: 
1.21      www       260: # ----------------------------------------------------------- Front page design
1.119     tempelho  261: my $pgbg=&Apache::loncommon::designparm('login.pgbg',$domain);
                    262: my $font=&Apache::loncommon::designparm('login.font',$domain);
                    263: my $link=&Apache::loncommon::designparm('login.link',$domain);
                    264: my $vlink=&Apache::loncommon::designparm('login.vlink',$domain);
1.107     tempelho  265: my $alink=&Apache::loncommon::designparm('login.alink',$domain);
1.119     tempelho  266: my $mainbg=&Apache::loncommon::designparm('login.mainbg',$domain);
1.107     tempelho  267: my $logo=&Apache::loncommon::designparm('login.logo',$domain);
                    268: my $img=&Apache::loncommon::designparm('login.img',$domain);
                    269: my $domainlogo=&Apache::loncommon::domainlogo($domain);
                    270: my $login=&Apache::loncommon::designparm('login.login',$domain);
                    271: if ($login eq '') {
                    272: $login = $iconpath.'/'.&mt('userauthentication.gif');
                    273: }
1.109     raeburn   274: my $showbanner = 1;
                    275: my $showmainlogo = 1;
                    276: if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
                    277:     $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
                    278: }
                    279: if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
                    280:     $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
                    281: }
1.107     tempelho  282: my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
                    283: my $showcoursecat =
                    284: &Apache::loncommon::designparm('login.coursecatalog',$domain);
                    285: my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
                    286: my $shownewuserlink = 
                    287: &Apache::loncommon::designparm('login.newuser',$domain);
                    288: my $now=time;
                    289: my $js = (<<ENDSCRIPT);
                    290: 
1.116     bisitz    291: <script type="text/javascript" language="JavaScript">
1.122     bisitz    292: // <![CDATA[
1.107     tempelho  293: function send()
                    294: {
                    295: this.document.server.elements.uname.value
                    296: =this.document.client.elements.uname.value;
                    297: 
                    298: this.document.server.elements.udom.value
                    299: =this.document.client.elements.udom.value;
                    300: 
                    301: uextkey=this.document.client.elements.uextkey.value;
                    302: lextkey=this.document.client.elements.lextkey.value;
                    303: initkeys();
                    304: 
                    305: this.document.server.elements.upass0.value
                    306:     =crypted(this.document.client.elements.upass$now.value.substr(0,15));
                    307: this.document.server.elements.upass1.value
                    308:     =crypted(this.document.client.elements.upass$now.value.substr(15,15));
                    309: this.document.server.elements.upass2.value
                    310:     =crypted(this.document.client.elements.upass$now.value.substr(30,15));
1.6       www       311: 
1.107     tempelho  312: this.document.client.elements.uname.value='';
                    313: this.document.client.elements.upass$now.value='';
1.6       www       314: 
1.107     tempelho  315: this.document.server.submit();
                    316: return false;
                    317: }
1.122     bisitz    318: // ]]>
1.107     tempelho  319: </script>
1.98      raeburn   320: 
1.16      www       321: ENDSCRIPT
1.6       www       322: 
1.98      raeburn   323: # --------------------------------------------------- Print login screen header
                    324: 
1.118     tempelho  325: my %add_entries = (
1.108     tempelho  326: 	       bgcolor      => "$mainbg",
1.107     tempelho  327: 	       text         => "$font",
                    328: 	       link         => "$link",
                    329: 	       vlink        => "$vlink",
                    330: 	       alink        => "$alink",);
                    331: 
                    332: $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
                    333: 			       { 'redirect'       => [$expire,'/adm/roles'], 
                    334: 				 'add_entries' => \%add_entries,
                    335: 				 'only_body'   => 1,}));
1.98      raeburn   336: 
                    337: # ----------------------------------------------------------------------- Texts
                    338: 
                    339: my %lt=&Apache::lonlocal::texthash(
1.129     bisitz    340:           'un'       => 'Username',
                    341:           'pw'       => 'Password',
                    342:           'dom'      => 'Domain',
                    343:           'perc'     => 'percent',
                    344:           'load'     => 'Server Load',
                    345:           'userload' => 'User Load',
                    346:           'catalog'  => 'Course/Community Catalog',
                    347:           'log'      => 'Log in',
                    348:           'help'     => 'Log-in Help',
                    349:           'serv'     => 'Server',
                    350:           'servadm'  => 'Server Administration',
                    351:           'helpdesk' => 'Contact Helpdesk',
                    352:           'forgotpw' => 'Forgot password?',
                    353:           'newuser'  => 'New User?',
                    354:        );
1.98      raeburn   355: # -------------------------------------------------- Change password field name
1.107     tempelho  356: my $forgotpw = &forgotpwdisplay(%lt);
                    357: my $loginhelp = &loginhelpdisplay(%lt);
1.98      raeburn   358: 
                    359: # ---------------------------------------------------- Serve out DES JavaScript
1.107     tempelho  360: {
                    361: my $jsh=Apache::File->new($include."/londes.js");
                    362: $r->print(<$jsh>);
                    363: }
1.98      raeburn   364: # ---------------------------------------------------------- Serve rest of page
                    365: 
1.107     tempelho  366: $r->print(
                    367: 	  '<div class="LC_loginpage_container">');
1.6       www       368: 
1.120     foxr      369: #
                    370: #  If the loadbalancing yielded just http:// because perhaps there's no loadbalancing?
                    371: #  then just us a relative link to authenticate:
                    372: #
                    373: 
1.107     tempelho  374: $r->print(<<ENDSERVERFORM);
                    375: <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33      www       376:    <input type="hidden" name="logtoken" value="$logtoken" />
                    377:    <input type="hidden" name="serverid" value="$lonhost" />
                    378:    <input type="hidden" name="uname" value="" />
1.65      www       379:    <input type="hidden" name="upass0" value="" />
                    380:    <input type="hidden" name="upass1" value="" />
                    381:    <input type="hidden" name="upass2" value="" />
1.33      www       382:    <input type="hidden" name="udom" value="" />
1.63      albertel  383:    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
                    384:    <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14      albertel  385:   </form>
1.16      www       386: ENDSERVERFORM
1.108     tempelho  387: my $coursecatalog;
                    388: if (($showcoursecat eq '') || ($showcoursecat)) {
                    389:     $coursecatalog = &coursecatalog_link($lt{'catalog'});
                    390: }
                    391: my $newuserlink;
                    392: if ($shownewuserlink) {
1.130   ! bisitz    393:     $newuserlink = &newuser_link($lt{'newuser'});
1.108     tempelho  394: }
                    395: my $logintitle;
                    396: if ($loginheader eq 'text') {
1.113     tempelho  397:     $logintitle ='<h2>'.$lt{'log'}.'</h2>';
1.108     tempelho  398: } else {
                    399:     $logintitle = '<img src="'.$login.'" alt="'.
                    400:                   &mt('User Authentication').'" />';
                    401: }
                    402: 
                    403: my $noscript_warning='<noscript><span class="LC_warning"><b>'
                    404:                      .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                    405:                     .'</b></span></noscript>';
                    406: my $helpdeskscript;
                    407: my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                    408:                             $version,$authdomain,\$helpdeskscript);
1.107     tempelho  409: 
1.108     tempelho  410: my $loginform=(<<LFORM);
1.122     bisitz    411: <form name="client" action="" onsubmit="return(send())">
1.115     bisitz    412:   <input type="hidden" name="lextkey" value="$lextkey" />
                    413:   <input type="hidden" name="uextkey" value="$uextkey" />
1.108     tempelho  414:   <b><label for="uname">$lt{'un'}</label>:</b><br />
1.130   ! bisitz    415:   <input type="text" name="uname" id="uname" size="15" value="$authusername" /><br />
1.108     tempelho  416:   <b><label for="upass$now">$lt{'pw'}</label>:</b><br />
1.130   ! bisitz    417:   <input type="password" name="upass$now" id="upass$now" size="15" /><br />
1.108     tempelho  418:   <b><label for="udom">$lt{'dom'}</label>:</b><br />
1.130   ! bisitz    419:   <input type="text" name="udom" id="udom" size="15" value="$authdomain" /><br />
1.108     tempelho  420:   <input type="submit" value="$lt{'log'}" />
                    421: </form>
                    422: LFORM
                    423: 
1.109     raeburn   424:     if ($showbanner) {
                    425:         $r->print(<<HEADER);
                    426: <!-- The LON-CAPA Header -->
                    427: <table border="0" align="left" width="100%" cellspacing="0" cellpadding="1">
                    428:  <tr>
                    429:   <td align="left" valign="top" bgcolor="$pgbg">
1.115     bisitz    430:       <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
1.109     raeburn   431:   </td>
                    432:  </tr>
                    433: </table>
                    434: HEADER
                    435:     }
                    436:     $r->print(<<ENDTOP);
1.118     tempelho  437: <div class="LC_loginpage_space">&nbsp;</div>
                    438: <div class="LC_loginpage_floatLeft">
1.108     tempelho  439: <div class="LC_loginpage_loginContainer">
1.112     muellerd  440:   $logintitle
                    441:    <table border="0" align="left" cellspacing="1" cellpadding="2" width="100%">
1.108     tempelho  442:       <tr>
                    443: 	   <td>
                    444: 		$loginform
                    445:            </td>
                    446:       </tr>
                    447:    </table>   	
                    448:    $noscript_warning
                    449: </div>
1.107     tempelho  450:   
                    451: <div class="LC_loginpage_loginInfo">
1.130   ! bisitz    452:   $loginhelp<br />
        !           453:   $forgotpw<br />
        !           454:   <br />
        !           455:   $contactblock<br />
        !           456:   <br />
        !           457:   $newuserlink<br />
        !           458:   $coursecatalog
1.107     tempelho  459: </div>
1.118     tempelho  460: </div>
                    461: ENDTOP
                    462:     if ($showmainlogo) {
                    463:         $r->print(' <img src="'.$logo.'" alt="" />'."\n");
                    464:     }
                    465: $r->print(<<ENDTOP);
                    466: $announcements
                    467: $domainlogo
1.107     tempelho  468: <div class="LC_loginpage_space">&nbsp;</div>
1.108     tempelho  469: ENDTOP
                    470: 
                    471: $r->print(<<ENDDOCUMENT);
1.115     bisitz    472:      <table border="0" cellspacing="0" cellpadding="0">
1.14      albertel  473:       <tr>
1.110     muellerd  474:        <td  align="left" valign="top">
1.51      www       475:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>
1.14      albertel  476:        </td>
1.110     muellerd  477:        <td  align="left" valign="top">
1.14      albertel  478:         <small><tt>&nbsp;$domain</tt></small>
                    479:        </td>
                    480:       </tr>
                    481:       <tr>
1.110     muellerd  482:        <td  align="left" valign="top">
1.51      www       483:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>
1.14      albertel  484:        </td>
1.110     muellerd  485:        <td align="left" valign="top">
1.14      albertel  486:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
                    487:        </td>
                    488:       </tr>
                    489:       <tr>
1.110     muellerd  490:        <td align="left" valign="top">
1.52      www       491:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>
1.14      albertel  492:        </td>
1.110     muellerd  493:        <td align="left" valign="top">
1.51      www       494:         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
1.42      albertel  495:        </td>
                    496:       </tr>
                    497:       <tr>
1.110     muellerd  498:        <td align="left" valign="top">
1.52      www       499:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>
1.42      albertel  500:        </td>
1.110     muellerd  501:        <td align="left" valign="top">
1.51      www       502:         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
1.14      albertel  503:        </td>
                    504:       </tr>
                    505:      </table>
1.107     tempelho  506:  </div>
1.25      bowersj2  507: 
1.59      albertel  508: <script type="text/javascript">
1.122     bisitz    509: // <![CDATA[
1.59      albertel  510: // the if prevents the script error if the browser can not handle this
1.25      bowersj2  511: if ( document.client.uname ) { document.client.uname.focus(); }
1.122     bisitz    512: // ]]>
1.25      bowersj2  513: </script>
1.62      raeburn   514: $helpdeskscript
1.14      albertel  515: 
1.1       albertel  516: ENDDOCUMENT
1.98      raeburn   517:     my %endargs = ( 'noredirectlink' => 1, );
                    518:     $r->print(&Apache::loncommon::end_page(\%endargs));
1.1       albertel  519:     return OK;
1.60      raeburn   520: }
                    521: 
1.126     raeburn   522: sub redirect_page {
                    523:     my ($desthost) = @_;
                    524:     my $protocol = $Apache::lonnet::protocol{$desthost};
                    525:     $protocol = 'http' if ($protocol ne 'https');
                    526:     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).'/';
                    527:     if ($env{'form.firsturl'} ne '') {
                    528:         $url .='?firsturl='.$env{'form.firsturl'};
                    529:     }
                    530:     my $start_page = &Apache::loncommon::start_page('Switching Server',undef,
                    531:                                                     {'redirect' => [0,$url],});
                    532:     my $end_page   = &Apache::loncommon::end_page();
                    533:     return $start_page.$end_page;
                    534: }
                    535: 
1.60      raeburn   536: sub contactdisplay {
1.90      raeburn   537:     my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_;
1.60      raeburn   538:     my $contactblock;
1.62      raeburn   539:     my $showhelpdesk = 0;
                    540:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                    541:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
                    542:         $showhelpdesk = 1;
                    543:     }
1.90      raeburn   544:     if ($servadm && $showadminmail) {
1.130   ! bisitz    545:         $contactblock .= $$lt{'servadm'}.':<br />'.
        !           546:                          '<tt>'.$servadm.'</tt><br />';
1.90      raeburn   547:     }
1.60      raeburn   548:     if ($showhelpdesk) {
1.114     tempelho  549:         $contactblock .= '<a href="javascript:helpdesk()">'.$lt->{'helpdesk'}.'</a><br />';
1.75      www       550:         my $thisurl = &escape('/adm/login');
1.62      raeburn   551:         $$helpdeskscript = <<"ENDSCRIPT";
                    552: <script type="text/javascript">
1.122     bisitz    553: // <![CDATA[
1.62      raeburn   554: function helpdesk() {
                    555:     var codedom = document.client.udom.value;
                    556:     if (codedom == '') {
                    557:         codedom = "$authdomain";
                    558:     }
                    559:     var querystr = "origurl=$thisurl&codedom="+codedom;
                    560:     document.location.href = "/adm/helpdesk?"+querystr;
                    561:     return;
                    562: }
1.122     bisitz    563: // ]]>
1.62      raeburn   564: </script>
                    565: ENDSCRIPT
1.60      raeburn   566:     }
1.130   ! bisitz    567:     $contactblock .= $version;
1.60      raeburn   568:     return $contactblock;
                    569: }
1.83      raeburn   570: 
                    571: sub forgotpwdisplay {
1.84      raeburn   572:     my (%lt) = @_;
1.83      raeburn   573:     my $prompt_for_resetpw = 1; 
                    574:     if ($prompt_for_resetpw) {
1.107     tempelho  575:         return '<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a>';
1.84      raeburn   576:     }
                    577:     return;
                    578: }
                    579: 
                    580: sub loginhelpdisplay {
                    581:     my (%lt) = @_;
                    582:     my $login_help = 1;
                    583:     if ($login_help) {
1.107     tempelho  584:         return '<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a>';
1.83      raeburn   585:     }
                    586:     return;
                    587: }
1.1       albertel  588: 
1.90      raeburn   589: sub coursecatalog_link {
                    590:     my ($linkname) = @_;
                    591:     return <<"END";
1.107     tempelho  592:       <a href="/adm/coursecatalog">$linkname</a>
1.90      raeburn   593: END
                    594: }
                    595: 
1.101     raeburn   596: sub newuser_link {
                    597:     my ($linkname) = @_;
1.130   ! bisitz    598:     return '<a href="/adm/createaccount">'.$linkname.'</a>';
1.101     raeburn   599: }
                    600: 
1.1       albertel  601: 1;
                    602: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>