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

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

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