Exemple #1
0
 public function Start()
 {
     $request = jf::$BaseRequest;
     if (jf::CurrentUser()) {
         // User is logged in, check if the user is authorized
         if (jf::Check("view_contest_chal")) {
             if (($activeContest = \webgoat\ContestDetails::getActive()) !== null) {
                 $this->ContestName = $activeContest[0]['ContestName'];
                 $startTime = $activeContest[0]['StartTimestamp'];
                 $currentTime = time();
                 if ($currentTime < $startTime) {
                     $this->TimeRemaining = $startTime - $currentTime;
                 } else {
                     $challenges = \webgoat\ContestChallenges::getByContestID();
                     if (count($challenges) == 0) {
                         $this->Error = "Currently there are no challenges in this contest";
                     } else {
                         $this->Challenges = $challenges;
                     }
                 }
             } else {
                 $this->Error = "Currently there is no active contest. Check back later!!";
             }
             return $this->Present();
         } else {
             // User is not authorized
             $this->Redirect(SiteRoot);
         }
     } else {
         // User is not logged in
         $this->Redirect(jf::url() . "/user/login?return=/{$request}");
     }
 }
 public function Start()
 {
     if (jf::CurrentUser()) {
         if (jf::Check("contest")) {
             if (isset($_POST['challenge']) && isset($_POST['name']) && isset($_POST['points']) && isset($_POST['flag'])) {
                 $hashedFlag = md5($_POST['flag']);
                 $activeContest = \webgoat\ContestDetails::getActive();
                 $activeContestID = $activeContest[0]['ID'];
                 $data = array('ContestID' => $activeContestID, 'ChallengeName' => $_POST['challenge'], 'NameToDisplay' => $_POST['name'], 'Points' => $_POST['points'], 'CorrectFlag' => $hashedFlag);
                 \webgoat\ContestChallenges::add($data);
                 echo json_encode(array('status' => true, 'message' => 'Challenge successfully added'));
                 return true;
             }
         }
     }
 }
Exemple #3
0
 public function Start()
 {
     if (jf::CurrentUser()) {
         if (jf::Check("contest")) {
             // User is authorized
             if (isset($_POST['contest_submit'])) {
                 // Request to store the contest in the database
                 $this->addContest();
             }
             if (\webgoat\ContestDetails::isActivePresent()) {
                 // If an active contest is present
                 $contestDetails = \webgoat\ContestDetails::getActive();
                 $contestChallenges = \webgoat\ContestChallenges::getByContestID($contestDetails[0]['ID']);
                 $contestUsers = \webgoat\ContestUsers::getAll();
                 $this->ContestName = $contestDetails[0]['ContestName'];
                 $this->ContestStart = date("d/m/Y h:i:s A", $contestDetails[0]['StartTimestamp']);
                 $this->ContestEnd = date("d/m/Y h:i:s A", $contestDetails[0]['EndTimestamp']);
                 $this->UserCount = count($contestUsers);
                 $this->ChallengeCount = count($contestChallenges);
                 $this->Challenges = $contestChallenges;
                 $this->insertNewChallenges();
             } else {
                 // Show the option to start a contest
                 $this->noActiveContest = true;
             }
             return $this->Present();
         } else {
             // User is not authorized
             $this->Redirect(SiteRoot);
             // Redirect to home page
         }
     } else {
         // User is not authenticated
         $this->Redirect(jf::url() . "/user/login?return=/" . jf::$BaseRequest);
     }
 }