--- loncom/auth/publiccheck.pm 2006/07/17 19:49:14 1.7 +++ loncom/auth/publiccheck.pm 2009/10/26 18:59:02 1.18 @@ -1,7 +1,7 @@ # The LearningOnline Network # Cookie Based Access Handler # -# $Id: publiccheck.pm,v 1.7 2006/07/17 19:49:14 albertel Exp $ +# $Id: publiccheck.pm,v 1.18 2009/10/26 18:59:02 droeschl Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,35 +34,43 @@ use Apache::Constants qw(:common :http : use Apache::lonnet; use Apache::loncommon(); use Apache::lonlocal; -use CGI::Cookie(); use Fcntl qw(:flock); use Apache::lonacc(); +use LONCAPA(); sub handler { my $r = shift; + my $requrl=$r->uri; - my %cookies=CGI::Cookie->parse($r->header_in('Cookie')); - my $lonid=$cookies{'lonID'}; - if ($lonid) { - my $handle=$lonid->value; - $handle=~s/\W//g; + + if (&Apache::lonnet::is_domainimage($requrl)) { + return OK; + } + + if ($requrl =~ m{^/res/adm/pages/[^/]+\.(gif|png)$}) { + return OK; + } + + my $handle = &Apache::lonnet::check_for_valid_session($r); + if ($handle ne '') { my $lonidsdir=$r->dir_config('lonIDsDir'); - if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) { - &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); - if ($env{'user.name'} ne 'public' - && $env{'user.domain'} ne 'public') { - return OK; - } + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$handle); + if ($env{'user.name'} ne 'public' + && $env{'user.domain'} ne 'public') { + return OK; } } if ($requrl=~m|^/public/| || $requrl=~m|^/adm/help/.*\.hlp$| - || (&Apache::lonnet::metadata($requrl,'copyright') eq 'public')) { + || $requrl=~m|^/adm/[^/]+/[^/]+/aboutme/portfolio$| + || (&Apache::lonnet::metadata($requrl,'copyright') eq 'public') + || $requrl=~m|^/adm/blockingstatus/.*$| + || $requrl eq '/adm/coursecatalog') { &process_public($r,$requrl); return OK; - } elsif (&Apache::lonacc::is_portfolio_url($requrl)) { + } elsif (&Apache::lonnet::is_portfolio_url($requrl)) { my (undef,$udom,$unum,$file_name,$group) = - &Apache::lonacc::parse_portfolio_url($requrl); + &Apache::lonnet::parse_portfolio_url($requrl); my $access = &process_portfolio($udom,$unum,$file_name,$group); if ($access) { &process_public($r,$requrl,$access); @@ -70,7 +78,11 @@ sub handler { } } elsif ($requrl eq '/adm/restrictedaccess') { &process_public($r,$requrl); - } + return OK; + } elsif ($requrl eq '/adm/blockedaccess') { + &process_public($r,$requrl); + return OK; + } return DECLINED; } @@ -81,7 +93,7 @@ sub process_public { my $cookie=&Apache::lonauth::success($r,'public','public','public'); my $lonidsdir=$r->dir_config('lonIDsDir'); &Apache::lonnet::transfer_profile_to_env($lonidsdir,$cookie); - $r->header_out('Set-cookie',"lonID=$cookie; path=/"); + $r->err_header_out('Set-cookie',"lonID=$cookie; path=/"); } &Apache::lonacc::get_posted_cgi($r); $env{'request.state'} = "published"; 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.