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

1.1       albertel    1: # The LearningOnline Network
                      2: # Login Screen
1.11      www         3: #
1.86    ! raeburn     4: # $Id: lonlogin.pm,v 1.85 2006/12/05 02:55:56 albertel 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);
1.55      www        33: use CGI::Cookie();
1.1       albertel   34: use Apache::File ();
1.63      albertel   35: use Apache::lonnet;
1.12      albertel   36: use Apache::loncommon();
1.49      www        37: use Apache::lonauth();
1.50      www        38: use Apache::lonlocal;
1.71      albertel   39: use Apache::migrateuser();
1.75      www        40: use lib '/home/httpd/lib/perl/';
                     41: use LONCAPA;
                     42:  
1.1       albertel   43: 
1.81      albertel   44: sub additional_machine_domains {
                     45:     my @domains;
                     46:     open(my $fh,"<".$Apache::lonnet::perlvar{'lonTabDir'}.'/expected_domains.tab');
                     47:     while( my $line = <$fh>) {
                     48: 	$line =~ s/\s//g;
                     49: 	push(@domains,$line);
                     50:     }
                     51:     return @domains;
                     52: }
                     53: 
1.1       albertel   54: sub handler {
                     55:     my $r = shift;
1.71      albertel   56: 
                     57:     &Apache::loncommon::get_unprocessed_cgi
1.79      albertel   58: 	(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
                     59: 	      $ENV{'REDIRECT_QUERY_STRING'}),
1.71      albertel   60: 	 ['interface','username','domain','firsturl','localpath','localres',
                     61: 	  'token']);
                     62: 
                     63: # -- check if they are a migrating user
                     64:     if (defined($env{'form.token'})) {
                     65: 	return &Apache::migrateuser::handler($r);
                     66:     }
                     67: 
1.53      www        68:     &Apache::loncommon::no_cache($r);
                     69:     &Apache::lonlocal::get_language_handle($r);
1.54      www        70:     &Apache::loncommon::content_type($r,'text/html');
1.1       albertel   71:     $r->send_http_header;
                     72:     return OK if $r->header_only;
                     73: 
1.49      www        74: 
                     75: # Are we re-routing?
                     76:     if (-e '/home/httpd/html/lon-status/reroute.txt') {
                     77: 	&Apache::lonauth::reroute($r);
                     78: 	return OK;
                     79:     }
1.55      www        80: 
1.71      albertel   81: 
1.55      www        82: # -------------------------------- Prevent users from attempting to login twice
                     83:     my %cookies=CGI::Cookie->parse($r->header_in('Cookie'));
                     84:     my $lonid=$cookies{'lonID'};
                     85:     my $cookie;
                     86:     if ($lonid) {
1.85      albertel   87: 	my $handle=&LONCAPA::clean_handle($lonid->value);
1.55      www        88:         my $lonidsdir=$r->dir_config('lonIDsDir');
1.70      www        89: 	if (-e "$lonidsdir/$handle.id") {
                     90: # Is there an existing token file?
                     91: 	    if ($handle=~/^publicuser\_/) {
                     92: # For "public user" - remove it, we apparently really want to login
                     93: 		unlink("$lonidsdir/$handle.id");
                     94: 	    } elsif ($handle ne '') {
1.55      www        95: # Indeed, a valid token is found
1.74      albertel   96: 		my $start_page = 
                     97: 		    &Apache::loncommon::start_page('Already logged in');
                     98: 		my $end_page = 
                     99: 		    &Apache::loncommon::end_page();
1.70      www       100: 		$r->print(<<ENDFAILED);
1.74      albertel  101: $start_page
1.55      www       102: <h1>You are already logged in</h1>
                    103: <p>Please either <a href="/adm/roles">continue the current session</a> or
                    104: <a href="/adm/logout">logout</a>.</p>
                    105: <p>
                    106: <a href="/adm/loginproblems.html">Problems?</a></p>
1.74      albertel  107: $end_page
1.55      www       108: ENDFAILED
1.70      www       109:                 return OK;
                    110:  	    }  
1.55      www       111: 	}
                    112:     }
                    113: 
                    114: # ---------------------------------------------------- No valid token, continue
