version 1.15, 2007/10/02 01:09:59
|
version 1.25, 2017/02/17 18:37:57
|
Line 42 sub handler {
|
Line 42 sub handler {
|
my $r = shift; |
my $r = shift; |
|
|
my $requrl=$r->uri; |
my $requrl=$r->uri; |
|
|
if (&Apache::lonnet::is_domainimage($requrl)) { |
if (&Apache::lonnet::is_domainimage($requrl)) { |
return OK; |
return OK; |
} |
} |
|
|
|
if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) { |
|
return OK; |
|
} |
|
|
my $handle = &Apache::lonnet::check_for_valid_session($r); |
my $handle = &Apache::lonnet::check_for_valid_session($r); |
if ($handle ne '') { |
if ($handle ne '') { |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
Line 58 sub handler {
|
Line 63 sub handler {
|
if ($requrl=~m|^/public/| |
if ($requrl=~m|^/public/| |
|| $requrl=~m|^/adm/help/.*\.hlp$| |
|| $requrl=~m|^/adm/help/.*\.hlp$| |
|| $requrl=~m|^/adm/[^/]+/[^/]+/aboutme/portfolio$| |
|| $requrl=~m|^/adm/[^/]+/[^/]+/aboutme/portfolio$| |
|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) { |
|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public') |
|
|| $requrl=~m|^/adm/blockingstatus/.*$|) { |
&process_public($r,$requrl); |
&process_public($r,$requrl); |
return OK; |
return OK; |
} elsif (&Apache::lonnet::is_portfolio_url($requrl)) { |
} elsif (&Apache::lonnet::is_portfolio_url($requrl)) { |
my (undef,$udom,$unum,$file_name,$group) = |
my (undef,$udom,$unum,$file_name,$group) = |
&Apache::lonnet::parse_portfolio_url($requrl); |
&Apache::lonnet::parse_portfolio_url($requrl); |
my $access = &process_portfolio($udom,$unum,$file_name,$group); |
my $access = &process_portfolio($r,$udom,$unum,$file_name,$group); |
if ($access) { |
if ($access) { |
&process_public($r,$requrl,$access); |
&process_public($r,$requrl,$access); |
return OK; |
return OK; |
Line 75 sub handler {
|
Line 81 sub handler {
|
} elsif ($requrl eq '/adm/blockedaccess') { |
} elsif ($requrl eq '/adm/blockedaccess') { |
&process_public($r,$requrl); |
&process_public($r,$requrl); |
return OK; |
return OK; |
} |
} |
return DECLINED; |
return DECLINED; |
} |
} |
|
|
Line 86 sub process_public {
|
Line 92 sub process_public {
|
my $cookie=&Apache::lonauth::success($r,'public','public','public'); |
my $cookie=&Apache::lonauth::success($r,'public','public','public'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie); |
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie); |
$r->err_header_out('Set-cookie',"lonID=$cookie; path=/"); |
$r->err_header_out('Set-cookie',"lonPublic=$cookie; path=/; HttpOnly"); |
} |
} |
&Apache::lonacc::get_posted_cgi($r); |
&Apache::lonacc::get_posted_cgi($r); |
$env{'request.state'} = "published"; |
$env{'request.state'} = "published"; |
Line 96 sub process_public {
|
Line 102 sub process_public {
|
} |
} |
|
|
sub process_portfolio { |
sub process_portfolio { |
my ($udom,$unum,$file_name,$group) = @_; |
my ($r,$udom,$unum,$file_name,$group) = @_; |
my $current_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum); |
my $current_perms = &Apache::lonnet::get_portfile_permissions($udom,$unum); |
my %access_controls = &Apache::lonnet::get_access_controls($current_perms,$group,$file_name); |
my %access_controls = &Apache::lonnet::get_access_controls($current_perms,$group,$file_name); |
my $access = ''; |
my $access = ''; |
my $now = time; |
my $now = time; |
|
my $clientip = $r->get_remote_host(); |
foreach my $key (keys(%{$access_controls{$file_name}})) { |
foreach my $key (keys(%{$access_controls{$file_name}})) { |
my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); |
my ($num,$scope,$end,$start) = ($key =~ /^([^:]+):([a-z]+)_(\d*)_?(\d*)$/); |
if ($start > $now) { |
if ($start > $now) { |
Line 113 sub process_portfolio {
|
Line 120 sub process_portfolio {
|
$access = 'public'; |
$access = 'public'; |
last; |
last; |
} |
} |
|
if ($scope eq 'ip') { |
|
if (ref($access_controls{$file_name}{$key}) eq 'HASH') { |
|
if (ref($access_controls{$file_name}{$key}{'ip'}) eq 'ARRAY') { |
|
if (&Apache::loncommon::check_ip_acc(join(',',@{$access_controls{$file_name}{$key}{'ip'}}),$clientip)) { |
|
$access = 'ip'; |
|
last; |
|
} |
|
} |
|
} |
|
} |
if ($scope eq 'guest') { |
if ($scope eq 'guest') { |
$access = 'guest'; |
$access = 'guest'; |
} |
} |