--- loncom/auth/lonlogin.pm 2002/09/17 19:45:11 1.22 +++ loncom/auth/lonlogin.pm 2003/09/11 20:54:11 1.49 @@ -1,7 +1,7 @@ # The LearningOnline Network # Login Screen # -# $Id: lonlogin.pm,v 1.22 2002/09/17 19:45:11 matthew Exp $ +# $Id: lonlogin.pm,v 1.49 2003/09/11 20:54:11 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,6 +40,7 @@ use Apache::Constants qw(:common); use Apache::File (); use Apache::lonnet(); use Apache::loncommon(); +use Apache::lonauth(); sub handler { my $r = shift; @@ -49,15 +50,40 @@ sub handler { return OK if $r->header_only; - &Apache::loncommon::get_unprocessed_cgi - ($ENV{'QUERY_STRING'},['interface']); +# Are we re-routing? + if (-e '/home/httpd/html/lon-status/reroute.txt') { + &Apache::lonauth::reroute($r); + return OK; + } + &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; - my $fullgraph=($ENV{'form.interface'} ne 'textual'); + my $textbrowsers=$r->dir_config('lonTextBrowsers'); + my $httpbrowser=$ENV{"HTTP_USER_AGENT"}; + + foreach (split(/\:/,$textbrowsers)) { + if ($httpbrowser=~/$_/i) { + $ENV{'form.interface'}='textual'; + } + } - my $iconpath= $r->dir_config('lonIconsURL'); + 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 $domain = $r->dir_config('lonDefDomain'); + if (($ENV{'form.domain'}) && + ($Apache::lonnet::domaindescription{$ENV{'form.domain'}})) { + $domain=$ENV{'form.domain'}; + } my $role = $r->dir_config('lonRole'); my $loadlim = $r->dir_config('lonLoadLim'); my $servadm = $r->dir_config('lonAdmEMail'); @@ -65,22 +91,37 @@ sub handler { 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'); + +# --------------------------------------------- Default values for login fields + my $authusername=($ENV{'form.username'}?$ENV{'form.username'}:''); + my $authdomain=($ENV{'form.domain'}?$ENV{'form.domain'}:$domain); + +# ---------------------------------------------------------- Determine own load my $loadavg; - { - my $loadfile=Apache::File->new('/proc/loadavg'); - $loadavg=<$loadfile>; - } + { + my $loadfile=Apache::File->new('/proc/loadavg'); + $loadavg=<$loadfile>; + } $loadavg =~ s/\s.*//g; my $loadpercent=100*$loadavg/$loadlim; + my $userloadpercent=&Apache::lonnet::userload(); +# ------------------------------------------------------- Do the load balancing my $otherserver='http://'.$ENV{'SERVER_NAME'}; - my $firsturl=$ENV{'request.firsturl'}; + my $firsturl= + ($ENV{'request.firsturl'}?$ENV{'request.firsturl'}:$ENV{'form.firsturl'}); # ---------------------------------------- Are we access server and overloaded? - if (($loadpercent>100.0)) { - $otherserver=Apache::lonnet::spareserver($loadpercent); + if (($role eq 'access') && + (($userloadpercent>100.0)||($loadpercent>100.0))) { + my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent); + if ($unloaded) { $otherserver=$unloaded; } } +# ----------------------------------------------------------- Get announcements + my $announcements=&Apache::lonnet::getannounce(); # -------------------------------------------------------- Set login parameters my @hexstr=('0','1','2','3','4','5','6','7', @@ -101,14 +142,50 @@ sub handler { my $uextkey=hex($ukey); if ($uextkey>2147483647) { $uextkey-=4294967296; } +# -------------------------------------------------------- Store away log token my $logtoken=Apache::lonnet::reply( 'tmpput:'.$ukey.$lkey.'&'.$firsturl, $lonhost); - my $domainlogo=&Apache::loncommon::domainlogo(); + +# ------------------- If we cannot talk to ourselves, we are in serious trouble + + 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)'; + } + } + } + $r->print(< +The LearningOnline Network with CAPA + + +

This LON-CAPA server is temporarily not available for login

+

Please attempt to login to one of the following servers:

$spares +

If the problem persists, please contact $servadm.

+ + +ENDTROUBLE + return OK; + } + +# ----------------------------------------------- Apparently we are in business + + my $domainlogo=&Apache::loncommon::domainlogo($domain); + $servadm=~s/\,/\
/g; + $sysadm=~s/\,/\
/g; + # --------------------------------------------------- Print login screen header $r->print(< + The LearningOnline Network with CAPA Login ENDHEADER @@ -119,22 +196,28 @@ ENDHEADER } # ----------------------------------------------------------- Front page design - my $pgbg=&Apache::loncommon::designparm('login.pgbg'); - my $font=&Apache::loncommon::designparm('login.font'); - my $link=&Apache::loncommon::designparm('login.link'); - my $vlink=&Apache::loncommon::designparm('login.vlink'); - my $alink=&Apache::loncommon::designparm('login.alink'); - my $mainbg=&Apache::loncommon::designparm('login.mainbg'); - my $sidebg=&Apache::loncommon::designparm('login.sidebg'); - my $logo=&Apache::loncommon::designparm('login.logo'); - my $img=&Apache::loncommon::designparm('login.img'); + my $pgbg= + ($fullgraph?&Apache::loncommon::designparm('login.pgbg',$domain):'#FFFFFF'); + my $font= + ($fullgraph?&Apache::loncommon::designparm('login.font',$domain):'#000000'); + my $link= + ($fullgraph?&Apache::loncommon::designparm('login.link',$domain):'#0000FF'); + my $vlink= + ($fullgraph?&Apache::loncommon::designparm('login.vlink',$domain):'#0000FF'); + my $alink=&Apache::loncommon::designparm('login.alink',$domain); + my $mainbg= + ($fullgraph?&Apache::loncommon::designparm('login.mainbg',$domain):'#FFFFFF'); + my $sidebg= + ($fullgraph?&Apache::loncommon::designparm('login.sidebg',$domain):'#FFFFFF'); + my $logo=&Apache::loncommon::designparm('login.logo',$domain); + my $img=&Apache::loncommon::designparm('login.img',$domain); # ---------------------------------------------------------- Serve rest of page $r->print(< + topmargin=0 leftmargin=0 marginwidth=0 marginheight=0> + ENDDOCUMENT } $r->print('');