Example #1
0
}
$p = $_GET['p'];
$db = new Database();
if (isset($_GET['k'])) {
    $k = $_GET['k'];
    if (!$db->checkKey($k)) {
        unset($k);
    }
}
if (isset($_GET['s']) && isset($k)) {
    $s = $db->limitScore((double) $_GET['s']);
    $s = $db->processScore($p, $s);
    echo json_encode(array('p' => $p, 'score' => $s));
    exit;
} else {
    $s = $db->getScore($p);
}
$messages = array('not_logged_in' => array('class' => 'warning', 'text' => 'You need to login before voting. Click <a href="#login">here</a> to login.'), 'invalid_key' => array('class' => 'error', 'text' => 'Your account could not be activated. Click <a href="#login">here</a> to re-activate.'), 'vote_saved' => array('class' => 'success', 'text' => 'Your vote has been saved. Thank you!'), 'already_voted' => array('class' => 'information', 'text' => 'You\\\'ve voted for this package.'), 'vote_changed' => array('class' => 'success', 'text' => 'Your vote has been changed.'));
$voted = false;
if (isset($k)) {
    if ($db->hasVoted($p)) {
        $voted = true;
        $status = 'vote_changed';
    } else {
        $status = 'vote_saved';
    }
} else {
    if (isset($_GET['k'])) {
        $status = 'invalid_key';
    } else {
        $status = 'not_logged_in';