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

1.1       albertel    1: # The LearningOnline Network
                      2: # Login Screen
1.11      www         3: #
1.106.2.2! raeburn     4: # $Id: lonlogin.pm,v 1.106.2.1 2008/12/10 17:45:29 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.106     bisitz    204:                 ' '.&mt('(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:     }
1.106.2.1  raeburn   269:     my $showbanner = 1;
                    270:     my $showmainlogo = 1;
                    271:     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
                    272:         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
                    273:     }
                    274:     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
                    275:         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
                    276:     }
1.98      raeburn   277:     my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
1.90      raeburn   278:     my $showcoursecat =
                    279:         &Apache::loncommon::designparm('login.coursecatalog',$domain);
1.98      raeburn   280:     my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
1.101     raeburn   281:     my $shownewuserlink = 
                    282:         &Apache::loncommon::designparm('login.newuser',$domain);
1.66      www       283:     my $now=time;
1.98      raeburn   284:     my $js = (<<ENDSCRIPT);
1.6       www       285: 
1.14      albertel  286:  <script language="JavaScript">
                    287:     function send()
                    288:     {
1.98      raeburn   289:         this.document.server.elements.uname.value
1.6       www       290:        =this.document.client.elements.uname.value;
                    291: 
                    292:         this.document.server.elements.udom.value
                    293:        =this.document.client.elements.udom.value;
                    294: 
1.33      www       295:         this.document.server.elements.imagesuppress.value
1.36      www       296:        =this.document.client.elements.imagesuppress.checked;
1.33      www       297: 
                    298:         this.document.server.elements.embedsuppress.value
1.36      www       299:        =this.document.client.elements.embedsuppress.checked;
1.33      www       300: 
1.34      www       301:         this.document.server.elements.appletsuppress.value
1.36      www       302:        =this.document.client.elements.appletsuppress.checked;
1.34      www       303: 
1.33      www       304:         this.document.server.elements.fontenhance.value
1.36      www       305:        =this.document.client.elements.fontenhance.checked;
1.33      www       306: 
                    307:         this.document.server.elements.blackwhite.value
1.36      www       308:        =this.document.client.elements.blackwhite.checked;
1.33      www       309: 
1.35      www       310:         this.document.server.elements.remember.value
1.36      www       311:        =this.document.client.elements.remember.checked;
1.35      www       312: 
1.6       www       313:         uextkey=this.document.client.elements.uextkey.value;
                    314:         lextkey=this.document.client.elements.lextkey.value;
                    315:         initkeys();
                    316: 
1.65      www       317:         this.document.server.elements.upass0.value
1.98      raeburn   318:             =crypted(this.document.client.elements.upass$now.value.substr(0,15));
                    319:         this.document.server.elements.upass1.value
                    320:             =crypted(this.document.client.elements.upass$now.value.substr(15,15));
                    321:         this.document.server.elements.upass2.value
                    322:             =crypted(this.document.client.elements.upass$now.value.substr(30,15));
1.66      www       323: 
                    324:         this.document.client.elements.uname.value='';
                    325:         this.document.client.elements.upass$now.value='';
1.6       www       326: 
                    327:         this.document.server.submit();
1.98      raeburn   328:         return false;
1.6       www       329:     }
1.14      albertel  330:  </script>
1.98      raeburn   331: 
1.16      www       332: ENDSCRIPT
1.6       www       333: 
1.98      raeburn   334: # --------------------------------------------------- Print login screen header
                    335: 
                    336:     my %add_entries = (topmargin    => "0",
                    337:                        leftmargin   => "0",
                    338:                        marginheight => "0",
                    339:                        marginwidth  => "0",
                    340:                        bgcolor      => "$pgbg",
                    341:                        text         => "$font",
                    342:                        link         => "$link",
                    343:                        vlink        => "$vlink",
                    344:                        alink        => "$alink",);
                    345: 
                    346:     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
                    347:                                        { 'redirect'       => [$expire,'/adm/roles'], 
                    348:                                          'add_entries' => \%add_entries,
                    349:                                          'only_body'   => 1,}));
                    350: 
                    351: # ----------------------------------------------------------------------- Texts
                    352: 
                    353: my %lt=&Apache::lonlocal::texthash(
                    354: 		  'un'  => 'Username',
                    355: 		  'pw'  => 'Password',
                    356: 		  'dom' => 'Domain',
                    357: 		  'perc' => 'percent',
1.105     bisitz    358: 		  'load' => 'Server Load',
1.98      raeburn   359:                   'userload' => 'User Load',
                    360:                   'about'  => 'About LON-CAPA',
                    361:                   'access' => 'Accessibility Options',
                    362:                   'catalog' => 'Course Catalog',
                    363: 		  'log' => 'Log in',
                    364: 		  'help' => 'Log-in Help',
                    365: 		  'serv' => 'Server',
                    366:                   'servadm' => 'Server Administration',
                    367:                   'helpdesk' => 'Contact Helpdesk',
1.99      bisitz    368:                   'forgotpw' => 'Forgot password?',
1.101     raeburn   369:                   'newuser'  => 'New User?',
1.99      bisitz    370:                   'options_headline' => 'Select Accessibility Options',
                    371:                   'sprs_img' => 'Suppress rendering of images',
                    372:                   'sprs_applet' => 'Suppress Java applets',
                    373:                   'sprs_embed' => 'Suppress rendering of embedded multimedia',
                    374:                   'sprs_font' => 'Increase font size',
                    375:                   'sprs_blackwhite' => 'Switch to black and white mode',
                    376:                   'remember' => 'Remember these settings for next login');
