version 1.21, 2003/01/09 22:11:52
|
version 1.22, 2003/02/04 21:54:17
|
Line 128 sub Debug {
|
Line 128 sub Debug {
|
my $log = $r->log; |
my $log = $r->log; |
my $message = shift; |
my $message = shift; |
|
|
# Put out the indicated message butonly if DEBUG is false. |
# Put out the indicated message butonly if DEBUG is true. |
|
|
if ($DEBUG) { |
if ($DEBUG) { |
$log->debug($message); |
$log->debug($message); |
Line 413 sub CloseForm1 {
|
Line 413 sub CloseForm1 {
|
&Debug($request, "Cancel url is: ".$cancelurl); |
&Debug($request, "Cancel url is: ".$cancelurl); |
$request->print('<p><input type=submit value=Continue></p></form>'); |
$request->print('<p><input type=submit value=Continue></p></form>'); |
$request->print('<form action="'.$cancelurl. |
$request->print('<form action="'.$cancelurl. |
'" method=GET"><p><input type=submit value=Cancel><p></form>'); |
'" method="GET"><p><input type=submit value=Cancel><p></form>'); |
|
|
} |
} |
|
|
Line 706 sub NewDir1
|
Line 706 sub NewDir1
|
|
|
=pod |
=pod |
|
|
|
=item NewFile1 |
|
|
|
Does all phase 1 processing of file creation: |
|
Ensures that the user provides a new filename, adds proper extension |
|
if needed and that the file does not already exist, if it is a html, |
|
problem, page, or sequence, it then creates a form link to hand the |
|
actual creation off to the proper handler. |
|
|
|
Parameters: |
|
|
|
=over 4 |
|
|
|
=item $request - Apache Request Object [in] - Server request object for the |
|
current url. |
|
|
|
=item $username - Name of the user that is requesting the directory creation. |
|
|
|
=item $domain - Name of the domain of the user |
|
|
|
=item $dir - current absolute diretory |
|
|
|
=item $newfilename |
|
- Name of the file to be created; no path information |
|
=back |
|
|
|
Side Effects: |
|
|
|
=over 4 |
|
|
|
=item 2 new forms are displayed. Clicking on the confirmation button |
|
causes the browser to attempt to load the specfied URL, allowing the |
|
proper handler to take care of file creation. There is also a Cancle |
|
button which returns you to the driectory listing you came from |
|
|
|
=back |
|
|
|
=cut |
|
|
|
|
|
sub NewFile1 { |
|
my ($request, $user, $domain, $dir, $newfilename) = @_; |
|
|
|
&Debug($request, "Dir is : ".$dir); |
|
&Debug($request, "Newfile is : ".$newfilename); |
|
|
|
my $cancelurl = "/priv/".$dir; |
|
$cancelurl =~ s/\/home\///; |
|
$cancelurl =~ s/\/public_html//; |
|
|
|
if ($ENV{'form.action'} =~ /new(.+)file/) { |
|
my $extension=$1; |
|
if ($newfilename !~ /\Q.$extension\E$/) { |
|
$newfilename.=".$extension"; |
|
} |
|
} |
|
|
|
my $fullpath = $dir.'/'.$newfilename; |
|
|
|
&Debug($request, "Full path is : ".$fullpath); |
|
|
|
if(-e $fullpath) { |
|
$request->print('<p>File exists.</p></form>'); |
|
} |
|
else { |
|
$request->print('<p>Make new file <tt>'.$newfilename.'</tt>?</p>'); |
|
my $dest=&MakeFinalUrl($request,$fullpath); |
|
&Debug($request, "Cancel url is: ".$cancelurl); |
|
&Debug($request, "Dest url is: ".$dest); |
|
$request->print('</form>'); |
|
$request->print('<form action="'.$dest. |
|
'" method="GET"><p><input type="submit" value="Continue" /></p></form>'); |
|
$request->print('<form action="'.$cancelurl. |
|
'" method="GET"><p><input type="submit" value="Cancel" /></p></form>'); |
|
} |
|
} |
|
|
|
=pod |
|
|
=item phaseone($r, $fn, $uname, $udom) |
=item phaseone($r, $fn, $uname, $udom) |
|
|
Peforms phase one processing of the request. In phase one, error messages |
Peforms phase one processing of the request. In phase one, error messages |
Line 765 sub phaseone {
|
Line 843 sub phaseone {
|
} |
} |
} elsif ($ENV{'form.action'} eq 'newdir') { |
} elsif ($ENV{'form.action'} eq 'newdir') { |
&NewDir1($r, $uname, $dir, $ENV{'form.newfilename'}); |
&NewDir1($r, $uname, $dir, $ENV{'form.newfilename'}); |
|
} elsif ($ENV{'form.action'} eq 'newfile' || |
|
$ENV{'form.action'} eq 'newhtmlfile' || |
|
$ENV{'form.action'} eq 'newproblemfile') { |
|
if($ENV{'form.newfilename'}) { |
|
my $newfilename = $ENV{'form.newfilename'}; |
|
if (!defined($dir)) { |
|
$fn=~m:(.*)/:; |
|
$dir=$1; |
|
} |
|
&NewFile1($r, $uname, $udom, $dir, $fn, $newfilename); |
|
}else { |
|
$r->print('<p>No new filename specified.</p></form>'); |
|
} |
} |
} |
|
|
} |
} |
|
|
=pod |
=pod |
Line 1059 sub phasetwo {
|
Line 1149 sub phasetwo {
|
# Substitute for priv for the first home in $dir to get our |
# Substitute for priv for the first home in $dir to get our |
# construction space path. |
# construction space path. |
# |
# |
|
$dest=&MakeFinalUrl($r,$dest); |
|
|
|
$r->print('<h3><a href="'.$dest.'">Done</a></h3>'); |
|
} |
|
|
|
sub MakeFinalUrl { |
|
my($r,$dest)=@_; |
&Debug($r, "Final url is: $dest"); |
&Debug($r, "Final url is: $dest"); |
$dest =~ s|/home/|/priv/|; |
$dest =~ s|/home/|/priv/|; |
$dest =~ s|/public_html||; |
$dest =~ s|/public_html||; |
|
|
my $base = &File::Basename::basename($dest); |
my $base = &File::Basename::basename($dest); |
my $dpath= &File::Basename::dirname($dest); |
my $dpath= &File::Basename::dirname($dest); |
if ($base eq '.') { $base=''; } |
if ($base eq '.') { $base=''; } |
$dest = &HTML::Entities::encode($dpath.'/'.$base); |
$dest = &HTML::Entities::encode($dpath.'/'.$base); |
|
|
|
|
&Debug($r, "Final url after rewrite: $dest"); |
&Debug($r, "Final url after rewrite: $dest"); |
|
return $dest; |
$r->print('<h3><a href="'.$dest.'">Done</a></h3>'); |
|
} |
} |
|
|
sub handler { |
sub handler { |
Line 1086 sub handler {
|
Line 1181 sub handler {
|
my $fn; |
my $fn; |
|
|
if ($ENV{'form.filename'}) { |
if ($ENV{'form.filename'}) { |
$fn=$ENV{'form.filename'}; |
$fn=&Apache::lonnet::unescape($ENV{'form.filename'}); |
&Debug($r, "loncfile::handler - raw url: $fn"); |
&Debug($r, "loncfile::handler - raw url: $fn"); |
# $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; |
# $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; |
# $fn=~s/^http\:\/\/[^\/]+//; |
# $fn=~s/^http\:\/\/[^\/]+//; |
Line 1153 sub handler {
|
Line 1248 sub handler {
|
$r->print('<h3>New Directory</h3>'); |
$r->print('<h3>New Directory</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' || |
|
$ENV{'form.action'} eq 'newhtmlfile' || |
|
$ENV{'form.action'} eq 'newproblemfile') { |
|
$r->print('<h3>New Resource</h3>'); |
} else { |
} else { |
$r->print('<p>Unknown Action</body></html>'); |
$r->print('<p>Unknown Action</body></html>'); |
return OK; |
return OK; |