--- loncom/publisher/lonupload.pm 2006/07/05 22:23:09 1.33 +++ loncom/publisher/lonupload.pm 2008/01/15 16:04:38 1.36 @@ -2,7 +2,7 @@ # The LearningOnline Network with CAPA # Handler to upload files into construction space # -# $Id: lonupload.pm,v 1.33 2006/07/05 22:23:09 albertel Exp $ +# $Id: lonupload.pm,v 1.36 2008/01/15 16:04:38 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -41,6 +41,7 @@ use Apache::lonnet; use HTML::Entities(); use Apache::lonlocal; use Apache::lonnet; +use LONCAPA(); my $DEBUG=0; @@ -98,7 +99,7 @@ sub phaseone { ''. ''.&mt('Store uploaded file as '). + '" />'.&mt('Save uploaded file as '). "/priv/$uname/". '
'. @@ -111,7 +112,7 @@ sub phaseone {

'); - $r->print(''); + $r->print(''); # Check for bad extension and warn user if ($fn=~/\.(\w+)$/ && (&Apache::loncommon::fileembstyle($1) eq 'hdn')) { @@ -157,15 +158,22 @@ sub phasetwo { &Debug($r, "URL is now ".$url); my $datatoken=$env{'form.datatoken'}; if (($fn) && ($datatoken)) { - if ((-e $target) && ($env{'form.override'} ne 'Yes')) { + if ($env{'form.cancel'}) { + my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; + my $dirpath=$path.'/'; + $dirpath=~s/\/+/\//g; + $r->print(&mt('Upload cancelled.').'
'. + &mt('Back to Directory').''); + } elsif ((-e $target) && (!$env{'form.override'})) { $r->print('
'. - &mt('File').' '.$fn.' '. - &mt('exists. Overwrite?').' '. + &mt('File [_1] exists. Overwrite?',''.$fn.''). ''. ''. ''. - '
'); - } else { + ''. + ''. + ''); + } else { my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; my $dirpath=$path.'/'; $dirpath=~s/\/+/\//g; @@ -289,7 +297,7 @@ function verifyForm() { $fn=$env{'form.filename'}; $fn=~s/^http\:\/\/[^\/]+\///; $fn=~s/^\///; - $fn=~s/(\~|priv\/)(\w+)//; + $fn=~s{(~|priv/)($LONCAPA::username_re)}{}; $fn=~s/\/+/\//g; } else { $r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}.