1.98      raeburn   377: # -------------------------------------------------- Change password field name
                    378:     my $forgotpw = &forgotpwdisplay(%lt);
                    379:     my $loginhelp = &loginhelpdisplay(%lt);
                    380: 
                    381: # ---------------------------------------------------- Serve out DES JavaScript
                    382:     {
                    383:         my $jsh=Apache::File->new($include."/londes.js");
                    384:         $r->print(<$jsh>);
                    385:     }
                    386: # ---------------------------------------------------------- Serve rest of page
                    387: 
1.16      www       388:     if ($fullgraph) {
                    389: 	$r->print(
                    390: 		  '<table width="100%" cellpadding=0 cellspacing=0 border=0>');
                    391:     }
1.6       www       392: 
1.16      www       393:     $r->print(<<ENDSERVERFORM);
1.14      albertel  394:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33      www       395:    <input type="hidden" name="logtoken" value="$logtoken" />
                    396:    <input type="hidden" name="serverid" value="$lonhost" />
1.63      albertel  397:    <input type="hidden" name="interface" value="$env{'form.interface'}" />
1.33      www       398:    <input type="hidden" name="uname" value="" />
1.65      www       399:    <input type="hidden" name="upass0" value="" />
                    400:    <input type="hidden" name="upass1" value="" />
                    401:    <input type="hidden" name="upass2" value="" />
1.33      www       402:    <input type="hidden" name="udom" value="" />
                    403:    <input type="hidden" name="imagesuppress"  value="" />
1.34      www       404:    <input type="hidden" name="appletsuppress"  value="" />
1.33      www       405:    <input type="hidden" name="embedsuppress"  value="" />
                    406:    <input type="hidden" name="fontenhance"  value="" />
                    407:    <input type="hidden" name="blackwhite"  value="" />
1.35      www       408:    <input type="hidden" name="remember"  value="" />
1.63      albertel  409:    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
                    410:    <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14      albertel  411:   </form>
1.16      www       412: ENDSERVERFORM
1.90      raeburn   413:     my $coursecatalog;
1.92      raeburn   414:     if (($showcoursecat eq '') || ($showcoursecat)) {
1.90      raeburn   415:         $coursecatalog = &coursecatalog_link($lt{'catalog'});
                    416:     }
1.101     raeburn   417:     my $newuserlink;
                    418:     if ($shownewuserlink) {
                    419:         $newuserlink = &newuser_link($lt{'newuser'});
                    420:     }
