예제 #1
0
function ArcadeV1Submit(&$game, $session_info)
{
    if (isset($_POST['score']) && is_numeric($_POST['score'])) {
        $score = (double) $_POST['score'];
    } else {
        return false;
    }
    $cheating = CheatingCheck();
    return array('cheating' => $cheating, 'score' => $score, 'start_time' => $session_info['start_time'], 'duration' => time() - $session_info['start_time'], 'end_time' => time());
}
예제 #2
0
function ArcadeVbSubmit(&$game, $session)
{
    global $scripturl, $context, $modSettings, $smcFunc;
    $diff = microtime_float() - $session['end_time'];
    if ($diff > 4500 || !empty($session['ping'])) {
        return false;
    }
    $session['ping'] = true;
    $cheating = CheatingCheck();
    unset($_SESSION['arcade_play_vb3g'][$_POST['id']]);
    return array('cheating' => $cheating, 'score' => $session['score'], 'start_time' => $session['start_time'], 'duration' => round($session['end_time'] - $session['start_time'], 0), 'end_time' => round($session['end_time'], 0));
}
예제 #3
0
function ArcadeIBP32Submit(&$game, $session_info)
{
    global $scripturl, $txt, $db_prefix, $modSettings, $context, $smcFunc;
    list($hash1, $hash2, $endTime) = $_SESSION['arcade']['ibp_verify'];
    // No longer needed
    unset($_SESSION['arcade']['ibp_verify']);
    // How long it took? Must be more than 0 secods and less than 7 seconds (same as in IPB arcade)
    $time_taken = microtime_float() - $endTime;
    if ($time_taken < 0 || $time_taken > 7) {
        return false;
    }
    // Was score even submitted
    if (isset($_POST['gscore']) && is_numeric($_POST['gscore'])) {
        $score = (double) $_POST['gscore'];
    } else {
        return false;
    }
    // Check 'hash'
    if (($score * $hash1 ^ $hash2) != $_POST['enscore']) {
        return false;
    }
    $cheating = CheatingCheck();
    return array('cheating' => $cheating, 'score' => $score, 'start_time' => $session_info['start_time'], 'duration' => round($endTime - $session_info['start_time'], 0), 'end_time' => round($endTime, 0));
}
예제 #4
0
function ArcadeSubmit()
{
    global $smcFunc, $scripturl, $txt, $arcSettings, $context;
    // if you cant save...we do nothing theres no point!!!
    if (allowedTo('arcade_submit')) {
        //what type of game is it?
        //normal ipb game
        if (isset($_REQUEST['gametype']) && $_REQUEST['gametype'] == 2) {
            $theGame = $_POST['gname'];
            $theScore = isset($_POST['gscore']) && is_numeric($_POST['gscore']) ? (double) $_POST['gscore'] : '';
        } elseif (isset($_REQUEST['gametype']) && $_REQUEST['gametype'] == 3) {
            $theGame = isset($_POST['gname']) ? $_POST['gname'] : $_SESSION['arcade']['ibp']['gamename'];
            $theScore = isset($_POST['gscore']) && is_numeric($_POST['gscore']) ? (double) $_POST['gscore'] : '';
            $time_taken = microtime_float() - $_SESSION['arcade']['ibp']['verify'][2];
            if ($time_taken < 0 || $time_taken > 7) {
                unset($_SESSION['arcade']['play']);
                fatal_lang_error('arcade_submit_ibp_error_time');
            }
            if ($_POST['enscore'] != ($theScore * $_SESSION['arcade']['ibp']['verify'][0] ^ $_SESSION['arcade']['ibp']['verify'][1])) {
                unset($_SESSION['arcade']['play']);
                fatal_lang_error('arcade_submit_ibp_error_check');
            }
        } elseif (isset($_REQUEST['gametype']) && $_REQUEST['gametype'] == 4) {
            $result = $smcFunc['db_query']('', '
				SELECT game , score
				FROM {db_prefix}arcade_v3temp
				WHERE id = {int:game}', array('game' => $_POST['id']));
            $tempGame = $smcFunc['db_fetch_assoc']($result);
            $smcFunc['db_free_result']($result);
            if (!isset($tempGame)) {
                fatal_lang_error('arcade_submit_v3_error');
            }
            $theGame = $tempGame['game'];
            $theScore = $tempGame['score'];
        } else {
            $theGame = isset($_POST['game']) ? $_POST['game'] : '';
            $theScore = isset($_POST['score']) && is_numeric($_POST['score']) ? (double) $_POST['score'] : '';
        }
        //we should have a game and a score so lets do some checks...
        //if no game or no score or no session were gone...
        if (!isset($theGame) || !isset($theScore) || !isset($_SESSION['arcade']['play'][$theGame])) {
            unset($_SESSION['arcade']['play']);
            fatal_lang_error('arcade_submit_error_empty');
        } else {
            //do the cheat check now..
            // Preset these
            $checkPassed = false;
            $allowFail = false;
            if (!CheatingCheck($allowFail, $checkPassed)) {
                ClearSession($game);
                fatal_lang_error('arcade_submit_error_check_failed');
            }
            //does the posted game match the session game name?
            if ($theGame != $_SESSION['arcade']['play'][$theGame]['game']) {
                // No..were gone..
                unset($_SESSION['arcade']['play']);
                fatal_lang_error('arcade_game_no_match');
            }
            //we have the game name so lets check it exists and get its info..
            $game = ArcadeGameInfo(0, $theGame);
            if ($game === false) {
                // No..were gone..
                unset($_SESSION['arcade']['play']);
                fatal_lang_error('arcade_game_not_found');
            }
            //so far so good..a game that matches, a score, a valid session and a header
            $session_info =& $_SESSION['arcade']['play'][$theGame];
            //..so lets check if the session game matches the temp game in the db...
            $result = $smcFunc['db_query']('', '
				SELECT game , score , starttime
				FROM {db_prefix}arcade_v3temp
				WHERE id = {int:game}', array('game' => $session_info['db_id']));
            $tempGame = $smcFunc['db_fetch_assoc']($result);
            $smcFunc['db_free_result']($result);
            if (!isset($tempGame)) {
                fatal_lang_error('arcade_submit_v3_error');
            }
            //..yip so lets check the session info matches the temp game info in the db...
            if ((string) $session_info['starttime'] != $tempGame['starttime'] || $session_info['game'] != $tempGame['game']) {
                fatal_lang_error('arcade_submit_error1');
            }
            //if we got this far we have a valid game, a score, and a session so we can go ahead and save...
            $start_time = round($tempGame['starttime']);
            $end_time = time();
            if (isset($_SESSION['arcade']['play']['tour'])) {
                $save = ArcadeSaveScore($game, $theScore, $start_time, $end_time, $checkPassed, $_SESSION['arcade']['play']['tour'], $_SESSION['arcade']['play']['round']);
                $tour = $_SESSION['arcade']['play']['tour'];
                ClearSession();
                redirectexit('action=arcade;sa=tour;ta=join;id=' . $tour);
            } else {
                $save = ArcadeSaveScore($game, $theScore, $start_time, $end_time, $checkPassed);
                ClearSession();
                // Saving failed
                if ($save === false || $save['id_score'] === false) {
                    $_SESSION['arcade']['highscore'] = array('id' => false, 'game' => $game['internal_name'], 'score' => $theScore, 'gameid' => $game['id'], 'position' => 0, 'start' => 0, 'saved' => false, 'error' => isset($save['error']) ? $save['error'] : 'arcade_no_permission');
                } else {
                    $_SESSION['arcade']['highscore'] = array('id' => $save['id_score'], 'game' => $game['internal_name'], 'score' => $theScore, 'gameid' => $game['id'], 'position' => $save['position'], 'start' => $save['start'], 'champion' => $save['new_champion'], 'best' => $save['ownbest'], 'saved' => true);
                }
                // Go to scores list
                redirectexit('action=arcade;sa=highscore;game=' . $game['id']);
            }
        }
    } else {
        //cant save
        fatal_lang_error('arcade_no_permission');
    }
}