1.16      www       115: 
1.70      www       116:  # ---------------------------- Not possible to really login to domain "public"
                    117:     if ($env{'form.domain'} eq 'public') {
                    118: 	$env{'form.domain'}='';
                    119: 	$env{'form.username'}='';
                    120:     }
1.32      www       121: # ----------------------------------------------------------- Process Interface
1.63      albertel  122:     $env{'form.interface'}=~s/\W//g;
1.16      www       123: 
1.32      www       124:     my $textbrowsers=$r->dir_config('lonTextBrowsers');
                    125:     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
                    126:     
                    127:     foreach (split(/\:/,$textbrowsers)) {
                    128: 	if ($httpbrowser=~/$_/i) {
1.63      albertel  129: 	    $env{'form.interface'}='textual';
1.32      www       130:         }
                    131:     }
                    132: 
1.63      albertel  133:     my $fullgraph=($env{'form.interface'} ne 'textual');
1.40      albertel  134:     my $port_to_use=$r->dir_config('lonhttpdPort');
                    135:     if (!defined($port_to_use)) {
                    136: 	$port_to_use='8080';
                    137:     }
                    138:     my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use.
1.26      www       139:                   $r->dir_config('lonIconsURL');
1.1       albertel  140:     my $domain  = $r->dir_config('lonDefDomain');
1.68      albertel  141:     my $testdomain=(split(/\./,$ENV{'HTTP_HOST'}))[0];
1.81      albertel  142:     foreach my $posdom (&Apache::lonnet::current_machine_domains(),
                    143: 			&additional_machine_domains()) {
1.73      albertel  144: 	if (lc($posdom) eq lc($testdomain)) { $domain=$posdom; }
1.68      albertel  145:     }
1.63      albertel  146:     if (($env{'form.domain'}) && 
                    147: 	 ($Apache::lonnet::domaindescription{$env{'form.domain'}})) {
                    148: 	$domain=$env{'form.domain'};
1.46      www       149:     }
1.1       albertel  150:     my $role    = $r->dir_config('lonRole');
                    151:     my $loadlim = $r->dir_config('lonLoadLim');
                    152:     my $lonhost = $r->dir_config('lonHostID');
                    153:     my $tabdir  = $r->dir_config('lonTabDir');
1.6       www       154:     my $include = $r->dir_config('lonIncludes');
1.37      www       155:     my $expire  = $r->dir_config('lonExpire');
1.44      www       156:     my $version = $r->dir_config('lonVersion');
1.76      albertel  157:     my $host_name = $Apache::lonnet::hostname{$lonhost};
1.1       albertel  158: 
1.30      www       159: # --------------------------------------------- Default values for login fields
                    160: 
1.63      albertel  161:     my $authusername=($env{'form.username'}?$env{'form.username'}:'');
                    162:     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
1.30      www       163: 
                    164: # ---------------------------------------------------------- Determine own load
1.1       albertel  165:     my $loadavg;
1.41      albertel  166:     {
                    167: 	my $loadfile=Apache::File->new('/proc/loadavg');
                    168: 	$loadavg=<$loadfile>;
                    169:     }
