'; require_once($boarddir . '/ArcadeSources/ArcadeGame.php'); if (isset($_POST['gameexit']) && is_numeric($_POST['gameexit'])) $gameexit = (int)$_POST['gameexit']; if (isset($_POST['game']) && is_numeric($_POST['game'])) $gameid = (int)$_POST['game']; else fatal_lang_error('arcade_submit_error', false); if (isset($_POST['score']) && is_numeric($_POST['score'])) $score = (float) $_POST['score']; else fatal_lang_error('arcade_submit_error', false); if (isset($_POST['time']) && is_numeric($_POST['time'])) $time = (int)$_POST['time'] > 0 ? (int)$_POST['time'] : time(); else fatal_lang_error('arcade_submit_error', false); if (isset($_POST['game_name'])) $gameName = ArcadeSpecialChars(mb_strtolower(trim($_POST['game_name']))); else fatal_lang_error('arcade_submit_error', false); $scoreid = ''; $guestName = $user_info['is_guest'] && !empty($_SESSION['playerName']) ? ArcadeSpecialChars(trim($_SESSION['playerName'])) : ''; // must surpass 3 seconds else a score loop is flagged if (empty($guestName)) { $result = $smcFunc['db_query']('', ' SELECT id_score, score, end_time, comment, id_member, id_game FROM {db_prefix}arcade_scores WHERE id_game = {int:game} AND id_member = {int:member} AND comment = "" AND UNIX_TIMESTAMP() - end_time < {int:max_exec_time} ORDER BY id_score DESC LIMIT 1', array( 'game' => $gameid, 'member' => empty($user_info['id']) || $user_info['id'] == -1 ? 0 : $user_info['id'], 'max_exec_time' => 3, ) ); } else $result = $smcFunc['db_query']('', ' SELECT id_score, score, end_time, comment, id_member, id_game, player_name FROM {db_prefix}arcade_scores WHERE id_game = {int:game} AND id_member = {int:member} AND comment = "" AND player_name = {string:name} AND UNIX_TIMESTAMP() - end_time < {int:max_exec_time} ORDER BY id_score DESC LIMIT 1', array( 'game' => $gameid, 'member' => empty($user_info['id']) || $user_info['id'] == -1 ? 0 : $user_info['id'], 'name' => $guestName, 'max_exec_time' => 3, ) ); while ($info = $smcFunc['db_fetch_assoc']($result)) $scoreid = !empty($info['id_score']) ? 'edit;score=' . $info['id_score'] . ';' : ''; $smcFunc['db_free_result']($result); $save = $user_info['is_guest'] && empty($scoreid) ? 'save' : 'highscore'; $checkFullscreen = isset($_REQUEST['sameArcadeWindow']) && $_REQUEST['sameArcadeWindow'] == 1 ? true : false; if (isset($_POST['popup']) && $_POST['popup'] == 1 && empty($checkFullscreen)) $url = $scripturl . '?action=arcade;sa=' . $save . ';pop=1;end;game=' . $gameid. ';' . $scoreid . '#commentform3'; else $url = $scripturl . '?action=arcade;sa=' . $save . ';end;game=' . $gameid. ';' . $scoreid . '#commentform3'; if (isset($_POST['gamesessid']) && !empty($_SESSION['arcade_html5_token']) && empty($_SESSION['game_' . $gameName]) && empty($scoreid)) { $gameToken = ArcadeSpecialChars($_POST['gamesessid']); $initialToken = $_SESSION['arcade_html5_token']; unset($_SESSION['arcade_html5_token']); $_SESSION['game_' . $gameName] = time(); } elseif (!empty($_SESSION['game_' . $gameName]) || !empty($scoreid)) { unset($_SESSION['game_' . $gameName], $_SESSION['arcade_html5_token']); // only submit an error in the log once per session if logging is enabled if (empty($_SESSION['game_log_' . $gameName])) { $_SESSION['game_log_' . $gameName] = time(); if (!empty($modSettings['arcade_log_scoreloop'])) log_error(sprintf($txt['arcade_submit_error_loop_log'], $gameName)); } redirectexit($url); //echo ''; exit(); fatal_lang_error('arcade_submit_error_loop', false); } else { if (isset($_POST['popup']) && $_POST['popup'] == 1 && empty($checkFullscreen)) $url = $scripturl . '?action=arcade;sa=' . $save . ';pop=1;end;game=' . $gameid. ';' . $scoreid . '#commentform3'; else $url = $scripturl . '?action=arcade;sa=' . $save . ';end;game=' . $gameid. ';' . $scoreid . '#commentform3'; redirectexit($url); exit(); fatal_lang_error('arcade_submit_error_session', false); } if ($initialToken[1] == $gameToken) { $context['game'] = getGameInfo($gameid, false); $cheating = CheatingCheck(); if (empty($cheating) && empty($_SESSION['arcade_check_' . $context['game']['id']])) { // DB session lifetime else 48 minutes max for playing a game $maxSessTime = !empty($modSettings['databaseSession_lifetime']) ? $modSettings['databaseSession_lifetime'] : 2880; if (empty($gameexit) && (time() - $initialToken[0]) > $maxSessTime) { fatal_lang_error('arcade_submit_error_session', false); return false; } $_SESSION['arcade_check_' . $context['game']['id']] = 'saved'; if (empty($gameexit)) ArcadeSubmit($url); //echo ''; if (isset($_POST['popup']) && $_POST['popup'] == 1) redirectexit($scripturl . '?action=arcade;end;sa=' . $save . ';pop=1;game=' . $gameid. ';#commentform3'); else redirectexit($scripturl . '?action=arcade;end;sa=' . $save . ';game=' . $gameid. ';#commentform3'); } elseif(!empty($_SESSION['arcade_check_' . $context['game']['id']])) { //echo ''; if (isset($_POST['popup']) && $_POST['popup'] == 1) redirectexit($scripturl . '?action=arcade;end;sa=' . $save . ';pop=1;game=' . $gameid. ';#commentform3'); else redirectexit($scripturl . '?action=arcade;end;sa=' . $save . ';game=' . $gameid. ';#commentform3'); } else fatal_lang_error('arcade_submit_error', false); } else fatal_lang_error('arcade_submit_error_session', false); return false; } // Get Score function ArcadeHTML53Submit(&$game, $session_info) { if (isset($_POST['score']) && is_numeric($_POST['score'])) $score = (float) $_POST['score']; elseif (isset($_POST['gscore']) && is_numeric($_POST['gscore'])) $score = floatval(preg_replace("/[^-0-9\.]/","", $_POST['gscore'])); 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(), ); } function ArcadeHTML53Play(&$game, &$session_info) { global $scripturl, $txt, $db_prefix, $context, $smcFunc; // We store this session to check cheating later $session_info = array( 'game' => $game['internal_name'], 'id' => $game['id'], 'start_time' => time(), 'done' => false, 'score' => 0, 'end_time' => 0, ); $_SESSION['arcade']['ibp_game'] = $game['internal_name']; } function ArcadeHTML53XMLPlay(&$game, &$session_info) { global $scripturl, $txt, $db_prefix, $context, $smcFunc; // We store this session to check cheating later $session_info = array( 'game' => $game['internal_name'], 'id' => $game['id'], 'start_time' => time(), 'done' => false, 'score' => 0, 'end_time' => 0, ); $_SESSION['arcade']['ibp_game'] = $game['internal_name']; return true; } function ArcadeHTML53Html(&$game, $auto_start = true) { global $txt, $context, $settings, $modSettings, $scripturl; $checkFull = isset($_REQUEST['full']) && $_REQUEST['full'] == 1 ? true : false; if (isset($_REQUEST['sameArcadeWindow']) && $_REQUEST['sameArcadeWindow'] == 1) { $_REQUEST['pop'] = 0; $_REQUEST['full'] = 0; $_REQUEST['sameArcadeWindow'] = 0; } echo '