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

1.1       albertel    1: # The LearningOnline Network
                      2: # Login Screen
1.11      www         3: #
1.106.4.8! raeburn     4: # $Id: lonlogin.pm,v 1.106.4.7 2010/03/10 02:49:49 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',
1.106.4.3  raeburn    49: 	  'token','role','symb']);
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.106.4.4  raeburn    84:         my $dest = '/adm/roles';
                     85:         if ($env{'form.firsturl'} ne '') {
                     86:             $dest = $env{'form.firsturl'};
                     87:         }
1.100     bisitz     88: 	$r->print(
                     89:                   $start_page
1.103     bisitz     90:                  .'<h1>'.&mt('You are already logged in!').'</h1>'
1.106.4.1  raeburn    91:                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
1.106.4.4  raeburn    92:                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
1.100     bisitz     93:                  .'<p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'
                     94:                  .$end_page
                     95:                  );
1.95      albertel   96:         return OK;
1.55      www        97:     }
                     98: 
                     99: # ---------------------------------------------------- No valid token, continue
1.16      www       100: 
1.70      www       101:  # ---------------------------- Not possible to really login to domain "public"
                    102:     if ($env{'form.domain'} eq 'public') {
                    103: 	$env{'form.domain'}='';
                    104: 	$env{'form.username'}='';
                    105:     }
1.32      www       106: # ----------------------------------------------------------- Process Interface
1.63      albertel  107:     $env{'form.interface'}=~s/\W//g;
1.16      www       108: 
1.32      www       109:     my $textbrowsers=$r->dir_config('lonTextBrowsers');
                    110:     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
                    111:     
                    112:     foreach (split(/\:/,$textbrowsers)) {
                    113: 	if ($httpbrowser=~/$_/i) {
1.63      albertel  114: 	    $env{'form.interface'}='textual';
1.32      www       115:         }
                    116:     }
                    117: 
1.63      albertel  118:     my $fullgraph=($env{'form.interface'} ne 'textual');
1.94      albertel  119: 
                    120:     my $iconpath= 
                    121: 	&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
                    122: 
1.106.4.7  raeburn   123:     my $lonhost = $r->dir_config('lonHostID');
1.87      raeburn   124:     my $domain = &Apache::lonnet::default_login_domain();
1.106.4.7  raeburn   125:     if ($lonhost ne '') {
                    126:         my $redirect = &check_loginvia($domain,$lonhost);
                    127:         if ($redirect) {
                    128:             $r->print($redirect);
                    129:             return OK;
                    130:         }
                    131:     }
                    132: 
1.63      albertel  133:     if (($env{'form.domain'}) && 
1.89      albertel  134: 	(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
1.63      albertel  135: 	$domain=$env{'form.domain'};
1.46      www       136:     }
1.1       albertel  137:     my $role    = $r->dir_config('lonRole');
                    138:     my $loadlim = $r->dir_config('lonLoadLim');
1.90      raeburn   139:     my $servadm = $r->dir_config('lonAdmEMail');
1.1       albertel  140:     my $tabdir  = $r->dir_config('lonTabDir');
1.6       www       141:     my $include = $r->dir_config('lonIncludes');
1.37      www       142:     my $expire  = $r->dir_config('lonExpire');
1.44      www       143:     my $version = $r->dir_config('lonVersion');
1.88      albertel  144:     my $host_name = &Apache::lonnet::hostname($lonhost);
1.1       albertel  145: 
1.30      www       146: # --------------------------------------------- Default values for login fields
                    147: 
1.63      albertel  148:     my $authusername=($env{'form.username'}?$env{'form.username'}:'');
                    149:     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
1.30      www       150: 
                    151: # ---------------------------------------------------------- Determine own load
1.1       albertel  152:     my $loadavg;
1.41      albertel  153:     {
                    154: 	my $loadfile=Apache::File->new('/proc/loadavg');
                    155: 	$loadavg=<$loadfile>;
                    156:     }
1.1       albertel  157:     $loadavg =~ s/\s.*//g;
1.57      matthew   158:     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
1.41      albertel  159:     my $userloadpercent=&Apache::lonnet::userload();
1.1       albertel  160: 
1.30      www       161: # ------------------------------------------------------- Do the load balancing
1.80      albertel  162:     my $otherserver= &Apache::lonnet::absolute_url($host_name);
1.31      www       163:     my $firsturl=
1.63      albertel  164:     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
1.97      albertel  165: # ---------------------------------------------------------- Are we overloaded?
                    166:     if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
1.47      albertel  167:         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
                    168: 	if ($unloaded) { $otherserver=$unloaded; }
1.1       albertel  169:     }
1.6       www       170: 
1.45      www       171: # ----------------------------------------------------------- Get announcements
                    172:     my $announcements=&Apache::lonnet::getannounce();
