function ArcadeHighscore() { global $smcFunc, $scripturl, $txt, $arcSettings, $context, $user_info; // Is game set if (!isset($_REQUEST['game'])) { fatal_lang_error('arcade_game_not_found'); } // Get game info $game = ArcadeGameInfo((int) $_REQUEST['game']); if ($game === false || !$game['highscoreSupport']) { fatal_lang_error('arcade_game_not_found'); } // Game was not found // Do we show remove score functions? $context['arcade']['show_editor'] = $context['arcade']['can_admin']; // Do we have scores to delete? if ($context['arcade']['can_admin'] && isset($_REQUEST['delete'])) { checkSession('request'); $_REQUEST['score'] = (int) $_REQUEST['score']; $smcFunc['db_query']('', ' DELETE FROM {db_prefix}arcade_scores WHERE id_score = {int:ids}', array('ids' => $_REQUEST['score'])); ArcadeFixPositions($game['id']); } //$context['template_layers'][] = 'ArcadeGame'; $context['sub_template'] = 'arcade_game_highscore'; $context['page_title'] = $txt['arcade_view_highscore']; // We don't play :) $context['arcade']['play'] = false; $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']); $scoresPerPage = isset($arcSettings['scoresPerPage']) ? $arcSettings['scoresPerPage'] : 50; // Did we just play if (isset($_SESSION['arcade']['highscore'])) { //if it was a popup kill it off if (isset($_SESSION['arcade']['pop']) && $_SESSION['arcade']['pop'] == 1) { $context['arcade']['popup'] = ' <script type="text/javascript"> opener.location.href="' . $scripturl . '?action=arcade;sa=highscore;game=' . $game['id'] . '"; self.close(); </script>'; $context['sub_template'] = 'arcade_popup_play'; $_SESSION['arcade']['pop'] = 0; return; } if ($_SESSION['arcade']['highscore']['gameid'] == $game['id']) { // For highlight $newScore = $_SESSION['arcade']['highscore']['saved']; $newScore_id = $_SESSION['arcade']['highscore']['id']; $context['arcade']['new_score'] = array('id' => $_SESSION['arcade']['highscore']['id'], 'saved' => $_SESSION['arcade']['highscore']['saved'], 'error' => isset($_SESSION['arcade']['highscore']['error']) ? $_SESSION['arcade']['highscore']['error'] : '', 'score' => round($_SESSION['arcade']['highscore']['score'], 3), 'position' => $_SESSION['arcade']['highscore']['position'], 'can_comment' => $context['arcade']['can_comment_own'] || $context['arcade']['can_comment_any'], 'is_new_champion' => isset($_SESSION['arcade']['highscore']['champion']) ? $_SESSION['arcade']['highscore']['champion'] : false, 'is_personal_best' => isset($_SESSION['arcade']['highscore']['best']) ? $_SESSION['arcade']['highscore']['best'] : false); if (!isset($_GET['start']) && !isset($_POST['start'])) { $_REQUEST['start'] = $_SESSION['arcade']['highscore']['start']; } } else { $newScore = false; unset($_SESSION['arcade']['highscore']); } } else { $newScore = false; } // How many scores there are $result = $smcFunc['db_query']('', ' SELECT count(*) AS sc FROM {db_prefix}arcade_scores WHERE id_game = {int:game}', array('game' => $game['id'])); $scoreCount = $smcFunc['db_fetch_row']($result); $smcFunc['db_free_result']($result); $score_sort = $game['score_type'] == 0 ? 'DESC' : 'ASC'; // Actual query // Get position $request = $smcFunc['db_query']('', ' SELECT scores.id_score, scores.score, scores.end_time, scores.game_duration, scores.comment,scores.position,scores.score_status, mem.id_member, mem.real_name FROM {db_prefix}arcade_scores AS scores LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = scores.id_member) WHERE scores.id_game = {int:game} ORDER BY position LIMIT {int:start},{int:spp}', array('game' => $game['id'], 'start' => $_REQUEST['start'], 'spp' => $scoresPerPage)); $context['arcade']['scores'] = array(); $context['arcade']['game'] = $game; while ($score = $smcFunc['db_fetch_assoc']($request)) { censorText($score['comment']); $own = $user_info['id'] == $score['id_member']; $context['arcade']['scores'][] = array('id' => $score['id_score'], 'own' => $own, 'memberLink' => !empty($score['real_name']) ? '<a href="' . $scripturl . '?action=profile;u=' . $score['id_member'] . '">' . $score['real_name'] . '</a>' : $txt['arcade_guest'], 'score' => round($score['score'], 3), 'time' => timeformat($score['end_time']), 'duration' => $score['game_duration'], 'position' => $score['position'], 'score_status' => $score['score_status'], 'comment' => parse_bbc(!empty($score['comment']) ? $score['comment'] : $txt['arcade_no_comment']), 'raw_comment' => $score['comment'], 'highlight' => $newScore ? $score['id_score'] == $newScore_id : false, 'can_edit' => $newScore ? false : $own ? $context['arcade']['can_comment_own'] || $context['arcade']['can_comment_any'] : $context['arcade']['can_comment_any'], 'edit' => isset($_REQUEST['edit']) && isset($_REQUEST['score']) && (int) $_REQUEST['score'] == $score['id_score']); } $smcFunc['db_free_result']($request); // Free results since we don't want to use too much memory $context['arcade']['pageIndex'] = constructPageIndex('?action=arcade;sa=highscore;game=' . $game['id'], $_REQUEST['start'], $scoreCount[0], $scoresPerPage, false); }
function GamesQuickEdit() { global $scripturl, $txt, $smcFunc, $context, $arcSettings; checkSession('post'); switch ($_REQUEST['qaction']) { case 'change': $games = implode(',', $_POST['games']); $category = (int) $_POST['qcategory']; if ($_REQUEST['qset'] == 0) { $games = implode(',', $_POST['games']); $category = (int) $_POST['qcategory']; $smcFunc['db_query']('', ' UPDATE {db_prefix}arcade_games SET id_category = {int:idc} WHERE id_game IN(' . $games . ')', array('idc' => $category)); } else { $smcFunc['db_query']('', ' UPDATE {db_prefix}arcade_games SET id_category = {int:idc}', array('idc' => $category)); } break; case 'gotd': if ($_REQUEST['qset'] == 0) { foreach ($_POST['games'] as $key => $value) { $value = (int) $value; $updates = array('arcadegotd' => $value); } saveArcadeSettings($updates); GamesCacheClear(); } break; case 'clear_scores': if ($_REQUEST['qset'] == 0) { foreach ($_POST['games'] as $key => $game) { ScoresDelete($game, 0); ArcadeFixPositions($game); } } else { $result = $smcFunc['db_query']('', ' SELECT id_game FROM {db_prefix}arcade_games', array()); while ($game = $smcFunc['db_fetch_assoc']($result)) { ScoresDelete($game['id_game'], 0); update_champ_cups($game['id_game']); } } break; case 'clear_scores2': if ($_REQUEST['qset'] == 0) { foreach ($_POST['games'] as $key => $game) { ScoresDelete($game, 1); ArcadeFixPositions($game); } } else { $result = $smcFunc['db_query']('', ' SELECT id_game FROM {db_prefix}arcade_games', array()); while ($game = $smcFunc['db_fetch_assoc']($result)) { ScoresDelete($game['id_game'], 1); update_champ_cups($game['id_game']); } } break; case 'del_games': if ($_REQUEST['qset'] == 0) { foreach ($_REQUEST['games'] as $key => $game) { GamesDelete($game); ArcadeCountGames(); } } else { $result = $smcFunc['db_query']('', ' SELECT id_game FROM {db_prefix}arcade_games', array()); while ($game = $smcFunc['db_fetch_row']($result)) { GamesDelete($game[0]); ArcadeCountGames(); } } break; case 'fix_scores': if ($_REQUEST['qset'] == 0) { foreach ($_REQUEST['games'] as $key => $game) { $result = $smcFunc['db_query']('', ' SELECT id_game, score_type FROM {db_prefix}arcade_games WHERE id_game = {int:idg}', array('idg' => $game)); while ($game = $smcFunc['db_fetch_assoc']($result)) { ArcadeFixPositions($game['id_game'], $game['score_type']); } } } else { $result = $smcFunc['db_query']('', ' SELECT id_game, score_type FROM {db_prefix}arcade_games', array()); while ($game = $smcFunc['db_fetch_assoc']($result)) { ArcadeFixPositions($game['id_game'], $game['score_type']); } } break; default: redirectexit('action=admin;area=managearcade;sa=listgames'); break; } redirectexit('action=admin;area=managearcade;sa=listgames'); }