protected function execute(InputInterface $input, OutputInterface $output)
 {
     $name = $input->getArgument('name');
     $id = SteamID::create($name);
     $status = $id->isOnline() ? 'Online' : 'Offline';
     $output->writeln("Current user nickname: <info>" . $id->getNickname() . '</info>, user is: <info>' . $status . '</info>');
     if ($input->getOption('showgames')) {
         $games = $id->getGames();
         foreach ($games as $gameId => $game) {
             $output->writeln('[' . $gameId . '] ' . $game->getName());
         }
     }
 }
 public function getProfileUrl($bLang = true)
 {
     // load config
     $oGpcConfig = GpcConfig::getInstance('get');
     // get selected id
     $sID = $oGpcConfig->getString('id', null);
     if ($sID == null) {
         throw new Exception('No profile ID assigned');
     }
     $oSteamID = new SteamID($sID);
     $sXmlUrl = 'http://steamcommunity.com/';
     // choose if we got a numeric id or an alias
     if (!$oSteamID->isValid()) {
         // complain about invalid characters, if found
         if (!preg_match('/^[a-zA-Z0-9-_]+$/', $sID)) {
             throw new Exception("Invalid profile alias: {$sID}");
         }
         $sXmlUrl .= 'id/' . $sID;
     } else {
         $sXmlUrl .= 'profiles/' . $oSteamID->getSteamComID();
     }
     // add xml parameter so we get xml data (hopefully)
     $sXmlUrl .= '?xml=1';
     // get language setting
     $sLang = $oGpcConfig->getString('lang', null);
     if (!$bLang || $sLang == null) {
         // we're done here
         return $sXmlUrl;
     }
     $sLang = strtolower($sLang);
     if (in_array($sLang, self::$aValidLang)) {
         // add language parameter
         $sXmlUrl .= '&l=' . $sLang;
     }
     return $sXmlUrl;
 }
Пример #3
0
<?php

// Simpler solution which doesn't perform any API requests and simply only works on /profiles/ urls
$SteamID = SteamID::SetFromURL('http://steamcommunity.com/profiles/[U:1:2]', function () {
    return null;
});
$WebAPIKey = 'YOUR WEBAPI KEY HERE';
$SteamID = SteamID::SetFromURL('http://steamcommunity.com/groups/valve', function ($URL, $Type) use($WebAPIKey) {
    $Parameters = ['format' => 'json', 'key' => $WebAPIKey, 'vanityurl' => $URL, 'url_type' => $Type];
    $c = curl_init();
    curl_setopt_array($c, [CURLOPT_USERAGENT => 'Steam Vanity URL Lookup', CURLOPT_ENCODING => 'gzip', CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => 'https://api.steampowered.com/ISteamUser/ResolveVanityUR/v1/?' . http_build_query($Parameters), CURLOPT_CONNECTTIMEOUT => 5, CURLOPT_TIMEOUT => 5]);
    $Response = curl_exec($c);
    curl_close($c);
    $Response = json_decode($Response, true);
    if (isset($Response['response']['success'])) {
        switch ((int) $Response['response']['success']) {
            case 1:
                return $Response['response']['steamid'];
            case 42:
                return null;
        }
    }
    throw new Exception('Failed to perform API request');
});
Пример #4
0
 /** -----------------------------------------------------------------------
  * Set the default setting for $resolve_vanity for Parse()
  *
  * @param bool $resolve_vanity Default $resolve_vanity value, 
  *                             see Parse function.
  */
 public static function SetResolveVanityDefault($resolve_vanity)
 {
     self::$default_resolve_vanity = $resolve_vanity;
 }
Пример #5
0
            <th>Jumps</th></tr>

            <?php 
                }
                ?>

          <tr><td>#<?php 
                echo $rank;
                ?>
</td>
          <td><?php 
                echo $id;
                ?>
</td>
          <td><?php 
                $steamid = SteamID::Parse($auth, SteamID::FORMAT_STEAMID3);
                echo "<a href=\"http://steamcommunity.com/profiles/" . $steamid->Format(SteamID::FORMAT_STEAMID64) . "/\">" . $auth . "</a>";
                ?>
</td>
          <td class="name"><?php 
                echo $name;
                ?>
</td>
          <td class="time">

          <?php 
                echo formattoseconds($time);
                ?>
</td>
          <td><?php 
                echo number_format($jumps);
Пример #6
0
<?php

