Error: could not connect to database. Please try again later.

"; return; } // Untaint all of our incoming variables preg_match('{/([^/]+)/answer/}',$_SERVER['SCRIPT_NAME'], $matches); $path = $matches[1]; $name = preg_replace('/[^\w\s]+/','',$_POST['name']); $phone = $_POST['phone']; $team_name = $_SERVER['REMOTE_USER']; // Find the puzzle $puzzle_query = pg_query_params("SELECT Puzzles.puzzle_id, title, captain FROM Unlocked JOIN Puzzles USING(puzzle_id) JOIN Teams USING(team_name) WHERE team_name = $1 AND path = $2 AND type IN ('puzzle','event','other')", array($team_name,$path)); if (!$puzzle_query or pg_num_rows($puzzle_query) != 1) { echo "

We couldn't find that puzzle. Please call HQ if you have questions.

"; return; } $row = pg_fetch_array($puzzle_query); $puzzle_id = $row['puzzle_id']; $title = $row['title']; $captain = $row['captain']; // Check that we don't already have a puzzle call request for this $puzzle_query = pg_query_params("SELECT * FROM CallRequests WHERE puzzle_id = $1 and team_name=$2", array($puzzle_id,$team_name)); if ($row = pg_fetch_array($puzzle_query)) { header("Location: /puzzles/queue.php"); return; } // Previous guesses for this puzzle: $result = pg_query_params("SELECT answer,to_char(at,'FMDay, HH24:MI') as time FROM CheckedAnswers WHERE puzzle_id=$1 and team_name=$2 ORDER BY at", array($puzzle_id,$team_name)); $guesses = pg_fetch_all($result); // Show a (very fake) input form. This should eventually go away if (!$_POST['Call']) { ?> Check answer: <?= $title ?>

Check Answer

You are about to submit a request for ''