1.6       www       173: # -------------------------------------------------------- Set login parameters
                    174: 
                    175:     my @hexstr=('0','1','2','3','4','5','6','7',
                    176:                 '8','9','a','b','c','d','e','f');
                    177:     my $lkey='';
                    178:     for (0..7) {
                    179:         $lkey.=$hexstr[rand(15)];
                    180:     }
                    181: 
                    182:     my $ukey='';
                    183:     for (0..7) {
                    184:         $ukey.=$hexstr[rand(15)];
                    185:     }
                    186: 
                    187:     my $lextkey=hex($lkey);
1.15      www       188:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
                    189: 
1.6       www       190:     my $uextkey=hex($ukey);
1.15      www       191:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
                    192: 
1.31      www       193: # -------------------------------------------------------- Store away log token
1.106.4.3  raeburn   194:     my $tokenextras;
                    195:     if ($env{'form.role'}) {
                    196:         $tokenextras = '&role='.&escape($env{'form.role'});
                    197:     }
                    198:     if ($env{'form.symb'}) {
                    199:         if (!$tokenextras) {
                    200:             $tokenextras = '&';
                    201:         }
                    202:         $tokenextras .= '&symb='.&escape($env{'form.symb'});
                    203:     }
1.6       www       204:     my $logtoken=Apache::lonnet::reply(
1.106.4.3  raeburn   205:        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
1.6       www       206:        $lonhost);
1.31      www       207: 
                    208: # ------------------- If we cannot talk to ourselves, we are in serious trouble
                    209: 
                    210:     if ($logtoken eq 'con_lost') {
                    211:         my $spares='';
1.64      albertel  212: 	my $last;
                    213:         foreach my $hostid (sort
                    214: 			    {
1.88      albertel  215: 				&Apache::lonnet::hostname($a) cmp
                    216: 				    &Apache::lonnet::hostname($b);
1.64      albertel  217: 			    }
                    218: 			    keys(%Apache::lonnet::spareid)) {
1.58      matthew   219:             next if ($hostid eq $lonhost);
1.88      albertel  220: 	    my $hostname = &Apache::lonnet::hostname($hostid);
                    221: 	    next if ($last eq $hostname);
1.58      matthew   222:             $spares.='<br /><font size="+1"><a href="http://'.
1.88      albertel  223:                 $hostname.
1.58      matthew   224:                 '/adm/login?domain='.$authdomain.'">'.
1.88      albertel  225:                 $hostname.'</a>'.
1.106     bisitz    226:                 ' '.&mt('(preferred)').'</font>'.$/;
1.88      albertel  227: 	    $last=$hostname;
1.58      matthew   228:         }
                    229:         $spares.= '<br />';
1.88      albertel  230: 	my %all_hostnames = &Apache::lonnet::all_hostnames();
1.64      albertel  231:         foreach my $hostid (sort
                    232: 			    {
1.88      albertel  233: 				&Apache::lonnet::hostname($a) cmp
                    234: 				    &Apache::lonnet::hostname($b);
1.64      albertel  235: 			    }
1.88      albertel  236: 			    keys(%all_hostnames)) {
1.58      matthew   237:             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
1.88      albertel  238: 	    my $hostname = &Apache::lonnet::hostname($hostid);
                    239:             next if ($last eq $hostname);
1.58      matthew   240:             $spares.='<br /><a href="http://'.
1.88      albertel  241:                 $hostname.
1.58      matthew   242:                 '/adm/login?domain='.$authdomain.'">'.
1.88      albertel  243:                 $hostname.'</a>';
                    244: 	    $last=$hostname;
1.31      www       245:         }
1.103     bisitz    246: 	$r->print(
                    247:            '<html>'
                    248:           .'<head><title>'
                    249:           .&mt('The LearningOnline Network with CAPA')
                    250:           .'</title></head>'
                    251:           .'<body bgcolor="#FFFFFF">'
                    252:           .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
                    253:           .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
                    254:           .'<h3>'.&mt('This LON-CAPA server is temporarily not available for login.').'</h3>'
                    255:           .'<p>'.&mt('Please attempt to login to one of the following servers:').'</p>'
                    256:           .$spares
                    257:           .'</body>'
                    258:           .'</html>'
                    259:         );
1.31      www       260:         return OK;
                    261:     }
                    262: 
                    263: # ----------------------------------------------- Apparently we are in business
1.90      raeburn   264:     $servadm=~s/\,/\<br \/\>/g;
1.38      www       265: 
1.21      www       266: # ----------------------------------------------------------- Front page design
1.35      www       267:     my $pgbg=
1.46      www       268:       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');
1.35      www       269:     my $font=
1.46      www       270:       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');
1.35      www       271:     my $link=
1.46      www       272:       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');
1.35      www       273:     my $vlink=
1.46      www       274:       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');
                    275:     my $alink=&Apache::loncommon::designparm('login.alink',$domain);