1.106.2.1  raeburn   421:     if ($fullgraph) {
                    422:         $r->print(<<HEADER);
1.14      albertel  423:   <!-- The LON-CAPA Header -->
                    424:   <tr>
                    425: 
                    426:    <!-- Row 1 Columns 2-4 -->
1.106.2.1  raeburn   427:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg">
                    428: HEADER
                    429:         if ($showbanner) {
                    430:             $r->print(<<ENDBANNER); 
                    431: <img src="$img" border=0 alt="The Learning Online Network with CAPA" />
                    432: ENDBANNER
                    433:         }
                    434:         $r->print(<<ENDSTART);
                    435:    </td>
1.14      albertel  436:   </tr>
                    437: 
                    438:   <!-- The gray bar that starts the two table frames -->
                    439:   <tr>
                    440: 
                    441:    <!-- Row 2 Column 1 -->
1.21      www       442:    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  443: 
                    444:    <!-- Row 2 Column 2 -->
1.19      bowersj2  445:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
1.14      albertel  446: 
                    447:    <!-- Row 2 Column 3 -->
1.19      bowersj2  448:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
1.14      albertel  449: 
                    450:    <!-- Row 2 Column 4 -->
1.19      bowersj2  451:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
1.14      albertel  452:   </tr>
                    453:   <tr>
                    454:    
1.84      raeburn   455:    <!-- A cell that will hold the 'access', 'about', and 'catalog' links -->
1.14      albertel  456:    <!-- Row 3 Column 1 -->
1.86      raeburn   457:    <td valign="top" height="60" align="left" bgcolor="$sidebg">
1.84      raeburn   458:     <table cellpadding="0" cellspacing="2" border="0">
                    459:      <tr>
                    460:       <td>&nbsp;</td>
                    461:       <td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td>
1.86      raeburn   462:      </tr>
                    463:      <tr>
                    464:       <td>&nbsp;</td>
                    465:       <td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td>
1.90      raeburn   466:      </tr>$coursecatalog
1.86      raeburn   467:      <tr>
1.84      raeburn   468:       <td colspan="2">&nbsp;</td>
1.86      raeburn   469:      </tr>
                    470:     </table>
                    471:    </td>
1.14      albertel  472:    <!-- The shaded space between the two main columns -->
                    473:    <!-- Row 3 Column 2 -->
1.19      bowersj2  474:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  475: 
                    476:    <!-- The right main column holding the large LON-CAPA logo-->
                    477:    <!-- Rows 3-4 Column 3 -->
1.45      www       478:    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">
1.106.2.1  raeburn   479: ENDSTART
                    480:         if ($showmainlogo) {
                    481:             $r->print(<<ENDLOGO);
1.14      albertel  482:     <center>
1.21      www       483:      <img src="$logo" alt="" />
1.14      albertel  484:     </center>
1.106.2.1  raeburn   485: ENDLOGO
                    486:         }
                    487:         $r->print(<<ENDTOP);
1.14      albertel  488:    </td>
                    489: 
                    490:    <!-- Row 3 Column 4 -->
1.19      bowersj2  491:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  492:   </tr>
                    493:   <tr>
                    494: 
                    495:    <!-- The entry form -->
                    496:    <!-- Row 4 Column 1 -->
1.21      www       497:    <td align="center" valign="middle" bgcolor="$sidebg">
1.16      www       498: ENDTOP
1.106.2.1  raeburn   499:     } else {
                    500:         $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1>'
                    501:                  .'<h2>'.&mt('Text-based Interface Login').'</h2>'
                    502:                  .$announcements);
                    503:     }
1.33      www       504:     $r->print('<form name="client" onsubmit="return(send())">');
                    505:     unless ($fullgraph) {
                    506:         $r->print(<<ENDACCESSOPTIONS);
1.99      bisitz    507: <h3>$lt{'options_headline'}</h3>
                    508: <label><input type="checkbox" name="imagesuppress" /> $lt{'sprs_img'}</label><br />
                    509: <label><input type="checkbox" name="appletsuppress" /> $lt{'sprs_applet'}</label><br />
                    510: <label><input type="checkbox" name="embedsuppress" /> $lt{'sprs_embed'}</label><br />
                    511: <label><input type="checkbox" name="fontenhance" /> $lt{'sprs_font'}</label><br />
                    512: <label><input type="checkbox" name="blackwhite" /> $lt{'sprs_blackwhite'}</label><br />
                    513: <br />
                    514: <input type="checkbox" name="remember" /> $lt{'remember'}<hr />
1.33      www       515: ENDACCESSOPTIONS
1.106.2.1  raeburn   516:     } else {
                    517:         $r->print(<<ENDNOOPT);
1.33      www       518: <input type="hidden" name="imagesuppress"  value="" />
                    519: <input type="hidden" name="embedsuppress"  value="" />
1.34      www       520: <input type="hidden" name="appletsuppress"  value="" />
1.33      www       521: <input type="hidden" name="fontenhance"  value="" />
                    522: <input type="hidden" name="blackwhite"  value="" />
1.35      www       523: <input type="hidden" name="remember"  value="" />
1.33      www       524: ENDNOOPT
1.106.2.1  raeburn   525:     }
1.98      raeburn   526:     my $logintitle;
                    527:     if ($loginheader eq 'text') {
                    528:         $logintitle = '<td bgcolor="'.$bgcol.'" colspan="2">&nbsp;&nbsp;&nbsp;<b><font size="+1" color="'.$textcol.'">'.$lt{'log'}.'</font></b></td>';
                    529:     } else {
                    530:         $logintitle = '<td bgcolor="'.$sidebg.'" colspan="2"><img src="'.$login.'" alt="'.
                    531:                       &mt('User Authentication').'" /></td>';
                    532:     }
