version 1.5, 2006/07/10 03:58:45
|
version 1.13, 2007/01/24 19:39:22
|
Line 37 use Apache::lonlocal;
|
Line 37 use Apache::lonlocal;
|
use CGI::Cookie(); |
use CGI::Cookie(); |
use Fcntl qw(:flock); |
use Fcntl qw(:flock); |
use Apache::lonacc(); |
use Apache::lonacc(); |
|
use LONCAPA(); |
|
|
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
my $requrl=$r->uri; |
my $requrl=$r->uri; |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); |
my $lonid=$cookies{'lonID'}; |
my $lonid=$cookies{'lonID'}; |
if ($lonid) { |
if ($lonid) { |
my $handle=$lonid->value; |
my $handle=&LONCAPA::clean_handle($lonid->value); |
$handle=~s/\W//g; |
|
my $lonidsdir=$r->dir_config('lonIDsDir'); |
my $lonidsdir=$r->dir_config('lonIDsDir'); |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { |
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); |
&Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); |
Line 57 sub handler {
|
Line 58 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$| |
|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) { |
|| (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) { |
&process_public($r,$requrl); |
&process_public($r,$requrl); |
return OK; |
return OK; |
} elsif ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/portfolio(/.+)$|) { |
} elsif (&Apache::lonnet::is_portfolio_url($requrl)) { |
my $access = &process_portfolio($1,$2,$3); |
my (undef,$udom,$unum,$file_name,$group) = |
|
&Apache::lonnet::parse_portfolio_url($requrl); |
|
my $access = &process_portfolio($udom,$unum,$file_name,$group); |
if ($access) { |
if ($access) { |
&process_public($r,$requrl,$access); |
&process_public($r,$requrl,$access); |
return OK; |
return OK; |
} |
} |
} elsif ($requrl =~ m|/+uploaded/([^/]+)/([^/]+)/groups/([^/]+)/portfolio/(.+)$|) { |
|
my $access = &process_portfolio($1,$2,$3.'/'.$4,$3); |
|
if ($access) { |
|
&process_public($r,$requrl,$access); |
|
return OK; |
|
} |
|
} elsif ($requrl eq '/adm/restrictedaccess') { |
} elsif ($requrl eq '/adm/restrictedaccess') { |
&process_public($r,$requrl); |
&process_public($r,$requrl); |
|
return OK; |
|
} elsif ($requrl eq '/adm/blockedaccess') { |
|
&process_public($r,$requrl); |
|
return OK; |
} |
} |
return DECLINED; |
return DECLINED; |
} |
} |
Line 85 sub process_public {
|
Line 87 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); |
if ($access eq 'guest') { |
$r->err_header_out('Set-cookie',"lonID=$cookie; path=/"); |
$r->err_headers_out('Set-cookie',"lonID=$cookie; path=/"); |
|
} else { |
|
$r->header_out('Set-cookie',"lonID=$cookie; path=/"); |
|
} |
|
} |
} |
&Apache::lonacc::get_posted_cgi($r); |
&Apache::lonacc::get_posted_cgi($r); |
$env{'request.state'} = "published"; |
$env{'request.state'} = "published"; |