version 1.44, 2003/11/19 14:57:32
|
version 1.46, 2003/12/13 19:54:16
|
Line 73 use Apache::Log ();
|
Line 73 use Apache::Log ();
|
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::loncommon(); |
use Apache::loncommon(); |
|
|
my $DEBUG=2; |
my $DEBUG=0; |
my $r; # Needs to be global for some stuff RF. |
my $r; # Needs to be global for some stuff RF. |
|
|
=pod |
=pod |
Line 110 sub Debug {
|
Line 110 sub Debug {
|
# Put out the indicated message butonly if DEBUG is true. |
# Put out the indicated message butonly if DEBUG is true. |
|
|
if ($DEBUG) { |
if ($DEBUG) { |
$r->log_reason($message); |
$r->log_reason($message); |
} |
} |
} |
} |
|
|
=pod |
=pod |
|
|
=item checksuffix($old, $new) |
|
|
|
Determine if a resource filename suffix (the stuff after the .) would change |
|
as a result of this operation. |
|
|
|
Parameters: |
|
|
|
=over 4 |
|
|
|
=item $old = string [in] Previous filename. |
|
|
|
=item $new = string [in] Resultant filename. |
|
|
|
=back |
|
|
|
=cut |
|
|
|
=pod |
|
|
|
=item URLToPath($url) |
=item URLToPath($url) |
|
|
Convert a URL to a file system path. |
Convert a URL to a file system path. |
Line 717 sub phaseone {
|
Line 698 sub phaseone {
|
|
|
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'}); |
my $newfilename=&cleanDest($r,$ENV{'form.newfilename'}); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
$newfilename=&relativeDest($fn,$newfilename,$uname); |
&Debug($r, "Newfile: $newfilename"); |
|
$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.'" />'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="phase" value="two" />'. |
Line 728 sub phaseone {
|
Line 708 sub phaseone {
|
} elsif ($ENV{'form.action'} eq 'delete') { |
} elsif ($ENV{'form.action'} eq 'delete') { |
&Delete1($r, $uname, $udom, $fn); |
&Delete1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'decompress') { |
} elsif ($ENV{'form.action'} eq 'decompress') { |
&Apache::lonnet::appenv('cgi.path' => $newfilename); |
|
&Decompress1($r, $uname, $udom, $fn); |
&Decompress1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
if($newfilename) { |
if($newfilename) { |
Line 872 Returns:
|
Line 851 Returns:
|
|
|
sub Delete2 { |
sub Delete2 { |
my ($request, $user, $filename) = @_; |
my ($request, $user, $filename) = @_; |
|
if(opendir DIR, $filename) { |
if(-e $filename) { |
my @files=readdir(DIR); |
unless(unlink($filename)) { |
shift @files; shift @files; # takes off . and .. |
$request->print('<font color="red">Error: '.$!.'</font>'); |
if(@files) { |
|
$request->print('<font color="red"> Error: Directory Non Empty</font>'); |
return 0; |
return 0; |
} |
} |
} else { |
else { |
$request->print('<p> No such file. </p></form'); |
if(-e $filename) { |
return 0; |
unless(rmdir($filename)) { |
|
$request->print('<font color="red">Error: '.$!.'</font>'); |
|
return 0; |
|
} |
|
} |
|
else { |
|
$request->print('<p> No such file. </p></form'); |
|
return 0; |
|
} |
|
|
|
} |
|
|
|
} |
|
else { |
|
if(-e $filename) { |
|
unless(unlink($filename)) { |
|
$request->print('<font color="red">Error: '.$!.'</font>'); |
|
return 0; |
|
} |
|
} |
|
else { |
|
$request->print('<p> No such file. </p></form'); |
|
return 0; |
} |
} |
|
} |
return 1; |
return 1; |
} |
} |
|
|
Line 1020 sub phasetwo {
|
Line 1023 sub phasetwo {
|
my $dir; # Directory path |
my $dir; # Directory path |
my $main; # Filename. |
my $main; # Filename. |
my $suffix; # Extension. |
my $suffix; # Extension. |
|
if ($fn=~m:(.*)/([^/]+):) { |
if ($fn=~m:(.*)/([^/]+)\.(\w+)$:) { |
|
$dir=$1; # Directory path |
$dir=$1; # Directory path |
$main=$2; # Filename. |
$main=$2; # Filename. |
$suffix=$3; # Extension. |
} |
} |
if($main=~m:\.(\w+)$:){ # Fixes problems with filenames with no extensions |
|
$main=$`; |
|
$suffix=$1; |
|
} |
my $dest; # On success this is where we'll go. |
my $dest; # On success this is where we'll go. |
|
|
&Debug($r, |
&Debug($r, |
Line 1114 sub handler {
|
Line 1118 sub handler {
|
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
} |
} |
|
#Just hijack the script only the first time around to inject the correct information for further processing |
elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
elsif($ENV{'QUERY_STRING'} && $ENV{'form.phase'} ne 'two') { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |