version 1.33, 2006/07/05 22:23:09
|
version 1.36, 2008/01/15 16:04:38
|
Line 41 use Apache::lonnet;
|
Line 41 use Apache::lonnet;
|
use HTML::Entities(); |
use HTML::Entities(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::lonnet; |
use Apache::lonnet; |
|
use LONCAPA(); |
|
|
my $DEBUG=0; |
my $DEBUG=0; |
|
|
Line 98 sub phaseone {
|
Line 99 sub phaseone {
|
'<input type="hidden" name="datatoken" value="'. |
'<input type="hidden" name="datatoken" value="'. |
&upfile_store.'" />'. |
&upfile_store.'" />'. |
'<input type="hidden" name="uploaduname" value="'.$uname. |
'<input type="hidden" name="uploaduname" value="'.$uname. |
'" />'.&mt('Store uploaded file as '). |
'" />'.&mt('Save uploaded file as '). |
"<span class='LC_filename'>/priv/$uname/</span>". |
"<span class='LC_filename'>/priv/$uname/</span>". |
'<input type="text" size="50" name="filename" value="'.$fn. |
'<input type="text" size="50" name="filename" value="'.$fn. |
'" /><br />'. |
'" /><br />'. |
Line 111 sub phaseone {
|
Line 112 sub phaseone {
|
<br /> |
<br /> |
<br /> |
<br /> |
'); |
'); |
$r->print('<input type="button" value="'.&mt('Store').'" onClick="javascript:verifyForm()"/></form>'); |
$r->print('<input type="button" value="'.&mt('Save').'" onClick="javascript:verifyForm()"/></form>'); |
# Check for bad extension and warn user |
# Check for bad extension and warn user |
if ($fn=~/\.(\w+)$/ && |
if ($fn=~/\.(\w+)$/ && |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
Line 157 sub phasetwo {
|
Line 158 sub phasetwo {
|
&Debug($r, "URL is now ".$url); |
&Debug($r, "URL is now ".$url); |
my $datatoken=$env{'form.datatoken'}; |
my $datatoken=$env{'form.datatoken'}; |
if (($fn) && ($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.').'<br /><font size="+2"><a href="'.$dirpath.'">'. |
|
&mt('Back to Directory').'</a></font>'); |
|
} elsif ((-e $target) && (!$env{'form.override'})) { |
$r->print('<form action="'.$action.'" method="post">'. |
$r->print('<form action="'.$action.'" method="post">'. |
&mt('File').' <span class="LC_filename">'.$fn.'</span> '. |
&mt('File [_1] exists. Overwrite?','<span class="LC_filename">'.$fn.'</span>'). |
&mt('exists. Overwrite?').' '. |
|
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="filename" value="'."$url".'" />'. |
'<input type="hidden" name="filename" value="'."$url".'" />'. |
'<input type="hidden" name="datatoken" value="'.$datatoken.'" />'. |
'<input type="hidden" name="datatoken" value="'.$datatoken.'" />'. |
'<input type="submit" name="override" value="'.&mt('Yes').'" /></form>'); |
'<input type="submit" name="override" value="'.&mt('Yes').'" />'. |
} else { |
'<input type="submit" name="cancel" value="'.&mt('Cancel').'" />'. |
|
'</form>'); |
|
} else { |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
my $dirpath=$path.'/'; |
my $dirpath=$path.'/'; |
$dirpath=~s/\/+/\//g; |
$dirpath=~s/\/+/\//g; |
Line 289 function verifyForm() {
|
Line 297 function verifyForm() {
|
$fn=$env{'form.filename'}; |
$fn=$env{'form.filename'}; |
$fn=~s/^http\:\/\/[^\/]+\///; |
$fn=~s/^http\:\/\/[^\/]+\///; |
$fn=~s/^\///; |
$fn=~s/^\///; |
$fn=~s/(\~|priv\/)(\w+)//; |
$fn=~s{(~|priv/)($LONCAPA::username_re)}{}; |
$fn=~s/\/+/\//g; |
$fn=~s/\/+/\//g; |
} else { |
} else { |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |
$r->log_reason($env{'user.name'}.' at '.$env{'user.domain'}. |