1.1       albertel  170:     $loadavg =~ s/\s.*//g;
1.57      matthew   171:     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
1.41      albertel  172:     my $userloadpercent=&Apache::lonnet::userload();
1.1       albertel  173: 
1.30      www       174: # ------------------------------------------------------- Do the load balancing
1.80      albertel  175:     my $otherserver= &Apache::lonnet::absolute_url($host_name);
1.31      www       176:     my $firsturl=
1.63      albertel  177:     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
1.1       albertel  178: # ---------------------------------------- Are we access server and overloaded?
1.41      albertel  179:     if (($role eq 'access') &&
                    180: 	(($userloadpercent>100.0)||($loadpercent>100.0))) {
1.47      albertel  181:         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
                    182: 	if ($unloaded) { $otherserver=$unloaded; }
1.1       albertel  183:     }
1.6       www       184: 
1.45      www       185: # ----------------------------------------------------------- Get announcements
                    186:     my $announcements=&Apache::lonnet::getannounce();
1.6       www       187: # -------------------------------------------------------- Set login parameters
                    188: 
                    189:     my @hexstr=('0','1','2','3','4','5','6','7',
                    190:                 '8','9','a','b','c','d','e','f');
                    191:     my $lkey='';
                    192:     for (0..7) {
                    193:         $lkey.=$hexstr[rand(15)];
                    194:     }
                    195: 
                    196:     my $ukey='';
                    197:     for (0..7) {
                    198:         $ukey.=$hexstr[rand(15)];
                    199:     }
                    200: 
                    201:     my $lextkey=hex($lkey);
1.15      www       202:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
                    203: 
1.6       www       204:     my $uextkey=hex($ukey);
1.15      www       205:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
                    206: 
1.31      www       207: # -------------------------------------------------------- Store away log token
1.6       www       208:     my $logtoken=Apache::lonnet::reply(
1.7       www       209:        'tmpput:'.$ukey.$lkey.'&'.$firsturl,
1.6       www       210:        $lonhost);
1.31      www       211: 
                    212: # ------------------- If we cannot talk to ourselves, we are in serious trouble
                    213: 
                    214:     if ($logtoken eq 'con_lost') {
                    215:         my $spares='';
1.64      albertel  216: 	my $last;
                    217:         foreach my $hostid (sort
                    218: 			    {
                    219: 				$Apache::lonnet::hostname{$a} cmp
                    220: 				    $Apache::lonnet::hostname{$b};
                    221: 			    }
                    222: 			    keys(%Apache::lonnet::spareid)) {
1.58      matthew   223:             next if ($hostid eq $lonhost);
1.64      albertel  224:             next if ($last eq $Apache::lonnet::hostname{$hostid});
1.58      matthew   225:             $spares.='<br /><font size="+1"><a href="http://'.
                    226:                 $Apache::lonnet::hostname{$hostid}.
                    227:                 '/adm/login?domain='.$authdomain.'">'.
                    228:                 $Apache::lonnet::hostname{$hostid}.'</a>'.
                    229:                 ' (preferred)</font>'.$/;
1.64      albertel  230: 	    $last=$Apache::lonnet::hostname{$hostid};
1.58      matthew   231:         }
                    232:         $spares.= '<br />';
1.64      albertel  233:         foreach my $hostid (sort
                    234: 			    {
                    235: 				$Apache::lonnet::hostname{$a} cmp
                    236: 				    $Apache::lonnet::hostname{$b};
                    237: 			    }
                    238: 			    keys(%Apache::lonnet::hostname)) {
1.58      matthew   239:             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
1.64      albertel  240:             next if ($last eq $Apache::lonnet::hostname{$hostid});
1.58      matthew   241:             $spares.='<br /><a href="http://'.
                    242:                 $Apache::lonnet::hostname{$hostid}.
                    243:                 '/adm/login?domain='.$authdomain.'">'.
                    244:                 $Apache::lonnet::hostname{$hostid}.'</a>';
1.64      albertel  245: 	    $last=$Apache::lonnet::hostname{$hostid};
1.31      www       246:         }
                    247: 	$r->print(<<ENDTROUBLE);
                    248: <html>
                    249: <head><title>The LearningOnline Network with CAPA</title></head>
                    250: <body bgcolor="#FFFFFF">
                    251: <img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />
                    252: <h3>This LON-CAPA server is temporarily not available for login</h3>
                    253: <p>Please attempt to login to one of the following servers:</p>$spares
                    254: </body>
                    255: </html>
                    256: ENDTROUBLE
                    257:         return OK;
                    258:     }
                    259: 
                    260: # ----------------------------------------------- Apparently we are in business
                    261: 
