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

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

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