1.35      www       276:     my $mainbg=
1.46      www       277:       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');
1.35      www       278:     my $sidebg=
1.46      www       279:       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');
1.98      raeburn   280:     my $textcol = 
                    281:       ($fullgraph?&Apache::loncommon::designparm('login.textcol',$domain):'#000000');
                    282:     my $bgcol =
                    283:       ($fullgraph?&Apache::loncommon::designparm('login.bgcol',$domain):'#FFFFFF');
1.46      www       284:     my $logo=&Apache::loncommon::designparm('login.logo',$domain);
                    285:     my $img=&Apache::loncommon::designparm('login.img',$domain);
1.90      raeburn   286:     my $domainlogo=&Apache::loncommon::domainlogo($domain);
1.98      raeburn   287:     my $login=&Apache::loncommon::designparm('login.login',$domain);
                    288:     if ($login eq '') {
                    289:         $login = $iconpath.'/'.&mt('userauthentication.gif');
                    290:     }
1.106.4.1  raeburn   291:     my $showbanner = 1;
                    292:     my $showmainlogo = 1;
                    293:     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
                    294:         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
                    295:     }
                    296:     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
                    297:         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
                    298:     }
1.98      raeburn   299:     my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
1.90      raeburn   300:     my $showcoursecat =
                    301:         &Apache::loncommon::designparm('login.coursecatalog',$domain);
1.98      raeburn   302:     my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
1.101     raeburn   303:     my $shownewuserlink = 
                    304:         &Apache::loncommon::designparm('login.newuser',$domain);
1.66      www       305:     my $now=time;
1.98      raeburn   306:     my $js = (<<ENDSCRIPT);
1.6       www       307: 
1.106.4.1  raeburn   308:  <script type="text/javascript">
1.106.4.2  raeburn   309:  // <![CDATA[
1.14      albertel  310:     function send()
                    311:     {
1.98      raeburn   312:         this.document.server.elements.uname.value
1.6       www       313:        =this.document.client.elements.uname.value;
                    314: 
                    315:         this.document.server.elements.udom.value
                    316:        =this.document.client.elements.udom.value;
                    317: 
1.33      www       318:         this.document.server.elements.imagesuppress.value
1.36      www       319:        =this.document.client.elements.imagesuppress.checked;
1.33      www       320: 
                    321:         this.document.server.elements.embedsuppress.value
1.36      www       322:        =this.document.client.elements.embedsuppress.checked;
1.33      www       323: 
1.34      www       324:         this.document.server.elements.appletsuppress.value
1.36      www       325:        =this.document.client.elements.appletsuppress.checked;
1.34      www       326: 
1.33      www       327:         this.document.server.elements.fontenhance.value
1.36      www       328:        =this.document.client.elements.fontenhance.checked;
1.33      www       329: 
                    330:         this.document.server.elements.blackwhite.value
1.36      www       331:        =this.document.client.elements.blackwhite.checked;
1.33      www       332: 
1.35      www       333:         this.document.server.elements.remember.value
1.36      www       334:        =this.document.client.elements.remember.checked;
1.35      www       335: 
1.6       www       336:         uextkey=this.document.client.elements.uextkey.value;
                    337:         lextkey=this.document.client.elements.lextkey.value;
                    338:         initkeys();
                    339: 
1.65      www       340:         this.document.server.elements.upass0.value
1.98      raeburn   341:             =crypted(this.document.client.elements.upass$now.value.substr(0,15));
                    342:         this.document.server.elements.upass1.value
                    343:             =crypted(this.document.client.elements.upass$now.value.substr(15,15));
                    344:         this.document.server.elements.upass2.value
                    345:             =crypted(this.document.client.elements.upass$now.value.substr(30,15));
1.66      www       346: 
                    347:         this.document.client.elements.uname.value='';
                    348:         this.document.client.elements.upass$now.value='';
1.6       www       349: 
                    350:         this.document.server.submit();
1.98      raeburn   351:         return false;
1.6       www       352:     }
1.106.4.2  raeburn   353:  // ]]>
1.14      albertel  354:  </script>
1.98      raeburn   355: 
1.16      www       356: ENDSCRIPT
1.6       www       357: 
1.98      raeburn   358: # --------------------------------------------------- Print login screen header
                    359: 
                    360:     my %add_entries = (topmargin    => "0",
                    361:                        leftmargin   => "0",
                    362:                        marginheight => "0",
                    363:                        marginwidth  => "0",
                    364:                        bgcolor      => "$pgbg",
                    365:                        text         => "$font",
                    366:                        link         => "$link",
                    367:                        vlink        => "$vlink",
                    368:                        alink        => "$alink",);
                    369: 
                    370:     $r->print(&Apache::loncommon::start_page('The LearningOnline Network with CAPA Login',$js,
                    371:                                        { 'redirect'       => [$expire,'/adm/roles'], 
                    372:                                          'add_entries' => \%add_entries,
                    373:                                          'only_body'   => 1,}));
                    374: 
                    375: # ----------------------------------------------------------------------- Texts
                    376: 
                    377: my %lt=&Apache::lonlocal::texthash(
                    378: 		  'un'  => 'Username',
                    379: 		  'pw'  => 'Password',
                    380: 		  'dom' => 'Domain',
1.105     bisitz    381: 		  'load' => 'Server Load',
1.98      raeburn   382:                   'userload' => 'User Load',
                    383:                   'about'  => 'About LON-CAPA',
                    384:                   'access' => 'Accessibility Options',
1.106.4.5  raeburn   385:                   'catalog' => 'Course/Community Catalog',
1.98      raeburn   386: 		  'log' => 'Log in',
                    387: 		  'help' => 'Log-in Help',
                    388: 		  'serv' => 'Server',
                    389:                   'servadm' => 'Server Administration',
                    390:                   'helpdesk' => 'Contact Helpdesk',
1.99      bisitz    391:                   'forgotpw' => 'Forgot password?',
1.101     raeburn   392:                   'newuser'  => 'New User?',
1.99      bisitz    393:                   'options_headline' => 'Select Accessibility Options',
                    394:                   'sprs_img' => 'Suppress rendering of images',
                    395:                   'sprs_applet' => 'Suppress Java applets',
                    396:                   'sprs_embed' => 'Suppress rendering of embedded multimedia',
                    397:                   'sprs_font' => 'Increase font size',
                    398:                   'sprs_blackwhite' => 'Switch to black and white mode',
                    399:                   'remember' => 'Remember these settings for next login');
