version 1.3, 2016/02/17 00:05:14
|
version 1.5, 2016/12/13 21:37:35
|
Line 44 sub handler {
|
Line 44 sub handler {
|
$request->content_type('text/plain'); |
$request->content_type('text/plain'); |
|
|
# path should be in the form "/daxeopen/priv/..." |
# path should be in the form "/daxeopen/priv/..." |
# or ^/daxeopen/uploaded/[^/]+/[^/]+/supplemental/.*html?$ |
# or ^/daxeopen/uploaded/[^/]+/[^/]+/.*html?$ |
my $path = $env{'form.path'}; |
my $path = $env{'form.path'}; |
$path =~ s/^\/daxeopen//; |
$path =~ s/^\/daxeopen//; |
|
|
Line 60 sub handler {
|
Line 60 sub handler {
|
} |
} |
} |
} |
} |
} |
} elsif ($path =~ m|^/uploaded/[^/]+/[^/]+/supplemental/|) { |
} elsif ($path =~ m|^/uploaded/[^/]+/[^/]+/|) { |
if ($env{'user.name'} ne '' && $env{'user.domain'} ne '' && $env{'request.course.id'}) { |
if ($env{'user.name'} ne '' && $env{'user.domain'} ne '' && $env{'request.course.id'}) { |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
if ($path =~ m|^/uploaded/\Q$cdom\E/\Q$cnum\E/supplemental/| && $path !~ /\.\./) { |
if ($path =~ m|^/uploaded/\Q$cdom\E/\Q$cnum\E/| && $path !~ /\.\./) { |
if (&Apache::lonnet::allowed('mdc', $env{'request.course.id'})) { |
if (&Apache::lonnet::allowed('mdc', $env{'request.course.id'})) { |
$allowed = 1; |
$allowed = 1; |
} |
} |
Line 82 sub handler {
|
Line 82 sub handler {
|
|
|
my $contents = $env{'form.file'}; |
my $contents = $env{'form.file'}; |
|
|
try { |
my $mode; |
$contents = &Apache::xml_to_loncapa::convert_file($contents); |
if ($path =~ /\.(task|problem|exam|quiz|assess|survey|library|xml|html|htm|xhtml|xhtm)$/) { |
} catch { |
try { |
$request->print("error\nconvert failed for $path: $_"); |
$contents = &Apache::xml_to_loncapa::convert_file($contents); |
return OK; |
} catch { |
}; |
$request->print("error\nconvert failed for $path: $_"); |
|
return OK; |
|
}; |
|
$mode = '>:encoding(UTF-8)'; |
|
} else { |
|
$mode = '>'; |
|
} |
|
|
my $filebak = $newpath.".bak"; |
my $filebak = $newpath.".bak"; |
if (-e $newpath) { |
if (-e $newpath) { |
copy($newpath, $filebak); # errors ignored |
copy($newpath, $filebak); # errors ignored |
} |
} |
open my $out, '>:encoding(UTF-8)', $newpath; |
open my $out, $mode, $newpath; |
print $out $contents; |
print $out $contents; |
close $out; |
close $out; |
|
|