public static function templateHook($hookName, &$contents, array $hookParams, XenForo_Template_Abstract $template) { switch ($hookName) { case 'user_criteria_extra': $s = new Steam_Helper_Steam(); $contents .= $template->create('steam_helper_criteria_privs', array_merge($hookParams, $template->getParams(), array_merge($hookParams, $template->getParams(), array("steam_games" => $s->getAvailableGames())))); break; } }
/** * Disassociates a forum account from Steam */ public function actionExternalAccountsDisassociate() { $response = parent::actionExternalAccountsDisassociate(); $input = $this->_input->filter(array('disassociate' => XenForo_Input::STRING, 'account' => XenForo_Input::STRING)); $visitor = XenForo_Visitor::getInstance(); if ($input['disassociate'] && $input['account'] == 'steam') { $sHelper = new Steam_Helper_Steam(); $sHelper->deleteSteamData($visitor['user_id']); } return $response; }
public function getAvailableGames($fetchOptions) { $rVal = array(); $db = XenForo_Application::get('db'); $limitOptions = $this->prepareLimitFetchOptions($fetchOptions); $results = $db->fetchAll($this->limitQueryResults('SELECT game_id, game_name, game_link, game_logo FROM xf_steam_games ORDER BY game_name ASC', $limitOptions['limit'], $limitOptions['offset'])); foreach ($results as $row) { $sHelper = new Steam_Helper_Steam(); $logoFixed = $sHelper->getSteamCDNDomain($row['game_logo']); $rVal[] = array('id' => $row['game_id'], 'name' => $row['game_name'], 'link' => $row['game_link'], 'logo' => $logoFixed); } return $rVal; }
public function actionTopRecentlyPlayedGames() { $sHelper = new Steam_Helper_Steam(); $visitor = XenForo_Visitor::getInstance(); $visitorPerms = $visitor->getPermissions(); //Make the following a XenForo Option $queryLimit = 25; if (!$visitorPerms['SteamAuth']['viewStats']) { return $this->responseError(new XenForo_Phrase('steam_do_not_have_permission')); } else { $viewParams = array('gameStats' => $sHelper->getGamePlayedRecentStatistics($queryLimit)); return $this->responseView('Steam_ViewPublic_Recent', 'steam_public_recent', $viewParams); } }
/** * Adds Steam Integration to External Accounts */ public function actionExtra() { $response = parent::actionExtra(); $stUser = false; if (!empty($response->params['external']['steam'])) { if (!empty($response->params['external']['steam']['extra_data'])) { $sHelper = new Steam_Helper_Steam(); $stUser = $sHelper->getUserInfo($response->params['external']['steam']['provider_key']); } } $stParams = $response->params; $stParams['stUser'] = $stUser; $response->params = $stParams; return $response; }
public static function update() { set_time_limit(0); ignore_user_abort(1); $options = XenForo_Application::get('options'); $gameStats = $options->steamGameStats; $forceUpdate = $options->steamGameStatsForce; if ($gameStats > 0) { $db = XenForo_Application::get('db'); $sHelper = new Steam_Helper_Steam(); $results = $db->fetchAll("SELECT u.user_id, p.provider_key FROM xf_user u, xf_user_external_auth p \n WHERE u.user_id = p.user_id \n AND p.provider = 'steam' \n AND p.provider_key > 0 \n AND u.is_banned \n NOT IN (1)"); foreach ($results as $row) { /* * Gets all game info * * @see Steam_Helper_Steam */ $games = $sHelper->getUserGames($row['provider_key']); foreach ($games as $id => $data) { // game info if ($forceUpdate > 0) { $gameInfoQuery = "INSERT IGNORE INTO xf_steam_games(game_id, game_name, game_logo, game_link) \n VALUES({$id}, '{$data['name']}', '{$data['logo']}', '{$data['link']}')\n ON DUPLICATE KEY UPDATE game_logo = '{$data['logo']}';"; } else { $gameInfoQuery = "INSERT IGNORE INTO xf_steam_games(game_id, game_name, game_logo, game_link) \n VALUES({$id}, '{$data['name']}', '{$data['logo']}', '{$data['link']}');"; } $db->query($gameInfoQuery); // update $r = $db->fetchRow("SELECT * FROM xf_user_steam_games \n WHERE user_id = {$row['user_id']} \n AND game_id = {$id};"); if ($r == NULL) { // Insert $db->insert("xf_user_steam_games", array('user_id' => $row['user_id'], 'game_id' => $id, 'game_hours' => $data['hours'], 'game_hours_recent' => $data['hours_recent'])); } else { // Update $db->query("UPDATE xf_user_steam_games \n SET game_hours = {$data['hours']}, game_hours_recent = {$data['hours_recent']} \n WHERE user_id = {$row['user_id']} AND game_id = {$id};"); } } } } }
/** * List all steam users in the database * * Used in the following: * ControllerAdmin\Steam.php * * @return array */ public function getSteamUsers() { $rVal = array(); $db = XenForo_Application::get('db'); $results = $db->fetchAll("SELECT u.provider_key, p.user_id, p.username \n FROM xf_user_external_auth u, xf_user p \n WHERE u.user_id = p.user_id \n AND u.provider = 'steam' \n ORDER BY p.username;"); foreach ($results as $row) { $rVal[] = array('id' => Steam_Helper_Steam::convertIdToString($row['provider_key']), 'id64' => $row['provider_key'], 'username' => $row['username'], 'user_id' => $row['user_id']); } return $rVal; }
XenForo_Application::initialize($fileDir . '/library', $fileDir); XenForo_Application::set('page_start_time', $startTime); XenForo_Application::disablePhpErrorHandler(); XenForo_Application::setDebugMode(false); XenForo_Application::$externalDataPath = $fileDir . '/data'; XenForo_Application::$externalDataUrl = $fileDir . '/data'; XenForo_Application::$javaScriptUrl = $fileDir . '/js'; restore_error_handler(); restore_exception_handler(); $options = XenForo_Application::get('options'); $STEAM_GAMEBANNER = $options->steamDisplayBanner; if (!empty($_GET['steamids'])) { /* * Fetch profile data */ $sHelper = new Steam_Helper_Steam(); $steamProfileAPI = $sHelper->getSteamProfileAPI($_GET['steamids']); $fullProfile = $_GET['fullprofile']; $contentJson = $sHelper->getJsonData($steamProfileAPI); $contentDecoded = json_decode($contentJson); if (isset($contentDecoded->response->players)) { foreach ($contentDecoded->response->players as $rows) { /* * Setup CDN on avatar URLs */ $avatarPath = parse_url($rows->avatar); $rows->avatar = $sHelper->getSteamCDNDomain($avatarPath["path"]); /* * Apply game image to SteamProfile and use HTTPS if enabled */ if ($fullProfile == 1 && isset($rows->gameid) && $STEAM_GAMEBANNER > 0) {
private function updateUserStats($userId, $steamId) { $options = XenForo_Application::get('options'); $gamestatsreg = $options->steamGameStatsReg; if ($gamestatsreg > 0) { $db = XenForo_Application::get('db'); $sHelper = new Steam_Helper_Steam(); $games = $sHelper->getUserGames($steamId); foreach ($games as $id => $data) { // game info $db->query("INSERT IGNORE INTO xf_steam_games(game_id, game_name, game_logo, game_link) \n VALUES({$id}, '{$data['name']}', '{$data['logo']}', '{$data['link']}');"); // update $r = $db->fetchRow("SELECT * FROM xf_user_steam_games WHERE user_id = {$userId} AND game_id = {$id};"); if ($r == NULL) { // Insert $db->insert("xf_user_steam_games", array('user_id' => $userId, 'game_id' => $id, 'game_hours' => $data['hours'], 'game_hours_recent' => $data['hours_recent'])); } else { // Update $db->query("UPDATE xf_user_steam_games SET game_hours = {$data['hours']}, game_hours_recent = {$data['hours_recent']} \n WHERE user_id = {$userId} AND game_id = {$id};"); } } } }
/** * Section that lists all top recently played games (in hours) */ public function actionTopPlayedRecent() { $sHelper = new Steam_Helper_Steam(); //Make the following a XenForo Option $queryLimit = 25; $viewParams = array('gameStats' => $sHelper->getGamePlayedRecentStatistics($queryLimit)); return $this->responseView('XenForo_ViewAdmin_Steam_TopPlayedRecent', 'steam_stats_topPlayedRecent', $viewParams); }