mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-21 20:28:41 +00:00
fix(contest/resources): send file as attachment
This commit is contained in:
parent
b0368c76c4
commit
b23313bd4f
@ -19,12 +19,15 @@ $sub_path = UOJRequest::get('sub_path', 'is_string', '');
|
|||||||
if ($sub_path) {
|
if ($sub_path) {
|
||||||
$filepath = realpath(UOJContest::cur()->getResourcesPath(rawurldecode($sub_path)));
|
$filepath = realpath(UOJContest::cur()->getResourcesPath(rawurldecode($sub_path)));
|
||||||
$realbasepath = realpath(UOJContest::cur()->getResourcesPath());
|
$realbasepath = realpath(UOJContest::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 = !UOJContest::cur()->userCanManage(Auth::user());
|
$global_readonly = !UOJContest::cur()->userCanManage(Auth::user());
|
||||||
|
Loading…
Reference in New Issue
Block a user