--- loncom/publisher/loncfile.pm 2002/05/24 05:11:40 1.9 +++ loncom/publisher/loncfile.pm 2002/05/27 03:18:46 1.10 @@ -10,7 +10,7 @@ # # -# $Id: loncfile.pm,v 1.9 2002/05/24 05:11:40 foxr Exp $ +# $Id: loncfile.pm,v 1.10 2002/05/27 03:18:46 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -63,8 +63,8 @@ use Apache::Constants qw(:common :http : use Apache::loncacc; use Apache::Log (); -my $DEBUG=1; - +my $DEBUG=0; +my $r; # Needs to be global for some stuff RF. # # Debug # If debugging is enabled puts out a debuggin message determined by the @@ -83,7 +83,26 @@ sub Debug { $log->debug($message); } } - +# +# URLToPath +# Convert a URL to a file system path. +# +# In order to manipulate the construction space objects, it's necessary +# to access url identified objects a filespace objects. This function +# translates a construction space URL to a file system path. +# Parameters: +# Url - string [in] The url to convert. +# Returns: +# The corresponing file system path. +sub URLToPath +{ + my $Url = shift; + &Debug($r, "UrlToPath got: $Url"); + $Url=~ s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; + $Url=~ s/^http\:\/\/[^\/]+//; + &Debug($r, "Returning $Url \n"); + return $Url; +} sub exists { my ($uname,$udom,$dir,$newfile)=@_; my $published='/home/httpd/html/res/'.$udom.'/'.$uname.'/'.$dir.'/'. @@ -265,7 +284,7 @@ sub phasetwo { sub handler { - my $r=shift; + $r=shift; &Debug($r, "loncfile.pm - handler entered"); @@ -275,8 +294,9 @@ sub handler { if ($ENV{'form.filename'}) { $fn=$ENV{'form.filename'}; &Debug($r, "loncfile::handler - raw url: $fn"); - $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; - $fn=~s/^http\:\/\/[^\/]+//; +# $fn=~s/^http\:\/\/[^\/]+\/\~(\w+)/\/home\/$1\/public_html/; +# $fn=~s/^http\:\/\/[^\/]+//; + $fn=URLToPath($fn); &Debug($r, "loncfile::handler - doctored url: $fn"); } else {