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

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

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