version 1.1075.2.149, 2020/11/12 01:18:26
|
version 1.1075.2.156, 2021/09/11 15:57:33
|
Line 5105 sub check_ip_acc {
|
Line 5105 sub check_ip_acc {
|
($ENV{'REMOTE_ADDR'} eq &Apache::lonnet::get_host_ip($Apache::lonnet::perlvar{'lonHostID'}))) { |
($ENV{'REMOTE_ADDR'} eq &Apache::lonnet::get_host_ip($Apache::lonnet::perlvar{'lonHostID'}))) { |
$ip = $env{'request.host'} || $ENV{'REMOTE_ADDR'} || $clientip; |
$ip = $env{'request.host'} || $ENV{'REMOTE_ADDR'} || $clientip; |
} else { |
} else { |
$ip = $ENV{'REMOTE_ADDR'} || $env{'request.host'} || $clientip; |
my $remote_ip = &Apache::lonnet::get_requestor_ip(); |
|
$ip = $remote_ip || $env{'request.host'} || $clientip; |
} |
} |
|
|
my $name; |
my $name; |
Line 7992 ADDMETA
|
Line 7993 ADDMETA
|
unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { |
unless (&Apache::lonnet::allowed('mau',$dom_in_use)) { |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); |
my %domdefs = &Apache::lonnet::get_domain_defaults($dom_in_use); |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $lonhost = $Apache::lonnet::perlvar{'lonHostID'}; |
my $offload; |
my ($offload,$offloadoth); |
if (ref($domdefs{'offloadnow'}) eq 'HASH') { |
if (ref($domdefs{'offloadnow'}) eq 'HASH') { |
if ($domdefs{'offloadnow'}{$lonhost}) { |
if ($domdefs{'offloadnow'}{$lonhost}) { |
$offload = 1; |
$offload = 1; |
|
if (($env{'user.domain'} ne '') && ($env{'user.domain'} ne $dom_in_use) && |
|
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
|
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
|
$offloadoth = 1; |
|
$dom_in_use = $env{'user.domain'}; |
|
} |
|
} |
} |
} |
} |
} |
unless ($offload) { |
unless ($offload) { |
Line 8005 ADDMETA
|
Line 8013 ADDMETA
|
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
(!(($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')))) { |
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
unless (&Apache::lonnet::shared_institution($env{'user.domain'})) { |
$offload = 1; |
$offload = 1; |
|
$offloadoth = 1; |
$dom_in_use = $env{'user.domain'}; |
$dom_in_use = $env{'user.domain'}; |
} |
} |
} |
} |
Line 8013 ADDMETA
|
Line 8022 ADDMETA
|
} |
} |
if ($offload) { |
if ($offload) { |
my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); |
my $newserver = &Apache::lonnet::spareserver(30000,undef,1,$dom_in_use); |
|
if (($newserver eq '') && ($offloadoth)) { |
|
my @domains = &Apache::lonnet::current_machine_domains(); |
|
if (($dom_in_use ne '') && (!grep(/^\Q$dom_in_use\E$/,@domains))) { |
|
($newserver) = &Apache::lonnet::choose_server($dom_in_use); |
|
} |
|
} |
if (($newserver) && ($newserver ne $lonhost)) { |
if (($newserver) && ($newserver ne $lonhost)) { |
my $numsec = 5; |
my $numsec = 5; |
my $timeout = $numsec * 1000; |
my $timeout = $numsec * 1000; |
Line 8026 ADDMETA
|
Line 8041 ADDMETA
|
} |
} |
if ($locknum) { |
if ($locknum) { |
my @lockinfo = sort(values(%locks)); |
my @lockinfo = sort(values(%locks)); |
$msg = &mt('Once the following tasks are complete: ')."\n". |
$msg = &mt('Once the following tasks are complete:')." \n". |
join(", ",sort(values(%locks)))."\n"; |
join(", ",sort(values(%locks)))."\n"; |
if (&show_course()) { |
if (&show_course()) { |
$msg .= &mt('your session will be transferred to a different server, after you click "Courses".'); |
$msg .= &mt('your session will be transferred to a different server, after you click "Courses".'); |
Line 8515 ENDLINK
|
Line 8530 ENDLINK
|
} |
} |
|
|
sub modal_adhoc_script { |
sub modal_adhoc_script { |
my ($funcname,$width,$height,$content)=@_; |
my ($funcname,$width,$height,$content,$possmathjax)=@_; |
|
my $mathjax; |
|
if ($possmathjax) { |
|
$mathjax = <<'ENDJAX'; |
|
if (typeof MathJax == 'object') { |
|
MathJax.Hub.Queue(["Typeset",MathJax.Hub]); |
|
} |
|
ENDJAX |
|
} |
return (<<ENDADHOC); |
return (<<ENDADHOC); |
<script type="text/javascript"> |
<script type="text/javascript"> |
// <![CDATA[ |
// <![CDATA[ |
Line 8526 sub modal_adhoc_script {
|
Line 8549 sub modal_adhoc_script {
|
modalWindow.height = $height; |
modalWindow.height = $height; |
modalWindow.content = '$content'; |
modalWindow.content = '$content'; |
modalWindow.open(); |
modalWindow.open(); |
|
$mathjax |
}; |
}; |
// ]]> |
// ]]> |
</script> |
</script> |
Line 8533 ENDADHOC
|
Line 8557 ENDADHOC
|
} |
} |
|
|
sub modal_adhoc_inner { |
sub modal_adhoc_inner { |
my ($funcname,$width,$height,$content)=@_; |
my ($funcname,$width,$height,$content,$possmathjax)=@_; |
my $innerwidth=$width-20; |
my $innerwidth=$width-20; |
$content=&js_ready( |
$content=&js_ready( |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
&start_page('Dialog',undef,{'only_body'=>1,'bgcolor'=>'#FFFFFF'}). |
Line 8542 sub modal_adhoc_inner {
|
Line 8566 sub modal_adhoc_inner {
|
&end_scrollbox(). |
&end_scrollbox(). |
&end_page() |
&end_page() |
); |
); |
return &modal_adhoc_script($funcname,$width,$height,$content); |
return &modal_adhoc_script($funcname,$width,$height,$content,$possmathjax); |
} |
} |
|
|
sub modal_adhoc_window { |
sub modal_adhoc_window { |
my ($funcname,$width,$height,$content,$linktext)=@_; |
my ($funcname,$width,$height,$content,$linktext,$possmathjax)=@_; |
return &modal_adhoc_inner($funcname,$width,$height,$content). |
return &modal_adhoc_inner($funcname,$width,$height,$content,$possmathjax). |
"<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>"; |
"<a href=\"javascript:$funcname();void(0);\">".$linktext."</a>"; |
} |
} |
|
|
Line 15783 sub compare_arrays {
|
Line 15807 sub compare_arrays {
|
return @difference; |
return @difference; |
} |
} |
|
|
|
sub lon_status_items { |
|
my %defaults = ( |
|
E => 100, |
|
W => 4, |
|
N => 1, |
|
U => 5, |
|
threshold => 200, |
|
sysmail => 2500, |
|
); |
|
my %names = ( |
|
E => 'Errors', |
|
W => 'Warnings', |
|
N => 'Notices', |
|
U => 'Unsent', |
|
); |
|
return (\%defaults,\%names); |
|
} |
|
|
# -------------------------------------------------------- Initialize user login |
# -------------------------------------------------------- Initialize user login |
sub init_user_environment { |
sub init_user_environment { |
my ($r, $username, $domain, $authhost, $form, $args) = @_; |
my ($r, $username, $domain, $authhost, $form, $args) = @_; |
Line 15885 sub init_user_environment {
|
Line 15927 sub init_user_environment {
|
# --------------------------------------------------------- Write first profile |
# --------------------------------------------------------- Write first profile |
|
|
{ |
{ |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
my %initial_env = |
my %initial_env = |
("user.name" => $username, |
("user.name" => $username, |
"user.domain" => $domain, |
"user.domain" => $domain, |
Line 15903 sub init_user_environment {
|
Line 15946 sub init_user_environment {
|
"request.course.sec" => '', |
"request.course.sec" => '', |
"request.role" => 'cm', |
"request.role" => 'cm', |
"request.role.adv" => $env{'user.adv'}, |
"request.role.adv" => $env{'user.adv'}, |
"request.host" => $ENV{'REMOTE_ADDR'},); |
"request.host" => $ip,); |
|
|
if ($form->{'localpath'}) { |
if ($form->{'localpath'}) { |
$initial_env{"browser.localpath"} = $form->{'localpath'}; |
$initial_env{"browser.localpath"} = $form->{'localpath'}; |
Line 17149 sub create_recaptcha {
|
Line 17192 sub create_recaptcha {
|
sub check_recaptcha { |
sub check_recaptcha { |
my ($privkey,$version) = @_; |
my ($privkey,$version) = @_; |
my $captcha_chk; |
my $captcha_chk; |
|
my $ip = &Apache::lonnet::get_requestor_ip(); |
if ($version >= 2) { |
if ($version >= 2) { |
my $ua = LWP::UserAgent->new; |
my $ua = LWP::UserAgent->new; |
$ua->timeout(10); |
$ua->timeout(10); |
my %info = ( |
my %info = ( |
secret => $privkey, |
secret => $privkey, |
response => $env{'form.g-recaptcha-response'}, |
response => $env{'form.g-recaptcha-response'}, |
remoteip => $ENV{'REMOTE_ADDR'}, |
remoteip => $ip, |
); |
); |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
my $response = $ua->post('https://www.google.com/recaptcha/api/siteverify',\%info); |
if ($response->is_success) { |
if ($response->is_success) { |
Line 17171 sub check_recaptcha {
|
Line 17215 sub check_recaptcha {
|
my $captcha_result = |
my $captcha_result = |
$captcha->check_answer( |
$captcha->check_answer( |
$privkey, |
$privkey, |
$ENV{'REMOTE_ADDR'}, |
$ip, |
$env{'form.recaptcha_challenge_field'}, |
$env{'form.recaptcha_challenge_field'}, |
$env{'form.recaptcha_response_field'}, |
$env{'form.recaptcha_response_field'}, |
); |
); |