Annotation of modules/gci/lonlogin.pm, revision 1.10

1.1       gci         1: # The LearningOnline Network
                      2: # Login Screen
                      3: #
1.10    ! gci         4: # $Id: lonlogin.pm,v 1.9 2010/01/11 02:31:32 gci Exp $
1.1       gci         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: #
                     28: 
                     29: package Apache::lonlogin;
                     30: 
                     31: use strict;
                     32: use Apache::Constants qw(:common);
                     33: use Apache::File ();
                     34: use Apache::lonnet;
                     35: use Apache::loncommon();
                     36: use Apache::lonauth();
                     37: use Apache::lonlocal;
                     38: use Apache::migrateuser();
                     39: use lib '/home/httpd/lib/perl/';
                     40: use LONCAPA;
1.9       gci        41: use HTML::Entities();
1.1       gci        42:  
                     43: sub handler {
                     44:     my $r = shift;
                     45: 
                     46:     &Apache::loncommon::get_unprocessed_cgi
                     47: 	(join('&',$ENV{'QUERY_STRING'},$env{'request.querystring'},
                     48: 	      $ENV{'REDIRECT_QUERY_STRING'}),
                     49: 	 ['interface','username','domain','firsturl','localpath','localres',
1.2       gci        50: 	  'token','role','symb']);
1.1       gci        51:     if (!defined($env{'form.firsturl'})) {
                     52:         &Apache::lonacc::get_posted_cgi($r,['firsturl']);
                     53:     }
                     54: 
                     55: # -- check if they are a migrating user
                     56:     if (defined($env{'form.token'})) {
                     57: 	return &Apache::migrateuser::handler($r);
                     58:     }
                     59: 
                     60:     &Apache::loncommon::no_cache($r);
                     61:     &Apache::lonlocal::get_language_handle($r);
                     62:     &Apache::loncommon::content_type($r,'text/html');
                     63:     $r->send_http_header;
                     64:     return OK if $r->header_only;
                     65: 
                     66: 
                     67: # Are we re-routing?
                     68:     if (-e '/home/httpd/html/lon-status/reroute.txt') {
                     69: 	&Apache::lonauth::reroute($r);
                     70: 	return OK;
                     71:     }
                     72: 
                     73: 
                     74: # -------------------------------- Prevent users from attempting to login twice
                     75:     my $handle = &Apache::lonnet::check_for_valid_session($r);
                     76:     if ($handle=~/^publicuser\_/) {
                     77: # For "public user" - remove it, we apparently really want to login
                     78: 	unlink($r->dir_config('lonIDsDir')."/$handle.id");
                     79:     } elsif ($handle ne '') {
                     80: # Indeed, a valid token is found
                     81: 	my $start_page = 
                     82: 	    &Apache::loncommon::start_page('Already logged in');
                     83: 	my $end_page = 
                     84: 	    &Apache::loncommon::end_page();
1.4       gci        85:         my $dest = '/adm/roles';
1.9       gci        86:         if ($env{'form.role'}) {
                     87:             $dest .= '?selectrole=1&'.$env{'form.role'}.'=1'; 
                     88:         }
                     89:         if ($env{'form.symb'}) {
                     90:             $dest .= ($dest =~ /\?/) ? '&' : '?'; 
                     91:             $dest .= 'destinationurl='.&HTML::Entities::encode($env{'form.symb'},'"&<>');
                     92:         }
1.4       gci        93:         if ($env{'form.firsturl'} ne '') {
                     94:             $dest = $env{'form.firsturl'};
                     95:         }
1.1       gci        96: 	$r->print(
                     97:                   $start_page
                     98:                  .'<h1>'.&mt('You are already logged in!').'</h1>'
1.2       gci        99:                  .'<p>'.&mt('Please either [_1]continue the current session[_2] or [_3]log out[_4].',
1.4       gci       100:                   '<a href="'.$dest.'">','</a>','<a href="/adm/logout">','</a>').'</p>'
1.1       gci       101:                  .'<p><a href="/adm/loginproblems.html">'.&mt('Login problems?').'</a></p>'
                    102:                  .$end_page
                    103:                  );
                    104:         return OK;
                    105:     }
                    106: 
                    107: # ---------------------------------------------------- No valid token, continue
                    108: 
                    109:  # ---------------------------- Not possible to really login to domain "public"
                    110:     if ($env{'form.domain'} eq 'public') {
                    111: 	$env{'form.domain'}='';
                    112: 	$env{'form.username'}='';
                    113:     }
                    114: # ----------------------------------------------------------- Process Interface
                    115:     $env{'form.interface'}=~s/\W//g;
                    116: 
                    117:     my $textbrowsers=$r->dir_config('lonTextBrowsers');
                    118:     my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
                    119:     
                    120:     foreach (split(/\:/,$textbrowsers)) {
                    121: 	if ($httpbrowser=~/$_/i) {
                    122: 	    $env{'form.interface'}='textual';
                    123:         }
                    124:     }
                    125: 
                    126:     my $fullgraph=($env{'form.interface'} ne 'textual');
                    127: 
                    128:     my $iconpath= 
                    129: 	&Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
                    130: 
                    131:     my $domain = &Apache::lonnet::default_login_domain();
                    132:     if (($env{'form.domain'}) && 
                    133: 	(&Apache::lonnet::domain($env{'form.domain'},'description'))) {
                    134: 	$domain=$env{'form.domain'};
                    135:     }
1.10    ! gci       136:     my %longname = (
        !           137:                      GCI  => 'Geoscience Concept Inventory',
        !           138:                      SLCI => 'Science Literacy Concept Inventory',
        !           139:                    );
        !           140:     my %allnums = &Apache::loncommon::get_faculty_cnums();
        !           141:     my ($inventory,$uc_inventory,$testdom);
        !           142:     if ($domain =~ /^(\w+ci)test$/) {
        !           143:         $inventory = $1;
        !           144:         $testdom = $domain;
        !           145:     } else {
        !           146:         $inventory = $domain;
        !           147:         $testdom = $domain.'test';
        !           148:     }
        !           149:     $uc_inventory = uc($inventory);
        !           150:     my $sitename; = $uc_inventory.' WebCenter';
1.4       gci       151:     my $shortsitename = 'WebCenter';
                    152:     my $existing = 'Existing WebCenter user?';
1.10    ! gci       153:     my $sitedesc = &mt('The [_1]WebCenter[_2] is a place to comment on existing concept questions, or submit new ones, and is also a place to build and manage Concept Tests which your students will complete via the [_3]Testing Center[_2].',$longname{$inventory}.' ('.$uc_inventory.') <a href="http://'.$inventory.'.lite.msu.edu/">','</a>','<a href="http://'.$testdom.'.lite.msu.edu/adm/login">');
1.1       gci       154:     my $role    = $r->dir_config('lonRole');
                    155:     my $loadlim = $r->dir_config('lonLoadLim');
                    156:     my $servadm = $r->dir_config('lonAdmEMail');
                    157:     my $lonhost = $r->dir_config('lonHostID');
                    158:     my $tabdir  = $r->dir_config('lonTabDir');
                    159:     my $include = $r->dir_config('lonIncludes');
                    160:     my $expire  = $r->dir_config('lonExpire');
                    161:     my $version = $r->dir_config('lonVersion');
                    162:     my $host_name = &Apache::lonnet::hostname($lonhost);
1.10    ! gci       163:     if ($domain =~ /^(\w+ci)test$/) {
        !           164:         $lonhost = $domain.'l1';
        !           165:         $host_name = $domain.'.lite.msu.edu';
        !           166:         $sitename = $inventory.' Testing Center';
1.4       gci       167:         $shortsitename = 'Testing Center';
                    168:         $existing = 'Student with Testing Center account?';
1.10    ! gci       169:         $sitedesc = &mt('The [_1] Testing Center is used by [_2]students[_3] to complete online concept tests created by their instructors using questions available in the [_4].',$inventory,'<i>','</i>',$longname{$inventory});
1.4       gci       170:     }
1.1       gci       171: 
                    172: # --------------------------------------------- Default values for login fields
                    173: 
                    174:     my $authusername=($env{'form.username'}?$env{'form.username'}:'');
                    175:     my $authdomain=($env{'form.domain'}?$env{'form.domain'}:$domain);
                    176: 
                    177: # ---------------------------------------------------------- Determine own load
                    178:     my $loadavg;
                    179:     {
                    180: 	my $loadfile=Apache::File->new('/proc/loadavg');
                    181: 	$loadavg=<$loadfile>;
                    182:     }
                    183:     $loadavg =~ s/\s.*//g;
                    184:     my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
                    185:     my $userloadpercent=&Apache::lonnet::userload();
                    186: 
                    187: # ------------------------------------------------------- Do the load balancing
                    188:     my $otherserver= &Apache::lonnet::absolute_url($host_name);
                    189:     my $firsturl=
                    190:     ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
                    191: # ---------------------------------------------------------- Are we overloaded?
                    192:     if ((($userloadpercent>100.0)||($loadpercent>100.0))) {
                    193:         my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent);
                    194: 	if ($unloaded) { $otherserver=$unloaded; }
                    195:     }
                    196: 
                    197: # ----------------------------------------------------------- Get announcements
                    198:     my $announcements=&Apache::lonnet::getannounce();
                    199: # -------------------------------------------------------- Set login parameters
                    200: 
                    201:     my @hexstr=('0','1','2','3','4','5','6','7',
                    202:                 '8','9','a','b','c','d','e','f');
                    203:     my $lkey='';
                    204:     for (0..7) {
                    205:         $lkey.=$hexstr[rand(15)];
                    206:     }
                    207: 
                    208:     my $ukey='';
                    209:     for (0..7) {
                    210:         $ukey.=$hexstr[rand(15)];
                    211:     }
                    212: 
                    213:     my $lextkey=hex($lkey);
                    214:     if ($lextkey>2147483647) { $lextkey-=4294967296; }
                    215: 
                    216:     my $uextkey=hex($ukey);
                    217:     if ($uextkey>2147483647) { $uextkey-=4294967296; }
                    218: 
                    219: # -------------------------------------------------------- Store away log token
