--- loncom/publisher/loncleanup.pm 2005/05/28 02:18:03 1.2 +++ loncom/publisher/loncleanup.pm 2005/05/28 18:53:50 1.3 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to cleanup XML files # -# $Id: loncleanup.pm,v 1.2 2005/05/28 02:18:03 www Exp $ +# $Id: loncleanup.pm,v 1.3 2005/05/28 18:53:50 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -257,62 +257,62 @@ sub phasethree { # ---------------------------------------------------------------- Main Handler sub handler { - my $r=shift; + my $r=shift; # Get query string for limited number of parameters - &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, - ['filename']); + &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, + ['filename']); - if ($env{'form.filename'}) { - $fn=$env{'form.filename'}; - $fn=~s/^http\:\/\/[^\/]+//; - } else { - $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. - ' unspecified filename for cleanup', $r->filename); - return HTTP_NOT_FOUND; - } - - unless ($fn) { - $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. - ' trying to cleanup non-existing file', $r->filename); - return HTTP_NOT_FOUND; - } + if ($env{'form.filename'}) { + $fn=$env{'form.filename'}; + $fn=~s/^http\:\/\/[^\/]+//; + } else { + $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. + ' unspecified filename for cleanup', $r->filename); + return HTTP_NOT_FOUND; + } + + unless ($fn) { + $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. + ' trying to cleanup non-existing file', $r->filename); + return HTTP_NOT_FOUND; + } # ----------------------------------------------------------- Start page output - my $uname; - my $udom; + my $uname; + my $udom; + + ($uname,$udom)= + &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); + unless (($uname) && ($udom)) { + $r->log_reason($uname.' at '.$udom. + ' trying to cleanup file '.$env{'form.filename'}. + ' ('.$fn.') - not authorized', + $r->filename); + return HTTP_NOT_ACCEPTABLE; + } + + $fn=~s/\/\~(\w+)//; - ($uname,$udom)= - &Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); - unless (($uname) && ($udom)) { - $r->log_reason($uname.' at '.$udom. - ' trying to cleanup file '.$env{'form.filename'}. - ' ('.$fn.') - not authorized', - $r->filename); - return HTTP_NOT_ACCEPTABLE; - } - - $fn=~s/\/\~(\w+)//; - - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - - $r->print('LON-CAPA Construction Space'); - - $r->print(&Apache::loncommon::bodytag('Cleanup XML Document')); - - if ($env{'form.phase'} eq 'three') { - &phasethree($r,$fn,$uname,$udom); - } elsif ($env{'form.phase'} eq 'two') { - &phasetwo($r,$fn,$uname,$udom); - } else { - &phaseone($r,$fn,$uname,$udom); - } + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + + $r->print('LON-CAPA Construction Space'); + + $r->print(&Apache::loncommon::bodytag('Cleanup XML Document')); + + if ($env{'form.phase'} eq 'three') { + &phasethree($r,$fn,$uname,$udom); + } elsif ($env{'form.phase'} eq 'two') { + &phasetwo($r,$fn,$uname,$udom); + } else { + &phaseone($r,$fn,$uname,$udom); + } - $r->print(''); - return OK; + $r->print(''); + return OK; } 1;