1.98      raeburn   400: # -------------------------------------------------- Change password field name
                    401:     my $forgotpw = &forgotpwdisplay(%lt);
                    402:     my $loginhelp = &loginhelpdisplay(%lt);
                    403: 
                    404: # ---------------------------------------------------- Serve out DES JavaScript
                    405:     {
                    406:         my $jsh=Apache::File->new($include."/londes.js");
                    407:         $r->print(<$jsh>);
                    408:     }
                    409: # ---------------------------------------------------------- Serve rest of page
                    410: 
1.16      www       411:     if ($fullgraph) {
                    412: 	$r->print(
1.106.4.1  raeburn   413: 		  '<table width="100%" cellpadding="0" cellspacing="0" border="0">');
1.16      www       414:     }
1.6       www       415: 
1.16      www       416:     $r->print(<<ENDSERVERFORM);
1.14      albertel  417:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
1.33      www       418:    <input type="hidden" name="logtoken" value="$logtoken" />
                    419:    <input type="hidden" name="serverid" value="$lonhost" />
1.63      albertel  420:    <input type="hidden" name="interface" value="$env{'form.interface'}" />
1.33      www       421:    <input type="hidden" name="uname" value="" />
1.65      www       422:    <input type="hidden" name="upass0" value="" />
                    423:    <input type="hidden" name="upass1" value="" />
                    424:    <input type="hidden" name="upass2" value="" />
1.33      www       425:    <input type="hidden" name="udom" value="" />
                    426:    <input type="hidden" name="imagesuppress"  value="" />
1.34      www       427:    <input type="hidden" name="appletsuppress"  value="" />
1.33      www       428:    <input type="hidden" name="embedsuppress"  value="" />
                    429:    <input type="hidden" name="fontenhance"  value="" />
                    430:    <input type="hidden" name="blackwhite"  value="" />
1.35      www       431:    <input type="hidden" name="remember"  value="" />
1.63      albertel  432:    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
                    433:    <input type="hidden" name="localres" value="$env{'form.localres'}" />
1.14      albertel  434:   </form>
1.16      www       435: ENDSERVERFORM
1.90      raeburn   436:     my $coursecatalog;
1.92      raeburn   437:     if (($showcoursecat eq '') || ($showcoursecat)) {
1.90      raeburn   438:         $coursecatalog = &coursecatalog_link($lt{'catalog'});
                    439:     }
1.101     raeburn   440:     my $newuserlink;
                    441:     if ($shownewuserlink) {
                    442:         $newuserlink = &newuser_link($lt{'newuser'});
                    443:     }