require_once APP_ROOT . '/lib/SteamID/SteamID.php';
use Curl\Curl;
$app->get('/tasks/link_steam_profiles', function () use($app) {
    $sleep_time = 100;
    $steam_api_key = $app['bm.config']['steam_api_key'];
    $unlinked_player_profiles = $app['mongo.db']->selectCollection('player_profiles')->find(['steamdata' => ['$type' => 10]])->sort(['points' => -1])->limit(50);
    $unlinked_player_profiles = array_map(function ($player_profile_doc) use($steam_api_key) {
        $steamid3_value = $player_profile_doc['payload_steamid'];
        $steam_api_url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?";
        $steam_api_url .= "key={$steam_api_key}";
        $steam_api_url .= "&steamids=";
        $steam_id = SteamID::Parse("[U:1:{$steamid3_value}]");
        $steamid64 = $steam_id->Format(SteamID::FORMAT_STEAMID64);
        if ($steamid64) {
            $steam_api_url .= $steamid64;
            $curl = new \Curl\Curl();
            $curl->get($steam_api_url);
            $steamdata = json_decode(json_encode($curl->response), 1);
            $player_profile_doc['steamdata'] = @$steamdata['response']['players'][0] ?: null;
            @($player_profile_doc['steamdata']['personaname'] = strip_tags($player_profile_doc['steamdata']['personaname']));
            // remove all unicode and html from usernames, move this to functions.php file
            $player_profile_doc['steamid64'] = $steamid64;
        }
        return $player_profile_doc;
    }, iterator_to_array($unlinked_player_profiles, 0));
    array_walk($unlinked_player_profiles, function ($player_profile_doc) use($app, $sleep_time) {
        if (empty($player_profile_doc['steamdata'])) {
            echo "no steamdata received for {$player_profile_doc['payload_steamid']}\n";
            return;
Пример #7
0
 /**
  * Returns a SteamID instance constructed from a steamcommunity.com
  * URL form, or simply from a vanity url.
  *
  * Please note that you must implement vanity lookup function using
  * ISteamUser/ResolveVanityURL api interface yourself.
  *
  * Callback function must return resolved SteamID as a string,
  * or null if API returns success=42 (meaning no match).
  * 
  * It's up to you to throw any exceptions if you wish to do so.
  *
  * This function can act as a pass-through for rendered Steam2/Steam3 ids.
  *
  * Example implementation is provided in `VanityURLs.php` file.
  *
  * @param string $Value Input URL
  * @param string $VanityCallback Callback which is called when a vanity lookup is required
  * 
  * @return SteamID Fluent interface
  * 
  * @throws InvalidArgumentException
  */
 public static function SetFromURL($Value, callable $VanityCallback)
 {
     if (preg_match('/^https?:\\/\\/steamcommunity.com\\/profiles\\/(.+?)(?:\\/|$)/', $Value, $Matches) === 1) {
         $Value = $Matches[1];
     } else {
         if (preg_match('/^https?:\\/\\/steamcommunity.com\\/(id|groups|games)\\/([\\w-]+)(?:\\/|$)/', $Value, $Matches) === 1 || preg_match('/^()([\\w-]+)$/', $Value, $Matches) === 1) {
             $Length = strlen($Matches[2]);
             if ($Length < 2 || $Length > 32) {
                 throw new InvalidArgumentException('Provided vanity url has bad length.');
             }
             // Steam doesn't allow vanity urls to be valid steamids
             if (self::IsNumeric($Matches[2])) {
                 $SteamID = new SteamID($Matches[2]);
                 if ($SteamID->IsValid()) {
                     return $SteamID;
                 }
             }
             switch ($Matches[1]) {
                 case 'groups':
                     $VanityType = self::VanityGroup;
                     break;
                 case 'games':
                     $VanityType = self::VanityGameGroup;
                     break;
                 default:
                     $VanityType = self::VanityIndividual;
             }
             $Value = call_user_func($VanityCallback, $Matches[2], $VanityType);
             if ($Value === null) {
                 throw new InvalidArgumentException('Provided vanity url does not resolve to any SteamID.');
             }
         }
     }
     return new SteamID($Value);
 }
 /**
  * @param $username
  * @param $game
  * @return array
  */
 public function hoursPlayed($username, $game)
 {
     $id = SteamID::create($username);
     $stats = $id->getGameStats('tf2');
     return $stats->getHoursPlayed();
 }
Пример #9
0
 /**
  * @dataProvider invalidVanityUrlProvider
  *
  * @expectedException InvalidArgumentException
  * @expectedExceptionMessage vanity url
  */
 public function testInvalidSetFromUrl($URL)
 {
     SteamID::SetFromURL($URL, [$this, 'fakeResolveVanityURL']);
 }
Пример #10
0
            $ReplaceText = str_replace("^6", "</span><span style='color:brown'>", $ReplaceText);
            $ReplaceText = str_replace("^7", "</span><span style='color:lightblue'>", $ReplaceText);
            $ReplaceText = str_replace("^8", "</span><span style='color:gray'>", $ReplaceText);
            $GetName = $ReplaceText . "</span>";
        }
        if ($row['online'] == "false") {
            $GetStatus = "";
        } else {
            $GetStatus = "<span style='color:green'>Online</span>";
        }
        if ($row['country'] == "") {
            $SetCountry = "00";
        } else {
            $SetCountry = $row['country'];
        }
        $oSteamID = new SteamID($row['authid']);
        $oSteamURL = "http://steamcommunity.com/profiles/" . $oSteamID->getSteamID64();
        echo "<img src='images/flags/{$SetCountry}.png' title='{$country[$SetCountry]}' height='11' width='16'> <a href='{$oSteamURL}' target='_blank'>" . $GetName . "</a> " . $GetStatus;
        ?>
				</td>
				<td class="row1" align="center" nowrap="" width="220">
					<span class="row2">
						<table cellpadding="5">
							<tbody>
								<tr>
									<td align="center">
										<?php 
        echo get_lastseen($row['date']);
        ?>
									</td>
								</tr>