1.48      albertel  262:     my $domainlogo=&Apache::loncommon::domainlogo($domain);
1.38      www       263: 
1.6       www       264: # --------------------------------------------------- Print login screen header
                    265:     $r->print(<<ENDHEADER);
1.1       albertel  266: <html>
                    267: <head>
1.37      www       268: <meta HTTP-EQUIV="Refresh" CONTENT="$expire; url=/adm/roles" />
1.2       www       269: <title>The LearningOnline Network with CAPA Login</title>
1.1       albertel  270: </head>
1.6       www       271: ENDHEADER
                    272: # ---------------------------------------------------- Serve out DES JavaScript
                    273:     {
                    274: 	my $jsh=Apache::File->new($include."/londes.js");
                    275:         $r->print(<$jsh>);
                    276:     }
1.21      www       277: 
                    278: # ----------------------------------------------------------- Front page design
1.35      www       279:     my $pgbg=
1.46      www       280:       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');
1.35      www       281:     my $font=
1.46      www       282:       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');
1.35      www       283:     my $link=
1.46      www       284:       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');
1.35      www       285:     my $vlink=
1.46      www       286:       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');
                    287:     my $alink=&Apache::loncommon::designparm('login.alink',$domain);
1.35      www       288:     my $mainbg=
1.46      www       289:       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');
1.35      www       290:     my $sidebg=
1.46      www       291:       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');
                    292:     my $logo=&Apache::loncommon::designparm('login.logo',$domain);
                    293:     my $img=&Apache::loncommon::designparm('login.img',$domain);
1.21      www       294: 
1.51      www       295: # ----------------------------------------------------------------------- Texts
                    296: 
                    297: my %lt=&Apache::lonlocal::texthash(
                    298: 		  'un'  => 'Username',
                    299: 		  'pw'  => 'Password',
                    300: 		  'dom' => 'Domain',
                    301: 		  'perc' => 'percent',
1.52      www       302: 		  'load' => 'Load',
                    303:                   'userload' => 'User Load',
1.84      raeburn   304:                   'about'  => 'About LON-CAPA',
                    305:                   'access' => 'Accessibility Options',
                    306:                   'catalog' => 'Course Catalog',
1.52      www       307: 		  'auth' => 'userauthentication.gif',
1.51      www       308: 		  'log' => 'Log in',
1.84      raeburn   309: 		  'help' => 'Log-in Help',
1.51      www       310: 		  'serv' => 'Server',
1.83      raeburn   311:                   'helpdesk' => 'Contact Helpdesk',
                    312:                   'forgotpw' => 'Forgot password?');
1.66      www       313: # -------------------------------------------------- Change password field name
                    314:     my $now=time;
1.84      raeburn   315:     my $forgotpw = &forgotpwdisplay(%lt);
                    316:     my $loginhelp = &loginhelpdisplay(%lt);
