version 1.101.8.3, 2010/08/18 19:39:42
|
version 1.101.8.7, 2011/09/27 20:18:45
|
Line 276 sub handler {
|
Line 276 sub handler {
|
my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'}, |
my $tmpinfo=Apache::lonnet::reply('tmpget:'.$form{'logtoken'}, |
$form{'serverid'}); |
$form{'serverid'}); |
|
|
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) { |
if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost') || |
|
($tmpinfo eq 'no_such_host')) { |
&failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form); |
&failed($r,'Information needed to verify your login information is missing, inaccessible or expired.',\%form); |
return OK; |
return OK; |
} else { |
} else { |
Line 362 sub handler {
|
Line 363 sub handler {
|
&Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'}); |
&Apache::lonnet::get_dom('configuration',['usercreation'],$form{'udom'}); |
if (grep(/^login$/,@cancreate)) { |
if (grep(/^login$/,@cancreate)) { |
my $domdesc = &Apache::lonnet::domain($form{'udom'},'description'); |
my $domdesc = &Apache::lonnet::domain($form{'udom'},'description'); |
&check_can_host($r,\%form,'no_account_on_host',$domdesc); |
unless (&check_can_host($r,\%form,'no_account_on_host',$domdesc)) { |
|
return OK; |
|
} |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create a user account in LON-CAPA', |
&Apache::loncommon::start_page('Create a user account in LON-CAPA', |
'',{'no_inline_link' => 1,}); |
'',{'no_inline_link' => 1,}); |
Line 415 sub handler {
|
Line 418 sub handler {
|
} |
} |
} |
} |
|
|
&check_can_host($r,\%form,$authhost); |
|
|
|
if ($r->dir_config("lonBalancer") eq 'yes') { |
if ($r->dir_config("lonBalancer") eq 'yes') { |
&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, |
my $otherserver = &Apache::lonnet::spareserver(30000,undef,1,$form{'udom'}); |
\%form); |
if (!$otherserver) { |
my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); |
($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); |
$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver); |
} |
|
if ($otherserver) { |
|
&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, |
|
\%form); |
|
$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl); |
|
} else { |
|
$r->print(&noswitch()); |
|
} |
|
return OK; |
} else { |
} else { |
&success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef, |
if (!&check_can_host($r,\%form,$authhost)) { |
\%form); |
my ($otherserver) = &Apache::lonnet::choose_server($form{'udom'}); |
|
if ($otherserver) { |
|
&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect',undef, |
|
\%form); |
|
$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver.'&origurl='.$firsturl); |
|
} else { |
|
$r->print(&noswitch()); |
|
} |
|
return OK; |
|
} |
|
# ------------------------------------------------------- Do the load balancing |
|
|
|
# ---------------------------------------------------------- Determine own load |
|
my $loadlim = $r->dir_config('lonLoadLim'); |
|
my $loadavg; |
|
{ |
|
my $loadfile=Apache::File->new('/proc/loadavg'); |
|
$loadavg=<$loadfile>; |
|
} |
|
$loadavg =~ s/\s.*//g; |
|
my $loadpercent=sprintf("%.1f",100*$loadavg/$loadlim); |
|
my $userloadpercent=&Apache::lonnet::userload(); |
|
|
|
# ---------------------------------------------------------- Are we overloaded? |
|
if ((($userloadpercent>100.0)||($loadpercent>100.0))) { |
|
my $unloaded=Apache::lonnet::spareserver($loadpercent,$userloadpercent,1,$form{'udom'}); |
|
if (!$unloaded) { |
|
($unloaded) = &Apache::lonnet::choose_server($form{'udom'}); |
|
} |
|
if ($unloaded) { |
|
&success($r,$form{'uname'},$form{'udom'},$authhost,'noredirect', |
|
undef,\%form); |
|
$r->internal_redirect('/adm/switchserver?otherserver='.$unloaded.'&origurl='.$firsturl); |
|
return OK; |
|
} |
|
} |
|
&success($r,$form{'uname'},$form{'udom'},$authhost,$firsturl,undef, |
|
\%form); |
|
return OK; |
} |
} |
return OK; |
|
} |
} |
|
|
sub check_can_host { |
sub check_can_host { |
Line 461 sub check_can_host {
|
Line 507 sub check_can_host {
|
} |
} |
unless ($canhost) { |
unless ($canhost) { |
if ($authhost eq 'no_account_on_host') { |
if ($authhost eq 'no_account_on_host') { |
my ($login_host,$hostname) = &Apache::lonnet::choose_server($udom); |
my $checkloginvia = 1; |
|
my ($login_host,$hostname) = |
|
&Apache::lonnet::choose_server($udom,$checkloginvia); |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
if ($login_host ne '') { |
if ($login_host ne '') { |
Line 481 sub check_can_host {
|
Line 529 sub check_can_host {
|
'<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'. |
'<p>'.&mt('Currently a LON-CAPA server is not available within the [_1] domain for you to log-in to, to create an account.',$domdesc).'</p>'. |
&Apache::loncommon::end_page()); |
&Apache::loncommon::end_page()); |
} |
} |
return OK; |
|
} else { |
} else { |
&success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef, |
&success($r,$form->{'uname'},$udom,$authhost,'noredirect',undef, |
$form); |
$form); |
Line 489 sub check_can_host {
|
Line 536 sub check_can_host {
|
$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver); |
$r->internal_redirect('/adm/switchserver?otherserver='.$otherserver); |
} |
} |
} |
} |
|
return $canhost; |
|
} |
|
|
|
sub noswitch { |
|
my $result = &Apache::loncommon::start_page('Access to LON-CAPA unavailable'). |
|
'<h3>'.&mt('Session unavailable').'</h3>'. |
|
&mt('This LON-CAPA server is unable to host your session.').'<br />'. |
|
'<p>'.&mt('Currently no other LON-CAPA server is available to host your session either.').'</p>'. |
|
&Apache::loncommon::end_page(); |
|
return $result; |
} |
} |
|
|
1; |
1; |