Exemplo n.º 1
0
<?php

header('Content-Type: application/json');
echo json_encode(getChallenge());
function getChallenge()
{
    $challenge = array();
    if ($categories = getCategories()) {
        // Shuffle the categories.
        shuffle($categories);
        // retrieve the top four.
        $categories = array_slice($categories, 0, 4);
        // grab the images from the first.
        shuffle($categories[0]['images']);
        // use the first image.
        $challenge['image'] = $categories[0]['images'][0];
        // Build the answer.
        $challenge['answer'] = array('id' => md5($challenge['image']['id'] . $categories[0]['id']), 'role' => $categories[0]['role'], 'title' => $categories[0]['title'], 'source' => $challenge['image']['source'], 'correct' => getResponse('correct'), 'incorrect' => getResponse('incorrect'));
        // Build the options.
        shuffle($categories);
        foreach ($categories as $category) {
            $challenge['options'][] = array('id' => $category['id'], 'title' => $category['title']['name'] . ($category['year'] ? ' (' . $category['year'] . ')' : ''));
        }
    }
    return (object) $challenge;
}
function getResponse($type = 'correct')
{
    $responses = array('correct' => array('Penglings', 'Jolly Good', 'Elementry', 'Smashing', 'Ha-Ha', 'Good Show', 'Quite Right'), 'incorrect' => array('Boring', 'Simpleton', 'How Drole', 'I dare say', 'Dear God', 'Why I never', 'The nerve', 'How dare you', 'Bloody hell'));
    shuffle($responses[$type]);
    return $responses[$type][0];
Exemplo n.º 2
0
     $challenge = getChallenge($_SESSION['puzzleID']);
     include 'view/Damion/Message2.php';
 } else {
     if ($action == '5') {
         $_SESSION['puzzleID'] = 5;
         $challenge = getChallenge($_SESSION['puzzleID']);
         include 'view/Damion/Message3.php';
     } else {
         if ($action == '6') {
             $_SESSION['puzzleID'] = 6;
             $challenge = getChallenge($_SESSION['puzzleID']);
             include 'view/d1gg3r/Message1.php';
         } else {
             if ($action == '7') {
                 $_SESSION['puzzleID'] = 7;
                 $challenge = getChallenge($_SESSION['puzzleID']);
                 include 'view/d1gg3r/Message2.php';
             } else {
                 if ($action == 'unlocked') {
                     $unlocked = getUnlocked($_SESSION['id']);
                     include 'view/unlockedSplash.php';
                 } else {
                     if ($action == 'puzzles') {
                         include 'view/puzzleSplash.php';
                     } else {
                         if ($action == 'check_solution') {
                             $text = filter_input(INPUT_GET, 'answer');
                             $answer = strtolower($text);
                             $value = getAnswer($_SESSION['puzzleID']);
                             if ($answer == $value[0]) {
                                 updateUnlocked($_SESSION['id'], $_SESSION['puzzleID']);