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

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

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