1.106.4.1  raeburn   444:     if ($fullgraph) {
                    445:         $r->print(<<HEADER);
1.14      albertel  446:   <!-- The LON-CAPA Header -->
                    447:   <tr>
                    448: 
                    449:    <!-- Row 1 Columns 2-4 -->
1.106.4.1  raeburn   450:    <td width="100%" height=75 colspan=4 align="left" valign="top" bgcolor="$pgbg">
                    451: HEADER
                    452:         if ($showbanner) {
                    453:             $r->print(<<ENDBANNER);
                    454: <img src="$img" border="0" alt="The Learning Online Network with CAPA" />
                    455: ENDBANNER
                    456:         }
                    457:         $r->print(<<ENDSTART);
                    458:    </td>
1.14      albertel  459:   </tr>
                    460: 
                    461:   <!-- The gray bar that starts the two table frames -->
                    462:   <tr>
                    463: 
                    464:    <!-- Row 2 Column 1 -->
1.21      www       465:    <td width=182 height=27 bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  466: 
                    467:    <!-- Row 2 Column 2 -->
1.19      bowersj2  468:    <td width=27 height=27 align="left" background="$iconpath/filltop.gif"><img src="$iconpath/upperleft.gif" border=0 alt="" /></td>
1.14      albertel  469: 
                    470:    <!-- Row 2 Column 3 -->
1.19      bowersj2  471:    <td height=27 background="$iconpath/filltop.gif"><img src="$iconpath/filltop.gif" alt="" /></td>
1.14      albertel  472: 
                    473:    <!-- Row 2 Column 4 -->
1.19      bowersj2  474:    <td width=27 height=27 align="right" background="$iconpath/filltop.gif"><img src="$iconpath/upperright.gif" border=0 alt="" /></td>
1.14      albertel  475:   </tr>
                    476:   <tr>
                    477:    
1.84      raeburn   478:    <!-- A cell that will hold the 'access', 'about', and 'catalog' links -->
1.14      albertel  479:    <!-- Row 3 Column 1 -->
1.86      raeburn   480:    <td valign="top" height="60" align="left" bgcolor="$sidebg">
1.84      raeburn   481:     <table cellpadding="0" cellspacing="2" border="0">
                    482:      <tr>
                    483:       <td>&nbsp;</td>
                    484:       <td><a href="/adm/login?interface=textual"><b>$lt{'access'}</b></a></td>
1.86      raeburn   485:      </tr>
                    486:      <tr>
                    487:       <td>&nbsp;</td>
                    488:       <td><a href="/adm/about.html"><b>$lt{'about'}</b></a></td>
1.90      raeburn   489:      </tr>$coursecatalog
1.86      raeburn   490:      <tr>
1.84      raeburn   491:       <td colspan="2">&nbsp;</td>
1.86      raeburn   492:      </tr>
                    493:     </table>
                    494:    </td>
1.14      albertel  495:    <!-- The shaded space between the two main columns -->
                    496:    <!-- Row 3 Column 2 -->
1.19      bowersj2  497:    <td width=27 height=60 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  498: 
                    499:    <!-- The right main column holding the large LON-CAPA logo-->
                    500:    <!-- Rows 3-4 Column 3 -->
1.45      www       501:    <td align="center" valign="top" width="100%" height="100%" bgcolor="$mainbg">
1.106.4.1  raeburn   502: ENDSTART
                    503:         if ($showmainlogo) {
                    504:             $r->print(<<ENDLOGO);
1.14      albertel  505:     <center>
1.21      www       506:      <img src="$logo" alt="" />
1.14      albertel  507:     </center>
1.106.4.1  raeburn   508: ENDLOGO
                    509:         }
                    510:         $r->print(<<ENDTOP);
1.14      albertel  511:    </td>
                    512: 
                    513:    <!-- Row 3 Column 4 -->
1.19      bowersj2  514:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  515:   </tr>
                    516:   <tr>
                    517: 
                    518:    <!-- The entry form -->
                    519:    <!-- Row 4 Column 1 -->
1.21      www       520:    <td align="center" valign="middle" bgcolor="$sidebg">
1.16      www       521: ENDTOP
1.106.4.1  raeburn   522:     } else {
                    523:         $r->print('<h1>The Learning<i>Online</i> Network with CAPA</h1>'
                    524:                  .'<h2>'.&mt('Text-based Interface Login').'</h2>'
                    525:                  .$announcements);
                    526:     }
1.106.4.2  raeburn   527:     $r->print('<form name="client" action="" onsubmit="return(send())">');
1.33      www       528:     unless ($fullgraph) {
                    529:         $r->print(<<ENDACCESSOPTIONS);
1.99      bisitz    530: <h3>$lt{'options_headline'}</h3>
                    531: <label><input type="checkbox" name="imagesuppress" /> $lt{'sprs_img'}</label><br />
                    532: <label><input type="checkbox" name="appletsuppress" /> $lt{'sprs_applet'}</label><br />
                    533: <label><input type="checkbox" name="embedsuppress" /> $lt{'sprs_embed'}</label><br />
                    534: <label><input type="checkbox" name="fontenhance" /> $lt{'sprs_font'}</label><br />
                    535: <label><input type="checkbox" name="blackwhite" /> $lt{'sprs_blackwhite'}</label><br />
                    536: <br />
                    537: <input type="checkbox" name="remember" /> $lt{'remember'}<hr />
1.33      www       538: ENDACCESSOPTIONS
1.106.4.1  raeburn   539:     } else {
                    540:         $r->print(<<ENDNOOPT);
1.33      www       541: <input type="hidden" name="imagesuppress"  value="" />
                    542: <input type="hidden" name="embedsuppress"  value="" />
1.34      www       543: <input type="hidden" name="appletsuppress"  value="" />
1.33      www       544: <input type="hidden" name="fontenhance"  value="" />
                    545: <input type="hidden" name="blackwhite"  value="" />
1.35      www       546: <input type="hidden" name="remember"  value="" />
1.33      www       547: ENDNOOPT
1.106.4.1  raeburn   548:     }
1.98      raeburn   549:     my $logintitle;
                    550:     if ($loginheader eq 'text') {
                    551:         $logintitle = '<td bgcolor="'.$bgcol.'" colspan="2">&nbsp;&nbsp;&nbsp;<b><font size="+1" color="'.$textcol.'">'.$lt{'log'}.'</font></b></td>';
                    552:     } else {
                    553:         $logintitle = '<td bgcolor="'.$sidebg.'" colspan="2"><img src="'.$login.'" alt="'.
                    554:                       &mt('User Authentication').'" /></td>';
                    555:     }
