function ArcadeSilverScore() { global $scripturl, $txt, $db_prefix, $context, $sourcedir, $modSettings, $smcFunc; file_put_contents('./debug/' . sha1(serialize($_REQUEST)) . '.txt', print_r(array($_REQUEST, $_SESSION['arcade']['v2_play']), true)); ArcadeXMLOutput(array('test' => 'ok')); obExit(false); }
function ArcadeFavorite() { global $scripturl, $txt, $db_prefix, $modSettings, $context, $user_info, $smcFunc; $xml = isset($_REQUEST['xml']); is_not_guest(); if (empty($modSettings['arcadeEnableFavorites']) || !($game = getGameInfo((int) $_REQUEST['game']))) { fatal_lang_error('arcade_game_not_found', false); } // It's favorite so we can remove it if ($game['is_favorite']) { $remove = true; $smcFunc['db_query']('', ' DELETE FROM {db_prefix}arcade_favorite WHERE id_member = {int:member} AND id_game = {int:game}', array('game' => $game['id'], 'member' => $user_info['id'])); // Update favorites count $request = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}arcade_favorite WHERE id_game = {int:game} GROUP BY id_game', array('game' => $game['id'])); list($num_favorites) = $smcFunc['db_fetch_row']($request); $smcFunc['db_free_result']($request); updateGame($game['id'], array('num_favorites' => $num_favorites)); if ($xml) { ArcadeXMLOutput(array('message' => &$txt['arcade_favorite_removed'], 'state' => 0)); } } else { $remove = false; $smcFunc['db_insert']('insert', '{db_prefix}arcade_favorite', array('id_member' => 'int', 'id_game' => 'int'), array($user_info['id'], $game['id']), array()); // Update favorites count updateGame($game['id'], array('num_favorites' => '+')); if ($xml) { ArcadeXMLOutput(array('message' => $txt['arcade_favorite_added'], 'state' => 1)); } } redirectexit('?action=arcade;sa=highscore;game=' . $game['id']); }
function ArcadeHighscore() { global $scripturl, $txt, $db_prefix, $modSettings, $context, $smcFunc, $user_info, $sourcedir; // Is game set if (!isset($_REQUEST['game'])) { fatal_lang_error('arcade_game_not_found', false); } // Get game info if (!($game = getGameInfo($_REQUEST['game']))) { fatal_lang_error('arcade_game_not_found', false); } if (!$game['highscore_support']) { fatal_lang_error('arcade_game_not_found', false); } $newScore = false; // Did we just play if (isset($_SESSION['arcade']['highscore']['game']) && $_SESSION['arcade']['highscore']['game'] == $game['id']) { // For highlight $newScore = $_SESSION['arcade']['highscore']['saved']; $newScore_id = $_SESSION['arcade']['highscore']['id']; $context['arcade']['submit'] = 'newscore'; $score =& $_SESSION['arcade']['highscore']; $context['arcade']['new_score'] = array('id' => $score['id'], 'saved' => $score['saved'], 'error' => !empty($score['error']) ? $score['error'] : '', 'score' => comma_format((double) $score['score']), 'position' => isset($score['position']) ? $score['position'] : 0, 'can_comment' => $context['arcade']['can_comment_own'] || $context['arcade']['can_comment_any'], 'is_new_champion' => !empty($score['newChampion']), 'is_personal_best' => !empty($score['personalBest'])); if (!isset($_GET['start'])) { $_REQUEST['start'] = $score['start']; } } elseif (isset($_SESSION['arcade']['highscore'])) { unset($_SESSION['arcade']['highscore']); } // Edit Comment if (isset($_REQUEST['csave'])) { if (isset($_SESSION['arcade']['highscore'])) { unset($_SESSION['arcade']['highscore']); } require_once $sourcedir . '/Subs-Post.php'; $where = $context['arcade']['can_comment_any'] ? '1 = 1' : ($context['arcade']['can_comment_own'] ? 'id_member = {int:member}' : '0 = 1'); $_REQUEST['new_comment'] = strtr($smcFunc['htmlspecialchars']($_REQUEST['new_comment'], ENT_QUOTES), array("\r" => '', "\n" => '', "\t" => '')); preparsecode($_REQUEST['new_comment']); if (!empty($modSettings['arcadeCommentLen'])) { $_REQUEST['new_comment'] = substr($_REQUEST['new_comment'], 0, $modSettings['arcadeCommentLen']); } $smcFunc['db_query']('', ' UPDATE {db_prefix}arcade_scores SET comment = {string:comment} WHERE id_score = {int:score} AND ' . $where, array('score' => (int) $_REQUEST['score'], 'comment' => $_REQUEST['new_comment'], 'member' => $user_info['id'])); $_SESSION['arcade']['highscore']['saved'] = true; if (isset($_REQUEST['xml'])) { ArcadeXMLOutput(array('comment' => parse_bbc($_REQUEST['new_comment']), 'message' => $txt['arcade_comment_saved']), null); } redirectexit('action=arcade;sa=highscore;game=' . $game['id']); } elseif ($context['arcade']['can_admin_arcade'] && isset($_REQUEST['qaction'])) { checkSession('request'); if ($_REQUEST['qaction'] == 'delete' && !empty($_REQUEST['scores'])) { deleteScores($game, $_REQUEST['scores']); } redirectexit('action=arcade;sa=highscore;game=' . $game['id']); } // How many scores there are $result = $smcFunc['db_query']('', ' SELECT COUNT(*) FROM {db_prefix}arcade_scores WHERE id_game = {int:game}', array('game' => $game['id'])); list($scoreCount) = $smcFunc['db_fetch_row']($result); $smcFunc['db_free_result']($result); $context['page_index'] = constructPageIndex($scripturl . '?action=arcade;sa=highscore;game=' . $game['id'], $_REQUEST['start'], $scoreCount, $context['scores_per_page'], false); // Actual query $result = $smcFunc['db_query']('', ' SELECT sc.id_score, sc.score, sc.end_time AS time, sc.duration, sc.comment, sc.position, sc.score_status, IFNULL(mem.id_member, 0) AS id_member, IFNULL(mem.real_name, sc.player_name) AS real_name FROM {db_prefix}arcade_scores AS sc LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = sc.id_member) WHERE id_game = {int:game} ORDER BY position LIMIT {int:start}, {int:scores_per_page}', array('game' => $game['id'], 'empty' => '', 'start' => $_REQUEST['start'], 'scores_per_page' => $context['scores_per_page'])); $context['arcade']['scores'] = array(); $context['game'] = $game; while ($score = $smcFunc['db_fetch_assoc']($result)) { censorText($score['comment']); if (empty($score['real_name'])) { $score['real_name'] = $txt['guest']; } $context['arcade']['scores'][$score['id_score']] = array('id' => $score['id_score'], 'own' => $user_info['id'] == $score['id_member'], 'member' => array('id' => $score['id_member'], 'name' => $score['real_name'], 'link' => !empty($score['id_member']) ? '<a href="' . $scripturl . '?action=profile;u=' . $score['id_member'] . '">' . $score['real_name'] . '</a>' : $score['real_name']), 'position' => $score['position'], 'score' => comma_format((double) $score['score']), 'time' => timeformat($score['time']), 'duration' => $score['duration'], 'scoreStatus' => $score['score_status'], 'comment' => parse_bbc(!empty($score['comment']) ? $score['comment'] : $txt['arcade_no_comment']), 'raw_comment' => $score['comment'], 'can_edit' => $user_info['id'] == $score['id_member'] ? $context['arcade']['can_comment_own'] || $context['arcade']['can_comment_any'] : $context['arcade']['can_comment_any']); } $smcFunc['db_free_result']($result); if (isset($_REQUEST['edit'])) { if ($context['arcade']['scores'][(int) $_REQUEST['score']]['can_edit']) { $context['arcade']['scores'][(int) $_REQUEST['score']]['edit'] = true; } } if ($newScore) { $context['arcade']['scores'][$newScore_id]['highlight'] = true; } // Template loadTemplate('ArcadeGame'); $context['template_layers'][] = 'arcade_game'; $context['sub_template'] = 'arcade_game_highscore'; $context['page_title'] = sprintf($txt['arcade_view_highscore'], $game['name']); $context['linktree'][] = array('url' => $scripturl . '?action=arcade;sa=play;game=' . $game['id'], 'name' => $game['name']); $context['linktree'][] = array('url' => $scripturl . '?action=arcade;sa=highscore;game=' . $game['id'], 'name' => $txt['arcade_viewscore']); // Do we show remove score functions? $context['arcade']['show_editor'] = $context['arcade']['can_admin_arcade']; return true; }