Example #1
0
function draw_cards(&$hand, &$deck)
{
    if (get_session_value(FINAL_KEY)) {
        return;
    }
    for ($card = 0; $card < HAND_CARDS; $card++) {
        $draw = $_POST[CARD_KEY . $card];
        if ($draw === DRAW) {
            $hand[$card] = $deck[0];
            $deck = array_slice($deck, 1);
        }
    }
    $type = hand_type($hand);
    $payoffs = PAYOFFS;
    set_session_value(BALANCE_KEY, get_session_value(BALANCE_KEY) + $payoffs[$type]);
    set_session_value(HAND_KEY, $hand);
    set_session_value(DECK_KEY, $deck);
    set_session_value(FINAL_KEY, TRUE);
    save_session();
}
Example #2
0
function set_loggedin($bool)
{
    global $session_data, $_SESSION, $_SERVER, $expire_time, $sk, $iv, $hmac_algo, $debugtrace;
    $debugtrace .= '<br>set_loggedin val=' . ($bool ? 'true' : 'false');
    $session_data['loggedin'] = $bool;
    $debugtrace .= '<br>set_loggedin save';
    save_session();
}
Example #3
0
            }
            fputcsv($fd, array('player' => $player, 'session' => serialize($session)), ';');
            flock($fd, LOCK_UN);
        }
        fclose($fd);
    }
}
function select_session($player)
{
    $session = get_database();
    if (isset($session[$player])) {
        return $session[$player];
    }
}
if (isset($_POST['player']) && isset($_SESSION['game']) && isset($_POST['submit'])) {
    if (!file_exists('save.csv')) {
        touch('save.csv');
    }
    switch ($_POST['submit']) {
        case 'save':
            save_session($_SESSION['game'], $_POST['player']);
            break;
        case 'getall':
            get_jsondb();
            break;
        case 'delete':
            delete_session(get_database(), $_POST['player']);
        case 'select':
            return select_session($_POST['player']);
    }
}