--- loncom/auth/lonlogin.pm 2003/08/25 15:24:43 1.46 +++ loncom/auth/lonlogin.pm 2004/08/10 18:55:13 1.58 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.46 2003/08/25 15:24:43 www Exp $ +# $Id: lonlogin.pm,v 1.58 2004/08/10 18:55:13 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,34 +25,69 @@ # # http://www.lon-capa.org/ # -# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14, -# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9, -# 1/17/01 Gerd Kortemeyer -# -# 2/7/02,2/8,2/12,2/14,2/15,2/19 Josh Brunskole -# -# 7/10/02 Jeremy Bowers package Apache::lonlogin; use strict; use Apache::Constants qw(:common); +use CGI::Cookie(); use Apache::File (); use Apache::lonnet(); use Apache::loncommon(); +use Apache::lonauth(); +use Apache::lonlocal; sub handler { my $r = shift; - $r->content_type('text/html'); &Apache::loncommon::no_cache($r); + &Apache::lonlocal::get_language_handle($r); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; +# Are we re-routing? + if (-e '/home/httpd/html/lon-status/reroute.txt') { + &Apache::lonauth::reroute($r); + return OK; + } + +# -------------------------------- 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=$lonid->value; + $handle=~s/\W//g; + my $lonidsdir=$r->dir_config('lonIDsDir'); + if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { +# Indeed, a valid token is found + my $bodytag=&Apache::loncommon::bodytag('Already logged in'); + $r->print(< + +Already logged in + +$bodytag +

You are already logged in

+

Please either continue the current session or +logout.

+

+Problems?

+ + +ENDFAILED + return OK; + } + } + +# ---------------------------------------------------- No valid token, continue + &Apache::loncommon::get_unprocessed_cgi ($ENV{'QUERY_STRING'}.'&'.$ENV{'request.querystring'}, ['interface','username','domain','firsturl','localpath','localres']); + # ----------------------------------------------------------- Process Interface $ENV{'form.interface'}=~s/\W//g; @@ -99,7 +134,7 @@ sub handler { $loadavg=<$loadfile>; } $loadavg =~ s/\s.*//g; - my $loadpercent=100*$loadavg/$loadlim; + my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim); my $userloadpercent=&Apache::lonnet::userload(); # ------------------------------------------------------- Do the load balancing @@ -109,7 +144,8 @@ sub handler { # ---------------------------------------- Are we access server and overloaded? if (($role eq 'access') && (($userloadpercent>100.0)||($loadpercent>100.0))) { - $otherserver=Apache::lonnet::spareserver($loadpercent,$userloadpercent); + my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); + if ($unloaded) { $otherserver=$unloaded; } } # ----------------------------------------------------------- Get announcements @@ -143,15 +179,22 @@ sub handler { if ($logtoken eq 'con_lost') { my $spares=''; - foreach (keys %Apache::lonnet::hostname) { - if ($_ ne $lonhost) { - $spares.='
'. - $Apache::lonnet::hostname{$_}.''; - if ($Apache::lonnet::spareid{$_}) { - $spares.=' (preferred)'; - } - } + + foreach my $hostid (keys(%Apache::lonnet::spareid)) { + next if ($hostid eq $lonhost); + $spares.='
'. + $Apache::lonnet::hostname{$hostid}.''. + ' (preferred)'.$/; + } + $spares.= '
'; + foreach my $hostid (keys(%Apache::lonnet::hostname)) { + next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid}); + $spares.='
'. + $Apache::lonnet::hostname{$hostid}.''; } $r->print(< @@ -169,7 +212,7 @@ ENDTROUBLE # ----------------------------------------------- Apparently we are in business - my $domainlogo=&Apache::loncommon::domainlogo(); + my $domainlogo=&Apache::loncommon::domainlogo($domain); $servadm=~s/\,/\
/g; $sysadm=~s/\,/\
/g; @@ -204,6 +247,24 @@ ENDHEADER my $logo=&Apache::loncommon::designparm('login.logo',$domain); my $img=&Apache::loncommon::designparm('login.img',$domain); +# ----------------------------------------------------------------------- Texts + +my %lt=&Apache::lonlocal::texthash( + 'un' => 'Username', + 'pw' => 'Password', + 'dom' => 'Domain', + 'perc' => 'percent', + 'load' => 'Load', + 'userload' => 'User Load', + 'about' => 'aboutlon.gif', + 'access' => 'accessbutton.gif', + 'auth' => 'userauthentication.gif', + 'log' => 'Log in', + 'help' => 'Help', + 'serv' => 'Server', + 'servadm' => 'Server Administration', + 'sysadm' => 'System Administration'); + # ---------------------------------------------------------- Serve rest of page $r->print(< - Accessibility Options + Accessibility Options
- About LON-CAPA + About LON-CAPA @@ -361,24 +422,24 @@ ENDNOOPT - + - + - + - + - +
User Authentication
User Authentication

   User Name:

   $lt{'un'}:

   Password:   $lt{'pw'}:
   Domain:   $lt{'dom'}:
   Help   $lt{'help'}
- +
@@ -406,7 +467,7 @@ ENDLOGIN
-    Domain:  +    $lt{'dom'}:   $domain @@ -414,7 +475,7 @@ ENDLOGIN
-    Server:  +    $lt{'serv'}:   $lonhost ($role) @@ -422,26 +483,26 @@ ENDLOGIN
-    Load:  +    $lt{'load'}:  -  $loadpercent percent +  $loadpercent $lt{'perc'}
-    User Load:  +    $lt{'userload'}:  -  $userloadpercent percent +  $userloadpercent $lt{'perc'}

-    System Administration:
+    $lt{'sysadm'}:
      $sysadm
-    Server Administration:
+    $lt{'servadm'}:
      $servadm
 
   $version