mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-21 21:48:42 +00:00
fix(problem/resources): send files as attachment
This commit is contained in:
parent
0098031da1
commit
b0368c76c4
@ -35,12 +35,15 @@ $sub_path = UOJRequest::get('sub_path', 'is_string', '');
|
|||||||
if ($sub_path) {
|
if ($sub_path) {
|
||||||
$filepath = realpath(UOJProblem::cur()->getResourcesPath(rawurldecode($sub_path)));
|
$filepath = realpath(UOJProblem::cur()->getResourcesPath(rawurldecode($sub_path)));
|
||||||
$realbasepath = realpath(UOJProblem::cur()->getResourcesPath());
|
$realbasepath = realpath(UOJProblem::cur()->getResourcesPath());
|
||||||
|
$filename = basename($filepath);
|
||||||
|
|
||||||
if (!strStartWith($filepath, $realbasepath)) {
|
if (!strStartWith($filepath, $realbasepath)) {
|
||||||
UOJResponse::page406();
|
UOJResponse::page406();
|
||||||
}
|
}
|
||||||
|
|
||||||
UOJResponse::xsendfile($filepath);
|
UOJResponse::xsendfile($filepath, [
|
||||||
|
'attachment' => $filename,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$global_readonly = !UOJProblem::cur()->userCanManage(Auth::user());
|
$global_readonly = !UOJProblem::cur()->userCanManage(Auth::user());
|
||||||
|
Loading…
Reference in New Issue
Block a user