--- loncom/publisher/loncfile.pm 2009/08/28 01:08:48 1.102 +++ loncom/publisher/loncfile.pm 2011/10/22 23:09:44 1.108 @@ -9,7 +9,7 @@ # and displays a page showing the results of the action. # # -# $Id: loncfile.pm,v 1.102 2009/08/28 01:08:48 raeburn Exp $ +# $Id: loncfile.pm,v 1.108 2011/10/22 23:09:44 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -168,14 +168,16 @@ sub URLToPath { sub url { my $fn=shift; - $fn=~s/^\/home\/($match_username)\/public\_html/\/priv\/$1/; + $fn=~s/^\/home\/httpd\/html//; + $fn=~s/\/\.\//\//g; $fn=&HTML::Entities::encode($fn,'<>"&'); return $fn; } sub display { my $fn=shift; - $fn=~s-^/home/($match_username)/public_html-/priv/$1-; + $fn=~s/^\/home\/httpd\/html//; + $fn=~s/\/\.\//\//g; return ''.$fn.''; } @@ -348,6 +350,7 @@ sub cleanDest { my ($request,$dest,$subdir,$fn,$uname)=@_; #remove bad characters my $foundbad=0; + my $error=''; if ($subdir && $dest =~/\./) { $foundbad=1; $dest=~s/\.//g; @@ -359,18 +362,18 @@ sub cleanDest { } if ($dest=~m|/|) { my ($newpath)=($dest=~m|(.*)/|); - $newpath=&relativeDest($fn,$newpath,$uname); + ($newpath,$error)=&relativeDest($fn,$newpath,$uname); if (! -d "$newpath") { $request->print('
' .&mt("You have requested to create file in directory [_1] which doesn't exist. The requested directory path has been removed from the requested file name." - ,''.&display($newpath).'') + ,&display($newpath)) .'
'); $dest=~s|.*/||; } } if ($dest =~ /\.(\d+)\.(\w+)$/){ $request->print(''
- .&mt('Bad filename [_1]',''.&display($dest).'')
+ .&mt('Bad filename [_1]',&display($dest))
.'
'
.&mt('[_1](name).(number).(extension)[_2] not allowed.','','')
.'
'
@@ -384,11 +387,12 @@ sub cleanDest {
.'
' - .&mt($action.' [_1] to [_2]?' - ,&display($fn),&display($newfilename)) + .&mt($action.' [_1] to [_2]?', + &display($fn), + &display($newfilename)) .'
' ); &CloseForm1($request, $fn); @@ -563,8 +579,8 @@ sub Rename1 { } } else { $request->print('' - .&mt('No such file: [_1]' - ,''.&display($fn).'') + .&mt('No such file: [_1]', + &display($fn)) .'
' ); return; @@ -625,15 +641,15 @@ sub Delete1 { } } $request->print('' - .&mt('Delete [_1]?' - ,''.&display($fn).'') + .&mt('Delete [_1]?', + &display($fn)) .'
' ); &CloseForm1($request, $fn); } else { $request->print('' - .&mt('No such file: [_1]' - ,''.&display($fn).'') + .&mt('No such file: [_1]', + &display($fn)) .'
' ); } @@ -689,19 +705,20 @@ sub Copy1 { $request->print('' - .&mt('Copy [_1] to [_2]?' - ,''.&display($fn).'' - ,''.&display($newfilename).'') - .'
' + $request->print( + '' + .'' + .&mt('Copy [_1] to [_2]?', + &display($fn), + &display($newfilename)) + .'
' ); &CloseForm1($request, $fn); } else { $request->print('' - .&mt('No such file: [_1]' - ,''.&display($fn).'') + .&mt('No such file: [_1]', + &display($fn)) .'
' ); } @@ -754,16 +771,15 @@ sub NewDir1 { if ($type eq 'error') { $request->print(''); } else { - if ($mode eq 'testbank') { - $request->print(''); - } elsif ($mode eq 'imsimport') { - $request->print(''); + if (($mode eq 'testbank') || ($mode eq 'imsimport')) { + $request->print(''."\n". + ''); } $request->print('' .'' - .&mt('Make new directory [_1]?' - ,''.&display($newfilename).'') + .&mt('Make new directory [_1]?', + &display($newfilename)) .'
' ); &CloseForm1($request, $fn); @@ -776,15 +792,15 @@ sub Decompress1 { if( -e $fn) { $request->print(''); $request->print('' - .&mt('Decompress [_1]?' - ,''.&display($fn).'') + .&mt('Decompress [_1]?', + &display($fn)) .'
' ); &CloseForm1($request, $fn); } else { $request->print('' - .&mt('No such file: [_1]' - ,''.&display($fn).'') + .&mt('No such file: [_1]', + &display($fn)) .'
' ); } @@ -935,8 +951,23 @@ sub phaseone { my $doingdir=0; if ($env{'form.action'} eq 'newdir') { $doingdir=1; } - my $newfilename=&cleanDest($r,$env{'form.newfilename'},$doingdir,$fn,$uname); - $newfilename=&relativeDest($fn,$newfilename,$uname); + my ($newfilename,$error) = + &cleanDest($r,$env{'form.newfilename'},$doingdir,$fn,$uname); + unless ($error) { + ($newfilename,$error)=&relativeDest($fn,$newfilename,$uname); + } + if ($error) { + my $dirlist; + if ($fn=~m{^(.*/)[^/]+$}) { + $dirlist=$1; + } else { + $dirlist=$fn; + } + $r->print('' + .&mt('No such file: [_1]', + &display($oldfile)) + .'
' ); return 0; } @@ -1469,7 +1501,7 @@ function writeDone() { $r->print('' + $r->print('
' .&mt('Co-Author [_1]',$uname.':'.$udom) .'
' );