--- loncom/publisher/loncfile.pm 2006/11/23 01:50:57 1.79 +++ loncom/publisher/loncfile.pm 2007/04/20 20:55:01 1.82 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.79 2006/11/23 01:50:57 banghart Exp $ +# $Id: loncfile.pm,v 1.82 2007/04/20 20:55:01 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -72,9 +72,8 @@ use Apache::loncacc; use Apache::lonnet; use Apache::loncommon(); use Apache::lonlocal; -use lib '/home/httpd/lib/perl/'; -use LONCAPA; - +use LONCAPA qw(:DEFAULT :match); + my $DEBUG=0; my $r; # Needs to be global for some stuff RF. @@ -151,21 +150,21 @@ sub URLToPath { $Url=~ s/\/+/\//g; $Url=~ s/^http\:\/\/[^\/]+//; $Url=~ s/^\///; - $Url=~ s/(\~|priv\/)(\w+)\//\/home\/$2\/public_html\//; + $Url=~ s/(\~|priv\/)($match_username)\//\/home\/$2\/public_html\//; &Debug($r, "Returning $Url \n"); return $Url; } sub url { my $fn=shift; - $fn=~s/^\/home\/(\w+)\/public\_html/\/priv\/$1/; + $fn=~s/^\/home\/($match_username)\/public\_html/\/priv\/$1/; $fn=&HTML::Entities::encode($fn,'<>"&'); return $fn; } sub display { my $fn=shift; - $fn=~s-^/home/(\w+)/public_html-/priv/$1-; + $fn=~s-^/home/($match_username)/public_html-/priv/$1-; return ''.$fn.''; } @@ -301,9 +300,9 @@ sub checksuffix { my $newsuffix; if ($new=~m:(.*/*)([^/]+)\.(\w+)$:) { $newsuffix=$3; } if ($old=~m:(.*)/+([^/]+)\.(\w+)$:) { $oldsuffix=$3; } - if ($oldsuffix ne $newsuffix) { + if (lc($oldsuffix) ne lc($newsuffix)) { $result.= - '

'.&mt('Warning: change of MIME type!').'

'; + '

'.&mt('Warning: change of MIME type!').'

'; } return $result; } @@ -464,9 +463,9 @@ sub Rename1 { if (-d $fn) { $newfilename=~/\.(\w+)$/; if (&Apache::loncommon::fileembstyle($1) eq 'ssi') { - $request->print('
'. + $request->print('
'. &mt('Cannot change MIME type of a directory'). - '
'. + ''. '
'.&mt('Cancel').''); return; } @@ -750,16 +749,16 @@ sub NewFile1 { return; } if ($newfilename !~ /\Q.$extension\E$/) { - if ($newfilename =~ m|^[^\.]*\.([^\.]+)$|) { + if ($newfilename =~ m|/[^/.]*\.(?:[^/.]+)$|) { #already has an extension strip it and add in expected one - $newfilename =~ s|.([^\.]+)$||; + $newfilename =~ s|(/[^./])\.(?:[^.]+)$|$1|; } $newfilename.=".$extension"; } } my $result=&exists($user,$domain,$newfilename); if($result) { - $request->print(''.$result.''); + $request->print(''.$result.''); } else { $request->print('

'.&mt('Make new file').' '.&display($newfilename).'?

'); $request->print('');