fix(problem/resources): send files as attachment

This commit is contained in:
Baoshuo Ren 2023-11-12 15:46:42 +08:00
parent 0098031da1
commit b0368c76c4
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

View File

@ -35,12 +35,15 @@ $sub_path = UOJRequest::get('sub_path', 'is_string', '');
if ($sub_path) {
$filepath = realpath(UOJProblem::cur()->getResourcesPath(rawurldecode($sub_path)));
$realbasepath = realpath(UOJProblem::cur()->getResourcesPath());
$filename = basename($filepath);
if (!strStartWith($filepath, $realbasepath)) {
UOJResponse::page406();
}
UOJResponse::xsendfile($filepath);
UOJResponse::xsendfile($filepath, [
'attachment' => $filename,
]);
}
$global_readonly = !UOJProblem::cur()->userCanManage(Auth::user());