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

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

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