--- loncom/interface/londocs.pm 2003/09/15 15:24:18 1.78 +++ loncom/interface/londocs.pm 2003/09/15 17:58:21 1.79 @@ -1,7 +1,7 @@ # The LearningOnline Network # Documents # -# $Id: londocs.pm,v 1.78 2003/09/15 15:24:18 www Exp $ +# $Id: londocs.pm,v 1.79 2003/09/15 17:58:21 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -136,8 +136,51 @@ sub dumpcourse { # Do the dumping unless ($outhash{'home_'.$ENV{'form.authorspace'}}) { return ''; } my ($ca,$cd)=split(/\@/,$ENV{'form.authorspace'}); + $r->print('

Copying Files

'); my $title=$ENV{'form.authorfolder'}; - + $title=~s/[^\w\/]+/\_/g; + my %replacehash=(); + foreach (keys %ENV) { + if ($_=~/^form\.namefor\_(.+)/) { + $replacehash{$1}=$ENV{$_}; + } + } + my $crs='/uploaded/'.$ENV{'request.course.id'}.'/'; + $crs=~s/\_/\//g; + foreach (keys %replacehash) { + my $newfilename=$title.'/'.$replacehash{$_}; + $newfilename=~s/[^\w\/\.]+/\_/g; + my @dirs=split(/\//,$newfilename); + my $path='/home/'.$ca.'/public_html'; + my $makepath=$path; + my $fail=0; + for (my $i=0;$i<$#dirs;$i++) { + $makepath.='/'.$dirs[$i]; + unless (-e $makepath) { + unless(mkdir($makepath,0777)) { $fail=1; } + } + } + $r->print('
'.$_.' => '.$newfilename.': '); + if (my $fh=Apache::File->new('>'.$path.'/'.$newfilename)) { + if ($_=~/\.(sequence|page|html|htm|xml|xhtml)$/) { + print $fh &Apache::loncreatecourse::rewritefile( + &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_), + (%replacehash,$crs => '') + ); + } else { + print $fh + &Apache::loncreatecourse::readfile($ENV{'request.course.id'},$_); + } + $fh->close(); + } else { + $fail=1; + } + if ($fail) { + $r->print('fail'); + } else { + $r->print('ok'); + } + } } else { # Input form unless ($home==1) { @@ -175,7 +218,7 @@ sub dumpcourse { $title=~s/\.(\w+)$//; $title=~s/\W+/\_/gs; $title.='.'.$ext; - $r->print("\n\n"); + $r->print("\n\n"); } $r->print("\n"); &untiehash();