version 1.11, 2009/09/09 17:58:37
|
version 1.17, 2012/10/29 17:38:55
|
Line 34 use strict;
|
Line 34 use strict;
|
use Apache::File; |
use Apache::File; |
use File::Copy; |
use File::Copy; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use Apache::loncacc; |
|
use Apache::loncommon(); |
use Apache::loncommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonhtmlcommon(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
Line 278 sub phaseone {
|
Line 277 sub phaseone {
|
sub phasetwo { |
sub phasetwo { |
# Check original file |
# Check original file |
my ($r,$fn,$uname,$udom)=@_; |
my ($r,$fn,$uname,$udom)=@_; |
open(IN,'/home/'.$uname.'/public_html/'.$fn); |
|
my $text=''; |
my $text=''; |
while (my $line=<IN>) { |
my $londocroot = $r->dir_config('lonDocRoot'); |
$text.=$line; |
if (open(IN,"<$londocroot/priv/$udom/$uname".$fn)) { |
|
while (my $line=<IN>) { |
|
$text.=$line; |
|
} |
|
close(IN); |
} |
} |
close(IN); |
my $uri="/priv/$udom/$uname".$fn; |
my $uri='/~'.$uname.$fn; |
|
my $result=&Apache::lonnet::ssi_body($uri, |
my $result=&Apache::lonnet::ssi_body($uri, |
('grade_target'=>'web', |
('grade_target'=>'web', |
'return_only_error_and_warning_counts' => 1)); |
'return_only_error_and_warning_counts' => 1)); |
Line 310 sub phasetwo {
|
Line 311 sub phasetwo {
|
($env{'form.symbol'} ne 'on')); |
($env{'form.symbol'} ne 'on')); |
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/); |
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/); |
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
open(OUT,'>/home/'.$uname.'/public_html'.$newfn); |
if (open(OUT,">$londocroot/priv/$udom/$uname".$newfn)) { |
print OUT $text; |
print OUT $text; |
close(OUT); |
close(OUT); |
my $newuri='/~'.$uname.$newfn; |
} |
|
my $newuri="/priv/$udom/$uname".$newfn; |
$result=&Apache::lonnet::ssi_body($newuri, |
$result=&Apache::lonnet::ssi_body($newuri, |
('grade_target'=>'web', |
('grade_target'=>'web', |
'return_only_error_and_warning_counts' => 1)); |
'return_only_error_and_warning_counts' => 1)); |
Line 356 sub phasetwo {
|
Line 358 sub phasetwo {
|
|
|
sub phasethree { |
sub phasethree { |
my ($r,$fn,$uname,$udom)=@_; |
my ($r,$fn,$uname,$udom)=@_; |
my $old='/home/'.$uname.'/public_html/'.$fn; |
my $old=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$fn; |
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/); |
my ($main,$ext)=($fn=~/^(.*)\.(\w+)/); |
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
my $newfn=$main.'_Auto_Cleaned_Up.'.$ext; |
my $new='/home/'.$uname.'/public_html'.$newfn; |
my $new=$r->dir_config('lonDocRoot')."/priv/$udom/$uname".$newfn; |
if ($env{'form.accept'}) { |
if ($env{'form.accept'}) { |
$r->print( |
$r->print( |
'<p class="LC_info">' |
'<p class="LC_info">' |
Line 390 sub handler {
|
Line 392 sub handler {
|
|
|
if ($env{'form.filename'}) { |
if ($env{'form.filename'}) { |
$fn=$env{'form.filename'}; |
$fn=$env{'form.filename'}; |
$fn=~s/^https?\:\/\/[^\/]+//; |
$fn=~s{^https?\://[^/]+}{}; |
} else { |
} else { |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
' unspecified filename for cleanup', $r->filename); |
' unspecified filename for cleanup', $r->filename); |
Line 407 sub handler {
|
Line 409 sub handler {
|
my $uname; |
my $uname; |
my $udom; |
my $udom; |
|
|
($uname,$udom)= |
($uname,$udom)=&Apache::lonnet::constructaccess($fn); |
&Apache::loncacc::constructaccess($fn,$r->dir_config('lonDefDomain')); |
|
unless (($uname) && ($udom)) { |
unless (($uname) && ($udom)) { |
$r->log_reason($uname.' at '.$udom. |
$r->log_reason($uname.' at '.$udom. |
' trying to cleanup file '.$env{'form.filename'}. |
' trying to cleanup file '.$env{'form.filename'}. |
Line 417 sub handler {
|
Line 418 sub handler {
|
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
|
|
$fn=~s{/~($LONCAPA::username_re)}{}; |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
|
|
# Breadcrumbs |
# Breadcrumbs |
my $brcrum = [{'href' => &Apache::loncommon::authorspace(), |
my $brcrum = [{'href' => &Apache::loncommon::authorspace($fn), |
'text' => 'Construction Space'}, |
'text' => 'Construction Space'}, |
{'href' => '', |
{'href' => '', |
'text' => 'Cleanup XML Document'}]; |
'text' => 'Cleanup XML Document'}]; |
|
|
|
$fn=~s{^/priv/$LONCAPA::domain_re/$LONCAPA::username_re}{}; |
|
|
$r->print(&Apache::loncommon::start_page('Cleanup XML Document', |
$r->print(&Apache::loncommon::start_page('Cleanup XML Document', |
undef, |
undef, |
{'bread_crumbs' => $brcrum,})); |
{'bread_crumbs' => $brcrum,})); |
Line 446 sub handler {
|
Line 447 sub handler {
|
} |
} |
} |
} |
my $dir=$fn; |
my $dir=$fn; |
$dir=~s/\/[^\/]+$/\//; |
$dir=~s{[^/]+$}{}; |
$r->print( |
$r->print( |
'</form>' |
'</form>' |
.&Apache::lonhtmlcommon::start_funclist() |
.&Apache::lonhtmlcommon::start_funclist() |
.&Apache::lonhtmlcommon::add_item_funclist( |
.&Apache::lonhtmlcommon::add_item_funclist( |
'<a href="/priv/'.$uname.'/'.$fn.'">'.&mt('Back to Source File').'</a>') |
'<a href="/priv/'.$udom.'/'.$uname.$fn.'">'.&mt('Back to Source File').'</a>') |
.&Apache::lonhtmlcommon::add_item_funclist( |
.&Apache::lonhtmlcommon::add_item_funclist( |
'<a href="/priv/'.$uname.'/'.$dir.'">'.&mt('Back to Source Directory').'</a>') |
'<a href="/priv/'.$udom.'/'.$uname.$dir.'">'.&mt('Back to Source Directory').'</a>') |
.&Apache::lonhtmlcommon::end_funclist() |
.&Apache::lonhtmlcommon::end_funclist() |
.&Apache::loncommon::end_page() |
.&Apache::loncommon::end_page() |
); |
); |