1.104     bisitz    533:     my $noscript_warning='<td colspan="2" bgcolor="'.$mainbg.'">'
                    534:                         .'<noscript><div class="LC_warning"><font size="-1">'
                    535:                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                    536:                         .'</font></div></noscript></td>';
1.16      www       537:     $r->print(<<ENDLOGIN);
1.14      albertel  538:      <input type="hidden" name="lextkey" value="$lextkey">
                    539:      <input type="hidden" name="uextkey" value="$uextkey">
                    540: 
                    541:      <!-- Start the sub-table for text and input alignment -->
                    542:      <table border=0 cellspacing=0 cellpadding=0>
1.98      raeburn   543:       <tr>$logintitle</tr>
1.104     bisitz    544:       <tr>$noscript_warning</tr>
1.14      albertel  545:       <tr>
1.93      www       546:        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="uname">$lt{'un'}</label>:</b></font></td>
1.30      www       547:        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
1.14      albertel  548:       </tr>
                    549:       <tr>
1.93      www       550:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="upass$now">$lt{'pw'}</label>:</b></font></td>
1.66      www       551:        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>
1.14      albertel  552:       </tr>
                    553:       <tr>
1.93      www       554:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="udom">$lt{'dom'}</label>:</b></font></td>
1.30      www       555:        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
1.14      albertel  556:       </tr>
                    557:       <tr>
1.84      raeburn   558:        <td bgcolor="$mainbg">&nbsp;</td>
1.28      www       559:        <td bgcolor="$mainbg" valign="bottom" align="center">
1.14      albertel  560:         <br />
1.51      www       561:         <input type="submit" value="$lt{'log'}" />
1.14      albertel  562:        </td>
                    563:       </tr>
1.83      raeburn   564:       <tr>
                    565:        <td bgcolor="$mainbg" valign="bottom" align="left" colspan="2">
1.84      raeburn   566:         $loginhelp
1.83      raeburn   567:         $forgotpw
1.101     raeburn   568:         $newuserlink
                    569:         <br />
1.83      raeburn   570:        </td>
                    571:       </tr>
1.14      albertel  572:      </table>
                    573:      <!-- End sub-table -->
                    574:     </form>
1.16      www       575: ENDLOGIN
                    576:     if ($fullgraph) {
1.62      raeburn   577:         my $helpdeskscript;
1.90      raeburn   578:         my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                    579:                                   $version,$authdomain,\$helpdeskscript);
1.16      www       580: 	$r->print(<<ENDDOCUMENT);
1.14      albertel  581:    </td>
                    582: 
                    583:    <!-- Row 4 Column 2 -->
1.19      bowersj2  584:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.45      www       585: 
                    586:    <!-- Row 4 Column 3 -->
                    587: <td bgcolor="$mainbg">$announcements</td>
1.14      albertel  588: 
                    589:    <!-- Row 4 Column 4 -->
1.19      bowersj2  590:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  591:   </tr>
                    592:   <tr>
                    593: 
                    594:    <!-- Row 5 Column 1 -->
1.21      www       595:    <td bgcolor="$sidebg" valign="middle" align="left">
1.14      albertel  596:      <br />
                    597:      <table border=0 cellspacing=0 cellpadding=0>
                    598:       <tr>
1.21      www       599:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       600:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>
1.14      albertel  601:        </td>
1.21      www       602:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  603:         <small><tt>&nbsp;$domain</tt></small>
                    604:        </td>
                    605:       </tr>
                    606:       <tr>
1.21      www       607:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       608:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>
1.14      albertel  609:        </td>
1.21      www       610:        <td bgcolor="$sidebg" align="left" valign="top">
1.14      albertel  611:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
                    612:        </td>
                    613:       </tr>
                    614:       <tr>
1.106.2.2! raeburn   615:        <td bgcolor="$sidebg" align="left" valign="top"><span class="LC_nobreak">
        !           616:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small></span>
1.14      albertel  617:        </td>
1.21      www       618:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       619:         <small><tt>&nbsp;$loadpercent $lt{'perc'}</tt></small>
1.42      albertel  620:        </td>
                    621:       </tr>
                    622:       <tr>
1.106.2.2! raeburn   623:        <td bgcolor="$sidebg" align="left" valign="top"><span class="LC_nobreak">
        !           624:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small></span>
1.42      albertel  625:        </td>
                    626:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       627:         <small><tt>&nbsp;$userloadpercent $lt{'perc'}</tt></small>
1.14      albertel  628:        </td>
                    629:       </tr>
                    630:      </table>
                    631:      <br />
