mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-08 14:18:40 +00:00
fix(web/contest/problem): disable testdata download during contest
This commit is contained in:
parent
6eca1a3c5e
commit
79d6cd8a38
@ -25,7 +25,7 @@ switch (UOJRequest::get('type')) {
|
||||
UOJProblem::init(UOJRequest::get('id')) || UOJResponse::page404();
|
||||
|
||||
if (!$auth) {
|
||||
UOJProblem::cur()->userCanDownloadTestData(Auth::user()) || UOJResponse::page404();
|
||||
UOJProblem::cur()->userCanDownloadTestData(Auth::user()) || UOJResponse::page403();
|
||||
}
|
||||
|
||||
$file_name = UOJProblem::cur()->getDataZipPath();
|
||||
|
@ -39,7 +39,7 @@ class UOJBlog {
|
||||
}
|
||||
|
||||
if ($problem_id = $this->getSolutionProblemId()) {
|
||||
$contests = UOJContest::queryContestsHasProblem($problem_id);
|
||||
$contests = UOJContest::queryContestsHasProblem(UOJProblem::query($problem_id));
|
||||
|
||||
foreach ($contests as $contest) {
|
||||
if ($contest->userHasRegistered($user) && $contest->progress() <= CONTEST_IN_PROGRESS) {
|
||||
|
@ -281,7 +281,23 @@ class UOJProblem {
|
||||
}
|
||||
|
||||
public function userCanDownloadTestData(array $user = null) {
|
||||
return $this->userCanManage($user) || UOJUser::checkPermission($user, 'problems.download_testdata');
|
||||
if ($this->userCanManage($user)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!UOJUser::checkPermission($user, 'problems.download_testdata')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$contests = UOJContest::queryContestsHasProblem($this);
|
||||
|
||||
foreach ($contests as $contest) {
|
||||
if ($contest->userHasRegistered($user) && $contest->progress() <= CONTEST_IN_PROGRESS) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function preHackCheck(array $user = null) {
|
||||
|
Loading…
Reference in New Issue
Block a user