1.104     bisitz    556:     my $noscript_warning='<td colspan="2" bgcolor="'.$mainbg.'">'
                    557:                         .'<noscript><div class="LC_warning"><font size="-1">'
                    558:                         .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                    559:                         .'</font></div></noscript></td>';
1.16      www       560:     $r->print(<<ENDLOGIN);
1.106.4.1  raeburn   561:      <input type="hidden" name="lextkey" value="$lextkey" />
                    562:      <input type="hidden" name="uextkey" value="$uextkey" />
1.14      albertel  563: 
                    564:      <!-- Start the sub-table for text and input alignment -->
1.106.4.1  raeburn   565:      <table border="0" cellspacing="0" cellpadding="0">
1.98      raeburn   566:       <tr>$logintitle</tr>
1.104     bisitz    567:       <tr>$noscript_warning</tr>
1.14      albertel  568:       <tr>
1.93      www       569:        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="uname">$lt{'un'}</label>:</b></font></td>
1.30      www       570:        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
1.14      albertel  571:       </tr>
                    572:       <tr>
1.93      www       573:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="upass$now">$lt{'pw'}</label>:</b></font></td>
1.66      www       574:        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>
1.14      albertel  575:       </tr>
                    576:       <tr>
1.93      www       577:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="udom">$lt{'dom'}</label>:</b></font></td>
1.30      www       578:        <td bgcolor="$mainbg"><input type="text" name="udom" size="10" value="$authdomain" /></td>
1.14      albertel  579:       </tr>
                    580:       <tr>
1.84      raeburn   581:        <td bgcolor="$mainbg">&nbsp;</td>
1.28      www       582:        <td bgcolor="$mainbg" valign="bottom" align="center">
1.14      albertel  583:         <br />
1.51      www       584:         <input type="submit" value="$lt{'log'}" />
1.14      albertel  585:        </td>
                    586:       </tr>
1.83      raeburn   587:       <tr>
                    588:        <td bgcolor="$mainbg" valign="bottom" align="left" colspan="2">
1.84      raeburn   589:         $loginhelp
1.83      raeburn   590:         $forgotpw
1.101     raeburn   591:         $newuserlink
                    592:         <br />
1.83      raeburn   593:        </td>
                    594:       </tr>
1.14      albertel  595:      </table>
                    596:      <!-- End sub-table -->
                    597:     </form>
1.16      www       598: ENDLOGIN
                    599:     if ($fullgraph) {
1.62      raeburn   600:         my $helpdeskscript;
1.90      raeburn   601:         my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                    602:                                   $version,$authdomain,\$helpdeskscript);
1.16      www       603: 	$r->print(<<ENDDOCUMENT);
1.14      albertel  604:    </td>
                    605: 
                    606:    <!-- Row 4 Column 2 -->
1.19      bowersj2  607:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.45      www       608: 
                    609:    <!-- Row 4 Column 3 -->
                    610: <td bgcolor="$mainbg">$announcements</td>
1.14      albertel  611: 
                    612:    <!-- Row 4 Column 4 -->
1.19      bowersj2  613:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  614:   </tr>
                    615:   <tr>
                    616: 
                    617:    <!-- Row 5 Column 1 -->
1.21      www       618:    <td bgcolor="$sidebg" valign="middle" align="left">
1.14      albertel  619:      <br />
1.106.4.1  raeburn   620:      <table border="0" cellspacing="0" cellpadding="0">
1.14      albertel  621:       <tr>
1.21      www       622:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       623:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'dom'}:&nbsp;</b></small>
1.14      albertel  624:        </td>
1.106.4.1  raeburn   625:        <td bgcolor="$sidebg" align="left" valign="middle">
1.14      albertel  626:         <small><tt>&nbsp;$domain</tt></small>
                    627:        </td>
                    628:       </tr>
                    629:       <tr>
