version 1.58, 2004/07/02 08:07:17
|
version 1.65, 2005/03/10 03:50:49
|
Line 289 sub checksuffix {
|
Line 289 sub checksuffix {
|
} |
} |
|
|
sub cleanDest { |
sub cleanDest { |
my ($request,$dest,$subdir)=@_; |
my ($request,$dest,$subdir,$fn,$uname)=@_; |
#remove bad characters |
#remove bad characters |
my $foundbad=0; |
my $foundbad=0; |
if ($subdir && $dest =~/\./) { |
if ($subdir && $dest =~/\./) { |
Line 298 sub cleanDest {
|
Line 298 sub cleanDest {
|
} |
} |
if ($dest=~/[\#\?&%\"]/) { |
if ($dest=~/[\#\?&%\"]/) { |
$foundbad=1; |
$foundbad=1; |
$dest=~s/[\#\?&%]//g; |
$dest=~s/[\#\?&%\"]//g; |
|
} |
|
if ($dest=~m|/|) { |
|
my ($newpath)=($dest=~m|(.*)/|); |
|
$newpath=&relativeDest($fn,$newpath,$uname); |
|
if (! -d "$newpath") { |
|
$request->print("<p><font color=\"red\">".&mt('You have requested to create file in directory [_1] which doesn\'t exist. The requested directory path has been removed from the requested file name.','"<tt>'.$newpath.'</tt>"')."</font></p>"); |
|
$dest=~s|.*/||; |
|
} |
} |
} |
if ($foundbad) { |
if ($foundbad) { |
$request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>"); |
$request->print("<p><font color=\"red\">".&mt('Invalid characters in requested name have been removed.')."</font></p>"); |
Line 760 sub phaseone {
|
Line 768 sub phaseone {
|
|
|
my $doingdir=0; |
my $doingdir=0; |
if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; } |
if ($ENV{'form.action'} eq 'newdir') { $doingdir=1; } |
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir); |
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'},$doingdir,$fn,$uname); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
$r->print('<form action="/adm/cfile" method="post">'. |
$r->print('<form action="/adm/cfile" method="post">'. |
'<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'. |
'<input type="hidden" name="qualifiedfilename" value="'.$fn.'" />'. |
Line 794 sub phaseone {
|
Line 802 sub phaseone {
|
$ENV{'form.action'} eq 'newsequencefile' || |
$ENV{'form.action'} eq 'newsequencefile' || |
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
|
$ENV{'form.action'} eq 'newlibraryfile' || |
$ENV{'form.action'} eq 'Select Action') { |
$ENV{'form.action'} eq 'Select Action') { |
if ($newfilename) { |
my $empty=&mt('Type Name Here'); |
|
if (($newfilename!~/\/$/) && ($newfilename!~/$empty$/)) { |
&NewFile1($r, $uname, $udom, $fn, $newfilename); |
&NewFile1($r, $uname, $udom, $fn, $newfilename); |
} else { |
} else { |
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
$r->print('<p>'.&mt('No new filename specified.').'</p></form>'); |
Line 988 sub Copy2 {
|
Line 998 sub Copy2 {
|
unless (copy($oldfile, $newfile)) { |
unless (copy($oldfile, $newfile)) { |
$request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>'); |
$request->print('<font color="red"> '.&mt('copy Error').': '.$!.'</font>'); |
return 0; |
return 0; |
|
} elsif (!chmod(0660, $newfile)) { |
|
$request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>'); |
|
return 0; |
|
} elsif (-e $oldfile.'.meta' && |
|
!copy($oldfile.'.meta', $newfile.'.meta') && |
|
!chmod(0660, $newfile.'.meta')) { |
|
$request->print('<font color="red"> '.&mt('copy metadata error'). |
|
': '.$!.'</font>'); |
|
return 0; |
} else { |
} else { |
unless (chmod(0660, $newfile)) { |
|
$request->print('<font color="red"> '.&mt('chmod error').': '.$!.'</font>'); |
|
return 0; |
|
} |
|
return 1; |
return 1; |
} |
} |
} else { |
} else { |
Line 1118 sub phasetwo {
|
Line 1133 sub phasetwo {
|
return ; |
return ; |
} |
} |
$dest = $dir."/."; |
$dest = $dir."/."; |
} elsif ($ENV{'form.action'} eq 'rename') { # Rename. |
} elsif ($ENV{'form.action'} eq 'rename' || |
|
$ENV{'form.action'} eq 'move') { |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
if (!defined($dir)) { |
if (!defined($dir)) { |
$fn=~m:^(.*)/:; |
$fn=~m:^(.*)/:; |
Line 1166 sub handler {
|
Line 1182 sub handler {
|
|
|
$r=shift; |
$r=shift; |
|
|
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress','action','filename','newfilename']); |
|
|
&Debug($r, "loncfile.pm - handler entered"); |
&Debug($r, "loncfile.pm - handler entered"); |
&Debug($r, " filename: ".$ENV{'form.filename'}); |
&Debug($r, " filename: ".$ENV{'form.filename'}); |
Line 1184 sub handler {
|
Line 1201 sub handler {
|
} elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
} elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
#Just hijack the script only the first time around to inject the |
#Just hijack the script only the first time around to inject the |
#correct information for further processing |
#correct information for further processing |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
|
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
$ENV{'form.action'}="decompress"; |
$ENV{'form.action'}="decompress"; |
Line 1272 function writeDone() {
|
Line 1288 function writeDone() {
|
$ENV{'form.action'} eq 'newsequencefile' || |
$ENV{'form.action'} eq 'newsequencefile' || |
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newrightsfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
$ENV{'form.action'} eq 'newstyfile' || |
|
$ENV{'form.action'} eq 'newlibraryfile' || |
$ENV{'form.action'} eq 'Select Action' ) { |
$ENV{'form.action'} eq 'Select Action' ) { |
$r->print('<h3>'.&mt('New Resource').'</h3>'); |
$r->print('<h3>'.&mt('New Resource').'</h3>'); |
} else { |
} else { |