Skip to content
This repository has been archived by the owner on Mar 3, 2020. It is now read-only.

Commit

Permalink
Fixed 2 bugs. One that allows you to grab attachments even when level…
Browse files Browse the repository at this point in the history
… is off. Other allows you to resubmit the answer which will update the timestamp on when submitted.
  • Loading branch information
v1ncenth committed Sep 14, 2018
1 parent eb06ec4 commit 4ec9b6b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/controllers/ajax/GameAjaxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ protected function getActions(): array<string> {
// Check if answer is valid
} else if ($check_answer) {
// Give points and update last score for team
await \HH\Asio\va(
Level::genScoreLevel($level_id, SessionUtils::sessionTeam()),
Team::genLastScore(SessionUtils::sessionTeam()),
);
$check_answered = await Level::genScoreLevel($level_id, SessionUtils::sessionTeam());
if (!$check_answered) {
return Utils::ok_response('Double score for you! SIKE!', 'game');
}
return Utils::ok_response('Success', 'game');
} else {
await FailureLog::genLogFailedScore(
Expand Down
3 changes: 2 additions & 1 deletion src/data/attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ class AttachmentDataController extends DataController {
if (intval($attachment_id) !== 0) {
$attachment_exists =
await Attachment::genCheckExists(intval($attachment_id));
if ($attachment_exists === true) {
$active = await Attachment::checkActive(intval($attachment_id));
if ($attachment_exists === true && $active === true) {
$attachment = await Attachment::gen(intval($attachment_id));
$filename = $attachment->getFilename();

Expand Down
13 changes: 13 additions & 0 deletions src/models/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,19 @@ public function getLevelId(): int {
}
}

public static async function checkActive(
int $attachment_id
): Awaitable<bool> {
$db = await self::genDb();
$result = await $db->queryf('SELECT active FROM levels
WHERE id=(SELECT level_id FROM attachments WHERE id=%d) AND active = 1', $attachment_id);
$rows = $result->numRows();
if ($rows) {
return true;
}
return false;
}

public static async function genCheckExists(
int $attachment_id,
bool $refresh = false,
Expand Down

0 comments on commit 4ec9b6b

Please sign in to comment.