1.60      raeburn   632:     $contactblock
1.14      albertel  633:    </td>
                    634: 
                    635:    <!-- Row 5 Column 2 -->
1.19      bowersj2  636:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  637: 
                    638:    <!-- Row 5 Column 3 -->
1.21      www       639:    <td width="100%" valign="bottom" bgcolor="$mainbg">
1.20      www       640: $domainlogo
                    641: </td>
1.14      albertel  642: 
                    643:    <!-- Row 5 Column 4 -->
1.19      bowersj2  644:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  645:   </tr>
                    646:   <tr>
                    647: 
                    648:    <!-- Row 6 Column 1 -->
1.21      www       649:    <td bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  650: 
                    651:    <!-- Row 6 Column 2 -->
1.19      bowersj2  652:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
1.14      albertel  653: 
                    654:    <!-- Row 6 Column 3 -->
1.19      bowersj2  655:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
1.14      albertel  656: 
                    657:    <!-- Row 6 Column 4 -->
1.19      bowersj2  658:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
1.14      albertel  659:   </tr>
1.1       albertel  660:  </table>
1.25      bowersj2  661: 
1.59      albertel  662: <script type="text/javascript">
                    663: // the if prevents the script error if the browser can not handle this
1.25      bowersj2  664: if ( document.client.uname ) { document.client.uname.focus(); }
                    665: </script>
1.62      raeburn   666: $helpdeskscript
1.14      albertel  667: 
1.1       albertel  668: ENDDOCUMENT
1.16      www       669: }
1.98      raeburn   670:     my %endargs = ( 'noredirectlink' => 1, );
                    671:     $r->print(&Apache::loncommon::end_page(\%endargs));
1.1       albertel  672:     return OK;
1.60      raeburn   673: }
                    674: 
                    675: sub contactdisplay {
1.90      raeburn   676:     my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_;
1.60      raeburn   677:     my $contactblock;
1.62      raeburn   678:     my $showhelpdesk = 0;
                    679:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                    680:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
                    681:         $showhelpdesk = 1;
                    682:     }
1.90      raeburn   683:     if ($servadm && $showadminmail) {
                    684:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.
                    685:                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';
                    686:     }
1.60      raeburn   687:     if ($showhelpdesk) {
1.84      raeburn   688:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />';
1.75      www       689:         my $thisurl = &escape('/adm/login');
1.62      raeburn   690:         $$helpdeskscript = <<"ENDSCRIPT";
                    691: <script type="text/javascript">
                    692: function helpdesk() {
                    693:     var codedom = document.client.udom.value;
                    694:     if (codedom == '') {
                    695:         codedom = "$authdomain";
                    696:     }
                    697:     var querystr = "origurl=$thisurl&codedom="+codedom;
                    698:     document.location.href = "/adm/helpdesk?"+querystr;
                    699:     return;
                    700: }
                    701: </script>
                    702: ENDSCRIPT
1.60      raeburn   703:     }
                    704:     $contactblock .= <<"ENDBLOCK";
                    705:      &nbsp;&nbsp;&nbsp;$version
                    706: ENDBLOCK
                    707:     return $contactblock;
                    708: }
1.83      raeburn   709: 
                    710: sub forgotpwdisplay {
1.84      raeburn   711:     my (%lt) = @_;
1.83      raeburn   712:     my $prompt_for_resetpw = 1; 
                    713:     if ($prompt_for_resetpw) {
1.101     raeburn   714:         return '<br />&nbsp;&nbsp;&nbsp;<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a></b><br />';
1.84      raeburn   715:     }
                    716:     return;
                    717: }
                    718: 
                    719: sub loginhelpdisplay {
                    720:     my (%lt) = @_;
                    721:     my $login_help = 1;
                    722:     if ($login_help) {
                    723:         return '&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a></b>';
1.83      raeburn   724:     }
                    725:     return;
                    726: }
1.1       albertel  727: 
1.90      raeburn   728: sub coursecatalog_link {
                    729:     my ($linkname) = @_;
                    730:     return <<"END";
                    731:      <tr>
                    732:       <td>&nbsp;</td>
                    733:       <td><a href="/adm/coursecatalog"><b>$linkname</b></a></td>
                    734:      </tr>
                    735: END
                    736: }
                    737: 
1.101     raeburn   738: sub newuser_link {
                    739:     my ($linkname) = @_;
                    740:     return '&nbsp;&nbsp;&nbsp;<a href="/adm/createaccount"><b>'.$linkname.'</b></a><br />';
                    741: }
                    742: 
1.1       albertel  743: 1;
                    744: __END__

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