version 1.42, 2003/09/11 21:02:38
|
version 1.45, 2003/11/19 15:06:33
|
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) { |
$log->debug($message); |
$log->debug($message); |
} |
} |
} |
} |
|
|
Line 168 sub url {
|
Line 168 sub url {
|
|
|
sub display { |
sub display { |
my $fn=shift; |
my $fn=shift; |
$fn=~s/^\/home\/(\w+)\/public\_html//; |
$fn=~s-^/home/(\w+)/public_html-/priv/$1-; |
return '<tt>'.$fn.'</tt>'; |
return '<tt>'.$fn.'</tt>'; |
} |
} |
|
|
Line 579 sub NewDir1
|
Line 579 sub NewDir1
|
} |
} |
} |
} |
|
|
|
|
|
sub Decompress1 { |
|
my ($request, $user, $domain, $fn) = @_; |
|
if( -e $fn) { |
|
$request->print('<input type="hidden" name="newfilename" value="'.$fn.'"/>'); |
|
$request->print('<p>Decompress '.&display($fn).'?</p>'); |
|
&CloseForm1($request, $fn); |
|
} else { |
|
$request->print('<p>No such file: '.&display($fn).'</p></form>'); |
|
} |
|
} |
=pod |
=pod |
|
|
=item NewFile1 |
=item NewFile1 |
Line 687 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); |
|
|
$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 697 sub phaseone {
|
Line 707 sub phaseone {
|
&Rename1($r, $uname, $udom, $fn, $newfilename); |
&Rename1($r, $uname, $udom, $fn, $newfilename); |
} 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') { |
|
&Decompress1($r, $uname, $udom, $fn); |
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
if($newfilename) { |
if($newfilename) { |
&Copy1($r, $uname, $udom, $fn, $newfilename); |
&Copy1($r, $uname, $udom, $fn, $newfilename); |
Line 935 sub NewDir2 {
|
Line 947 sub NewDir2 {
|
} |
} |
return 1; |
return 1; |
} |
} |
|
sub decompress2 { |
|
my ($r, $user, $dir, $file) = @_; |
|
&Apache::lonnet::appenv('cgi.file' => $file); |
|
&Apache::lonnet::appenv('cgi.dir' => $dir); |
|
my $result=&Apache::lonnet::ssi_body('/cgi-bin/decompress.pl'); |
|
$r->print($result); |
|
&Apache::lonnet::delenv('cgi.file'); |
|
&Apache::lonnet::delenv('cgi.dir'); |
|
return 1; |
|
} |
=pod |
=pod |
|
|
=item phasetwo($r, $fn, $uname, $udom) |
=item phasetwo($r, $fn, $uname, $udom) |
Line 1001 sub phasetwo {
|
Line 1022 sub phasetwo {
|
"loncfie::phase2 action is $ENV{'form.action'}"); |
"loncfie::phase2 action is $ENV{'form.action'}"); |
|
|
# Select the appropriate processing sub. |
# Select the appropriate processing sub. |
|
if ($ENV{'form.action'} eq 'decompress') { |
if ($ENV{'form.action'} eq 'rename') { # Rename. |
$main .= '.'; |
|
$main .= $suffix; |
|
if(!&decompress2($r, $uname, $dir, $main)) { |
|
return ; |
|
} |
|
$dest = $dir."/."; |
|
|
|
|
|
} elsif ($ENV{'form.action'} eq 'rename') { # Rename. |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
if (!defined($dir)) { |
if (!defined($dir)) { |
$fn=~m:^(.*)/:; |
$fn=~m:^(.*)/:; |
Line 1024 sub phasetwo {
|
Line 1053 sub phasetwo {
|
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { |
if(!&Copy2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { |
return |
return ; |
} |
} |
$dest = $ENV{'form.newfilename'}; |
$dest = $ENV{'form.newfilename'}; |
|
|
Line 1059 sub handler {
|
Line 1088 sub handler {
|
my $fn; |
my $fn; |
|
|
if ($ENV{'form.filename'}) { |
if ($ENV{'form.filename'}) { |
|
|
|
&Debug($r, "test: $ENV{'form.filename'}"); |
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
$fn=&URLToPath($fn); |
$fn=&URLToPath($fn); |
} elsif ($ENV{'form.qualifiedfilename'}) { |
} |
|
#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') { |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['decompress']); |
|
$fn=&Apache::lonnet::unescape($ENV{'form.decompress'}); |
|
$fn=&URLToPath($fn); |
|
$ENV{'form.action'}="decompress"; |
|
} |
|
|
|
elsif ($ENV{'form.qualifiedfilename'}) { |
$fn=$ENV{'form.qualifiedfilename'}; |
$fn=$ENV{'form.qualifiedfilename'}; |
} else { |
} else { |
&Debug($r, "loncfile::handler - no form.filename"); |
&Debug($r, "loncfile::handler - no form.filename"); |
Line 1118 sub handler {
|
Line 1158 sub handler {
|
$r->print('<h3>Rename</h3>'); |
$r->print('<h3>Rename</h3>'); |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
$r->print('<h3>New Directory</h3>'); |
$r->print('<h3>New Directory</h3>'); |
|
} elsif ($ENV{'form.action'} eq 'decompress') { |
|
$r->print('<h3>Decompress</h3>'); |
} elsif ($ENV{'form.action'} eq 'copy') { |
} elsif ($ENV{'form.action'} eq 'copy') { |
$r->print('<h3>Copy</h3>'); |
$r->print('<h3>Copy</h3>'); |
} elsif ($ENV{'form.action'} eq 'newfile' || |
} elsif ($ENV{'form.action'} eq 'newfile' || |