1.6       www       317: # ---------------------------------------------------------- Serve rest of page
1.16      www       318:     $r->print(<<ENDSCRIPT);
1.6       www       319: 
1.21      www       320: <body bgcolor="$pgbg" text="$font" link="$link" vlink="$vlink" alink="$alink"
1.27      albertel  321:   topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>
1.6       www       322: 
1.14      albertel  323:  <script language="JavaScript">
                    324:     function send()
                    325:     {
1.6       www       326: 	this.document.server.elements.uname.value
                    327:        =this.document.client.elements.uname.value;
                    328: 
                    329:         this.document.server.elements.udom.value
                    330:        =this.document.client.elements.udom.value;
                    331: 
1.33      www       332:         this.document.server.elements.imagesuppress.value
1.36      www       333:        =this.document.client.elements.imagesuppress.checked;
1.33      www       334: 
                    335:         this.document.server.elements.embedsuppress.value
1.36      www       336:        =this.document.client.elements.embedsuppress.checked;
1.33      www       337: 
1.34      www       338:         this.document.server.elements.appletsuppress.value
1.36      www       339:        =this.document.client.elements.appletsuppress.checked;
1.34      www       340: 
1.33      www       341:         this.document.server.elements.fontenhance.value
1.36      www       342:        =this.document.client.elements.fontenhance.checked;
1.33      www       343: 
                    344:         this.document.server.elements.blackwhite.value
1.36      www       345:        =this.document.client.elements.blackwhite.checked;
1.33      www       346: 
1.35      www       347:         this.document.server.elements.remember.value
1.36      www       348:        =this.document.client.elements.remember.checked;
1.35      www       349: 
1.6       www       350:         uextkey=this.document.client.elements.uextkey.value;
                    351:         lextkey=this.document.client.elements.lextkey.value;
                    352:         initkeys();
                    353: 
1.65      www       354:         this.document.server.elements.upass0.value
1.66      www       355: 	    =crypted(this.document.client.elements.upass$now.value.substr(0,15));
1.65      www       356: 	this.document.server.elements.upass1.value
1.66      www       357: 	    =crypted(this.document.client.elements.upass$now.value.substr(15,15));
1.65      www       358: 	this.document.server.elements.upass2.value
1.66      www       359: 	    =crypted(this.document.client.elements.upass$now.value.substr(30,15));
                    360: 
                    361:         this.document.client.elements.uname.value='';
                    362:         this.document.client.elements.upass$now.value='';
1.6       www       363: 
                    364:         this.document.server.submit();
1.19      bowersj2  365: 	return false;
1.6       www       366:     }
1.14      albertel  367:  </script>
1.16      www       368: ENDSCRIPT
1.6       www       369: 
1.16      www       370:     if ($fullgraph) {
                    371: 	$r->print(
                    372: 		  '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
                    373:     }
1.6       www       374: 
1.16      www       375:     $r->print(<<ENDSERVERFORM);
1.14      albertel  376:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33      www       377:    <input type="hidden" name="logtoken" value="$logtoken" />
                    378:    <input type="hidden" name="serverid" value="$lonhost" />
1.63      albertel  379:    <input type="hidden" name="interface" value="$env{'form.interface'}" />
1.33      www       380:    <input type="hidden" name="uname" value="" />
1.65      www       381:    <input type="hidden" name="upass0" value="" />
                    382:    <input type="hidden" name="upass1" value="" />
                    383:    <input type="hidden" name="upass2" value="" />
1.33      www       384:    <input type="hidden" name="udom" value="" />
                    385:    <input type="hidden" name="imagesuppress"  value="" />
1.34      www       386:    <input type="hidden" name="appletsuppress"  value="" />
1.33      www       387:    <input type="hidden" name="embedsuppress"  value="" />
                    388:    <input type="hidden" name="fontenhance"  value="" />
                    389:    <input type="hidden" name="blackwhite"  value="" />
1.35      www       390:    <input type="hidden" name="remember"  value="" />
1.63      albertel  391:    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
                    392:    <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14      albertel  393:   </form>
1.16      www       394: ENDSERVERFORM
                    395:     if ($fullgraph) { $r->print(<<ENDTOP);
1.14      albertel  396:   <!-- The LON-CAPA Header -->
                    397:   <tr>
                    398: 
                    399:    <!-- Row 1 Columns 2-4 -->
1.29      www       400:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg"><img src="$img" border=0 alt="The Learning Online Network with CAPA" /></td>
1.14      albertel  401:   </tr>
                    402: 
                    403:   <!-- The gray bar that starts the two table frames -->
                    404:   <tr>
                    405: 
                    406:    <!-- Row 2 Column 1 -->
1.21      www       407:    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  408: 
                    409:    <!-- Row 2 Column 2 -->
1.19      bowersj2  410:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
1.14      albertel  411: 
                    412:    <!-- Row 2 Column 3 -->
1.19      bowersj2  413:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
1.14      albertel  414: 
                    415:    <!-- Row 2 Column 4 -->
1.19      bowersj2  416:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
1.14      albertel  417:   </tr>
                    418:   <tr>
                    419:    
1.84      raeburn   420:    <!-- A cell that will hold the 'access', 'about', and 'catalog' links -->
1.14      albertel  421:    <!-- Row 3 Column 1 -->
1.86    ! raeburn   422:    <td valign="top" height="60" align="left" bgcolor="$sidebg">
1.84      raeburn   423:     <table cellpadding="0" cellspacing="2" border="0">
                    424:      <tr>
                    425:       <td>&nbsp;</td>
                    426:       <td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td>
1.86    ! raeburn   427:      </tr>
        !           428:      <tr>
        !           429:       <td>&nbsp;</td>
        !           430:       <td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td>
        !           431:      </tr>
        !           432:      <tr>
        !           433:       <td>&nbsp;</td>
        !           434:       <td><a href="/adm/coursecatalog"><b>$lt{'catalog'}</b></a></td>
        !           435:      </tr>
        !           436:      <tr>
1.84      raeburn   437:       <td colspan="2">&nbsp;</td>
1.86    ! raeburn   438:      </tr>
        !           439:     </table>
        !           440:    </td>
1.14      albertel  441:    <!-- The shaded space between the two main columns -->
                    442:    <!-- Row 3 Column 2 -->
1.19      bowersj2  443:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  444: 
                    445:    <!-- The right main column holding the large LON-CAPA logo-->
                    446:    <!-- Rows 3-4 Column 3 -->
1.45      www       447:    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">
1.14      albertel  448:     <center>
1.21      www       449:      <img src="$logo" alt="" />
1.14      albertel  450:     </center>
                    451:    </td>
                    452: 
                    453:    <!-- Row 3 Column 4 -->
1.19      bowersj2  454:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  455:   </tr>
                    456:   <tr>
                    457: 
                    458:    <!-- The entry form -->
                    459:    <!-- Row 4 Column 1 -->
1.21      www       460:    <td align="center" valign="middle" bgcolor="$sidebg">
1.16      www       461: ENDTOP
1.32      www       462: } else {
1.45      www       463:     $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1><h2>Text-based Interface Login</h2>'.$announcements);
1.33      www       464: }
                    465:     $r->print('<form name="client" onsubmit="return(send())">');
                    466:     unless ($fullgraph) {
                    467:         $r->print(<<ENDACCESSOPTIONS);
1.35      www       468: <h3>Select Accessibility Options</h3>
1.67      albertel  469: <label><input type="checkbox" name="imagesuppress" /> Suppress rendering of images</label><br />
                    470: <label><input type="checkbox" name="appletsuppress" /> Suppress Java applets</label><br />
                    471: <label><input type="checkbox" name="embedsuppress" /> Suppress rendering of embedded multimedia</label><br />
                    472: <label><input type="checkbox" name="fontenhance" /> Increase font size</label><br />
                    473: <label><input type="checkbox" name="blackwhite" /> Switch to black and white mode</label><br />
1.35      www       474: <input type="checkbox" name="remember" /> Remember these settings for next login<hr />
1.33      www       475: ENDACCESSOPTIONS
                    476: } else {
                    477:     $r->print(<<ENDNOOPT);
                    478: <input type="hidden" name="imagesuppress"  value="" />
                    479: <input type="hidden" name="embedsuppress"  value="" />
1.34      www       480: <input type="hidden" name="appletsuppress"  value="" />
1.33      www       481: <input type="hidden" name="fontenhance"  value="" />
                    482: <input type="hidden" name="blackwhite"  value="" />
1.35      www       483: <input type="hidden" name="remember"  value="" />
1.33      www       484: ENDNOOPT
1.16      www       485: }
                    486:     $r->print(<<ENDLOGIN);
1.14      albertel  487:      <input type="hidden" name="lextkey" value="$lextkey">
                    488:      <input type="hidden" name="uextkey" value="$uextkey">
                    489: 
                    490:      <!-- Start the sub-table for text and input alignment -->
                    491:      <table border=0 cellspacing=0 cellpadding=0>
1.52      www       492:       <tr><td bgcolor="$sidebg" colspan=2><img src="$iconpath/$lt{'auth'}" alt="User Authentication" /></td></tr>
1.14      albertel  493:       <tr>
1.51      www       494:        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'un'}:</b></font></td>
1.30      www       495:        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
1.14      albertel  496:       </tr>
                    497:       <tr>