1.21      www       630:        <td bgcolor="$sidebg" align="left" valign="top">
1.51      www       631:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'serv'}:&nbsp;</b></small>
1.14      albertel  632:        </td>
1.106.4.1  raeburn   633:        <td bgcolor="$sidebg" align="left" valign="middle">
1.14      albertel  634:         <small><tt>&nbsp;$lonhost ($role)</tt></small>
                    635:        </td>
                    636:       </tr>
                    637:       <tr>
1.106.4.1  raeburn   638:        <td bgcolor="$sidebg" align="left" valign="top"><span class="LC_nobreak">
                    639:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'load'}:&nbsp;</b></small></span>
1.14      albertel  640:        </td>
1.106.4.1  raeburn   641:        <td bgcolor="$sidebg" align="left" valign="middle">
                    642:         <small><tt>&nbsp;$loadpercent%</tt></small>
1.42      albertel  643:        </td>
                    644:       </tr>
                    645:       <tr>
1.106.4.1  raeburn   646:        <td bgcolor="$sidebg" align="left" valign="top"><span class="LC_nobreak">
                    647:         <small><b>&nbsp;&nbsp;&nbsp;$lt{'userload'}:&nbsp;</b></small></span>
1.42      albertel  648:        </td>
1.106.4.1  raeburn   649:        <td bgcolor="$sidebg" align="left" valign="middle">
                    650:         <small><tt>&nbsp;$userloadpercent%</tt></small>
1.14      albertel  651:        </td>
                    652:       </tr>
                    653:      </table>
                    654:      <br />
1.60      raeburn   655:     $contactblock
1.14      albertel  656:    </td>
                    657: 
                    658:    <!-- Row 5 Column 2 -->
1.19      bowersj2  659:    <td width=27 background="$iconpath/fillleft.gif"><img src="$iconpath/fillleft.gif" alt="" /></td>
1.14      albertel  660: 
                    661:    <!-- Row 5 Column 3 -->
1.21      www       662:    <td width="100%" valign="bottom" bgcolor="$mainbg">
1.20      www       663: $domainlogo
                    664: </td>
1.14      albertel  665: 
                    666:    <!-- Row 5 Column 4 -->
1.19      bowersj2  667:    <td width=27 background="$iconpath/fillright.gif"><img src="$iconpath/fillright.gif" alt="" /></td>
1.14      albertel  668:   </tr>
                    669:   <tr>
                    670: 
                    671:    <!-- Row 6 Column 1 -->
1.21      www       672:    <td bgcolor="$sidebg">&nbsp;</td>
1.14      albertel  673: 
                    674:    <!-- Row 6 Column 2 -->
1.19      bowersj2  675:    <td align="left" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerleft.gif" alt="" /></td>
1.14      albertel  676: 
                    677:    <!-- Row 6 Column 3 -->
1.19      bowersj2  678:    <td background="$iconpath/fillbottom.gif"><img src="$iconpath/fillbottom.gif" alt="" /></td>
1.14      albertel  679: 
                    680:    <!-- Row 6 Column 4 -->
1.19      bowersj2  681:    <td align="right" background="$iconpath/fillbottom.gif"><img src="$iconpath/lowerright.gif" alt="" /></td>
1.14      albertel  682:   </tr>
1.1       albertel  683:  </table>
1.25      bowersj2  684: 
1.59      albertel  685: <script type="text/javascript">
1.106.4.2  raeburn   686: // <![CDATA[
1.59      albertel  687: // the if prevents the script error if the browser can not handle this
1.25      bowersj2  688: if ( document.client.uname ) { document.client.uname.focus(); }
1.106.4.2  raeburn   689: // ]]>
1.25      bowersj2  690: </script>
1.62      raeburn   691: $helpdeskscript
1.14      albertel  692: 
1.1       albertel  693: ENDDOCUMENT
1.16      www       694: }
1.98      raeburn   695:     my %endargs = ( 'noredirectlink' => 1, );
                    696:     $r->print(&Apache::loncommon::end_page(\%endargs));
1.1       albertel  697:     return OK;
1.60      raeburn   698: }
                    699: 
