function backpack_viewer($sid) { globalSchemas(440); $profile = json_decode(get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . AKey() . '&steamids=' . $sid . '&format=json'), true); $profile = $profile['response']['players'][0]; $bp = ''; $hours = getHours($sid); $backpack = json_decode(get_data('http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=' . AKey() . '&SteamID=' . $sid . '&format=json'), true); if (isset($backpack) && $backpack['result']['status'] == 1) { usort($backpack['result']['items'], "sortInvPos"); $mplace = ''; $itemCount = array(); //misplaced items foreach ($backpack['result']['items'] as $key => $item) { if ($item['inventory'] == 3221225475) { item_prepare($item); item_price($item); $mplace .= item_image($item); $itemCount[$item['defindex']] = 1; } } if ($mplace != '') { $bp .= '<div class="bp-mplaced">' . $mplace . '</div><br>'; } $inv_pos = 2147483649; $total_items = 0; //start normal items foreach ($backpack['result']['items'] as $key => $item) { if ($item['inventory'] == 3221225475) { //end-of-backpack handler, writes out empty slots until we reach the max slots in the backpack. while ($backpack['result']['num_backpack_slots'] >= $total_items) { $bp .= '<div><img alt="empty" class="mt" src="img/mt.gif"></div>'; $total_items++; $bp .= pg_chk($total_items); // echoes empty backpack slots. } break; } while ($item['inventory'] > $inv_pos + 1) { $bp .= '<div><img alt="empty" class="mt" src="img/mt.gif"></div>'; $total_items++; $inv_pos++; $bp .= pg_chk($total_items); } item_prepare($item); item_price($item); $bp .= item_image($item); $inv_pos = $item['inventory']; $total_items++; $bp .= pg_chk($total_items); $itemCount[$item['defindex']] = 1; } } else { $bp .= 'problem retrieving backpack.'; } echo '<div class="bp-container w800">', '<div class="bp-head">', '<img src=', $profile['avatarfull'], ' />', '<h1>', htmlspecialchars($profile['personaname']), '</h1>', '<h3>TF2: ', $hours[440], ' / DOTA 2: ', $hours[570], ' / CSGO: ', $hours[730], '</h3>', '</div>', '<div class="bp-mweapons">'; fav_class_weapons_box($sid, $itemCount); echo '</div>', '<div class="bp-info">', '</div>', '<div class="bp-content">', $bp, '</div></div>'; //end bp container. }
function LoginButton() { if (isset($_POST['logout'])) { unset($_POST); session_destroy(); return 'Logged out.'; } if (!isset($_SESSION['sid']) && isset($_SERVER['REQUEST_METHOD'])) { try { // Change 'localhost' to your domain name. $openid = new LightOpenID('http://endgame.tf'); //$openid = new LightOpenID('http://76.164.223.234'); //elseif ( is_v4() ) $openid = new LightOpenID( 'http://65.111.166.150' ); if (!$openid->mode) { if (isset($_GET['login'])) { $openid->identity = 'http://steamcommunity.com/openid'; header('Location: ' . $openid->authUrl()); } return '<form action="?login" method="post"><input class="steamlogin" type="image" src="img/sits.gif" alt="Login With Steam"></form>'; } elseif ($openid->mode == 'cancel') { return 'User has canceled authentication!'; } else { if ($openid->validate()) { $id = $openid->identity; // identity is something like: http://steamcommunity.com/openid/id/76561197994761333 // we only care about the unique account ID at the end of the URL. $ptn = "/^http:\\/\\/steamcommunity\\.com\\/openid\\/id\\/(7[0-9]{15,25}+)\$/"; preg_match($ptn, $id, $matches); if (strlen($matches[1]) < 16) { return 'Invalid steamid.'; } //echo "User is logged in (steamID: $matches[1])\n"; //session_start(); database_login((int) $matches[1]); $_SESSION['sid'] = (int) $matches[1]; //This is where the user's steamID is set, IMPORTANT. if (isset($_SESSION['sid']) && is_numeric($_SESSION['sid']) == TRUE && !isset($_SESSION['currentUserName'])) { $playerURL = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . AKey() . "&steamids=" . $_SESSION['sid'] . "&format=json"; $playerData = json_decode(get_data($playerURL), true); $_SESSION['currentUserName'] = $playerData['response']['players'][0]['personaname']; //addUser( $_SESSION['sid'] ); header("Location: " . "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']); } } else { return 'User is not logged in.'; } } } catch (ErrorException $e) { return $e->getMessage(); } } else { return '<form action="' . $_SERVER['PHP_SELF'] . '" method="post"><INPUT TYPE = "Submit" Name = "logout" VALUE = "Log out"></form>'; } }
function market_classid_scrape($num_to_scrape) { $latest = (int) latest_classid() + 1; if (!is_numeric($latest)) { $latest = 4; } $i = 0; while ($i < $num_to_scrape) { save_classid_data(json_decode(get_data('http://api.steampowered.com/ISteamEconomy/GetAssetClassInfo/v0001/?appid=440&classid0=' . $latest . '&class_count=1&key=' . AKey()), true)); $latest++; $i++; } }
function multi_scan_start($url, $gid) { //http://steamcommunity.com/app/204300 //http://steamcommunity.com/ogg/230410 if (isset($_POST['pg']) && is_numeric($_POST['pg'])) { $page = (int) $_POST['pg']; } else { $page = 1; } //community hub if (substr($url, 0, 30) == 'http://steamcommunity.com/app/') { // this is a community hub, convert it to a group. $group_id = explode("/", substr($url, 30), 2); $dl_url = 'http://steamcommunity.com/ogg/' . $group_id[0] . '/memberslistxml/?xml=1&p=' . $page; group_scan_start($dl_url, $gid); } //normal group if (substr($url, 0, 33) == 'http://steamcommunity.com/groups/') { $dl_url = $url . '/memberslistxml/?xml=1&p=' . $page; group_scan_start($dl_url, $gid); } // official games group if (substr($url, 0, 32) == 'http://steamcommunity.com/games/') { $dl_url = $url . '/memberslistxml/?xml=1&p=' . $page; group_scan_start($dl_url, $gid); } $sid = any_to_64($url); if ($sid != false) { $dl_url = 'http://api.steampowered.com/ISteamUser/GetFriendList/v0001/?key=' . AKey() . "&steamid=" . $sid . "&relationship=friend"; //this is a steamid. $userlist = json_decode(get_data($dl_url), true); if (isset($userlist['friendslist']['friends'][0]['steamid'])) { $scan_list = array(); $userlist = $userlist['friendslist']['friends']; foreach ($userlist as $user) { $scan_list[] = $user['steamid']; } $playerData = json_decode(get_data($dl_url), true); echo '<img src="' . $playerData['response']['players'][0]['avatarFull'] . '"><br>'; echo "<h1>Scanning " . (isset($playerData['response']['players'][0]['personaname']) ? htmlentities($playerData['response']['players'][0]['personaname']) : 'Error retrieving username') . "'s Friend list</h1>"; scan_start($scan_list, $gid); } else { echo 'Target friend list is empty.'; } } if (isset($dl_url)) { } }
function current_user_states(&$profiles100) { $playerData = json_decode(get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . AKey() . '&steamids=' . implode($profiles100, ',') . '&format=json'), true); if (isset($playerData["response"]["players"]['0']["steamid"])) { foreach ($playerData['response']['players'] as $key => $UTDprofile) { $user_profile_states[$key]['profile']['personaname'] = $UTDprofile['personaname']; $user_profile_states[$key]['profile']['avatarmedium'] = $UTDprofile['avatarmedium']; $profiles100[$key]['profile']['personastate'] = $UTDprofile['personastate']; $user_profile_states[$key]['profile']['lastlogoff'] = $UTDprofile['lastlogoff']; if (isset($userProfile['gameid'])) { $user_profile_states[$key]['profile']['gameid'] = $UTDprofile['gameid']; } } } else { return false; } }
function update_schema() { $schema = json_decode(get_data('http://api.steampowered.com/IEconItems_570/GetSchema/v0001/?key=' . AKey() . '&language=en_us', 12), true); if (isset($schema['result']['status']) && $schema['result']['status'] == 1 && isset($schema['result']['items'][1]['defindex'])) { $schema = $schema['result']; } else { return 0; } $res = array(); foreach ($schema['originNames'] as $key => $val) { $schema['origin'][$val['origin']] = $val['name']; } //insert all items by defindex. foreach ($schema['items'] as $key => $item) { unset($item['item_description']); unset($item['proper_name']); unset($item['image_inventory']); unset($item['capabilities']); unset($item['tool']); unset($item['attributes']); $res[$item['defindex']] = $item; } $schema['items'] = $res; unset($res); //put all effects into the effect key. foreach ($schema['attribute_controlled_attached_particles'] as $key => $effect) { $schema['effect'][$effect['id']]['name'] = $effect['name']; $schema['effect'][$effect['id']]['id'] = $effect['id']; } foreach ($schema['qualities'] as $qual => $val) { $schema['quality'][$val]['name'] = $qual; $schema['quality'][$val]['display_name'] = $schema['qualityNames'][$qual]; } unset($schema['attribute_controlled_attached_particles']); $result = json_encode($schema); $dir = json_directory(); file_put_contents($dir . "/570_schema.json", $result); file_put_contents($dir . "/570_schema_time.txt", time()); }
function get_100_users() { $c = db_init('archive', 'items_730'); $OOD = $c->find(array("recent" => array('$lt' => time() - 172800)), array('_id' => 1))->sort(array("recent" => 1))->limit(100); //get a list of the most out of date steamids in the database (returns steamids only) $sids = ''; if ($OOD->count() > 100) { $is_additive = false; foreach ($OOD as $k => $usr) { $sids .= ',' . $usr['_id']; } } else { $steamid1 = db_load('start_steamid_730'); if (empty($steamid1)) { $steamid1 = 76561197960287930; } $sc = 0; while ($sc <= 100 && $sc++) { $sids .= ',' . ($steamid1 + $sc); } } $playerData = json_decode(get_data('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' . AKey() . '&steamids=' . $sids . '&format=json'), true); return $playerData['response']['players']; }
function scan_queue($profile_list, $gid) { if (donator_level(20)) { $max_requests = 24; } else { $max_requests = 2; } $curl_options = array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 7, CURLOPT_FOLLOWLOCATION => TRUE); $parallel_curl = new ParallelCurl($max_requests, $curl_options); foreach ($profile_list as $profile) { if ($gid == 440) { $url = 'http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=' . AKey() . '&SteamID=' . $profile['steamid'] . '&format=json'; $parallel_curl->startRequest($url, 'scan_440_single', $profile); } if ($gid == 730) { $url = 'http://steamcommunity.com/profiles/' . $profile['steamid'] . '/inventory/json/730/2'; $parallel_curl->startRequest($url, 'scan_730_single', $profile); } if ($gid == 570) { $url = 'http://api.steampowered.com/IEconItems_570/GetPlayerItems/v0001/?key=' . AKey() . '&SteamID=' . $profile['steamid'] . '&format=json'; $parallel_curl->startRequest($url, 'scan_570_single', $profile); } //ob_flush(); //flush(); } // This should be called when you need to wait for the requests to finish. // This will automatically run on destruct of the ParallelCurl object, so the next line is optional. $parallel_curl->finishAllRequests(); }
function updateTF2Schema() { $dir = json_directory(); //loadSchemaFromLocal(); $old = db_load('440_schema_time'); if ($old == false || time() - $old >= 14400) { $res = json_decode(get_data('http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=' . AKey() . '&language=en', 5), TRUE); echo 'updating.'; if (isset($res['result']['status']) && $res['result']['status'] == 1) { //why check if attributes is set? So that we're sure we didn't miss anything important in between. $res = $res['result']; foreach ($res['originNames'] as $key => $val) { $res['origin'][$val['origin']] = $val['name']; } foreach ($res['qualities'] as $qual => $val) { $res['quality'][$val]['name'] = $qual; $res['quality'][$val]['display_name'] = $res['qualityNames'][$qual]; } foreach ($res['attribute_controlled_attached_particles'] as $key => $effect) { $res['effect'][$effect['id']]['name'] = $effect['name']; $res['effect'][$effect['id']]['id'] = $effect['id']; } //lighten the list a bit. Attributes, string lookups are not necessary and take a lot of space. //qualitynames and qualities have been replaced by quality. unset($res['originNames']); unset($res['qualities']); unset($res['qualityNames']); unset($res['item_levels']); unset($res['item_sets']); unset($res['kill_eater_score_types']); unset($res['attributes']); unset($res['string_lookups']); unset($res['attribute_controlled_attached_particles']); //sort by item name if (!function_exists('cmp')) { function cmp($a, $b) { return strcmp($a['defindex'], $b['defindex']); } } $items = $res['items']; $add = false; if (file_exists($dir . "/schema_addon.json")) { $add = json_decode(file_get_contents($dir . "/schema_addon.json"), true); } usort($items, "cmp"); foreach ($items as &$item) { if (isset($add[$item['defindex']])) { $item = $add[$item['defindex']]; } unset($item['item_class']); unset($item['model_player']); unset($item['image_inventory']); $items_new[$item['defindex']] = $item; } $res['items'] = $items_new; $results = json_encode($res); file_put_contents($dir . '/qualities.json', json_encode($res['quality'])); file_put_contents($dir . "/440_schema.json", $results); db_save('440_schema_time', time()); } } }
function any_to_64($input) { if (substr($input, 0, 29) === 'http://steamcommunity.com/id/') { $vanity = rtrim(substr($input, 29, 32), '/'); //remove slash if present, vanity urls are up to 32 characters. $userData = json_decode(get_data('http://api.steampowered.com/ISteamUser/ResolveVanityURL/v0001/?key=' . AKey() . '&vanityurl=' . $vanity), true); if ($userData['response']['success'] === 1) { return (int) $userData['response']['steamid']; } return false; } //Try if it's a steamid else return false. $input = preg_replace('/[^0-9]/', '', $input); if (is_numeric($input)) { return (int) $input; } return false; }
function checkCurrentUserData($profiles) { $user_profile_states = array(); $completeProfileSize = 0; $profileSize = count($profiles); $S = 0; $L = 100; $profiles100 = array(); while ($profileSize > $completeProfileSize) { $profiles100 = array_slice($profiles, $S, $L); $urlProfiles = implode(",", $profiles100); $playerURL = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=" . AKey() . "&steamids=" . $urlProfiles . "&format=json"; $playerData = get_data($playerURL); $playerData = json_decode($playerData, true); if (isset($playerData["response"]["players"]['0']["steamid"])) { $userList = $playerData['response']['players']; //lol headache. foreach ($userList as $key => $userProfile) { $user_profile_states[$userProfile['steamid']]['personastate'] = $userProfile['personastate']; $user_profile_states[$userProfile['steamid']]['lastlogoff'] = $userProfile['lastlogoff']; if (isset($userProfile['gameid'])) { $user_profile_states[$userProfile['steamid']]['gameid'] = $userProfile['gameid']; } } } $S = $S + 100; $L = $L + 100; $completeProfileSize = $completeProfileSize + 100; } if (isset($playerData["response"]["players"]['0']["steamid"])) { return $user_profile_states; } else { return 0; } }
function mongoUpdateUsers($profile, $is_additive) { $timestamp = time(); file_put_contents('/cron/history.txt', 'started on ' . gmdate("Y-m-d\\TH:i:s\\Z", $timestamp) . ' ', FILE_APPEND); $i = 0; $add = 0; $upd = 0; $rmv = 0; foreach ($profile as $userProfile) { $i++; $userUnusuals = array(); $profile = $userProfile['steamid']; $backpack = NULL; $steamHours = getHours($profile); $backpackURL = "http://api.steampowered.com/IEconItems_440/GetPlayerItems/v0001/?key=" . AKey() . "&SteamID=" . $profile . "&format=json"; $backpack = json_decode(get_data($backpackURL), true); if (isset($backpack['result']['items'][0]['defindex'])) { $items = $backpack['result']['items']; } else { $items = ""; goto skipBackPack; } if (!isset($backpack['result']['status']) || $backpack['result']['status'] === 15) { goto skipBackPack; } foreach ($items as $item) { if (array_key_exists('flag_cannot_trade', $item)) { $item['flag_cannot_trade'] = 1; } else { $item['flag_cannot_trade'] = 0; } if (array_key_exists('flag_cannot_craft', $item)) { $item['flag_cannot_craft'] = 1; } else { $item['flag_cannot_craft'] = 0; } if ($item['quality'] == 5 && array_key_exists('attributes', $item)) { foreach ($item['attributes'] as $key => $value) { if ($value['defindex'] == 134) { $item['_particleEffect'] = $item['attributes'][$key]['float_value']; } } if ($item['defindex'] != 267 && $item['defindex'] != 266 && $item['quality'] === 5) { $userUnusuals[] = $item; } } else { if ($item['quality'] == 5 && !isset($item['_particleEffect'])) { $item['_particleEffect'] = "none"; } } $item['crateNum'] = 0; if (array_key_exists('attributes', $item)) { foreach ($item['attributes'] as $key => $value) { if ($value['defindex'] == 187) { $item['crateNum'] = $item['attributes'][$key]['float_value']; } if ($value['defindex'] == 2027) { $item['isAus'] = 1; } } } } skipBackPack: //echo $i . ' <a href="http://steamcommunity.com/profiles/' . $profile . '" target=blank>' . $userProfile['personaname'] . '</a> '; if (!empty($userUnusuals)) { addUnusualToDB($userUnusuals, $userProfile, $steamHours); if ($is_additive == true) { $add++; } else { $upd++; } } if (empty($userUnusuals) && $backpack['result']['status'] === 1) { //deleteUserFromDB($profile); //echo'removed. (no unusuals)'; //deleteUserFromDB($profile); if ($is_additive == true) { } else { $rmv++; } } /* if ( $backpack['result']['status'] === 15 ) { deleteUserFromDB( $profile ); //echo'removed. (private bp)'; deleteUserFromDB( $profile ); if ( $is_additive == true ); else $rmv++; } */ } $timestamp = time(); file_put_contents('/cron/history.txt', 'finished on ' . gmdate("Y-m-d\\TH:i:s\\Z", $timestamp) . ' add:' . $add . ' rem' . $rmv . ' updt' . $upd . "\n", FILE_APPEND); }
<?php include 'php/440_core.php'; createHead('Restricted Test'); if (isset($_SESSION['sid']) && $_SESSION['sid'] == 76561198013370444) { $res = get_data('http://api.steampowered.com/IEconItems_440/GetSchema/v0001/?key=' . AKey() . '&language=en', 5); var_dump($res); } else { echo 'Hey! you\'re not digits, get out of here!'; } createFooter(440);