1.51      www       498:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'pw'}:</b></font></td>
1.66      www       499:        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>
1.14      albertel  500:       </tr>
                    501:       <tr>
1.51      www       502:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:</b></font></td>
1.30      www       503:        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
1.14      albertel  504:       </tr>
                    505:       <tr>
1.84      raeburn   506:        <td bgcolor="$mainbg">&nbsp;</td>
1.28      www       507:        <td bgcolor="$mainbg" valign="bottom" align="center">
1.14      albertel  508:         <br />
1.51      www       509:         <input type="submit" value="$lt{'log'}" />
1.14      albertel  510:        </td>
                    511:       </tr>
1.83      raeburn   512:       <tr>
                    513:        <td bgcolor="$mainbg" valign="bottom" align="left" colspan="2">
1.84      raeburn   514:         $loginhelp
1.83      raeburn   515:         $forgotpw
                    516:        </td>
                    517:       </tr>
1.14      albertel  518:      </table>
                    519:      <!-- End sub-table -->
                    520:     </form>
1.16      www       521: ENDLOGIN
                    522:     if ($fullgraph) {
1.62      raeburn   523:         my $helpdeskscript;
1.82      www       524:         my $contactblock = &contactdisplay(\%lt,$version,$authdomain,\$helpdeskscript);
1.16      www       525: 	$r->print(<<ENDDOCUMENT);
1.14      albertel  526:    </td>
                    527: 
                    528:    <!-- Row 4 Column 2 -->
1.19      bowersj2  529:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.45      www       530: 
                    531:    <!-- Row 4 Column 3 -->
                    532: <td bgcolor="$mainbg">$announcements</td>
1.14      albertel  533: 
                    534:    <!-- Row 4 Column 4 -->
1.19      bowersj2  535:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  536:   </tr>
                    537:   <tr>
                    538: 
                    539:    <!-- Row 5 Column 1 -->
1.21      www       540:    <td bgcolor="$sidebg" valign="middle" align="left">
1.14      albertel  541:      <br />
                    542:      <table border=0 cellspacing=0 cellpadding=0>
                    543:       <tr>
1.21      www       544:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       545:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>
1.14      albertel  546:        </td>
1.21      www       547:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  548:         <small><tt>&nbsp;$domain</tt></small>
                    549:        </td>
                    550:       </tr>
                    551:       <tr>
1.21      www       552:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       553:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>
1.14      albertel  554:        </td>
1.21      www       555:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  556:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
                    557:        </td>
                    558:       </tr>
                    559:       <tr>
1.21      www       560:        <td bgcolor="$sidebg" align="left" valign="top">
1.52      www       561:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small>
1.14      albertel  562:        </td>
1.21      www       563:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       564:         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
1.42      albertel  565:        </td>
                    566:       </tr>
                    567:       <tr>
                    568:        <td bgcolor="$sidebg" align="left" valign="top">
1.52      www       569:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small>
1.42      albertel  570:        </td>
                    571:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       572:         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
1.14      albertel  573:        </td>
                    574:       </tr>
                    575:      </table>
                    576:      <br />
1.60      raeburn   577:     $contactblock
1.14      albertel  578:    </td>
                    579: 
                    580:    <!-- Row 5 Column 2 -->
1.19      bowersj2  581:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  582: 
                    583:    <!-- Row 5 Column 3 -->
1.21      www       584:    <td width="100%" valign="bottom" bgcolor="$mainbg">
1.20      www       585: $domainlogo
                    586: </td>
1.14      albertel  587: 
                    588:    <!-- Row 5 Column 4 -->
1.19      bowersj2  589:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  590:   </tr>
                    591:   <tr>
                    592: 
                    593:    <!-- Row 6 Column 1 -->
1.21      www       594:    <td bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  595: 
                    596:    <!-- Row 6 Column 2 -->
1.19      bowersj2  597:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
1.14      albertel  598: 
                    599:    <!-- Row 6 Column 3 -->
1.19      bowersj2  600:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
1.14      albertel  601: 
                    602:    <!-- Row 6 Column 4 -->
1.19      bowersj2  603:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
1.14      albertel  604:   </tr>
1.1       albertel  605:  </table>
1.25      bowersj2  606: 
1.59      albertel  607: <script type="text/javascript">
                    608: // the if prevents the script error if the browser can not handle this
1.25      bowersj2  609: if ( document.client.uname ) { document.client.uname.focus(); }
                    610: </script>
1.62      raeburn   611: $helpdeskscript
1.14      albertel  612: 
1.1       albertel  613: ENDDOCUMENT
1.16      www       614: }
                    615:     $r->print('</body></html>');
