version 1.22, 2003/11/08 11:04:52
|
version 1.23, 2003/11/08 11:11:01
|
Line 94 sub phaseone {
|
Line 94 sub phaseone {
|
|
|
&Debug($r, "Filename for upload: $fn"); |
&Debug($r, "Filename for upload: $fn"); |
if (($fn) && ($fn!~/\/$/)) { |
if (($fn) && ($fn!~/\/$/)) { |
$r->print('<form action=/adm/upload method=post>'. |
$r->print('<form action="/adm/upload" method="post">'. |
'<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.'" />'. |
'<input type=hidden name=uploaduname value="'.$uname.'">'. |
'<input type="hidden" name="uploaduname" value="'.$uname. |
&mt('Store uploaded file as ')."<tt>/priv/$uname/</tt>". |
'" />'.&mt('Store uploaded file as '). |
'<input type=text size=50 name=filename value="'.$fn.'"><br>'. |
"<tt>/priv/$uname/</tt>". |
'<input type=submit value="'.&mt('Store').'"></form>'); |
'<input type="text" size="50" name="filename" value="'.$fn. |
|
'" /><br />'. |
|
'<input type="submit" value="'.&mt('Store').'" /></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')) { |
$r->print('<font color=red>'.&mt('The extension on this file,'). |
$r->print('<font color="red">'.&mt('The extension on this file,'). |
' "'.$1.'"'.&mt(', is reserved internally by LON-CAPA.'). |
' "'.$1.'"'.&mt(', is reserved internally by LON-CAPA.'). |
' <br \>'.&mt('Please change the extension.').'</font>'); |
' <br />'.&mt('Please change the extension.').'</font>'); |
} elsif($fn=~/\.(\w+)$/ && |
} elsif($fn=~/\.(\w+)$/ && |
!defined(&Apache::loncommon::fileembstyle($1))) { |
!defined(&Apache::loncommon::fileembstyle($1))) { |
$r->print('<font color=red>'.&mt('The extension on this file,'). |
$r->print('<font color="red">'.&mt('The extension on this file,'). |
' "'.$1.'"'.&mt(', is not recognized by LON-CAPA.'). |
' "'.$1.'"'.&mt(', is not recognized by LON-CAPA.'). |
' <br \>'.&mt('Please change the extension.'). |
' <br />'.&mt('Please change the extension.'). |
'</font>'); |
'</font>'); |
} |
} |
} else { |
} else { |
$r->print('<font color=red>'.&mt('Illegal filename.').'</font>'); |
$r->print('<font color="red">'.&mt('Illegal filename.').'</font>'); |
} |
} |
} else { |
} else { |
$r->print('<font color=red>'.&mt('No upload file specified.').'</font>'); |
$r->print('<font color="red">'.&mt('No upload file specified.').'</font>'); |
} |
} |
} |
} |
|
|
Line 141 sub phasetwo {
|
Line 143 sub phasetwo {
|
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=/adm/upload method=post>'. |
$r->print('<form action="/adm/upload" method="post">'. |
&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('exists. Overwrite?').' '. |
&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').'" /></form>'); |
} else { |
} else { |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
my $source=$r->dir_config('lonDaemons').'/tmp/'.$datatoken.'.tmp'; |
# Check for bad extension and disallow upload |
# Check for bad extension and disallow upload |
Line 155 sub phasetwo {
|
Line 157 sub phasetwo {
|
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
(&Apache::loncommon::fileembstyle($1) eq 'hdn')) { |
$r->print(&mt('File').' <tt>'.$fn.'</tt> '. |
$r->print(&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('could not be copied.').'<br />'. |
&mt('could not be copied.').'<br />'. |
'<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('<p><font size=+2><a href="'.$path.'">'. |
$r->print('<p><font size=+2><a href="'.$path.'">'. |
Line 164 sub phasetwo {
|
Line 166 sub phasetwo {
|
!defined(&Apache::loncommon::fileembstyle($1))) { |
!defined(&Apache::loncommon::fileembstyle($1))) { |
$r->print(&mt('File').' <tt>'.$fn.'</tt> '. |
$r->print(&mt('File').' <tt>'.$fn.'</tt> '. |
&mt('could not be copied.').'<br />'. |
&mt('could not be copied.').'<br />'. |
'<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('<p><font size=+2><a href="'.$path.'">'. |
$r->print('<br /><font size="+2"><a href="'.$path.'">'. |
&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>'); |
'</font><br />'); |
$r->print('<p><font size=+2><a href="'.$path.'">'. |
$r->print('<font size="+2"><a href="'.$path.'">'. |
&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---. |
$r->print(&mt('File copied.')); |
$r->print(&mt('File copied.')); |
$r->print('<p><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('<p><font size=+2><a href="'.$path.'">'. |
$r->print('<font size="+2"><a href="'.$path.'">'. |
&mt('Back to Directory').'</a></font>'); |
&mt('Back to Directory').'</a></font><br />'); |
} else { |
} else { |
$r->print('Failed to copy: '.$!); |
$r->print('Failed to copy: '.$!); |
$r->print('<p><font size=+2><a href="'.$path.'">'. |
$r->print('<br /><font size="+2"><a href="'.$path.'">'. |
&mt('Back to Directory').'</a></font>'); |
&mt('Back to Directory').'</a></font>'); |
} |
} |
} |
} |
} else { |
} else { |
$r->print('<font size=+1 color=red>'. |
$r->print('<font size="+1" color="red">'. |
&mt('Please use browser "Back" button and pick a filename'). |
&mt('Please use browser "Back" button and pick a filename'). |
'</font><p>'); |
'</font><br />>'); |
} |
} |
} else { |
} else { |
$r->print('<font size=+1 color=red>'. |
$r->print('<font size=+1 color=red>'. |