<?php } ?> <li onclick="location.assign('account.php')"><span class="text">Account</span></li> <li onclick="location.assign('index.php')"><span class="text">Home</span></li> <li onclick="location.assign('scoreboard.php')"><span class="text">Scoreboard</span></li> <li onclick="Data.SignOut()"><span class="text">Log Out</span></li> <?php } ?> </ul> </div> <div id="main" class="challenges"> <?php if (load_user_data('team')) { $all = load_challenges(); if (count($all) > 0) { $lst = []; foreach ($all as $chal) { $lst[] = load_full_challenge($chal); } $dsp = []; foreach ($lst as $item) { $cat = $item['category']; $dsp[$cat][] = ["points" => $item['points'], "id" => $item['challenge_id']]; } foreach ($dsp as $cname => $category) { echo "<div class=\"row\">"; echo "<div class=\"cname\">" . htmlentities($cname) . "</div>"; foreach ($category as $questiondata) { $question = htmlentities($questiondata['points']);
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME); switch ($action) { case 'fetch': if (!isset($_POST['id'])) { die("No ID provided for challenge fetch."); } echo load_challenge($_POST['id']); break; case 'fetch_full': if (!isset($_POST['id'])) { die("No ID provided for challenge fetch."); } echo json_encode(load_full_challenge($_POST['id'])); break; case 'list': $cs = load_challenges(); $qs = []; foreach ($cs as $item) { $fc = load_full_challenge($item); $qs[] = json_encode(['qtext' => $fc['qtext'], 'challenge_id' => $fc['challenge_id'], 'points' => $fc['points'], 'category' => $fc['category']]); } echo json_encode($qs); break; case 'verify': if (!(isset($_POST['id']) && isset($_POST['answer']))) { die('ID or answer not provided to verify question.'); } $id = $conn->real_escape_string($_POST['id']); $ans = $conn->real_escape_string($_POST['answer']); $hassolved = check_has_solved($id); if ($hassolved) {