version 1.28, 2004/12/07 22:11:02
|
version 1.29, 2005/04/07 06:56:27
|
Line 41 use Apache::Log();
|
Line 41 use Apache::Log();
|
use Apache::lonnet; |
use Apache::lonnet; |
use HTML::Entities(); |
use HTML::Entities(); |
use Apache::lonlocal; |
use Apache::lonlocal; |
|
use Apache::lonnet; |
|
|
my $DEBUG=0; |
my $DEBUG=0; |
|
|
Line 62 sub Debug {
|
Line 63 sub Debug {
|
sub upfile_store { |
sub upfile_store { |
my $r=shift; |
my $r=shift; |
|
|
my $fname=$ENV{'form.upfile.filename'}; |
my $fname=$env{'form.upfile.filename'}; |
$fname=~s/\W//g; |
$fname=~s/\W//g; |
|
|
chomp($ENV{'form.upfile'}); |
chomp($env{'form.upfile'}); |
|
|
my $datatoken=$ENV{'user.name'}.'_'.$ENV{'user.domain'}. |
my $datatoken=$env{'user.name'}.'_'.$env{'user.domain'}. |
'_upload_'.$fname.'_'.time.'_'.$$; |
'_upload_'.$fname.'_'.time.'_'.$$; |
{ |
{ |
my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons'). |
my $fh=Apache::File->new('>'.$r->dir_config('lonDaemons'). |
'/tmp/'.$datatoken.'.tmp'); |
'/tmp/'.$datatoken.'.tmp'); |
print $fh $ENV{'form.upfile'}; |
print $fh $env{'form.upfile'}; |
} |
} |
return $datatoken; |
return $datatoken; |
} |
} |
Line 86 sub phaseone {
|
Line 87 sub phaseone {
|
} elsif ($mode eq 'imsimport') { |
} elsif ($mode eq 'imsimport') { |
$action = '/adm/imsimport'; |
$action = '/adm/imsimport'; |
} |
} |
$ENV{'form.upfile.filename'}=~s/\\/\//g; |
$env{'form.upfile.filename'}=~s/\\/\//g; |
$ENV{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/; |
$env{'form.upfile.filename'}=~s/^.*\/([^\/]+)$/$1/; |
if ($ENV{'form.upfile.filename'}) { |
if ($env{'form.upfile.filename'}) { |
$fn=~s/\/[^\/]+$//; |
$fn=~s/\/[^\/]+$//; |
$fn=~s/([^\/])$/$1\//; |
$fn=~s/([^\/])$/$1\//; |
$fn.=$ENV{'form.upfile.filename'}; |
$fn.=$env{'form.upfile.filename'}; |
$fn=~s/^\///; |
$fn=~s/^\///; |
$fn=~s/(\/)+/\//g; |
$fn=~s/(\/)+/\//g; |
|
|
Line 168 sub phasetwo {
|
Line 169 sub phasetwo {
|
$base = &HTML::Entities::encode($base,'<>&"'); |
$base = &HTML::Entities::encode($base,'<>&"'); |
my $url = $path."/".$base; |
my $url = $path."/".$base; |
&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 ((-e $target) && ($env{'form.override'} ne 'Yes')) { |
$r->print('<form action="'.$action.'" method="post">'. |
$r->print('<form action="'.$action.'" method="post">'. |
&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('exists. Overwrite?').' '. |
&mt('exists. Overwrite?').' '. |
Line 250 sub handler {
|
Line 251 sub handler {
|
# |
# |
# phase two: re-attach user |
# phase two: re-attach user |
# |
# |
if ($ENV{'form.uploaduname'}) { |
if ($env{'form.uploaduname'}) { |
$ENV{'form.filename'}='/priv/'.$ENV{'form.uploaduname'}.'/'. |
$env{'form.filename'}='/priv/'.$env{'form.uploaduname'}.'/'. |
$ENV{'form.filename'}; |
$env{'form.filename'}; |
} |
} |
|
|
unless ($ENV{'form.phase'} eq 'two') { |
unless ($env{'form.phase'} eq 'two') { |
$javascript = qq| |
$javascript = qq| |
function verifyForm() { |
function verifyForm() { |
var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value |
var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value |
Line 294 function testbankWin() {
|
Line 295 function testbankWin() {
|
|; |
|; |
} |
} |
($uname,$udom)= |
($uname,$udom)= |
&Apache::loncacc::constructaccess($ENV{'form.filename'}, |
&Apache::loncacc::constructaccess($env{'form.filename'}, |
$r->dir_config('lonDefDomain')); |
$r->dir_config('lonDefDomain')); |
unless (($uname) && ($udom)) { |
unless (($uname) && ($udom)) { |
$r->log_reason($uname.' at '.$udom. |
$r->log_reason($uname.' at '.$udom. |
' trying to publish file '.$ENV{'form.filename'}. |
' trying to publish file '.$env{'form.filename'}. |
' - not authorized', |
' - not authorized', |
$r->filename); |
$r->filename); |
return HTTP_NOT_ACCEPTABLE; |
return HTTP_NOT_ACCEPTABLE; |
} |
} |
|
|
my $fn; |
my $fn; |
if ($ENV{'form.filename'}) { |
if ($env{'form.filename'}) { |
$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\/)(\w+)//; |
$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'}. |
' unspecified filename for upload', $r->filename); |
' unspecified filename for upload', $r->filename); |
return HTTP_NOT_FOUND; |
return HTTP_NOT_FOUND; |
} |
} |
Line 327 function testbankWin() {
|
Line 328 function testbankWin() {
|
|
|
$r->print(&Apache::loncommon::bodytag('Upload file to Construction Space')); |
$r->print(&Apache::loncommon::bodytag('Upload file to Construction Space')); |
|
|
if (($uname ne $ENV{'user.name'}) || ($udom ne $ENV{'user.domain'})) { |
if (($uname ne $env{'user.name'}) || ($udom ne $env{'user.domain'})) { |
$r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname. |
$r->print('<h3><font color=red>'.&mt('Co-Author').': '.$uname. |
&mt(' at ').$udom.'</font></h3>'); |
&mt(' at ').$udom.'</font></h3>'); |
} |
} |
|
|
if ($ENV{'form.phase'} eq 'two') { |
if ($env{'form.phase'} eq 'two') { |
&phasetwo($r,$fn,$uname,$udom); |
&phasetwo($r,$fn,$uname,$udom); |
} else { |
} else { |
&phaseone($r,$fn,$uname,$udom); |
&phaseone($r,$fn,$uname,$udom); |