version 1.25, 2004/02/17 15:23:53
|
version 1.28, 2004/12/07 22:11:02
|
Line 100 sub phaseone {
|
Line 100 sub phaseone {
|
|
|
&Debug($r, "Filename for upload: $fn"); |
&Debug($r, "Filename for upload: $fn"); |
if (($fn) && ($fn!~/\/$/)) { |
if (($fn) && ($fn!~/\/$/)) { |
$r->print('<form action="'.$action.'" method="post">'. |
$r->print('<form action="'.$action.'" method="post" name="fileupload">'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="phase" value="two" />'. |
'<input type="hidden" name="datatoken" value="'. |
'<input type="hidden" name="datatoken" value="'. |
&upfile_store.'" />'. |
&upfile_store.'" />'. |
Line 165 sub phasetwo {
|
Line 165 sub phasetwo {
|
# target is the full filesystem path of the destination file. |
# target is the full filesystem path of the destination file. |
my $base = &File::Basename::basename($fn); |
my $base = &File::Basename::basename($fn); |
my $path = &File::Basename::dirname($fn); |
my $path = &File::Basename::dirname($fn); |
$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'}; |
Line 180 sub phasetwo {
|
Line 180 sub phasetwo {
|
'<input type="submit" name="override" value="'.&mt('Yes').'" /></form>'); |
'<input type="submit" name="override" value="'.&mt('Yes').'" /></form>'); |
} else { |
} else { |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
|
my $dirpath=$path.'/'; |
|
$dirpath=~s/\/+/\//g; |
# Check for bad extension and disallow upload |
# Check for bad extension and disallow upload |
if ($fn=~/\.(\w+)$/ && |
if ($fn=~/\.(\w+)$/ && |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
Line 188 sub phasetwo {
|
Line 190 sub phasetwo {
|
'<font color="red">'. |
'<font color="red">'. |
&mt('The extension on this file is reserved internally by LON-CAPA.'). |
&mt('The extension on this file is reserved internally by LON-CAPA.'). |
'</font>'); |
'</font>'); |
$r->print('<br /><font size=+2><a href="'.$path.'">'. |
$r->print('<br /><font size=+2><a href="'.$dirpath.'">'. |
&mt('Back to Directory').'</a></font>'); |
&mt('Back to Directory').'</a></font>'); |
} elsif ($fn=~/\.(\w+)$/ && |
} elsif ($fn=~/\.(\w+)$/ && |
!defined(&Apache::loncommon::fileembstyle($1))) { |
!defined(&Apache::loncommon::fileembstyle($1))) { |
Line 197 sub phasetwo {
|
Line 199 sub phasetwo {
|
'<font color="red">'. |
'<font color="red">'. |
&mt('The extension on this file is not recognized by LON-CAPA.'). |
&mt('The extension on this file is not recognized by LON-CAPA.'). |
'</font>'); |
'</font>'); |
$r->print('<br /><font size="+2"><a href="'.$path.'">'. |
$r->print('<br /><font size="+2"><a href="'.$dirpath.'">'. |
&mt('Back to Directory').'</a></font>'); |
&mt('Back to Directory').'</a></font>'); |
} elsif (-d $target) { |
} elsif (-d $target) { |
$r->print('File <tt>'.$fn.'</tt> could not be copied.<br />'. |
$r->print('File <tt>'.$fn.'</tt> could not be copied.<br />'. |
'<font color="red">'. |
'<font color="red">'. |
&mt('The target is an existing directory.'). |
&mt('The target is an existing directory.'). |
'</font><br />'); |
'</font><br />'); |
$r->print('<font size="+2"><a href="'.$path.'">'. |
$r->print('<font size="+2"><a href="'.$dirpath.'">'. |
&mt('Back to Directory').'</a></font>'); |
&mt('Back to Directory').'</a></font>'); |
} elsif (copy($source,$target)) { |
} elsif (copy($source,$target)) { |
chmod(0660, $target); # Set permissions to rw-rw---. |
chmod(0660, $target); # Set permissions to rw-rw---. |
Line 215 sub phasetwo {
|
Line 217 sub phasetwo {
|
$r->print(&mt('File copied.')); |
$r->print(&mt('File copied.')); |
$r->print('<br /><font size="+2"><a href="'.$url.'">'. |
$r->print('<br /><font size="+2"><a href="'.$url.'">'. |
&mt('View file').'</a></font>'); |
&mt('View file').'</a></font>'); |
$r->print('<br /><font size="+2"><a href="'.$path.'">'. |
$r->print('<br /><font size="+2"><a href="'.$dirpath.'">'. |
&mt('Back to Directory').'</a></font><br />'); |
&mt('Back to Directory').'</a></font><br />'); |
} |
} |
} else { |
} else { |
Line 256 sub handler {
|
Line 258 sub handler {
|
unless ($ENV{'form.phase'} eq 'two') { |
unless ($ENV{'form.phase'} eq 'two') { |
$javascript = qq| |
$javascript = qq| |
function verifyForm() { |
function verifyForm() { |
var mode = document.forms[0].filetype.options[document.forms[0].filetype.selectedIndex].value |
var mode = document.fileupload.filetype.options[document.fileupload.filetype.selectedIndex].value |
if (mode == "testbank") { |
if (mode == "testbank") { |
document.forms[0].action = "/adm/testbank"; |
document.fileupload.action = "/adm/testbank"; |
} |
} |
if (mode == "imsimport") { |
if (mode == "imsimport") { |
document.forms[0].action = "/adm/imsimport"; |
document.fileupload.action = "/adm/imsimport"; |
} |
} |
if (mode == "standard") { |
if (mode == "standard") { |
document.forms[0].action = "/adm/upload"; |
document.fileupload.action = "/adm/upload"; |
} |
} |
document.forms[0].submit(); |
document.fileupload.submit(); |
} |
} |
|
|
function testbankWin() { |
function testbankWin() { |