1.1       albertel  616:     return OK;
1.60      raeburn   617: }
                    618: 
                    619: sub contactdisplay {
1.82      www       620:     my ($lt,$version,$authdomain,$helpdeskscript) = @_;
1.60      raeburn   621:     my $contactblock;
1.62      raeburn   622:     my $showhelpdesk = 0;
                    623:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                    624:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
                    625:         $showhelpdesk = 1;
                    626:     }
1.60      raeburn   627:     if ($showhelpdesk) {
1.84      raeburn   628:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />';
1.75      www       629:         my $thisurl = &escape('/adm/login');
1.62      raeburn   630:         $$helpdeskscript = <<"ENDSCRIPT";
                    631: <script type="text/javascript">
                    632: function helpdesk() {
                    633:     var codedom = document.client.udom.value;
                    634:     if (codedom == '') {
                    635:         codedom = "$authdomain";
                    636:     }
                    637:     var querystr = "origurl=$thisurl&codedom="+codedom;
                    638:     document.location.href = "/adm/helpdesk?"+querystr;
                    639:     return;
                    640: }
                    641: </script>
                    642: ENDSCRIPT
1.60      raeburn   643:     }
                    644:     $contactblock .= <<"ENDBLOCK";
                    645:      &nbsp;&nbsp;&nbsp;$version
                    646: ENDBLOCK
                    647:     return $contactblock;
                    648: }
1.83      raeburn   649: 
                    650: sub forgotpwdisplay {
1.84      raeburn   651:     my (%lt) = @_;
1.83      raeburn   652:     my $prompt_for_resetpw = 1; 
                    653:     if ($prompt_for_resetpw) {
1.84      raeburn   654:         return '<br />&nbsp;&nbsp;&nbsp;<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a></b><br /><br />';
                    655:     }
                    656:     return;
                    657: }
                    658: 
                    659: sub loginhelpdisplay {
                    660:     my (%lt) = @_;
                    661:     my $login_help = 1;
                    662:     if ($login_help) {
                    663:         return '&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a></b>';
1.83      raeburn   664:     }
                    665:     return;
                    666: }
1.1       albertel  667: 
                    668: 1;
                    669: __END__

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