コード例 #1
0
 /**
  * Get a value from the database from this specific guess.
  *
  * @param string $columnName The column name.
  *
  * @return mixed The value.
  *
  * @throws Exception Throws if an error occurred.
  */
 private function getDatabaseValue($columnName)
 {
     // Prepare a query for the database to list guesses with this ID
     $statement = Database::getPDO()->prepare('SELECT ' . $columnName . ' FROM ' . GuessManager::getDatabaseTableName() . ' WHERE guess_id=:id');
     $statement->bindParam(':id', $this->id, PDO::PARAM_INT);
     // Execute the prepared query
     if (!$statement->execute()) {
         throw new Exception('Failed to query the database.');
     }
     // Return the result
     $data = $statement->fetch(PDO::FETCH_ASSOC);
     return $data[$columnName];
 }
コード例 #2
0
 /**
  * Get the number of guesses left for this client.
  *
  * @return int Number of guesses left.
  *
  * @throws Exception Throws if an error occurred.
  */
 public static function getClientGuessesLeft()
 {
     return max(GuessManager::getMaximumGuessesPerClient() - self::getClientGuessCount(), 0);
 }
コード例 #3
0
        <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>

    <?php 
PageFooterBuilder::create()->build();
?>
</div>
<?php 
// Include the page bottom
require_once 'bottom.php';
コード例 #4
0
} else {
    ?>
                <p><i>Je hebt nog geen schattingen ingestuurd.</i></p>
            <?php 
}
// Check whether this client has any guesses left, if so, show the entry button
if (GuessManager::hasClientGuessesLeft()) {
    ?>
                <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 
    }
    ?>
                </fieldset>
                <?php 
}
?>
        </div>

        <?php 
PageFooterBuilder::create()->build();
?>
    </div>
コード例 #5
0
<?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'));
コード例 #6
0
<?php

use app\guess\Guess;
use app\guess\GuessManager;
// Initialize the ajax scripts
require_once 'ajaxinit.php';
// Get all guesses
$guesses = GuessManager::getGuesses();
$clientGuesses = GuessManager::getClientGuesses();
// Create an array of guesses
$guessesArray = array();
$clientGuessesArray = array();
// Add each guess to the data array
foreach ($guesses as $guess) {
    // Validate the guess instance
    if (!$guess instanceof Guess) {
        returnError("Internal error occurred");
    }
    // Append the guess
    $guessesArray[] = array('id' => $guess->getId(), 'firstName' => $guess->getFirstName(), 'weight' => $guess->getWeight());
}
// Add each guess from this client to the data array
foreach ($clientGuesses as $guess) {
    // Validate the guess instance
    if (!$guess instanceof Guess) {
        returnError("Internal error occurred");
    }
    // Append the guess
    $clientGuessesArray[] = array('id' => $guess->getId(), 'firstName' => $guess->getFirstName(), 'lastName' => $guess->getLastName(), 'weight' => $guess->getWeight());
}
// Return the result with JSON
コード例 #7
0
echo __('pageStatus', 'currentStatusShownBelow');
?>
</p><br />

        <table class="ui-responsive list-table">
            <tr>
                <td><?php 
echo __('general', 'database');
?>
</td>
                <td><span style="color: green;">Connected!</span></td>
            </tr>
            <tr>
                <td>Schattingen</td>
                <td><?php 
echo GuessManager::getGuessCount();
?>
</td>
            </tr>
            <tr>
                <td>Sessie</td>
                <td><?php 
echo getSessionKey();
?>
</td>
            </tr>
            <tr>
                <td><?php 
echo __('pageStatus', 'uptime');
?>
</td>