1.2       gci       220:     my $tokenextras;
                    221:     if ($env{'form.role'}) {
                    222:         $tokenextras = '&role='.&escape($env{'form.role'});
                    223:     }
1.10    ! gci       224:     if ($domain !~ /^\w+citest$/) {
1.9       gci       225:         unless ($env{'form.symb'} eq '/adm/statistics') {
1.10    ! gci       226:             $env{'form.symb'} = '/adm/ci_info';
1.9       gci       227:         }
1.6       gci       228:     }
1.2       gci       229:     if ($env{'form.symb'}) {
                    230:         if (!$tokenextras) {
                    231:             $tokenextras = '&';
                    232:         }
                    233:         $tokenextras .= '&symb='.&escape($env{'form.symb'});
                    234:     }
1.1       gci       235:     my $logtoken=Apache::lonnet::reply(
1.6       gci       236:        'tmpput:'.$ukey.$lkey.'&'.$firsturl.$tokenextras,
1.1       gci       237:        $lonhost);
                    238: 
                    239: # ------------------- If we cannot talk to ourselves, we are in serious trouble
                    240: 
                    241:     if ($logtoken eq 'con_lost') {
                    242:         my $spares='';
                    243: 	my $last;
                    244:         foreach my $hostid (sort
                    245: 			    {
                    246: 				&Apache::lonnet::hostname($a) cmp
                    247: 				    &Apache::lonnet::hostname($b);
                    248: 			    }
                    249: 			    keys(%Apache::lonnet::spareid)) {
                    250:             next if ($hostid eq $lonhost);
                    251: 	    my $hostname = &Apache::lonnet::hostname($hostid);
                    252: 	    next if ($last eq $hostname);
                    253:             $spares.='<br /><font size="+1"><a href="http://'.
                    254:                 $hostname.
                    255:                 '/adm/login?domain='.$authdomain.'">'.
                    256:                 $hostname.'</a>'.
                    257:                 ' '.&mt('(preferred)').'</font>'.$/;
                    258: 	    $last=$hostname;
                    259:         }
                    260:         $spares.= '<br />';
                    261: 	my %all_hostnames = &Apache::lonnet::all_hostnames();
                    262:         foreach my $hostid (sort
                    263: 			    {
                    264: 				&Apache::lonnet::hostname($a) cmp
                    265: 				    &Apache::lonnet::hostname($b);
                    266: 			    }
                    267: 			    keys(%all_hostnames)) {
                    268:             next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
                    269: 	    my $hostname = &Apache::lonnet::hostname($hostid);
                    270:             next if ($last eq $hostname);
                    271:             $spares.='<br /><a href="http://'.
                    272:                 $hostname.
                    273:                 '/adm/login?domain='.$authdomain.'">'.
                    274:                 $hostname.'</a>';
                    275: 	    $last=$hostname;
                    276:         }
                    277: 	$r->print(
                    278:            '<html>'
                    279:           .'<head><title>'
                    280:           .&mt('The LearningOnline Network with CAPA')
                    281:           .'</title></head>'
                    282:           .'<body bgcolor="#FFFFFF">'
                    283:           .'<h1>'.&mt('The LearningOnline Network with CAPA').'</h1>'
                    284:           .'<img src="/adm/lonKaputt/lonlogo_broken.gif" align="right" />'
1.4       gci       285:           .'<h3>'.&mt("The $sitename server is temporarily not available for login.").'</h3>'
1.1       gci       286:           .'</body>'
                    287:           .'</html>'
                    288:         );
                    289:         return OK;
                    290:     }
                    291: 
                    292: # ----------------------------------------------- Apparently we are in business
                    293:     $servadm=~s/\,/\<br \/\>/g;
                    294: 
                    295: # ----------------------------------------------------------- Front page design
                    296:     my $pgbg=
                    297:       ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF');
                    298:     my $font=
                    299:       ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000');
                    300:     my $link=
                    301:       ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF');
                    302:     my $vlink=
                    303:       ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF');
                    304:     my $alink=&Apache::loncommon::designparm('login.alink',$domain);
                    305:     my $mainbg=
                    306:       ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF');
                    307:     my $sidebg=
                    308:       ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF');
                    309:     my $textcol = 
                    310:       ($fullgraph?&Apache::loncommon::designparm('login.textcol',$domain):'#000000');
                    311:     my $bgcol =
                    312:       ($fullgraph?&Apache::loncommon::designparm('login.bgcol',$domain):'#FFFFFF');
                    313:     my $logo=&Apache::loncommon::designparm('login.logo',$domain);
                    314:     my $img=&Apache::loncommon::designparm('login.img',$domain);
                    315:     my $domainlogo=&Apache::loncommon::domainlogo($domain);
                    316:     my $login=&Apache::loncommon::designparm('login.login',$domain);
                    317:     if ($login eq '') {
                    318:         $login = $iconpath.'/'.&mt('userauthentication.gif');
                    319:     }
                    320:     my $showbanner = 1;
                    321:     my $showmainlogo = 1;
                    322:     if (defined(&Apache::loncommon::designparm('login.showlogo_img',$domain))) {
                    323:         $showbanner = &Apache::loncommon::designparm('login.showlogo_img',$domain);
                    324:     }
                    325:     if (defined(&Apache::loncommon::designparm('login.showlogo_logo',$domain))) {
                    326:         $showmainlogo = &Apache::loncommon::designparm('login.showlogo_logo',$domain);
                    327:     }
                    328:     my $showadminmail=&Apache::loncommon::designparm('login.adminmail',$domain);
                    329:     my $showcoursecat =
                    330:         &Apache::loncommon::designparm('login.coursecatalog',$domain);
                    331:     my $loginheader =&Apache::loncommon::designparm('login.loginheader',$domain);
                    332:     my $shownewuserlink = 
                    333:         &Apache::loncommon::designparm('login.newuser',$domain);
                    334:     my $now=time;
                    335:     my $js = (<<ENDSCRIPT);
                    336: 
