version 1.22, 2013/12/13 01:34:38
|
version 1.29, 2023/12/28 18:14:08
|
Line 44 sub handler {
|
Line 44 sub handler {
|
my $requrl=$r->uri; |
my $requrl=$r->uri; |
|
|
if (&Apache::lonnet::is_domainimage($requrl)) { |
if (&Apache::lonnet::is_domainimage($requrl)) { |
if (($r->user() eq '') && ($Apache::lonnet::apache >= 2.4)) { |
|
$r->user('public'); |
|
} |
|
return OK; |
return OK; |
} |
} |
|
|
if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) { |
if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) { |
if (($r->user() eq '') && ($Apache::lonnet::apache >= 2.4)) { |
|
$r->user('public'); |
|
} |
|
return OK; |
return OK; |
} |
} |
|
|
Line 76 sub handler {
|
Line 70 sub handler {
|
} 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 98 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',"lonPubID=$cookie; path=/; HttpOnly"); |
} |
} |
&Apache::lonacc::get_posted_cgi($r); |
&Apache::lonacc::get_posted_cgi($r); |
$env{'request.state'} = "published"; |
$env{'request.state'} = "published"; |
Line 108 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); |
|
return unless (ref($access_controls{$file_name}) eq 'HASH'); |
my $access = ''; |
my $access = ''; |
my $now = time; |
my $now = time; |
|
my $clientip = &Apache::lonnet::get_requestor_ip($r); |
|
my $portaccess = &Apache::lonnet::usertools_access($unum,$udom,'portaccess',undef,'tools'); |
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 (!$portaccess) { |
|
next unless ($scope eq 'ip'); |
|
} |
if ($start > $now) { |
if ($start > $now) { |
next; |
next; |
} |
} |
Line 125 sub process_portfolio {
|
Line 125 sub process_portfolio {
|
$access = 'public'; |
$access = 'public'; |
last; |
last; |
} |
} |
|
if (($scope eq 'ip') || ($scope eq 'userip')) { |
|
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'; |
} |
} |