'
+ .$end_page
+ );
+ return OK;
+ }
+
+# ---------------------------------------------------- No valid token, continue
- my $fullgraph=($ENV{'form.interface'} ne 'textual');
+ # ---------------------------- Not possible to really login to domain "public"
+ if ($env{'form.domain'} eq 'public') {
+ $env{'form.domain'}='';
+ $env{'form.username'}='';
+ }
+# ----------------------------------------------------------- Process Interface
+ $env{'form.interface'}=~s/\W//g;
- my $iconpath= $r->dir_config('lonIconsURL');
- my $domain = $r->dir_config('lonDefDomain');
+ my $httpbrowser=$ENV{"HTTP_USER_AGENT"};
+
+ my $fullgraph=($env{'form.interface'} ne 'textual');
+
+ my $iconpath=
+ &Apache::loncommon::lonhttpdurl($r->dir_config('lonIconsURL'));
+
+ my $domain = &Apache::lonnet::default_login_domain();
+ if (($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 $sysadm = $r->dir_config('lonSysEMail');
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);
+
+# --------------------------------------------- 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 $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim);
+ my $userloadpercent=&Apache::lonnet::userload();
- my $otherserver='http://'.$ENV{'SERVER_NAME'};
- my $firsturl=$ENV{'request.firsturl'};
-# ---------------------------------------- Are we access server and overloaded?
- if (($loadpercent>100.0)) {
- $otherserver=Apache::lonnet::spareserver($loadpercent);
+# ------------------------------------------------------- Do the load balancing
+ my $otherserver= &Apache::lonnet::absolute_url($host_name);
+ my $firsturl=
+ ($env{'request.firsturl'}?$env{'request.firsturl'}:$env{'form.firsturl'});
+# ---------------------------------------------------------- Are we overloaded?
+ if ((($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,245 +171,399 @@ 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();
-# --------------------------------------------------- Print login screen header
- $r->print(<
-
-The LearningOnline Network with CAPA Login
-
-ENDHEADER
-# ---------------------------------------------------- Serve out DES JavaScript
- {
- my $jsh=Apache::File->new($include."/londes.js");
- $r->print(<$jsh>);
- }
-# ----------------------------------------------------------- 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');
+# ------------------- If we cannot talk to ourselves, we are in serious trouble
+ if ($logtoken eq 'con_lost') {
+ my $spares='';
+ my $last;
+ foreach my $hostid (sort
+ {
+ &Apache::lonnet::hostname($a) cmp
+ &Apache::lonnet::hostname($b);
+ }
+ keys(%Apache::lonnet::spareid)) {
+ next if ($hostid eq $lonhost);
+ my $hostname = &Apache::lonnet::hostname($hostid);
+ next if ($last eq $hostname);
+ $spares.=' '.
+ $hostname.''.
+ ' '.&mt('(preferred)').''.$/;
+ $last=$hostname;
+ }
+$spares.= ' ';
+my %all_hostnames = &Apache::lonnet::all_hostnames();
+foreach my $hostid (sort
+ {
+ &Apache::lonnet::hostname($a) cmp
+ &Apache::lonnet::hostname($b);
+ }
+ keys(%all_hostnames)) {
+ next if ($hostid eq $lonhost || $Apache::lonnet::spareid{$hostid});
+ my $hostname = &Apache::lonnet::hostname($hostid);
+ next if ($last eq $hostname);
+ $spares.=' '.
+ $hostname.'';
+ $last=$hostname;
+}
+$r->print(
+ ''
+ .''
+ .&mt('The LearningOnline Network with CAPA')
+ .''
+ .''
+ .'
'.&mt('The LearningOnline Network with CAPA').'
'
+ .''
+ .'
'.&mt('This LON-CAPA server is temporarily not available for login.').'
'
+ .'
'.&mt('Please attempt to login to one of the following servers:').'