<?php

use app\guess\GuessManager;
use app\util\AccountUtils;
// Initialize the ajax scripts
require_once 'ajaxinit.php';
// Make sure all parameters are set
if (!isset($_GET['guess_first_name']) || !isset($_GET['guess_last_name']) || !isset($_GET['guess_mail']) || !isset($_GET['guess_weight'])) {
    returnError("Received invalid data. Some parameters are missing.");
}
// Get all parameters
$firstName = $_GET['guess_first_name'];
$lastName = $_GET['guess_last_name'];
$mail = $_GET['guess_mail'];
$weight = $_GET['guess_weight'];
// Make sure the full name is valid
if (!AccountUtils::isValidName($firstName) || !AccountUtils::isValidName($lastName)) {
    returnError("Ongeldige naam.");
}
// Make sure the mail is valid
if (!AccountUtils::isValidMail($mail)) {
    returnError("Ongeldig E-mail adres.");
}
// TODO: Make sure the guessed value is valid!
if (!GuessManager::hasClientGuessesLeft()) {
    returnError("Maximum aantal schattingen overschreden.");
}
// Add the guess
$guess = GuessManager::createGuess($firstName, $lastName, $mail, $weight);
// Return the result with JSON
returnJson(array('result' => 'success'));
Example #2
0
                Welkom bij de Mohicanen NJO van 2016.<br />
                <br />
                Weet jij hoe zwaar deze taart is?<br />
                Stuur jouw schatting in en maak kans op het winnen van deze taart.
            </p>
        </div>

        <br />

        <fieldset data-role="controlgroup" data-type="vertical" class="ui-shadow ui-corner-all">
            <?php 
if (!GuessManager::hasClientGuesses()) {
    ?>
                <a href="guess.php" class="ui-btn ui-icon-plus ui-btn-icon-left">Schatting insturen</a>
            <?php 
} elseif (GuessManager::hasClientGuessesLeft()) {
    ?>
                <a href="guess.php" class="ui-btn ui-icon-plus ui-btn-icon-left">Schatting voor een ander insturen</a>
            <?php 
}
?>
            <a href="overview.php" class="ui-btn ui-icon-info ui-btn-icon-left">Overzicht bekijken</a>
            <?php 
if (GuessManager::hasClientGuesses()) {
    ?>
                <a href="myguesses.php" class="ui-btn ui-icon-bullets ui-btn-icon-left">Mijn schattingen</a>
            <?php 
}
?>
        </fieldset>
    </div>
Example #3
0
// Include the page top
require_once 'top.php';
// Get the register step
$guessStep = 1;
if (isset($_GET['guess_step'])) {
    // Get the value
    $registerStepValue = $_GET['guess_step'];
    // Make sure the value is an integer, or show an error page instead
    if (!is_numeric($registerStepValue)) {
        showErrorPage();
    }
    // Set the register step
    $guessStep = (int) $registerStepValue;
}
// Make sure the user isn't guessing more than it's allowed to
if (!GuessManager::hasClientGuessesLeft() && $guessStep != 6) {
    showErrorPage('Je kunt geen schattingen meer insturen via dit apparaat. Je hebt het maximum van <b>' . GuessManager::getMaximumGuessesPerClient() . '</b> schattingen ingestuurd.', 'Rustig aan!');
}
if ($guessStep == 1) {
    if (!GuessManager::hasClientGuesses() || isset($_GET['ignoreWarning'])) {
        ?>
        <div data-role="page" id="page-guess" data-unload="false">
            <?php 
        PageHeaderBuilder::create("Schatting insturen")->setBackButton('index.php')->build();
        ?>

            <div data-role="main" class="ui-content">
                <p>
                    Vul hier onder uw voor- en achternaam in om mee te doen met het raden van het gewicht van de taart.<br />
                    <br />
                    <i><?php