1.2       gci       337:  <script type="text/javascript" language="JavaScript">
1.4       gci       338:  // <![CDATA[
                    339: 
1.1       gci       340:     function send(caller)
                    341:     {
                    342: 
                    343:         if (caller == "newaccount") {
                    344:             this.document.signup.submit();
                    345:             return false;
                    346:         }
                    347:         if (document.client.uname.value == "" || !document.client.uname.value) {
                    348:             alert("You must provide a username ");
                    349:             return false;
                    350:         }
                    351:         if (document.client.upass$now.value == "" || !document.client.upass$now.value) {
                    352:             alert("You must provide a password");
                    353:             return false;
                    354:         }
                    355: 
                    356:         this.document.server.elements.uname.value
                    357:        =this.document.client.elements.uname.value;
                    358: 
                    359:         this.document.server.elements.udom.value
                    360:        =this.document.client.elements.udom.value;
                    361: 
                    362:         this.document.server.elements.imagesuppress.value
                    363:        =this.document.client.elements.imagesuppress.checked;
                    364: 
                    365:         this.document.server.elements.embedsuppress.value
                    366:        =this.document.client.elements.embedsuppress.checked;
                    367: 
                    368:         this.document.server.elements.appletsuppress.value
                    369:        =this.document.client.elements.appletsuppress.checked;
                    370: 
                    371:         this.document.server.elements.fontenhance.value
                    372:        =this.document.client.elements.fontenhance.checked;
                    373: 
                    374:         this.document.server.elements.blackwhite.value
                    375:        =this.document.client.elements.blackwhite.checked;
                    376: 
                    377:         this.document.server.elements.remember.value
                    378:        =this.document.client.elements.remember.checked;
                    379: 
                    380:         uextkey=this.document.client.elements.uextkey.value;
                    381:         lextkey=this.document.client.elements.lextkey.value;
                    382:         initkeys();
                    383: 
                    384:         this.document.server.elements.upass0.value
                    385:             =crypted(this.document.client.elements.upass$now.value.substr(0,15));
                    386:         this.document.server.elements.upass1.value
                    387:             =crypted(this.document.client.elements.upass$now.value.substr(15,15));
                    388:         this.document.server.elements.upass2.value
                    389:             =crypted(this.document.client.elements.upass$now.value.substr(30,15));
                    390: 
                    391:         this.document.client.elements.uname.value='';
                    392:         this.document.client.elements.upass$now.value='';
                    393: 
                    394:         this.document.server.submit();
                    395:         return false;
                    396:     }
