--- loncom/auth/lonlogin.pm 2007/01/14 02:00:04 1.87 +++ loncom/auth/lonlogin.pm 2007/10/09 16:27:08 1.97 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.87 2007/01/14 02:00:04 raeburn Exp $ +# $Id: lonlogin.pm,v 1.97 2007/10/09 16:27:08 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -30,7 +30,6 @@ package Apache::lonlogin; use strict; use Apache::Constants qw(:common); -use CGI::Cookie(); use Apache::File (); use Apache::lonnet; use Apache::loncommon(); @@ -69,24 +68,17 @@ sub handler { # -------------------------------- Prevent users from attempting to login twice - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - my $cookie; - if ($lonid) { - my $handle=&LONCAPA::clean_handle($lonid->value); - my $lonidsdir=$r->dir_config('lonIDsDir'); - if (-e "$lonidsdir/$handle.id") { -# Is there an existing token file? - if ($handle=~/^publicuser\_/) { + my $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle=~/^publicuser\_/) { # For "public user" - remove it, we apparently really want to login - unlink("$lonidsdir/$handle.id"); - } elsif ($handle ne '') { + unlink($r->dir_config('lonIDsDir')."/$handle.id"); + } elsif ($handle ne '') { # Indeed, a valid token is found - my $start_page = - &Apache::loncommon::start_page('Already logged in'); - my $end_page = - &Apache::loncommon::end_page(); - $r->print(<print(<You are already logged in

Please either continue the current session or @@ -95,9 +87,7 @@ $start_page Problems?

$end_page ENDFAILED - return OK; - } - } + return OK; } # ---------------------------------------------------- No valid token, continue @@ -120,25 +110,24 @@ ENDFAILED } my $fullgraph=($env{'form.interface'} ne 'textual'); - my $port_to_use=$r->dir_config('lonhttpdPort'); - if (!defined($port_to_use)) { - $port_to_use='8080'; - } - my $iconpath= 'http://'.$ENV{'HTTP_HOST'}.':'.$port_to_use. - $r->dir_config('lonIconsURL'); + + my $iconpath= + &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL')); + my $domain = &Apache::lonnet::default_login_domain(); if (($env{'form.domain'}) && - ($Apache::lonnet::domaindescription{$env{'form.domain'}})) { + (&Apache::lonnet::domain($env{'form.domain'},'description'))) { $domain=$env{'form.domain'}; } my $role = $r->dir_config('lonRole'); my $loadlim = $r->dir_config('lonLoadLim'); + my $servadm = $r->dir_config('lonAdmEMail'); my $lonhost = $r->dir_config('lonHostID'); my $tabdir = $r->dir_config('lonTabDir'); my $include = $r->dir_config('lonIncludes'); my $expire = $r->dir_config('lonExpire'); my $version = $r->dir_config('lonVersion'); - my $host_name = $Apache::lonnet::hostname{$lonhost}; + my $host_name = &Apache::lonnet::hostname($lonhost); # --------------------------------------------- Default values for login fields @@ -159,9 +148,8 @@ ENDFAILED my $otherserver= &Apache::lonnet::absolute_url($host_name); my $firsturl= ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'}); -# ---------------------------------------- Are we access server and overloaded? - if (($role eq 'access') && - (($userloadpercent>100.0)||($loadpercent>100.0))) { +# ---------------------------------------------------------- Are we overloaded? + if ((($userloadpercent>100.0)||($loadpercent>100.0))) { my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); if ($unloaded) { $otherserver=$unloaded; } } @@ -200,33 +188,36 @@ ENDFAILED my $last; foreach my $hostid (sort { - $Apache::lonnet::hostname{$a} cmp - $Apache::lonnet::hostname{$b}; + &Apache::lonnet::hostname($a) cmp + &Apache::lonnet::hostname($b); } keys(%Apache::lonnet::spareid)) { next if ($hostid eq $lonhost); - next if ($last eq $Apache::lonnet::hostname{$hostid}); + my $hostname = &Apache::lonnet::hostname($hostid); + next if ($last eq $hostname); $spares.='
'. - $Apache::lonnet::hostname{$hostid}.''. + $hostname.''. ' (preferred)'.$/; - $last=$Apache::lonnet::hostname{$hostid}; + $last=$hostname; } $spares.= '
'; + my %all_hostnames = &Apache::lonnet::all_hostnames(); foreach my $hostid (sort { - $Apache::lonnet::hostname{$a} cmp - $Apache::lonnet::hostname{$b}; + &Apache::lonnet::hostname($a) cmp + &Apache::lonnet::hostname($b); } - keys(%Apache::lonnet::hostname)) { + keys(%all_hostnames)) { next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid}); - next if ($last eq $Apache::lonnet::hostname{$hostid}); + my $hostname = &Apache::lonnet::hostname($hostid); + next if ($last eq $hostname); $spares.='
'. - $Apache::lonnet::hostname{$hostid}.''; - $last=$Apache::lonnet::hostname{$hostid}; + $hostname.''; + $last=$hostname; } $r->print(< @@ -242,8 +233,7 @@ ENDTROUBLE } # ----------------------------------------------- Apparently we are in business - - my $domainlogo=&Apache::loncommon::domainlogo($domain); + $servadm=~s/\,/\
/g; # --------------------------------------------------- Print login screen header $r->print(< 'Log in', 'help' => 'Log-in Help', 'serv' => 'Server', + 'servadm' => 'Server Administration', 'helpdesk' => 'Contact Helpdesk', 'forgotpw' => 'Forgot password?'); # -------------------------------------------------- Change password field name @@ -376,6 +372,10 @@ ENDSCRIPT ENDSERVERFORM + my $coursecatalog; + if (($showcoursecat eq '') || ($showcoursecat)) { + $coursecatalog = &coursecatalog_link($lt{'catalog'}); + } if ($fullgraph) { $r->print(< @@ -412,11 +412,7 @@ ENDSERVERFORM   $lt{'about'} - - -   - $lt{'catalog'} - + $coursecatalog   @@ -475,15 +471,15 @@ ENDNOOPT - + - + - + @@ -505,7 +501,8 @@ ENDNOOPT ENDLOGIN if ($fullgraph) { my $helpdeskscript; - my $contactblock = &contactdisplay(\%lt,$version,$authdomain,\$helpdeskscript); + my $contactblock = &contactdisplay(\%lt,$servadm,$showadminmail, + $version,$authdomain,\$helpdeskscript); $r->print(< @@ -601,13 +598,17 @@ ENDDOCUMENT } sub contactdisplay { - my ($lt,$version,$authdomain,$helpdeskscript) = @_; + my ($lt,$servadm,$showadminmail,$version,$authdomain,$helpdeskscript) = @_; my $contactblock; my $showhelpdesk = 0; my $requestmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; if ($requestmail =~ m/^[^\@]+\@[^\@]+$/) { $showhelpdesk = 1; } + if ($servadm && $showadminmail) { + $contactblock .= '   '.$$lt{'servadm'}.':
'. + '      '.$servadm.'
 
'; + } if ($showhelpdesk) { $contactblock .= '   '.$lt->{'helpdesk'}.'
'; my $thisurl = &escape('/adm/login'); @@ -649,5 +650,15 @@ sub loginhelpdisplay { return; } +sub coursecatalog_link { + my ($linkname) = @_; + return <<"END"; +
+ + + +END +} + 1; __END__
User Authentication

   $lt{'un'}:

   :

   $lt{'pw'}:   :
   $lt{'dom'}:   :
 $linkname