private function insertNewChallenges() { $allChallenges = \webgoat\ContestChallengeScanner::run(); $result = array(); foreach ($allChallenges as $challenge) { if (($details = \webgoat\ContestChallenges::getByName($challenge)) === null) { array_push($result, $challenge); } } $this->newChallenges = $result; }
private function addSubmission($challenge) { $challengeDetails = \webgoat\ContestChallenges::getByName($challenge); $flag = $_POST['flag']; $ip = \jf\HttpRequest::IP(); $challengeID = $challengeDetails[0]['ID']; $userID = jf::CurrentUser(); $data = array('UserID' => $userID, 'ChallengeID' => $challengeID, 'Flag' => $flag, 'IP' => $ip, 'timestamp' => time()); \webgoat\ContestSubmissions::add($data); \webgoat\ContestChallenges::incrementTotalAttempts($challenge); if (\webgoat\ContestSubmissions::evaluate($challengeID, $flag)) { $this->Submission = 1; // Increment complete count \webgoat\ContestChallenges::incrementCompletedCount($challenge); } else { $this->Submission = 0; } }