1.4       gci       397:  // ]]>
1.1       gci       398:  </script>
1.4       gci       399: 
1.1       gci       400: ENDSCRIPT
                    401: 
                    402: # --------------------------------------------------- Print login screen header
                    403: 
                    404:     my %add_entries = (topmargin    => "0",
                    405:                        leftmargin   => "0",
                    406:                        marginheight => "0",
                    407:                        marginwidth  => "0",
                    408:                        bgcolor      => "$pgbg",
                    409:                        text         => "$font",
                    410:                        link         => "$link",
                    411:                        vlink        => "$vlink",
                    412:                        alink        => "$alink",
                    413:                        onload       => "if ( document.client.uname ) { document.client.uname.focus(); }",
                    414:                        marginheight => "0",);
                    415: 
1.4       gci       416:     my $css_url = "/css/$domain/login.css";
                    417:     $js .= "\n".'<link type="text/css" rel="stylesheet" href="'.$css_url.'">'."\n";
1.10    ! gci       418:     $r->print(&Apache::loncommon::start_page($uc_inventory.' WebCenter Login',$js,
1.1       gci       419:                                        { 'redirect'       => [$expire,'/adm/roles'], 
                    420:                                          'add_entries' => \%add_entries,
                    421:                                          'only_body'   => 1,}));
                    422: 
                    423: # ----------------------------------------------------------------------- Texts
                    424: 
                    425: my %lt=&Apache::lonlocal::texthash(
                    426: 		  'un'  => 'Username',
                    427: 		  'pw'  => 'Password',
                    428: 		  'dom' => 'Domain',
                    429: 		  'load' => 'Server Load',
                    430:                   'userload' => 'User Load',
                    431:                   'about'  => 'About LON-CAPA',
                    432:                   'access' => 'Accessibility Options',
                    433:                   'catalog' => 'Course Catalog',
                    434: 		  'log' => 'Log in',
                    435: 		  'help' => 'Log-in Help',
                    436: 		  'serv' => 'Server',
                    437:                   'servadm' => 'Server Administration',
                    438:                   'helpdesk' => 'Contact Helpdesk',
                    439:                   'forgotpw' => 'Forgot password?',
                    440:                   'newuser'  => 'New User?',
                    441:                   'options_headline' => 'Select Accessibility Options',
                    442:                   'sprs_img' => 'Suppress rendering of images',
                    443:                   'sprs_applet' => 'Suppress Java applets',
                    444:                   'sprs_embed' => 'Suppress rendering of embedded multimedia',
                    445:                   'sprs_font' => 'Increase font size',
                    446:                   'sprs_blackwhite' => 'Switch to black and white mode',
                    447:                   'remember' => 'Remember these settings for next login',
                    448:                   'tbli'     => 'Text-based Interface Login');
                    449: # -------------------------------------------------- Change password field name
                    450:     my $forgotpw = &forgotpwdisplay(%lt);
                    451:     my $loginhelp = &loginhelpdisplay(%lt);
                    452: 
                    453: # ---------------------------------------------------- Serve out DES JavaScript
                    454:     {
                    455:         my $jsh=Apache::File->new($include."/londes.js");
                    456:         $r->print(<$jsh>);
                    457:     }
                    458: # ---------------------------------------------------------- Serve rest of page
                    459: 
                    460:     my $coursecatalog;
                    461:     if (($showcoursecat eq '') || ($showcoursecat)) {
                    462:         $coursecatalog = &coursecatalog_link($lt{'catalog'},$fullgraph);
                    463:     }
                    464:     my $newuserlink;
                    465:     if ($shownewuserlink) {
                    466:         $newuserlink = &newuser_link($lt{'newuser'});
                    467:     }
                    468:     if ($fullgraph) {
1.4       gci       469:         $r->print(<<"END_OF_BLOCK1");
1.1       gci       470: <br />
                    471: <div align="center">
                    472: <table class="LC_loginbox">
                    473:   <tr>
1.4       gci       474:     <td align="left" valign="top" width="11">
                    475:      <img name="login_r1_c1" src="/images/login/$domain/r1_c1.png" width="11" height="11" border="0" alt="">
1.1       gci       476:     </td>
                    477:     <td width="450" valign="top">
                    478:       <table class="LC_loginbox_left">
                    479:         <tr>
1.10    ! gci       480:           <td width="411" align="left"><br /><img src="/images/login/$domain/logo_smrnd.png" width="411" height="51" alt="$uc_inventory" align="left"></td>
1.1       gci       481:         </tr>
                    482:         <tr>
                    483:          <td>
                    484:           <div align="left" style="display:block; margin-top:5px; margin-bottom:5px; margin-left:0px; margin-right:0px; width:440px; height:5px;">
1.4       gci       485:            <div class="divider">
1.1       gci       486:             </div>
                    487:           </div>
                    488:         </td>
                    489:        </tr>
                    490:       </table>
                    491:       <table class="LC_loginbox_left">
                    492:        <tr>
                    493:         <td height="10" colspan="4">&nbsp;</td>
                    494:        </tr>
                    495:        <tr>
                    496:         <td width="10">&nbsp;</td>
                    497:         <td valign="top" class="bodyblue" width="430" align="left">
1.4       gci       498:          <span style="font-size: 18px; line-height: 22px; "><font style="font-size: 18px; line-height: 22px;"><br />New to the $sitename?</font></span><br />
                    499:           <font class="bodyblue">$sitedesc<br /><br />The $shortsitename runs on <a href="http://loncapa.org/">LON-CAPA</a> - an open source freeware distributed learning content management and assessment system.</font><br /><br />
                    500: END_OF_BLOCK1
1.10    ! gci       501:     if ($domain !~ /^\w+citest$/) {
        !           502:         my $review;
        !           503:         if (ref($allnums{$domain}) eq 'HASH') {
        !           504:             $review = $domain.'_'.$allnums{$domain}{'review'};
        !           505:         }
1.4       gci       506:         $r->print(<<"END_OF_BLOCK2"); 
1.10    ! gci       507:           <font class="bodyblue"><b>Create a $uc_inventory WebCenter ID</b> &#150; use your ID to submit comments or new content, or to create a new test.  If you are already a $uc_inventory WebCenter user, please log-in.</font><br /><br /><br />
        !           508:          <form name="signup" method="post" action="/adm/createaccount?courseid=$review"><input type="hidden" name="process" value="signup"/>
1.1       gci       509:          <table class="LC_signup">
                    510:            <tr>
1.4       gci       511:              <td align="left" valign="top" width="11" height="11"><img src="/images/login/$domain/r2_c4.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       512:              <td>&nbsp;</td>
1.4       gci       513:              <td align="right" valign="top" width="11" height="11"><img src="/images/login/$domain/r2_c6.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       514:            </tr>
                    515:            <tr>
1.7       gci       516:              <td>&nbsp;</td>
1.10    ! gci       517:              <td align="center" valign="middle"><span style="white-space: nowrap;">New to $uc_inventory WebCenter:&nbsp;<a href="javascript:send('newaccount')" style="color: #ffffff">Click here to sign up</a></span></td>
1.7       gci       518:              <td>&nbsp;</td>
1.1       gci       519:            </tr>
                    520:            <tr>
1.4       gci       521:              <td align="left" valign="bottom" width="11" height="11"><img src="/images/login/$domain/r8_c4.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       522:              <td>&nbsp;</td>
1.4       gci       523:              <td align="right" valign="bottom" width="11" height="11"><img src="/images/login/$domain/r8_c6.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       524:            </tr>
                    525:          </table>
                    526:          </form>
1.4       gci       527: END_OF_BLOCK2
                    528:     } else {
                    529:         $r->print('<font class="bodyblue">'.
                    530:                   &mt("If you are already a $sitename user, please log-in.").' '.&mt('If not, contact your instructor to request a username and password.').
                    531:                  '</font><br /><br /><br />');
                    532:     }
                    533:     $r->print(<<"END_OF_BLOCK3");
1.1       gci       534:         </td>
                    535:        </tr>
                    536:       </table>
                    537:      </td>
                    538:      <td width="10">&nbsp;</td>
                    539:      <td valign="top">
1.4       gci       540:       <form name="client" method="post" onsubmit="return(send());">
1.1       gci       541:       <table class="LC_loginbox_right">
                    542:        <tr>
                    543:         <td colspan="3" height="23" class="LC_loginbox_strip">&nbsp;</td>
                    544:        </tr>
                    545:        <tr>
1.4       gci       546:         <td align="left" valign="top" width="11" height="11"><img src="/images/login/$domain/r2_c4.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       547:         <td>&nbsp;</td>
1.4       gci       548:         <td align="right" valign="top" width="11" height="11"><img src="/images/login/$domain/r2_c6.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       549:        </tr>
                    550:        <tr>
                    551:         <td width="10">&nbsp;</td>
                    552:         <td>
                    553:          <table border="0" cellspacing="0" cellpadding="0">
                    554:           <tr>
                    555:            <td align="right" class="bodywhite" height=50><br>
                    556:             <span style="font-size: 15px; line-height: 17px; font-weight: bold;">
1.4       gci       557:              $existing</span>
1.1       gci       558:              <br />Please log-in.<br>
1.4       gci       559:              <hr class="login"><br /><br />
1.1       gci       560:             </td>
                    561:            </tr>
                    562:            <tr>
                    563:             <td>
                    564:              <table border="0" cellpadding="2" cellspacing="0">
                    565:               <tr>
                    566:                <td align="right" class="bodywhite"><label for="uname">$lt{'un'}</label>:</td>
                    567:                <td align="right"><input type="text" name="uname" size="17" value="$authusername" /></td>
                    568:                </tr>
                    569:                <tr>
                    570:                 <td align="right" class="bodywhite"><label for="upass$now">$lt{'pw'}</label>:</td>
1.4       gci       571:                 <td align="right"><input name="upass$now" size="17" value="" type="password"><input type="hidden" name="udom" value="$domain" /></td>
1.1       gci       572:                </tr>
                    573:                <tr><td>&nbsp;</td></tr>
                    574:                <tr>
                    575:                 <td colspan="2" align="right"><input name="signin" type="submit" value="Log-in" class=buttonwhite /></td>
                    576:                </tr>
                    577:               </table>
                    578:              </td>
                    579:             </tr>
                    580:             <tr>
                    581:              <td align="right" valign="top" class="bodywhite">
                    582:               <br />
                    583:               <br /><br />
1.4       gci       584:               <hr class="login" />
1.1       gci       585:               <br />
                    586:               <a href="/adm/resetpw" style="color: #ffffff">Forgot your password?</a><br>
                    587:               <br />
                    588:              </td>
                    589:             </tr>
                    590:            </table>
                    591:           </td>
                    592:           <td width="9">&nbsp;</td>
                    593:         </tr>
                    594:         <tr>
1.4       gci       595:           <td align="left" valign="bottom" width="11" height="11"><img src="/images/login/$domain/r8_c4.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       596:           <td>&nbsp;</td>
1.4       gci       597:           <td align="right" valign="bottom" width="11" height="11"><img src="/images/login/$domain/r8_c6.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       598:         </tr>
                    599:         <tr>
                    600:           <td colspan="3" height="10" class="LC_loginbox_strip">&nbsp;</td>
                    601:         </tr>
                    602:       </table>
                    603:     </td>
1.4       gci       604:     <td align="right" valign="top" width="11"><img src="/images/login/$domain/r1_c7.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       605:   </tr>
                    606:   <tr>
                    607:     <td colspan="4">
1.7       gci       608:       <div align="left">
1.1       gci       609:       <table border="0" cellspacing="0" cellpadding="0">
                    610:         <tr>
                    611:           <td width="10">&nbsp;</td>
                    612:        <td><font size="-1">
1.7       gci       613:      <b>Note</b>:<br />
1.1       gci       614:       If log-in fails, it may be because your browser is not accepting session cookies, or javascript is disabled. <a href="http://loncapa.msu.edu/student/cookies.html">Learn more</a>.
                    615:      </font>
                    616:          </td>
                    617:          <td width="10">&nbsp;</td>
                    618:        </tr>
                    619:      </table>
1.7       gci       620:      </div>
1.1       gci       621:    </td>
                    622:   </tr>
                    623:   <tr>
1.4       gci       624:     <td align="left" valign="bottom" width="11"><img src="/images/login/$domain/r9_c1.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       625:     <td colspan="3" width="698">&nbsp;</td>
1.4       gci       626:     <td align="right" valign="bottom" width="11"><img src="/images/login/$domain/r9_c7.png" width="11" height="11" border="0" alt=""></td>
1.1       gci       627:   </tr>
                    628: </table>
                    629: </div>
                    630: <p>&nbsp;</p>
                    631: <noscript><font size='3'>&nbsp;&nbsp;<b>Please Note:</b>
                    632:  Javascript must be enabled in your web browser in order to use this web site.
                    633:  </font></noscript>
                    634: <p>&nbsp;</p>
                    635: <input type="hidden" name="imagesuppress"  value="" />
                    636: <input type="hidden" name="embedsuppress"  value="" />
                    637: <input type="hidden" name="appletsuppress"  value="" />
                    638: <input type="hidden" name="fontenhance"  value="" />
                    639: <input type="hidden" name="blackwhite"  value="" />
                    640: <input type="hidden" name="remember"  value="" />
1.4       gci       641: END_OF_BLOCK3
1.1       gci       642:     } else {
                    643:         $r->print(<<ENDACCESSOPTIONS);
                    644: <h1>The Learning<i>Online</i> Network with CAPA</h1>
                    645: <h2>$lt{'tbli'}</h2>$announcements
                    646: <h3>$lt{'options_headline'}</h3>
1.2       gci       647: <form name="client" action="" onsubmit="return(send())">
1.1       gci       648: <label><input type="checkbox" name="imagesuppress" /> $lt{'sprs_img'}</label><br />
                    649: <label><input type="checkbox" name="appletsuppress" /> $lt{'sprs_applet'}</label><br />
                    650: <label><input type="checkbox" name="embedsuppress" /> $lt{'sprs_embed'}</label><br />
                    651: <label><input type="checkbox" name="fontenhance" /> $lt{'sprs_font'}</label><br />
                    652: <label><input type="checkbox" name="blackwhite" /> $lt{'sprs_blackwhite'}</label><br />
                    653: <br />
                    654: <input type="checkbox" name="remember" /> $lt{'remember'}
                    655: ENDACCESSOPTIONS
                    656:     }
                    657:     $r->print('
1.2       gci       658:      <input type="hidden" name="lextkey" value="'.$lextkey.'" />
                    659:      <input type="hidden" name="uextkey" value="'.$uextkey.'" />
1.1       gci       660: ');
                    661:     unless ($fullgraph) {
                    662:         my $logintitle;
                    663:         if ($loginheader eq 'text') {
                    664:             $logintitle = '<td bgcolor="'.$bgcol.'" colspan="2">&nbsp;&nbsp;&nbsp;<b><font size="+1" color="'.$textcol.'">'.$lt{'log'}.'</font></b></td>';
                    665:         } else {
                    666:             $logintitle = '<td bgcolor="'.$sidebg.'" colspan="2"><img src="'.$login.'" alt="'.
                    667:                           &mt('User Authentication').'" /></td>';
                    668:         }
                    669:         my $noscript_warning='<td colspan="2" bgcolor="'.$mainbg.'">'
                    670:                              .'<noscript><div class="LC_warning"><font size="-1">'
                    671:                              .&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.')
                    672:                             .'</font></div></noscript></td>';
                    673:         $r->print(<<ENDTEXTUAL);
                    674:      <hr />
1.4       gci       675:      <table border="0" cellspacing="0" cellpadding="0">
1.1       gci       676:       <tr>$logintitle</tr>
                    677:       <tr>$noscript_warning</tr>
                    678:       <tr>
                    679:        <td bgcolor="$mainbg"><br /><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="uname">$lt{'un'}</label>:</b></font></td>
                    680:        <td bgcolor="$mainbg"><br /><input type="text" name="uname" size="10" value="$authusername" /></td>
                    681:       </tr>
                    682:       <tr>
                    683:        <td bgcolor="$mainbg"><font size=-1><b>&nbsp;&nbsp;&nbsp;<label for="upass$now">$lt{'pw'}</label>:</b></font></td>
                    684:        <td bgcolor="$mainbg"><input type="password" name="upass$now" size="10" /></td>
                    685:       </tr>
                    686:       <tr>
                    687:        <td bgcolor="$mainbg">&nbsp;</td>
                    688:        <td bgcolor="$mainbg" valign="bottom" align="center">
                    689:         <br />
                    690:         <input type="submit" value="$lt{'log'}" />
1.4       gci       691:         <input type="hidden" name="udom" value="$domain" />
1.1       gci       692:        </td>
                    693:       </tr>
                    694:       <tr>
                    695:        <td bgcolor="$mainbg" valign="bottom" align="left" colspan="2">
                    696:         $loginhelp
                    697:         $forgotpw
                    698:         $newuserlink
                    699:         $coursecatalog
                    700:         <br />
                    701:        </td>
                    702:       </tr>
                    703:      </table>
                    704: ENDTEXTUAL
                    705:     }
                    706:     $r->print(<<"ENDLOGIN");
                    707:   </form>
                    708:   <form name="server" action="$otherserver/adm/authenticate" method="post" target="_top">
                    709:    <input type="hidden" name="logtoken" value="$logtoken" />
                    710:    <input type="hidden" name="serverid" value="$lonhost" />
                    711:    <input type="hidden" name="interface" value="$env{'form.interface'}" />
                    712:    <input type="hidden" name="uname" value="" />
                    713:    <input type="hidden" name="upass0" value="" />
                    714:    <input type="hidden" name="upass1" value="" />
                    715:    <input type="hidden" name="upass2" value="" />
                    716:    <input type="hidden" name="udom" value="" />
                    717:    <input type="hidden" name="imagesuppress"  value="" />
                    718:    <input type="hidden" name="appletsuppress"  value="" />
                    719:    <input type="hidden" name="embedsuppress"  value="" />
                    720:    <input type="hidden" name="fontenhance"  value="" />
                    721:    <input type="hidden" name="blackwhite"  value="" />
                    722:    <input type="hidden" name="remember"  value="" />
                    723:    <input type="hidden" name="localpath" value="$env{'form.localpath'}" />
                    724:    <input type="hidden" name="localres" value="$env{'form.localres'}" />
                    725:   </form>
                    726: ENDLOGIN
                    727:     if ($fullgraph) {
                    728:         my $helpdeskscript;
                    729:         my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail,
                    730:                                   $version,$authdomain,\$helpdeskscript);
                    731:     }
                    732:     my %endargs = ( 'noredirectlink' => 1, );
                    733:     $r->print(&Apache::loncommon::end_page(\%endargs));
                    734:     return OK;
                    735: }
                    736: 
                    737: sub contactdisplay {
                    738:     my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_;
                    739:     my $contactblock;
                    740:     my $showhelpdesk = 0;
                    741:     my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
                    742:     if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) {
                    743:         $showhelpdesk = 1;
                    744:     }
                    745:     if ($servadm && $showadminmail) {
                    746:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;'.$$lt{'servadm'}.':</b><br />'.
                    747:                          '<tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.$servadm.'</tt><br />&nbsp;<br />';
                    748:     }
                    749:     if ($showhelpdesk) {
                    750:         $contactblock .= '<b>&nbsp;&nbsp;&nbsp;<a href="javascript:helpdesk()"><font size="+1">'.$lt->{'helpdesk'}.'</font></a></b><br />';
                    751:         my $thisurl = &escape('/adm/login');
                    752:         $$helpdeskscript = <<"ENDSCRIPT";
                    753: <script type="text/javascript">
1.2       gci       754: // <![CDATA[
1.1       gci       755: function helpdesk() {
                    756:     var codedom = document.client.udom.value;
                    757:     if (codedom == '') {
                    758:         codedom = "$authdomain";
                    759:     }
                    760:     var querystr = "origurl=$thisurl&codedom="+codedom;
                    761:     document.location.href = "/adm/helpdesk?"+querystr;
                    762:     return;
                    763: }
1.2       gci       764: // ]]>
1.1       gci       765: </script>
                    766: ENDSCRIPT
                    767:     }
                    768:     $contactblock .= <<"ENDBLOCK";
                    769:      &nbsp;&nbsp;&nbsp;$version
                    770: ENDBLOCK
                    771:     return $contactblock;
                    772: }
                    773: 
                    774: sub forgotpwdisplay {
                    775:     my (%lt) = @_;
                    776:     my $prompt_for_resetpw = 1; 
                    777:     if ($prompt_for_resetpw) {
                    778:         return '<br />&nbsp;&nbsp;&nbsp;<a href="/adm/resetpw"><b>'.$lt{'forgotpw'}.'</b></a><br />';
                    779:     }
                    780:     return;
                    781: }
                    782: 
                    783: sub loginhelpdisplay {
                    784:     my (%lt) = @_;
                    785:     my $login_help = 1;
                    786:     if ($login_help) {
                    787:         return '&nbsp;&nbsp;&nbsp;<a href="/adm/loginproblems.html"><b>'.$lt{'help'}.'</b></a>';
                    788:     }
                    789:     return;
                    790: }
                    791: 
                    792: sub coursecatalog_link {
                    793:     my ($linkname,$fullgraph) = @_;
                    794:     my $link = '/adm/coursecatalog';
                    795:     if (!$fullgraph) {
                    796:         $link.= '?interface=textual';
                    797:     }
                    798:     return '&nbsp;&nbsp;&nbsp;<a href="/adm/coursecatalog"><b>'.$linkname.'</b></a><br />';
                    799: END
                    800: }
                    801: 
                    802: sub newuser_link {
                    803:     my ($linkname) = @_;
                    804:     return '&nbsp;&nbsp;&nbsp;<a href="/adm/createaccount"><b>'.$linkname.'</b></a><br />';
                    805: }
                    806: 
                    807: 1;
                    808: __END__

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