version 1.23, 2003/02/04 22:01:38
|
version 1.27, 2003/02/12 19:56:14
|
Line 7
|
Line 7
|
# presents a page that describes the proposed action to the user |
# presents a page that describes the proposed action to the user |
# and requests confirmation. The second phase commits the action |
# and requests confirmation. The second phase commits the action |
# and displays a page showing the results of the action. |
# and displays a page showing the results of the action. |
# |
# |
|
|
# |
# |
# $Id$ |
# $Id$ |
# |
# |
Line 495 sub Rename1 {
|
Line 494 sub Rename1 {
|
if(-e $conspace) { |
if(-e $conspace) { |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
my $newfilename = $ENV{'form.newfilename'}; |
my $newfilename = $ENV{'form.newfilename'}; |
|
if ($newfilename =~ m|^[^\.]+$|) { |
|
#no extension add on orignal extension |
|
if ($filename =~ m|/[^\.]*\.([^\.]+)$|) { |
|
$newfilename.='.'.$1; |
|
} |
|
} |
$request->print(&checksuffix($filename, $newfilename)); |
$request->print(&checksuffix($filename, $newfilename)); |
|
#renaming a dir, delete the trailing / |
|
#remove last element for current dir |
|
if ($filename =~ m|/$|) { |
|
$filename =~ s|/$||; |
|
$dir =~ s|/[^/]*$||; |
|
} |
my $return=&exists($user, $domain, $dir, $newfilename); |
my $return=&exists($user, $domain, $dir, $newfilename); |
$request->print($return); |
$request->print($return); |
if ($return =~/^Error:/) { |
if ($return =~/^Error:/) { |
Line 759 sub NewFile1 {
|
Line 770 sub NewFile1 {
|
if ($ENV{'form.action'} =~ /new(.+)file/) { |
if ($ENV{'form.action'} =~ /new(.+)file/) { |
my $extension=$1; |
my $extension=$1; |
if ($newfilename !~ /\Q.$extension\E$/) { |
if ($newfilename !~ /\Q.$extension\E$/) { |
|
if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) { |
|
#already has an extension strip it and add in expected one |
|
$newfilename =~ s|.([^\.]+)$||; |
|
} |
$newfilename.=".$extension"; |
$newfilename.=".$extension"; |
} |
} |
} |
} |
Line 771 sub NewFile1 {
|
Line 786 sub NewFile1 {
|
$request->print('<p>File exists.</p></form>'); |
$request->print('<p>File exists.</p></form>'); |
} |
} |
else { |
else { |
$request->print('<p>Make new file <tt>'.$newfilename.'</tt>?</p>'); |
$request->print('<p>Make new file <tt>'.$dir.'/'.$newfilename.'</tt>?</p>'); |
my $dest=&MakeFinalUrl($request,$fullpath); |
my $dest=&MakeFinalUrl($request,$fullpath); |
&Debug($request, "Cancel url is: ".$cancelurl); |
&Debug($request, "Cancel url is: ".$cancelurl); |
&Debug($request, "Dest url is: ".$dest); |
&Debug($request, "Dest url is: ".$dest); |
Line 828 sub phaseone {
|
Line 843 sub phaseone {
|
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
'<input type="hidden" name="action" value="'.$ENV{'form.action'}.'" />'); |
|
|
if ($ENV{'form.action'} eq 'rename') { |
if ($ENV{'form.action'} eq 'rename') { |
|
if (!defined($dir)) { |
&Rename1($r, $fn, $uname, $udom, $dir); |
$fn=~m:(.*)/:; |
|
$dir=$1; |
|
} |
|
&Rename1($r, $fn, $uname, $udom, $dir); |
} elsif ($ENV{'form.action'} eq 'delete') { |
} elsif ($ENV{'form.action'} eq 'delete') { |
|
|
&Delete1($r, $uname, $fn); |
&Delete1($r, $uname, $fn); |
Line 847 sub phaseone {
|
Line 864 sub phaseone {
|
} elsif ($ENV{'form.action'} eq 'newfile' || |
} elsif ($ENV{'form.action'} eq 'newfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newhtmlfile' || |
$ENV{'form.action'} eq 'newproblemfile') { |
$ENV{'form.action'} eq 'newproblemfile') { |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
my $newfilename = $ENV{'form.newfilename'}; |
my $newfilename = $ENV{'form.newfilename'}; |
if (!defined($dir)) { |
if (!defined($dir)) { |
$fn=~m:(.*)/:; |
$fn=~m:(.*)/:; |
$dir=$1; |
$dir=$1; |
|
} |
|
&NewFile1($r, $uname, $udom, $dir, $newfilename); |
|
} else { |
|
$r->print('<p>No new filename specified.</p></form>'); |
} |
} |
&NewFile1($r, $uname, $udom, $dir, $fn, $newfilename); |
|
}else { |
|
$r->print('<p>No new filename specified.</p></form>'); |
|
} |
|
} |
} |
} |
} |
|
|
Line 904 sub Rename2 {
|
Line 921 sub Rename2 {
|
$newfile); |
$newfile); |
|
|
if(-e $oldfile) { |
if(-e $oldfile) { |
unless(rename($oldfile, |
my $dest; |
$directory.'/'.$newfile)) { |
|
|
if ($oldfile =~ m|/$|) { |
|
#renaming a dir |
|
$oldfile =~ s|/$||; |
|
$dest=$directory; |
|
$dest=~s|(/)([^/]*)$|$1|; |
|
$dest.='/'.$newfile; |
|
} else { |
|
$dest=$directory.'/'.$newfile; |
|
} |
|
|
|
unless(rename($oldfile,$dest)) { |
$request->print('<font color="red">Error: '.$!.'</font>'); |
$request->print('<font color="red">Error: '.$!.'</font>'); |
return 0; |
return 0; |
} else {} |
} else {} |
Line 1083 sub phasetwo {
|
Line 1111 sub phasetwo {
|
|
|
# Break down the file into it's component pieces. |
# Break down the file into it's component pieces. |
|
|
$fn=~/(.*)\/([^\/]+)\.(\w+)$/; |
my $dir; # Directory path |
my $dir=$1; # Directory path |
my $main; # Filename. |
my $main=$2; # Filename. |
my $suffix; # Extension. |
my $suffix=$3; # Extension. |
|
|
if ($fn=~m:(.*)/([^/]+)\.(\w+)$:) { |
|
$dir=$1; # Directory path |
|
$main=$2; # Filename. |
|
$suffix=$3; # Extension. |
|
} |
|
|
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 1107 sub phasetwo {
|
Line 1140 sub phasetwo {
|
|
|
if ($ENV{'form.action'} eq 'rename') { # Rename. |
if ($ENV{'form.action'} eq 'rename') { # Rename. |
if($ENV{'form.newfilename'}) { |
if($ENV{'form.newfilename'}) { |
|
if (!defined($dir)) { |
|
$fn=~m:^(.*)/:; |
|
$dir=$1; |
|
} |
if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { |
if(!&Rename2($r, $uname, $dir, $fn, $ENV{'form.newfilename'})) { |
return; |
return; |
} |
} |
# Prepend the directory to the new name to form the basis of the |
# Prepend the directory to the new name to form the basis of the |
# url of the new resource. |
# url of the new resource. |
# |
# |
|
#renaming a dir |
|
#remove last element for current dir |
|
if ($fn =~ m|/$|) { $dir =~ s|/[^/]*$||; } |
$dest = $dir."/".$ENV{'form.newfilename'}; |
$dest = $dir."/".$ENV{'form.newfilename'}; |
} |
} |
} elsif ($ENV{'form.action'} eq 'delete') { |
} elsif ($ENV{'form.action'} eq 'delete') { |