1.106.4.7  raeburn   700: sub check_loginvia {
                    701:     my ($domain,$lonhost) = @_;
                    702:     if ($domain eq '' || $lonhost eq '') {
                    703:         return;
                    704:     }
                    705:     my %domconfhash = &Apache::loncommon::get_domainconf($domain);
                    706:     my $loginvia = $domconfhash{$domain.'.login.loginvia_'.$lonhost};
                    707:     my $loginvia_exempt = $domconfhash{$domain.'.login.loginvia_exempt_'.$lonhost};
                    708:     my $output;
                    709:     if ($loginvia ne '') {
                    710:         my $noredirect;
                    711:         my $ip = $ENV{'REMOTE_ADDR'};
                    712:         if ($ip eq '127.0.0.1') {
                    713:             $noredirect = 1;
                    714:         } else {
                    715:             if ($loginvia_exempt ne '') {
                    716:                 my @exempt = split(',',$loginvia_exempt);
                    717:                 if (grep(/^\Q$ip\E$/,@exempt)) {
                    718:                     $noredirect = 1;
                    719:                 }
                    720:             }
                    721:         }
                    722:         unless ($noredirect) {
                    723:             my ($newhost,$path);
                    724:             if ($loginvia =~ /:/) {
                    725:                 ($newhost,$path) = split(':',$loginvia);
                    726:             } else {
                    727:                 $newhost = $loginvia;
                    728:             }
                    729:             if ($newhost ne $lonhost) {
                    730:                 if (&Apache::lonnet::hostname($newhost) ne '') {
                    731:                     $output = &redirect_page($newhost,$path);
                    732:                 }
                    733:             }
                    734:         }
                    735:     }
                    736:     return $output;
                    737: }
                    738: 
                    739: sub redirect_page {
                    740:     my ($desthost,$path) = @_;
                    741:     my $protocol = $Apache::lonnet::protocol{$desthost};
                    742:     $protocol = 'http' if ($protocol ne 'https');
                    743:     unless ($path =~ m{^/}) {
                    744:         $path = '/'.$path;
                    745:     }
                    746:     my $url = $protocol.'://'.&Apache::lonnet::hostname($desthost).$path;
                    747:     if ($env{'form.firsturl'} ne '') {
                    748:         $url .='?firsturl='.$env{'form.firsturl'};
                    749:     }
1.106.4.8! raeburn   750:     my $start_page = &Apache::loncommon::start_page('Switching Server ...',undef,
1.106.4.7  raeburn   751:                                                     {'redirect' => [0,$url],});
                    752:     my $end_page   = &Apache::loncommon::end_page();
                    753:     return $start_page.$end_page;
                    754: }
                    755: 
1.60      raeburn   756: sub contactdisplay {
1.90      raeburn   757:     my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_;
1.60      raeburn   758:     my $contactblock;
1.62      raeburn   759:     my $showhelpdesk = 0;
                    760:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                    761:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
                    762:         $showhelpdesk = 1;
                    763:     }
1.90      raeburn   764:     if ($servadm && $showadminmail) {
                    765:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.
                    766:                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';
                    767:     }
1.60      raeburn   768:     if ($showhelpdesk) {
1.84      raeburn   769:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />';
1.75      www       770:         my $thisurl = &escape('/adm/login');
1.62      raeburn   771:         $$helpdeskscript = <<"ENDSCRIPT";
                    772: <script type="text/javascript">
1.106.4.2  raeburn   773: // <![CDATA[
1.62      raeburn   774: function helpdesk() {
                    775:     var codedom = document.client.udom.value;
                    776:     if (codedom == '') {
                    777:         codedom = "$authdomain";
                    778:     }
                    779:     var querystr = "origurl=$thisurl&codedom="+codedom;
                    780:     document.location.href = "/adm/helpdesk?"+querystr;
                    781:     return;
                    782: }
1.106.4.2  raeburn   783: // ]]>
1.62      raeburn   784: </script>
                    785: ENDSCRIPT
1.60      raeburn   786:     }
                    787:     $contactblock .= <<"ENDBLOCK";
                    788:      &nbsp;&nbsp;&nbsp;$version
                    789: ENDBLOCK
                    790:     return $contactblock;
                    791: }
1.83      raeburn   792: 
                    793: sub forgotpwdisplay {
1.84      raeburn   794:     my (%lt) = @_;
1.83      raeburn   795:     my $prompt_for_resetpw = 1; 
                    796:     if ($prompt_for_resetpw) {
1.101     raeburn   797:         return '<br />&nbsp;&nbsp;&nbsp;<a href="/adm/resetpw">'.$lt{'forgotpw'}.'</a></b><br />';
1.84      raeburn   798:     }
                    799:     return;
                    800: }
                    801: 
                    802: sub loginhelpdisplay {
                    803:     my (%lt) = @_;
                    804:     my $login_help = 1;
                    805:     if ($login_help) {
                    806:         return '&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html">'.$lt{'help'}.'</a></b>';
1.83      raeburn   807:     }
                    808:     return;
                    809: }
1.1       albertel  810: 
1.90      raeburn   811: sub coursecatalog_link {
                    812:     my ($linkname) = @_;
                    813:     return <<"END";
                    814:      <tr>
                    815:       <td>&nbsp;</td>
1.106.4.6  raeburn   816:       <td><span class="LC_nobreak"><a href="/adm/coursecatalog"><b>$linkname</b></a></span></td>
1.90      raeburn   817:      </tr>
                    818: END
                    819: }
                    820: 
1.101     raeburn   821: sub newuser_link {
                    822:     my ($linkname) = @_;
                    823:     return '&nbsp;&nbsp;&nbsp;<a href="/adm/createaccount"><b>'.$linkname.'</b></a><br />';
                    824: }
                    825: 
1.1       albertel  826: 1;
                    827: __END__

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