repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/bootstrap.php
src/bootstrap.php
<?php declare(strict_types=1); const RELEASE_ROOT = __DIR__."/.."; const PROJECT_ROOT = RELEASE_ROOT."/../.."; const TEMP_DIR = RELEASE_ROOT."/temp"; const LOGS_DIR = RELEASE_ROOT."/logs"; const BIN_DIR = RELEASE_ROOT."/bin"; require_once RELEASE_ROOT."/vendor/autoload.php"; use AugmentedSteam\Server\Config\BrightDataConfig; use AugmentedSteam\Server\Config\CoreConfig; use AugmentedSteam\Server\Endpoints\EndpointsConfig; use AugmentedSteam\Server\Endpoints\KeysConfig; use AugmentedSteam\Server\Environment\Container; use AugmentedSteam\Server\Lib\Logging\LoggingConfig; use AugmentedSteam\Server\Lib\Redis\RedisConfig; use IsThereAnyDeal\Config\Config; use IsThereAnyDeal\Database\DbConfig; $config = new Config(); $config->map([ CoreConfig::class => "core", DbConfig::class => "db", RedisConfig::class => "redis", LoggingConfig::class => "logging", KeysConfig::class => "keys", EndpointsConfig::class => "endpoints", BrightDataConfig::class => "brightdata" ]); $config->loadJsonFile(PROJECT_ROOT."/".getenv("AS_SERVER_CONFIG")); Container::init($config); /** @var AugmentedSteam\Server\Config\CoreConfig $coreConfig */ $coreConfig = $config->getConfig(CoreConfig::class); if ($coreConfig->usePrettyErrors()) { $whoops = (new \Whoops\Run); $whoops->pushHandler( \Whoops\Util\Misc::isCommandLine() ? new \Whoops\Handler\PlainTextHandler() : new \Whoops\Handler\JsonResponseHandler() ); $whoops->register(); } if ($coreConfig->isSentryEnabled()) { Sentry\init([ "dsn" => $coreConfig->getSentryDsn(), "environment" => $coreConfig->getSentryEnvironment(), "error_types" => E_ALL, ]); }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Routing/Router.php
src/Routing/Router.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Routing; use AugmentedSteam\Server\Config\CoreConfig; use AugmentedSteam\Server\Controllers\AppController; use AugmentedSteam\Server\Controllers\DLCController; use AugmentedSteam\Server\Controllers\EarlyAccessController; use AugmentedSteam\Server\Controllers\MarketController; use AugmentedSteam\Server\Controllers\PricesController; use AugmentedSteam\Server\Controllers\ProfileController; use AugmentedSteam\Server\Controllers\ProfileManagementController; use AugmentedSteam\Server\Controllers\RatesController; use AugmentedSteam\Server\Controllers\SimilarController; use AugmentedSteam\Server\Controllers\TwitchController; use AugmentedSteam\Server\Environment\Container; use AugmentedSteam\Server\Lib\Logging\LoggerFactoryInterface; use AugmentedSteam\Server\Lib\Redis\RedisClient; use AugmentedSteam\Server\Routing\Middleware\AccessLogMiddleware; use AugmentedSteam\Server\Routing\Middleware\IpThrottleMiddleware; use AugmentedSteam\Server\Routing\Strategy\ApiStrategy; use Laminas\Diactoros\ServerRequestFactory; use Laminas\HttpHandlerRunner\Emitter\SapiEmitter; use League\Route\RouteGroup; use Psr\Http\Message\ResponseFactoryInterface; class Router { private function defineRoutes(\League\Route\Router $router): void { $router->get("/rates/v1", [RatesController::class, "rates_v1"]); $router->get("/early-access/v1", [EarlyAccessController::class, "appids_v1"]); $router->post("/prices/v2", [PricesController::class, "prices_v2"]); $router->get("/app/{appid:\d+}/v2", [AppController::class, "appInfo_v2"]); $router->get("/dlc/{appid:\d+}/v2", [DLCController::class, "dlcInfo_v2"]); $router->get("/similar/{appid:\d+}/v2", [SimilarController::class, "similar_v2"]); $router->get("/twitch/{channel}/stream/v2", [TwitchController::class, "stream_v2"]); // TODO obsolete, remove $router->group("/market", function(RouteGroup $g) { $g->get("/cards/v2", [MarketController::class, "cards_v2"]); $g->get("/cards/average-prices/v2", [MarketController::class, "averageCardPrices_v2"]); }); $router->group("/profile", function(RouteGroup $g) { $g->get("/{steamId:\d+}/v2", [ProfileController::class, "profile_v2"]); $g->get("/background/list/v2", [ProfileManagementController::class, "backgrounds_v2"]); $g->get("/background/games/v1", [ProfileManagementController::class, "games_v1"]); $g->get("/background/delete/v2", [ProfileManagementController::class, "deleteBackground_v2"]); $g->get("/background/save/v2", [ProfileManagementController::class, "saveBackground_v2"]); $g->get("/style/delete/v2", [ProfileManagementController::class, "deleteStyle_v2"]); $g->get("/style/save/v2", [ProfileManagementController::class, "saveStyle_v2"]); }); } public function route(Container $container): void { $redis = $container->get(RedisClient::class); $strategy = new ApiStrategy( $container->get(CoreConfig::class), $container->get(ResponseFactoryInterface::class) ); $strategy->setContainer($container); $router = new \League\Route\Router(); $logger = $container->get(LoggerFactoryInterface::class)->access(); $router->middleware(new AccessLogMiddleware($logger)); $router->middleware(new IpThrottleMiddleware($redis, $logger)); $router->setStrategy($strategy); $this->defineRoutes($router); $request = ServerRequestFactory::fromGlobals(); $response = $router->dispatch($request); (new SapiEmitter)->emit($response); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Routing/Strategy/ApiStrategy.php
src/Routing/Strategy/ApiStrategy.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Routing\Strategy; use AugmentedSteam\Server\Config\CoreConfig; use GuzzleHttp\Exception\ClientException; use League\Route\ContainerAwareInterface; use League\Route\Http; use League\Route\Route; use League\Route\Strategy\JsonStrategy; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Throwable; class ApiStrategy extends JsonStrategy implements ContainerAwareInterface { private readonly bool $isDev; public function __construct( CoreConfig $config, ResponseFactoryInterface $responseFactory, int $jsonFlags=0 ) { parent::__construct($responseFactory, $jsonFlags); $this->isDev = $config->isDev(); $this->addResponseDecorator(static function (ResponseInterface $response): ResponseInterface { if (false === $response->hasHeader("access-control-allow-origin")) { $response = $response->withHeader("access-control-allow-origin", "*"); } return $response; }); } public function getThrowableHandler(): MiddlewareInterface { return new class ($this->responseFactory->createResponse(), $this->isDev) implements MiddlewareInterface { public function __construct( private readonly ResponseInterface $response, private readonly bool $isDev ) {} public function process( ServerRequestInterface $request, RequestHandlerInterface $handler ): ResponseInterface { try { return $handler->handle($request); } catch (Throwable $e) { if ($this->isDev) { throw $e; } $response = $this->response; if ($e instanceof Http\Exception) { return $e->buildJsonResponse($response); } if ($e instanceof ClientException && $e->getCode() === 429) { return (new Http\Exception\TooManyRequestsException()) ->buildJsonResponse($response); } \Sentry\captureException($e); $response->getBody()->write(json_encode([ "status_code" => 500, "reason_phrase" => "Internal Server Error" ], flags: JSON_THROW_ON_ERROR)); return $response ->withAddedHeader("content-type", "application/json") ->withStatus(500, "Internal Server Error"); } } }; } public function invokeRouteCallable(Route $route, ServerRequestInterface $request): ResponseInterface { $controller = $route->getCallable($this->getContainer()); $response = $controller($request, $route->getVars()); if ($this->isJsonSerializable($response)) { $body = json_encode($response, $this->jsonFlags | JSON_THROW_ON_ERROR); $response = $this->responseFactory->createResponse(); $response->getBody()->write($body); } return $this->decorateResponse($response); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Routing/Middleware/IpThrottleMiddleware.php
src/Routing/Middleware/IpThrottleMiddleware.php
<?php namespace AugmentedSteam\Server\Routing\Middleware; use AugmentedSteam\Server\Lib\Redis\ERedisKey; use AugmentedSteam\Server\Lib\Redis\RedisClient; use Laminas\Diactoros\Response\EmptyResponse; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Log\LoggerInterface; /** * IP-based throttling instead of App-based throttling */ class IpThrottleMiddleware implements MiddlewareInterface { private const int WindowLength = 60*60; private const int Requests = 200; public function __construct( private readonly RedisClient $redis, private readonly LoggerInterface $logger ) {} public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $server = $request->getServerParams(); $ip = $server['REMOTE_ADDR']; $key = ERedisKey::ApiThrottleIp->getKey($ip); $count = $this->redis->get($key); if (!is_null($count) && $count >= self::Requests) { $expireTime = $this->redis->expiretime($key); if ($expireTime > 0) { $this->logger->info("{$ip} throttled", $request->getQueryParams()); return new EmptyResponse(429, [ "Retry-After" => (string)($expireTime - time()) ]); } } $this->redis->incr($key); $this->redis->expire($key, self::WindowLength, "NX"); return $handler->handle($request); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Routing/Middleware/AccessLogMiddleware.php
src/Routing/Middleware/AccessLogMiddleware.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Routing\Middleware; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\MiddlewareInterface; use Psr\Http\Server\RequestHandlerInterface; use Psr\Log\LoggerInterface; class AccessLogMiddleware implements MiddlewareInterface { public function __construct( private readonly LoggerInterface $logger ) {} public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { $method = $request->getMethod(); $path = $request->getUri()->getPath(); $this->logger->info("{$method} {$path}", $request->getQueryParams()); return $handler->handle($request); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/ProfileController.php
src/Controllers/ProfileController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Managers\SteamRepManager; use AugmentedSteam\Server\Data\Managers\UserManager; use AugmentedSteam\Server\Database\DBadges; use Psr\Http\Message\ServerRequestInterface; class ProfileController extends Controller { public function __construct( private readonly UserManager $userManager, private readonly SteamRepManager $steamRepManager ) {} /** * @param array{steamId: int} $params * @return array<string, mixed> */ public function profile_v2(ServerRequestInterface $request, array $params): array { $steamId = (int)$params['steamId']; $info = $this->userManager->getProfileInfo($steamId); $badges = $this->userManager->getBadges($steamId) ->toArray(fn(DBadges $badge) => [ "title" => $badge->getTitle(), "img" => $badge->getImg() ]); return [ "badges" => $badges, "steamrep" => $this->steamRepManager->getReputation($steamId), "style" => $info?->getStyle(), "bg" => [ "img" => $info?->getBgImg(), "appid" => $info?->getBgAppid(), ], ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/RatesController.php
src/Controllers/RatesController.php
<?php namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Exceptions\InvalidValueException; use AugmentedSteam\Server\Lib\Http\ListParam; use AugmentedSteam\Server\Lib\Money\CurrencyConverter; use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ServerRequestInterface; class RatesController extends Controller { public function __construct( private readonly CurrencyConverter $converter ) {} public function rates_v1(ServerRequestInterface $request): JsonResponse { /** @var list<string> $currencies */ $currencies = (new ListParam($request, "to"))->value(); if (count($currencies) == 0 || count($currencies) > 2) { throw new InvalidValueException("to"); } return (new JsonResponse( $this->converter->getAllConversionsTo($currencies) ))->withHeader("Cache-Control", "max-age=43200, public"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/Controller.php
src/Controllers/Controller.php
<?php namespace AugmentedSteam\Server\Controllers; use League\Route\Http\Exception\BadRequestException; abstract class Controller { /** * @param array<mixed> $data * @return list<int> */ protected function validateIntList(array $data, string $key): array { if (isset($data[$key])) { if (!is_array($data[$key]) || !array_is_list($data[$key])) { throw new BadRequestException(); } foreach($data[$key] as $value) { if (!is_int($value)) { throw new BadRequestException(); } } } return $data[$key] ?? []; // @phpstan-ignore-line } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/DLCController.php
src/Controllers/DLCController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Database\DDlcCategories; use AugmentedSteam\Server\Database\TDlcCategories; use AugmentedSteam\Server\Database\TGameDlc; use IsThereAnyDeal\Database\DbDriver; use Psr\Http\Message\ServerRequestInterface; class DLCController extends Controller { public function __construct( private readonly DbDriver $db ) {} /** * @param array{appid: numeric-string} $params * @return list<array{id: number, name: string, description: string}> */ public function dlcInfo_v2(ServerRequestInterface $request, array $params): array { $appid = intval($params['appid']); if (empty($appid)) { return []; } $g = new TGameDlc(); $d = new TDlcCategories(); return $this->db->select(<<<SQL SELECT $d->id, $d->name, $d->description, $d->icon FROM $g JOIN $d ON $g->dlc_category=$d->id WHERE $g->appid=:appid ORDER BY $g->score DESC LIMIT 3 SQL )->params([ ":appid" => $appid ])->fetch(DDlcCategories::class) ->toArray(fn(DDlcCategories $o) => [ "id" => $o->getId(), "name" => $o->getName(), "description" => $o->getDescription(), "icon" => $o->getIcon() ]); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/ProfileManagementController.php
src/Controllers/ProfileManagementController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Managers\Market\MarketManager; use AugmentedSteam\Server\Data\Managers\UserManager; use AugmentedSteam\Server\Lib\Http\IntParam; use AugmentedSteam\Server\Lib\Http\StringParam; use AugmentedSteam\Server\Lib\OpenId\Session; use Laminas\Diactoros\Response\RedirectResponse; use Psr\Http\Message\ServerRequestInterface; use Throwable; class ProfileManagementController extends Controller { private const string ReturnUrl = "https://steamcommunity.com/my/profile"; private const string Error_BadRequest = "#as-error:badrequest"; private const string Error_NotFound = "#as-error:notfound"; private const string Success = "#as-success"; private const string Failure = "#as-failure"; public function __construct( private readonly Session $session, private readonly MarketManager $marketManager, private readonly UserManager $userManager ) { } /** * @return list<array{string, string}> */ public function backgrounds_v2(ServerRequestInterface $request): array { /** @var int $appid */ $appid = (new IntParam($request, "appid"))->value(); return $this->marketManager ->getBackgrounds($appid); } /** * @return list<array{int, string}> */ public function games_v1(ServerRequestInterface $request): array { return $this->marketManager ->getGamesWithBackgrounds(); } public function deleteBackground_v2(ServerRequestInterface $request): RedirectResponse { /** @var ?int $profile */ $profile = (new IntParam($request, "profile", default: null, nullable: true))->value(); $authResponse = $this->session->authorize( $request, "/profile/background/delete/v2", self::ReturnUrl.self::Failure, $profile ); if ($authResponse instanceof RedirectResponse) { return $authResponse; } $steamId = $authResponse; $this->userManager ->deleteBackground($steamId); return new RedirectResponse(self::ReturnUrl.self::Success); } public function saveBackground_v2(ServerRequestInterface $request): RedirectResponse { try { /** @var int $appid */ $appid = (new IntParam($request, "appid"))->value(); /** @var string $img */ $img = (new StringParam($request, "img"))->value(); /** @var ?int $profile */ $profile = (new IntParam($request, "profile", default: null, nullable: true))->value(); } catch(Throwable) { return new RedirectResponse(self::ReturnUrl.self::Error_BadRequest); } if (!$this->marketManager->doesBackgroundExist($appid, $img)) { return new RedirectResponse(self::ReturnUrl.self::Error_NotFound); } $authResponse = $this->session->authorize( $request, "/profile/background/save/v2?appid=$appid&img=$img", self::ReturnUrl.self::Failure, $profile ); if ($authResponse instanceof RedirectResponse) { return $authResponse; } $steamId = $authResponse; $this->userManager ->saveBackground($steamId, $appid, $img); return new RedirectResponse(self::ReturnUrl.self::Success); } public function deleteStyle_v2(ServerRequestInterface $request): RedirectResponse { /** @var ?int $profile */ $profile = (new IntParam($request, "profile", default: null, nullable: true))->value(); $authResponse = $this->session->authorize( $request, "/profile/style/delete/v2", self::ReturnUrl.self::Failure, $profile ); if ($authResponse instanceof RedirectResponse) { return $authResponse; } $steamId = $authResponse; $this->userManager ->deleteStyle($steamId); return new RedirectResponse(self::ReturnUrl.self::Success); } public function saveStyle_v2(ServerRequestInterface $request): RedirectResponse { try { /** @var string $style */ $style = (new StringParam($request, "style"))->value(); /** @var ?int $profile */ $profile = (new IntParam($request, "profile", default: null, nullable: true))->value(); } catch(Throwable) { return new RedirectResponse(self::ReturnUrl.self::Error_BadRequest); } $authResponse = $this->session->authorize( $request, "/profile/style/save/v2?style=$style", self::ReturnUrl.self::Failure, $profile ); if ($authResponse instanceof RedirectResponse) { return $authResponse; } $steamId = $authResponse; $this->userManager ->saveStyle($steamId, $style); return new RedirectResponse(self::ReturnUrl.self::Success); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/MarketController.php
src/Controllers/MarketController.php
<?php namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Managers\Market\MarketIndex; use AugmentedSteam\Server\Data\Managers\Market\MarketManager; use AugmentedSteam\Server\Exceptions\InvalidValueException; use AugmentedSteam\Server\Lib\Http\IntParam; use AugmentedSteam\Server\Lib\Http\ListParam; use AugmentedSteam\Server\Lib\Http\StringParam; use AugmentedSteam\Server\Lib\Money\CurrencyConverter; use Psr\Http\Message\ServerRequestInterface; class MarketController extends Controller { public function __construct( private readonly CurrencyConverter $converter, private readonly MarketIndex $index, private readonly MarketManager $manager ) {} /** * @return array<mixed> */ public function averageCardPrices_v2(ServerRequestInterface $request): array { /** @var string $currency */ $currency = (new StringParam($request, "currency"))->value(); /** @var list<string> $appids */ $appids = (new ListParam($request, "appids"))->value(); $appids = array_values(array_filter( array_map(fn($id) => intval($id), $appids), fn($id) => $id > 0 )); if (count($appids) == 0) { throw new InvalidValueException("appids"); } $conversion = $this->converter->getConversion("USD", $currency); if (!is_float($conversion)) { throw new \Exception(); } $this->index->recordRequest(...$appids); return $this->manager->getAverageCardPrices($appids, $conversion); } /** * @return array<mixed> */ public function cards_v2(ServerRequestInterface $request): array { /** @var string $currency */ $currency = (new StringParam($request, "currency"))->value(); /** @var int $appid */ $appid = (new IntParam($request, "appid"))->value(); $conversion = $this->converter->getConversion("USD", $currency); if (!is_float($conversion)) { throw new \Exception(); } $this->index->recordRequest($appid); return $this->manager->getCards($appid, $conversion); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/AppController.php
src/Controllers/AppController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Interfaces\AppData\AppDataProviderInterface; use AugmentedSteam\Server\Data\Interfaces\AppData\HLTBProviderInterface; use AugmentedSteam\Server\Data\Interfaces\AppData\PlayersProviderInterface; use AugmentedSteam\Server\Data\Interfaces\AppData\ReviewsProviderInterface; use AugmentedSteam\Server\Data\Interfaces\AppData\WSGFProviderInterface; use AugmentedSteam\Server\Data\Interfaces\ExfglsProviderInterface; use AugmentedSteam\Server\Lib\Cache\CacheInterface; use AugmentedSteam\Server\Lib\Cache\ECacheKey; use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ServerRequestInterface; class AppController extends Controller { public function __construct( private readonly CacheInterface $cache, private readonly WSGFProviderInterface $wsgf, private readonly ExfglsProviderInterface $exfgls, private readonly HLTBProviderInterface $hltb, private readonly ReviewsProviderInterface $reviews, private readonly PlayersProviderInterface $players, ) {} public function getData( AppDataProviderInterface $provider, ECacheKey $cacheKey, int $appid, int $ttl ): mixed { $key = $cacheKey; $field = (string)$appid; if ($this->cache->has($key, $field)) { return $this->cache->get($key, $field); } $data = $provider->fetch($appid); $this->cache->set($key, $field, $data, $ttl); return $data; } /** * @param array{appid: numeric-string} $params */ public function appInfo_v2(ServerRequestInterface $request, array $params): JsonResponse { $appid = intval($params['appid']); return (new JsonResponse([ "family_sharing" => !$this->getData($this->exfgls, ECacheKey::Exfgls, $appid, 6*3600), "players" => $this->getData($this->players, ECacheKey::Players, $appid, 30*60), "wsgf" => $this->getData($this->wsgf, ECacheKey::WSGF, $appid, 3*86400), "hltb" => $this->getData($this->hltb, ECacheKey::HLTB, $appid, 86400), "reviews" => $this->getData($this->reviews, ECacheKey::Reviews, $appid, 86400) ]))->withHeader("Cache-Control", "max-age=1800, public"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/EarlyAccessController.php
src/Controllers/EarlyAccessController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Interfaces\EarlyAccessProviderInterface; use AugmentedSteam\Server\Lib\Cache\CacheInterface; use AugmentedSteam\Server\Lib\Cache\ECacheKey; use Laminas\Diactoros\Response\JsonResponse; use Psr\Http\Message\ServerRequestInterface; class EarlyAccessController extends Controller { private const int TTL = 3600; public function __construct( private readonly CacheInterface $cache, private readonly EarlyAccessProviderInterface $provider ) {} public function appids_v1(ServerRequestInterface $request): JsonResponse { $key = ECacheKey::EarlyAccess; $field = "ea"; $appids = null; if ($this->cache->has($key, $field)) { $appids = $this->cache->get($key, $field) ?? []; if (!is_array($appids) || !array_is_list($appids)) { throw new \Exception(); } } if (empty($appids)) { $appids = $this->provider->fetch(); $this->cache->set($key, $field, $appids, self::TTL); } return (new JsonResponse($appids)) ->withHeader("Cache-Control", "max-age=3600, public");; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/TwitchController.php
src/Controllers/TwitchController.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Interfaces\TwitchProviderInterface; use AugmentedSteam\Server\Data\Objects\TwitchStream; use AugmentedSteam\Server\Lib\Cache\CacheInterface; use AugmentedSteam\Server\Lib\Cache\ECacheKey; use JsonSerializable; use Psr\Http\Message\ServerRequestInterface; class TwitchController extends Controller { public function __construct( private readonly CacheInterface $cache, private readonly TwitchProviderInterface $twitch ) {} /** * @param array{channel: string} $params * @return array<mixed>|JsonSerializable */ public function stream_v2(ServerRequestInterface $request, array $params): array|JsonSerializable { $channel = $params['channel']; $key = ECacheKey::Twitch; $field = $channel; if ($this->cache->has($key, $field)) { $stream = $this->cache->get($key, $field); if (!is_null($stream) && !($stream instanceof TwitchStream)) { throw new \Exception(); } } else { $stream = $this->twitch->fetch($channel); $this->cache->set($key, $field, $stream, 1800); } return $stream ?? []; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/SimilarController.php
src/Controllers/SimilarController.php
<?php namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Interfaces\AppData\SteamPeekProviderInterface; use AugmentedSteam\Server\Data\Objects\SteamPeak\SteamPeekResults; use AugmentedSteam\Server\Lib\Cache\CacheInterface; use AugmentedSteam\Server\Lib\Cache\ECacheKey; use AugmentedSteam\Server\Lib\Http\BoolParam; use AugmentedSteam\Server\Lib\Http\IntParam; use Psr\Http\Message\ServerRequestInterface; class SimilarController extends Controller { public function __construct( private readonly CacheInterface $cache, private readonly SteamPeekProviderInterface $steamPeek ) {} /** * @param array{ * appid: numeric-string * } $params * @return array<mixed>|\JsonSerializable */ public function similar_v2(ServerRequestInterface $request, array $params): array|\JsonSerializable { $appid = intval($params['appid']); /** @var int $count */ $count = (new IntParam($request, "count", 5))->value(); /** @var bool $shuffle */ $shuffle = (new BoolParam($request, "shuffle", false))->value(); $key = ECacheKey::SteamPeek; $field = (string)$appid; if ($this->cache->has($key, $field)) { $games = $this->cache->get($key, $field); if (!is_null($games) && !($games instanceof SteamPeekResults)) { throw new \Exception(); } } else { $games = $this->steamPeek->fetch($appid); $this->cache->set($key, $field, $games, 10*86400); } if (is_null($games)) { return []; } return $games ->shuffle($shuffle) ->limit($count); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Controllers/PricesController.php
src/Controllers/PricesController.php
<?php namespace AugmentedSteam\Server\Controllers; use AugmentedSteam\Server\Data\Interfaces\PricesProviderInterface; use JsonSerializable; use League\Route\Http\Exception\BadRequestException; use Psr\Http\Message\ServerRequestInterface; class PricesController extends Controller { public function __construct( private readonly PricesProviderInterface $pricesProvider ) {} /** * @return array<mixed>|JsonSerializable */ public function prices_v2(ServerRequestInterface $request): array|JsonSerializable { $data = $request->getBody()->getContents(); if (!json_validate($data)) { throw new BadRequestException(); } $params = json_decode($data, true, flags: JSON_THROW_ON_ERROR); if (!is_array($params) || !isset($params['country']) || !is_string($params['country'])) { throw new BadRequestException(); } $country = $params['country']; $shops = $this->validateIntList($params, "shops"); $apps = $this->validateIntList($params, "apps"); $subs = $this->validateIntList($params, "subs"); $bundles = $this->validateIntList($params, "bundles"); $voucher = filter_var($params['voucher'] ?? true, FILTER_VALIDATE_BOOLEAN); $ids = array_merge( array_map(fn($id) => "app/$id", array_filter($apps)), array_map(fn($id) => "sub/$id", array_filter($subs)), array_map(fn($id) => "bundle/$id", array_filter($bundles)), ); if (count($ids) == 0) { throw new BadRequestException(); } $overview = $this->pricesProvider->fetch($ids, $shops, $country, $voucher); return $overview ?? []; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Exceptions/InvalidValueException.php
src/Exceptions/InvalidValueException.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Exceptions; class InvalidValueException extends ApiException { public function __construct(string $paramName) { parent::__construct("invalid_value", "Parameter '{$paramName}' has invalid value"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Exceptions/MissingParameterException.php
src/Exceptions/MissingParameterException.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Exceptions; class MissingParameterException extends ApiException { public function __construct(string $missingParamName) { parent::__construct("missing_param", "Required parameter '{$missingParamName}' is missing"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Exceptions/ApiException.php
src/Exceptions/ApiException.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Exceptions; use League\Route\Http\Exception\BadRequestException; use Psr\Http\Message\ResponseInterface; abstract class ApiException extends BadRequestException { public function __construct( private readonly string $errorCode, private readonly string $errorMessage ) { parent::__construct(); } public function buildJsonResponse(ResponseInterface $response): ResponseInterface { $this->headers['content-type'] = 'application/json'; foreach ($this->headers as $key => $value) { /** @var ResponseInterface $response */ $response = $response->withAddedHeader($key, $value); } if ($response->getBody()->isWritable()) { $response->getBody()->write(json_encode([ "error" => $this->errorCode, "error_description" => $this->errorMessage, "status_code" => $this->status, "reason_phrase" => $this->message ], flags: JSON_THROW_ON_ERROR)); } return $response->withStatus($this->status, $this->message); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Endpoints/EndpointBuilder.php
src/Endpoints/EndpointBuilder.php
<?php namespace AugmentedSteam\Server\Endpoints; class EndpointBuilder { public function __construct( private readonly EndpointsConfig $endpoints, private readonly KeysConfig $keys ) {} public function getSteamRep(int $steamId): string { return sprintf($this->endpoints->getSteamRepEndpoint(), $steamId); } public function getSteamPeek(int $appid): string { return sprintf($this->endpoints->getSteamPeekEndpoint(), $appid, $this->keys->getSteamPeekApiKey()); } public function getEarlyAccess(): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/early-access/v1?key={$key}"; } public function getSteamIdLookup(): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/lookup/id/shop/61/v1?key={$key}"; } /** * @param list<int> $shops */ public function getPrices(string $country, array $shops, bool $withVouchers): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/games/overview/v2?".http_build_query([ "key" => $key, "country" => $country, "shops" => implode(",", $shops), "vouchers" => $withVouchers ]); } public function getTwitchStream(string $channel): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/twitch/stream/v1?key={$key}&channel={$channel}"; } public function getPlayers(int $appid): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/players/v1?key={$key}&appid={$appid}"; } public function getReviews(int $appid): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/reviews/v1?key={$key}&appid={$appid}"; } public function getHLTB(int $appid): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/hltb/v1?key={$key}&appid={$appid}"; } public function getWSGF(int $appid): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/wsgf/v1?key={$key}&appid={$appid}"; } public function getRates(): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/rates/v1?key={$key}"; } public function getExfgls(): string { $host = $this->endpoints->getIsThereAnyDealApiHost(); $key = $this->keys->getIsThereAnyDealApiKey(); return $host."/internal/exfgls/v1?key={$key}"; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Endpoints/EndpointsConfig.php
src/Endpoints/EndpointsConfig.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Endpoints; use Nette\Schema\Expect; use Nette\Schema\Processor; class EndpointsConfig { /** * @var object{ * wsgf: string, * steamspy: string, * steamrep: string, * steampeek: string, * itad: string * } */ private readonly object $config; public function __construct(mixed $config) { // @phpstan-ignore-next-line $this->config = (new Processor())->process(Expect::structure([ "wsgf" => Expect::string()->required(), "steamspy" => Expect::string()->required(), "steamrep" => Expect::string()->required(), "steampeek" => Expect::string()->required(), "itad" => Expect::string()->required() ]), $config); } public function getWSGFEndpoint(): string { return $this->config->wsgf; } public function getSteamSpyEndpoint(int $appid): string { return sprintf($this->config->steamspy, $appid); } public function getSteamRepEndpoint(): string { return $this->config->steamrep; } public function getSteamPeekEndpoint(): string { return $this->config->steampeek; } public function getIsThereAnyDealApiHost(): string { return $this->config->itad; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Endpoints/KeysConfig.php
src/Endpoints/KeysConfig.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Endpoints; use Nette\Schema\Expect; use Nette\Schema\Processor; class KeysConfig { /** * @var object{ * itad: string, * steampeek: string * } */ private readonly object $config; public function __construct(mixed $config) { // @phpstan-ignore-next-line $this->config = (new Processor())->process(Expect::structure([ "itad" => Expect::string()->required(), "steampeek" => Expect::string()->required() ]), $config); } public function getIsThereAnyDealApiKey(): string { return $this->config->itad; } public function getSteamPeekApiKey(): string { return $this->config->steampeek; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Redis/ERedisKey.php
src/Lib/Redis/ERedisKey.php
<?php namespace AugmentedSteam\Server\Lib\Redis; enum ERedisKey: string { case ApiThrottleIp = "throttle"; case PriceOverview = "overview"; case Gids = "gids"; public function getKey(string $suffix=""): string { return empty($suffix) ? $this->value : "{$this->value}:{$suffix}"; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Redis/RedisConfig.php
src/Lib/Redis/RedisConfig.php
<?php namespace AugmentedSteam\Server\Lib\Redis; use Nette\Schema\Expect; use Nette\Schema\Processor; class RedisConfig { /** * @var object{ * scheme: string, * host: string, * port: int, * prefix: string, * database: int * } */ private object $data; /** @param array<mixed> $config */ public function __construct(array $config) { $this->data = (new Processor())->process( // @phpstan-ignore-line Expect::structure([ "scheme" => Expect::anyOf("tcp")->required(), "host" => Expect::string()->required(), "port" => Expect::int(6379), "prefix" => Expect::string()->required(), "database" => Expect::int()->required() ]), $config ); } public function getScheme(): string { return $this->data->scheme; } public function getHost(): string { return $this->data->host; } public function getPort(): int { return $this->data->port; } public function getPrefix(): string { return $this->data->prefix; } public function getDatabase(): int { return $this->data->database; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Redis/RedisClient.php
src/Lib/Redis/RedisClient.php
<?php namespace AugmentedSteam\Server\Lib\Redis; class RedisClient extends \Predis\Client{ public function __construct(RedisConfig $config) { parent::__construct([ "scheme" => $config->getScheme(), "host" => $config->getHost(), "port" => $config->getPort(), "database" => $config->getDatabase() ], [ "prefix" => $config->getPrefix(), ]); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Money/CurrencyConverter.php
src/Lib/Money/CurrencyConverter.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Money; use AugmentedSteam\Server\Database\DCurrency; use AugmentedSteam\Server\Database\TCurrency; use IsThereAnyDeal\Database\DbDriver; readonly class CurrencyConverter { public function __construct( private DbDriver $db ) {} public function getConversion(string $from, string $to): ?float { $from = strtoupper($from); $to = strtoupper($to); if ($from == $to) { return 1; } $c = new TCurrency(); $data = $this->db->select(<<<SQL SELECT $c->rate FROM $c WHERE $c->from=:from AND $c->to=:to SQL )->params([ ":from" => $from, ":to" => $to ])->fetch(DCurrency::class) ->getOne(); return $data?->getRate(); } /** * @param list<string> $currencies * @return array<string, array<string, float>> */ public function getAllConversionsTo(array $currencies): array { $c = new TCurrency(); $select = $this->db->select(<<<SQL SELECT $c->from, $c->to, $c->rate FROM $c WHERE $c->to IN :to SQL )->params([ ":to" => $currencies ])->fetch(DCurrency::class); $result = []; foreach($select as $o) { $result[$o->getFrom()][$o->getTo()] = $o->getRate(); } return $result; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Http/IntParam.php
src/Lib/Http/IntParam.php
<?php namespace AugmentedSteam\Server\Lib\Http; use AugmentedSteam\Server\Exceptions\InvalidValueException; use AugmentedSteam\Server\Exceptions\MissingParameterException; use Psr\Http\Message\ServerRequestInterface; class IntParam { private ?int $value; public function __construct( ServerRequestInterface $request, string $name, ?int $default = null, bool $nullable = false ) { $params = $request->getQueryParams(); if (array_key_exists($name, $params)) { $value = $params[$name]; if (!preg_match("#^[0-9]+$#", $value)) { throw new InvalidValueException($name); } $this->value = intval($value); } else { if (is_null($default) && !$nullable) { throw new MissingParameterException($name); } $this->value = $default; } } public function value(): ?int { return $this->value; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Http/StringParam.php
src/Lib/Http/StringParam.php
<?php namespace AugmentedSteam\Server\Lib\Http; use AugmentedSteam\Server\Exceptions\InvalidValueException; use AugmentedSteam\Server\Exceptions\MissingParameterException; use Psr\Http\Message\ServerRequestInterface; class StringParam { private ?string $value; public function __construct( ServerRequestInterface $request, string $name, ?string $default = null, bool $nullable = false ) { $params = $request->getQueryParams(); if (array_key_exists($name, $params)) { $value = trim($params[$name]); if (empty($value)) { throw new InvalidValueException($name); } $this->value = $value; } else { if (is_null($default) && !$nullable) { throw new MissingParameterException($name); } $this->value = $default; } } public function value(): ?string { return $this->value; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Http/ListParam.php
src/Lib/Http/ListParam.php
<?php namespace AugmentedSteam\Server\Lib\Http; use AugmentedSteam\Server\Exceptions\MissingParameterException; use Psr\Http\Message\ServerRequestInterface; class ListParam { /** @var list<string>|null */ private ?array $value; /** * @param list<string>|null $default * @param non-empty-string $separator */ public function __construct( ServerRequestInterface $request, string $name, string $separator = ",", ?array $default = null, bool $nullable = false ) { $params = $request->getQueryParams(); if (array_key_exists($name, $params) && is_string($params[$name])) { $this->value = explode($separator, $params[$name]); } else { if (is_null($default) && !$nullable) { throw new MissingParameterException($name); } $this->value = $default; } } /** * @return ?list<string> */ public function value(): ?array { return $this->value; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Http/BoolParam.php
src/Lib/Http/BoolParam.php
<?php namespace AugmentedSteam\Server\Lib\Http; use AugmentedSteam\Server\Exceptions\InvalidValueException; use AugmentedSteam\Server\Exceptions\MissingParameterException; use Psr\Http\Message\ServerRequestInterface; class BoolParam { private ?bool $value; public function __construct( ServerRequestInterface $request, string $name, ?bool $default = null, bool $nullable = false ) { $params = $request->getQueryParams(); if (array_key_exists($name, $params)) { $this->value = match($params[$name]) { "1", "true" => true, "0", "false" => false, default => throw new InvalidValueException($name) }; } else { if (is_null($default) && !$nullable) { throw new MissingParameterException($name); } $this->value = $default; } } public function value(): ?bool { return $this->value; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Logging/LoggerFactory.php
src/Lib/Logging/LoggerFactory.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Logging; use Monolog\Formatter\LineFormatter; use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Level; use Monolog\Logger; use Monolog\Processor\UidProcessor; use Monolog\Processor\WebProcessor; use Psr\Log\LoggerInterface; class LoggerFactory implements LoggerFactoryInterface { public function __construct( private readonly LoggingConfig $config, private readonly string $logsPath ) {} private function getLineFormatter(): LineFormatter { return (new LineFormatter("[%extra.uid%][%datetime%]%extra.prefix% %level_name%: %message% %context% %extra%\n", "Y-m-d H:i:s.u")) ->ignoreEmptyContextAndExtra(); } private function getFileHandler(string $channel): StreamHandler { $date = date("Y-m-d"); $logPath = $this->logsPath."/{$date}.{$channel}.log"; return (new StreamHandler($logPath, Level::Debug, true, 0666)); } public function getNullLogger(): LoggerInterface { return new Logger("null", [new NullHandler()]); } public function logger(string $channel): LoggerInterface { if (!$this->config->isEnabled()) { return $this->getNullLogger(); } $lineFormatter = $this->getLineFormatter(); $fileHandler = $this->getFileHandler($channel); $fileHandler->setFormatter($lineFormatter); return (new Logger($channel)) ->pushHandler($fileHandler) ->pushProcessor(new UidProcessor()); } public function access(): LoggerInterface { if (!$this->config->isEnabled()) { return $this->getNullLogger(); } $lineFormatter = $this->getLineFormatter(); $channel = "access"; $fileHandler = $this->getFileHandler($channel); $fileHandler->setFormatter($lineFormatter); return (new Logger($channel)) ->pushHandler($fileHandler) ->pushProcessor(new UidProcessor()) ->pushProcessor(new WebProcessor(extraFields: ["ip", "server", "referrer"])); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Logging/LoggerFactoryInterface.php
src/Lib/Logging/LoggerFactoryInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Logging; use Psr\Log\LoggerInterface; interface LoggerFactoryInterface { public function logger(string $channel): LoggerInterface; public function access(): LoggerInterface; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Logging/LoggingConfig.php
src/Lib/Logging/LoggingConfig.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Logging; use Nette\Schema\Expect; use Nette\Schema\Processor; class LoggingConfig { /** * @var object{enabled: boolean} */ private readonly object $config; /** * @param array<string, mixed> $config */ public function __construct(array $config) { // @phpstan-ignore-next-line $this->config = (new Processor())->process(Expect::structure([ "enabled" => Expect::bool(true) ]), $config); } public function isEnabled(): bool { return $this->config->enabled; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Cache/CacheInterface.php
src/Lib/Cache/CacheInterface.php
<?php namespace AugmentedSteam\Server\Lib\Cache; interface CacheInterface { public function has(ECacheKey $key, string $field): bool; public function get(ECacheKey $key, string $field): mixed; /** * @template T * @param T $data */ public function set(ECacheKey $key, string $field, mixed $data, int $ttl): void; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Cache/DCache.php
src/Lib/Cache/DCache.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Cache; class DCache { private ECacheKey $key; private string $field; private ?string $data; private int $expiry; public function getKey(): ECacheKey { return $this->key; } public function setKey(ECacheKey $key): self { $this->key = $key; return $this; } public function getField(): string { return $this->field; } public function setField(string $field): self { $this->field = $field; return $this; } public function getData(): ?string { return $this->data; } public function setData(?string $data): self { $this->data = $data; return $this; } public function getExpiry(): int { return $this->expiry; } public function setExpiry(int $expiry): self { $this->expiry = $expiry; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Cache/Cache.php
src/Lib/Cache/Cache.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Cache; use AugmentedSteam\Server\Database\TCache; use IsThereAnyDeal\Database\DbDriver; class Cache implements CacheInterface { private readonly DbDriver $db; private readonly TCache $c; public function __construct(DbDriver $db) { $this->db = $db; $this->c = new TCache(); } #[\Override] public function has(ECacheKey $key, string $field): bool { $c = $this->c; return $this->db->select(<<<SQL SELECT 1 FROM $c WHERE $c->key=:key AND $c->field=:field AND $c->expiry > UNIX_TIMESTAMP() SQL )->exists([ ":key" => $key, ":field" => $field ]); } #[\Override] public function get(ECacheKey $key, string $field): mixed { $c = $this->c; $data = $this->db->select(<<<SQL SELECT $c->data FROM $c WHERE $c->key=:key AND $c->field=:field AND $c->expiry > UNIX_TIMESTAMP() SQL )->fetchValue([ ":key" => $key, ":field" => $field ]); if (!is_null($data)) { try { if (!is_string($data)) { throw new \Exception(); } return igbinary_unserialize($data); } catch(\Throwable) { $this->db->delete(<<<SQL DELETE FROM $c WHERE $c->key=:key AND $c->field=:field SQL )->delete([ ":key" => $key, ":field" => $field ]); } } return null; } #[\Override] public function set(ECacheKey $key, string $field, mixed $data, int $ttl): void { $c = $this->c; $this->db->insert($c) ->columns($c->key, $c->field, $c->data, $c->expiry) ->onDuplicateKeyUpdate($c->data, $c->expiry) ->persist((new DCache()) ->setKey($key) ->setField($field) ->setData(igbinary_serialize($data)) ->setExpiry(time()+$ttl) ) ; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Cache/ECacheKey.php
src/Lib/Cache/ECacheKey.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Cache; enum ECacheKey: int { case WSGF = 1; case Reviews = 2; case SteamPeek = 3; case Players = 4; case Twitch = 5; case EarlyAccess = 6; case HLTB = 7; case Exfgls = 8; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Loader.php
src/Lib/Loader/Loader.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Loader; use AugmentedSteam\Server\Lib\Loader\Proxy\ProxyInterface; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Pool; use Iterator; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; use Throwable; class Loader { private const int ConnectTimeout = 5; private const int Timeout = 15; private readonly LoggerInterface $logger; private readonly Client $guzzle; private int $concurrency = 5; private ?ProxyInterface $proxy = null; public function __construct(LoggerInterface $logger, Client $guzzle) { $this->logger = $logger; $this->guzzle = $guzzle; } public function setConcurrency(int $concurrency): self { $this->concurrency = $concurrency; return $this; } public function setProxy(?ProxyInterface $proxy): self { $this->proxy = $proxy; return $this; } public function createRequest(Item $item, callable $responseHandler, callable $errorHandler): callable { return function() use ($item, $responseHandler, $errorHandler) { $curlOptions = array_replace( is_null($this->proxy) ? [] : $this->proxy->getCurlOptions(), $item->getCurlOptions() ); $curlOptions[CURLOPT_FOLLOWLOCATION] = false; // Force CURL follow location off, and let Guzzle handle it $settings = [ "http_errors" => false, // do not throw on 400 and 500 level errors "connect_timeout" => self::ConnectTimeout, "timeout" => self::Timeout, "allow_redirects" => [ "track_redirects" => true ], "headers" => [ "Accept-Encoding" => "gzip,deflate" ], "curl" => $curlOptions ]; foreach($item->getHeaders() as $header => $value) { $settings['headers'][$header] = $value; } if (!empty($item->getBody())) { $settings['body'] = $item->getBody(); } return $this->guzzle ->requestAsync($item->getMethod(), $item->getUrl(), $settings) ->then( function(ResponseInterface $response) use($item, $responseHandler) { try { $redirects = $response->getHeader("X-Guzzle-Redirect-History"); $uri = (empty($redirects) ? $item->getUrl() : end($redirects)); $responseHandler($item, $response, $uri); } catch (Throwable $e) { $this->logger->error($e->getMessage()); } }, function(GuzzleException $e) use($item, $errorHandler) { try { $errorHandler($item, $e); } catch (Throwable $e) { $this->logger->error($e->getMessage()); } } ); }; } /** * @param Iterator<callable> $requests */ public function run(Iterator $requests): void { $pool = new Pool($this->guzzle, $requests, [ "concurrency" => $this->concurrency, ]); $pool ->promise() ->wait(); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/SimpleLoader.php
src/Lib/Loader/SimpleLoader.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Loader; use GuzzleHttp\Client; use GuzzleHttp\Exception\GuzzleException; use Psr\Http\Message\ResponseInterface; readonly class SimpleLoader { public function __construct( private Client $guzzle ) {} /** * @param array<string, mixed> $curlOptions */ public function get(string $url, array $curlOptions = [], bool $throw=false): ?ResponseInterface { try { return $this->guzzle->get($url, [ "headers" => [ "User-Agent" => "AugmentedSteam/1.0 (+bots@isthereanydeal.com)", ], "curl" => $curlOptions ]); } catch (GuzzleException $e) { if ($throw) { throw $e; } else { \Sentry\captureException($e); } } return null; } /** * @param array<string, mixed> $curlOptions */ public function post(string $url, mixed $body, array $curlOptions = []): ?ResponseInterface { try { return $this->guzzle->post($url, [ "headers" => [ "User-Agent" => "AugmentedSteam/1.0 (+bots@isthereanydeal.com)", ], "body" => $body, "curl" => $curlOptions ]); } catch (GuzzleException $e) { \Sentry\captureException($e); } return null; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Crawler.php
src/Lib/Loader/Crawler.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Loader; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; use SplQueue; use Throwable; abstract class Crawler { private SplQueue $requestQueue; public function __construct( private readonly Loader $loader, protected readonly LoggerInterface $logger ) { $this->requestQueue = new SplQueue(); } protected function enqueueRequest(Item $item): void { $request = $this->loader->createRequest( $item, fn(Item $item, ResponseInterface $response, string $effectiveUri) => $this->successHandler($item, $response, $effectiveUri), fn(Item $item, Throwable $e) => $this->errorHandler($item, $e) ); $this->requestQueue->enqueue($request); } protected function mayProcess(Item $request, ResponseInterface $response, int $maxAttempts): bool { $status = $response->getStatusCode(); if ($status !== 200) { if ($status === 429) { $this->logger->info("Throttling"); sleep(60); } if ($request->getAttempt() <= $maxAttempts) { // replay request $request->incrementAttempt(); $this->enqueueRequest($request); $this->logger->info("Retrying", ["url" => $request->getUrl()]); } else { $this->logger->error($request->getUrl()); } return false; } return true; } protected abstract function successHandler(Item $request, ResponseInterface $response, string $effectiveUri): void; protected function errorHandler(Item $item, Throwable $e): void { $this->logger->error($e->getMessage().": ".$item->getUrl(), $item->getData()); } protected function requestGenerator(): \Generator { while(true) { if ($this->requestQueue->isEmpty()) { break; } yield $this->requestQueue->dequeue(); } } protected function runLoader(): void { while (true) { if ($this->requestQueue->isEmpty()) { break; } $this->loader->run($this->requestGenerator()); } } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Item.php
src/Lib/Loader/Item.php
<?php namespace AugmentedSteam\Server\Lib\Loader; final class Item { private string $id; private string $method = "GET"; private string $url; /** @var array<int, mixed> */ private array $curlOptions = []; private bool $allowRedirect = true; private ?string $body = null; /** @var array<string, mixed> */ private array $headers = []; /** @var array<mixed> */ private array $data = []; private int $attempt = 1; public function __construct(string $url) { $this->id = uniqid("", true); $this->url = $url; } public function getId(): string { return $this->id; } public function getMethod(): string { return $this->method; } public function setMethod(string $method): self { $this->method = $method; return $this; } public function getUrl(): string { return $this->url; } public function setUrl(string $url): self { $this->url = $url; return $this; } /** * @return array<int, mixed> */ public function getCurlOptions(): array { return $this->curlOptions; } /** * @param array<int, mixed> $options */ public function setCurlOptions(array $options): self { $this->curlOptions = $options; return $this; } public function isAllowRedirect(): bool { return $this->allowRedirect; } public function setAllowRedirect(bool $allowRedirect): self { $this->allowRedirect = $allowRedirect; return $this; } public function getBody(): ?string { return $this->body; } public function setBody(?string $body): self { $this->body = $body; return $this; } /** * @return array<mixed> */ public function getHeaders(): array { return $this->headers; } /** * @param array<mixed> $headers */ public function setHeaders(array $headers): self { $this->headers = $headers; return $this; } /** * @return array<mixed> */ public function getData(): array { return $this->data; } /** * @param array<mixed> $data */ public function setData(array $data): self { $this->data = $data; return $this; } public function getAttempt(): int { return $this->attempt; } public function setAttempt(int $attempt): self { $this->attempt = $attempt; return $this; } public function incrementAttempt(): self { $this->attempt += 1; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Proxy/ProxyFactoryInterface.php
src/Lib/Loader/Proxy/ProxyFactoryInterface.php
<?php namespace AugmentedSteam\Server\Lib\Loader\Proxy; interface ProxyFactoryInterface { public function createProxy(): ProxyInterface; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Proxy/ProxyFactory.php
src/Lib/Loader/Proxy/ProxyFactory.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\Loader\Proxy; use AugmentedSteam\Server\Config\BrightDataConfig; class ProxyFactory implements ProxyFactoryInterface { private BrightDataConfig $config; public function __construct(BrightDataConfig $config) { $this->config = $config; } public function createProxy(): ProxyInterface { return new BrightDataProxy($this->config); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Proxy/BrightDataProxy.php
src/Lib/Loader/Proxy/BrightDataProxy.php
<?php namespace AugmentedSteam\Server\Lib\Loader\Proxy; use AugmentedSteam\Server\Config\BrightDataConfig; class BrightDataProxy implements ProxyInterface { private BrightDataConfig $config; public function __construct(BrightDataConfig $config) { $this->config = $config; } /** * @return array<int, string|int> */ public function getCurlOptions(): array { $rand = mt_rand(10000, 99999); $setup = "lum-customer-{$this->config->getUser()}-zone-{$this->config->getZone()}-session-rand{$rand}"; return [ CURLOPT_PROXY => $this->config->getUrl(), CURLOPT_PROXYPORT => $this->config->getPort(), CURLOPT_PROXYUSERPWD => "$setup:{$this->config->getPassword()}" ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/Loader/Proxy/ProxyInterface.php
src/Lib/Loader/Proxy/ProxyInterface.php
<?php namespace AugmentedSteam\Server\Lib\Loader\Proxy; interface ProxyInterface { /** * @return array<int, mixed> */ public function getCurlOptions(): array; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/OpenId/OpenIdProvider.php
src/Lib/OpenId/OpenIdProvider.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Lib\OpenId; /** * An implementation of OpenID authentication for Steam, adapted from xPaw's version: * {@link https://github.com/xPaw/SteamOpenID.php} */ class OpenIdProvider { private const string ProviderLoginUrl = "https://steamcommunity.com/openid/login"; private string $host; private string $returnUrl; public function __construct(string $host, string $returnPath) { $this->host = $host; $this->returnUrl = rtrim($host, "/")."/".ltrim($returnPath, "/"); } public function isAuthenticationInProgress(): bool { return isset($_GET['openid_claimed_id']); } public function getAuthUrl(): string { return self::ProviderLoginUrl."?".http_build_query([ "openid.identity" => "http://specs.openid.net/auth/2.0/identifier_select", "openid.claimed_id" => "http://specs.openid.net/auth/2.0/identifier_select", "openid.ns" => "http://specs.openid.net/auth/2.0", "openid.mode" => "checkid_setup", "openid.realm" => $this->host, "openid.return_to" => $this->returnUrl ]); } /** * Validates OpenID data, and verifies with Steam * @return ?string Returns the 64-bit SteamID if successful or null on failure */ public function validateLogin(): ?string { // PHP automatically replaces dots with underscores in GET parameters // See https://www.php.net/variables.external#language.variables.external.dot-in-names if (filter_input(INPUT_GET, 'openid_mode') !== "id_res") { return null; } // See http://openid.net/specs/openid-authentication-2_0.html#positive_assertions $arguments = filter_input_array(INPUT_GET, [ "openid_ns" => FILTER_SANITIZE_URL, "openid_op_endpoint" => FILTER_SANITIZE_URL, "openid_claimed_id" => FILTER_SANITIZE_URL, "openid_identity" => FILTER_SANITIZE_URL, "openid_return_to" => FILTER_SANITIZE_URL, // Should equal to url we sent "openid_response_nonce" => FILTER_SANITIZE_SPECIAL_CHARS, "openid_assoc_handle" => FILTER_SANITIZE_SPECIAL_CHARS, // Steam just sends 1234567890 "openid_signed" => FILTER_SANITIZE_SPECIAL_CHARS, "openid_sig" => FILTER_SANITIZE_SPECIAL_CHARS ], true); if (!is_array($arguments)) { return null; } foreach ($arguments as $value) { // An array value will be FALSE if the filter fails, or NULL if the variable is not set. // In our case we want everything to be a string. if (!is_string($value)) { return null; } } if ($arguments['openid_claimed_id'] !== $arguments['openid_identity'] || $arguments['openid_op_endpoint'] !== self::ProviderLoginUrl || $arguments['openid_ns'] !== "http://specs.openid.net/auth/2.0" || !is_string($arguments['openid_return_to']) || !is_string($arguments['openid_identity']) || strpos($arguments['openid_return_to'], $this->returnUrl) !== 0 || preg_match("#^https?://steamcommunity.com/openid/id/(7656119\d{10})/?$#", $arguments['openid_identity'], $communityID) !== 1) { return null; } $arguments['openid_mode'] = "check_authentication"; $c = curl_init(); curl_setopt_array($c, [ CURLOPT_USERAGENT => "OpenID Verification (+https://github.com/xPaw/SteamOpenID.php)", CURLOPT_URL => self::ProviderLoginUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_CONNECTTIMEOUT => 6, CURLOPT_TIMEOUT => 6, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $arguments, ]); $response = curl_exec($c); $code = curl_getinfo($c, CURLINFO_RESPONSE_CODE); if ($code !== 200 || !is_string($response)) { return null; } $keyValues = $this->parseKeyValues($response); if (($keyValues['ns'] ?? null) !== "http://specs.openid.net/auth/2.0") { return null; } if (($keyValues['is_valid'] ?? null) !== "true") { return null; } return $communityID[1]; } /** * @return array<string, string> */ private function parseKeyValues(string $response): array { // A message in Key-Value form is a sequence of lines. Each line begins with a key, // followed by a colon, and the value associated with the key. The line is terminated // by a single newline (UCS codepoint 10, "\n"). A key or value MUST NOT contain a // newline and a key also MUST NOT contain a colon. $responseLines = explode("\n", $response); $responseKeys = []; foreach($responseLines as $line) { $pair = explode(":", $line, 2); if (!isset($pair[1])) { continue; } list($key, $value) = $pair; $responseKeys[$key] = $value; } return $responseKeys; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/OpenId/Session.php
src/Lib/OpenId/Session.php
<?php namespace AugmentedSteam\Server\Lib\OpenId; use AugmentedSteam\Server\Database\DSession; use AugmentedSteam\Server\Database\TSessions; use IsThereAnyDeal\Database\DbDriver; use Laminas\Diactoros\Response\RedirectResponse; use Psr\Http\Message\ServerRequestInterface; class Session { private const string CookieName = "session"; private const int CookieExpiry = 30*86400; private const string HashAlgorithm = "sha256"; public function __construct( private readonly DbDriver $db, private readonly string $host ) {} private function hasSession(ServerRequestInterface $request, int $steamId): bool { $cookie = $request->getCookieParams(); if (!isset($cookie[self::CookieName])) { return false; } $sessionCookie = $cookie[self::CookieName]; $parts = explode(":", $sessionCookie); if (count($parts) != 2) { return false; } $s = new TSessions(); /** @var ?DSession $session */ $session = $this->db->select(<<<SQL SELECT $s->hash, $s->steam_id FROM $s WHERE $s->token = :token AND $s->expiry >= :timestamp SQL )->params([ ":token" => $parts[0], ":timestamp" => time() ])->fetch(DSession::class) ->getOne(); return !is_null($session) && $session->getSteamId() === $steamId && hash_equals($session->getHash(), hash(self::HashAlgorithm, $parts[1])); } private function saveSession(int $steamId): void { $token = bin2hex(openssl_random_pseudo_bytes(5)); $validator = bin2hex(openssl_random_pseudo_bytes(20)); $expiry = time() + self::CookieExpiry; setcookie(self::CookieName, "{$token}:{$validator}", $expiry, "/"); $s = new TSessions(); $this->db->delete(<<<SQL DELETE FROM $s WHERE $s->expiry < :timestamp SQL )->delete([ ":timestamp" => time() ]); $this->db->insert($s) ->columns($s->token, $s->hash, $s->steam_id, $s->expiry) ->persist((new DSession()) ->setToken($token) ->setHash(hash(self::HashAlgorithm, $validator)) ->setSteamId($steamId) ->setExpiry($expiry) ); } public function authorize(ServerRequestInterface $request, string $selfPath, string $errorUrl, ?int $steamId): int|RedirectResponse { if (is_null($steamId) || !$this->hasSession($request, $steamId)) { $openId = new OpenId($this->host, $selfPath); if (!$openId->isAuthenticationStarted()) { return new RedirectResponse($openId->getAuthUrl()->toString()); } if (!$openId->authenticate()) { return new RedirectResponse($errorUrl); } else { $steamId = (int)($openId->getSteamId()); $this->saveSession($steamId); } } return $steamId; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Lib/OpenId/OpenId.php
src/Lib/OpenId/OpenId.php
<?php namespace AugmentedSteam\Server\Lib\OpenId; use League\Uri\Uri; class OpenId { private readonly OpenIdProvider $provider; private string $steamId; public function __construct(string $host, string $returnPath) { $this->provider = new OpenIdProvider("https://".$host, $returnPath); } public function isAuthenticationStarted(): bool { return $this->provider->isAuthenticationInProgress(); } public function getAuthUrl(): Uri { return Uri::new($this->provider->getAuthUrl()); } public function getSteamId(): string { return $this->steamId; } public function authenticate(): bool { $result = $this->provider->validateLogin(); if (is_null($result)) { return false; } $this->steamId = $result; return true; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Cron/CronJob.php
src/Cron/CronJob.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Cron; use AugmentedSteam\Server\Environment\Lock; class CronJob { private ?Lock $lock = null; /** @var callable */ private $callable; public function lock(string $name, int $durationMin): self { $this->lock = new Lock("temp/locks/{$name}.lock"); $this->lock->tryLock($durationMin * 60); return $this; } public function callable(callable $callable): self { $this->callable = $callable; return $this; } public function execute(): void { try { call_user_func($this->callable); } catch(\Throwable $e) { if (!is_null($this->lock)) { $this->lock->unlock(); } throw $e; // rethrow exception so we know about it } if (!is_null($this->lock)) { $this->lock->unlock(); } } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Cron/CronJobFactory.php
src/Cron/CronJobFactory.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Cron; use AugmentedSteam\Server\Data\Interfaces\RatesProviderInterface; use AugmentedSteam\Server\Data\Updaters\Market\MarketCrawler; use AugmentedSteam\Server\Data\Updaters\Rates\RatesUpdater; use AugmentedSteam\Server\Database\TCache; use AugmentedSteam\Server\Environment\Container; use AugmentedSteam\Server\Lib\Loader\Loader; use AugmentedSteam\Server\Lib\Loader\Proxy\ProxyFactoryInterface; use AugmentedSteam\Server\Lib\Logging\LoggerFactoryInterface; use GuzzleHttp\Client; use InvalidArgumentException; use IsThereAnyDeal\Database\DbDriver; class CronJobFactory { private readonly LoggerFactoryInterface $loggerFactory; private readonly DbDriver $db; public function __construct( private readonly Container $container ) { $this->loggerFactory = $this->container->get(LoggerFactoryInterface::class); $this->db = $this->container->get(DbDriver::class); } private function createRatesJob(): CronJob { return (new CronJob()) ->lock("rates", 5) ->callable(function(){ $container = Container::getInstance(); $logger = $this->loggerFactory->logger("rates"); $provider = $container->get(RatesProviderInterface::class); $updater = new RatesUpdater($this->db, $provider, $logger); $updater->update(); }); } private function createMarketJob(): CronJob { return (new CronJob()) ->lock("market", 60) ->callable(function(){ $logger = $this->loggerFactory->logger("market"); $guzzle = $this->container->get(Client::class); $proxy = $this->container->get(ProxyFactoryInterface::class) ->createProxy(); $loader = new Loader($logger, $guzzle); $updater = new MarketCrawler($this->db, $loader, $logger, $proxy); $updater->update(); }); } private function createCacheMaintenanceJob(): CronJob { return (new CronJob()) ->callable(function(){ $db = $this->container->get(DbDriver::class); $c = new TCache(); $db->delete(<<<SQL DELETE FROM $c WHERE $c->expiry < UNIX_TIMESTAMP() SQL )->delete(); }); } public function getJob(string $job): CronJob { return match($job) { "rates" => $this->createRatesJob(), "market" => $this->createMarketJob(), "cache-maintenance" => $this->createCacheMaintenanceJob(), default => throw new InvalidArgumentException() }; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TMarketIndex.php
src/Database/TMarketIndex.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("market_index")] class TMarketIndex extends Table { public Column $appid; public Column $last_update; public Column $last_request; public Column $request_counter; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DMarketData.php
src/Database/DMarketData.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use AugmentedSteam\Server\Data\Managers\Market\ERarity; use AugmentedSteam\Server\Data\Managers\Market\EType; class DMarketData { private string $hash_name; private int $appid; private string $appname; private string $name; private int $sell_listings; private int $sell_price_usd; private string $img; private string $url; private EType $type; private ERarity $rarity; private int $timestamp; public function getHashName(): string { return $this->hash_name; } public function setHashName(string $hash_name): self { $this->hash_name = $hash_name; return $this; } public function getAppid(): int { return $this->appid; } public function setAppid(int $appid): self { $this->appid = $appid; return $this; } public function getAppName(): string { return $this->appname; } public function setAppName(string $appname): self { $this->appname = $appname; return $this; } public function getName(): string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getSellListings(): int { return $this->sell_listings; } public function setSellListings(int $sell_listings): self { $this->sell_listings = $sell_listings; return $this; } public function getSellPriceUsd(): int { return $this->sell_price_usd; } public function setSellPriceUsd(int $sell_price_usd): self { $this->sell_price_usd = $sell_price_usd; return $this; } public function getImg(): string { return $this->img; } public function setImg(string $img): self { $this->img = $img; return $this; } public function getUrl(): string { return $this->url; } public function setUrl(string $url): self { $this->url = $url; return $this; } public function getType(): EType { return $this->type; } public function setType(EType $type): self { $this->type = $type; return $this; } public function getRarity(): ERarity { return $this->rarity; } public function setRarity(ERarity $rarity): self { $this->rarity = $rarity; return $this; } public function getTimestamp(): int { return $this->timestamp; } public function setTimestamp(int $timestamp): self { $this->timestamp = $timestamp; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DBadges.php
src/Database/DBadges.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DBadges { private int $id; private string $title; private string $img; public function getId(): int { return $this->id; } public function setId(int $id): self { $this->id = $id; return $this; } public function getTitle(): string { return $this->title; } public function setTitle(string $title): self { $this->title = $title; return $this; } public function getImg(): string { return $this->img; } public function setImg(string $img): self { $this->img = $img; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TSessions.php
src/Database/TSessions.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("sessions")] class TSessions extends Table { public Column $token; public Column $hash; public Column $steam_id; public Column $expiry; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TDlcCategories.php
src/Database/TDlcCategories.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("dlc_categories")] class TDlcCategories extends Table { public Column $id; public Column $name; public Column $icon; public Column $description; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TUsersProfiles.php
src/Database/TUsersProfiles.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("users_profiles")] class TUsersProfiles extends Table { public Column $steam64; public Column $bg_img; public Column $bg_appid; public Column $style; public Column $update_time; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DSession.php
src/Database/DSession.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DSession { private string $token; private string $hash; private int $steam_id; private int $expiry; public function getToken(): string { return $this->token; } public function setToken(string $token): self { $this->token = $token; return $this; } public function getHash(): string { return $this->hash; } public function setHash(string $hash): self { $this->hash = $hash; return $this; } public function getSteamId(): int { return $this->steam_id; } public function setSteamId(int $steam_id): self { $this->steam_id = $steam_id; return $this; } public function getExpiry(): int { return $this->expiry; } public function setExpiry(int $expiry): self { $this->expiry = $expiry; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TBadges.php
src/Database/TBadges.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("badges")] class TBadges extends Table { public Column $id; public Column $title; public Column $img; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TGameDlc.php
src/Database/TGameDlc.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("game_dlc")] class TGameDlc extends Table { public Column $appid; public Column $dlc_category; public Column $score; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DUsersProfiles.php
src/Database/DUsersProfiles.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DUsersProfiles { private int $steam64; private ?string $bg_img; private ?int $bg_appid; private ?string $style; public function getSteam64(): int { return $this->steam64; } public function setSteam64(int $steam64): self { $this->steam64 = $steam64; return $this; } public function getBgImg(): ?string { return $this->bg_img; } public function setBgImg(?string $bg_img): self { $this->bg_img = $bg_img; return $this; } public function getBgAppid(): ?int { return $this->bg_appid; } public function setBgAppid(?int $bg_appid): self { $this->bg_appid = $bg_appid; return $this; } public function getStyle(): ?string { return $this->style; } public function setStyle(?string $style): self { $this->style = $style; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TCache.php
src/Database/TCache.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("cache")] class TCache extends Table { public Column $key; public Column $field; public Column $data; public Column $expiry; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DDlcCategories.php
src/Database/DDlcCategories.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DDlcCategories { private int $id; private string $name; private string $icon; private string $description; public function getId(): int { return $this->id; } public function setId(int $id): self { $this->id = $id; return $this; } public function getName(): string { return $this->name; } public function setName(string $name): self { $this->name = $name; return $this; } public function getIcon(): string { return $this->icon; } public function setIcon(string $icon): self { $this->icon = $icon; return $this; } public function getDescription(): string { return $this->description; } public function setDescription(string $description): self { $this->description = $description; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TMarketData.php
src/Database/TMarketData.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("market_data")] class TMarketData extends Table { public Column $hash_name; public Column $appid; public Column $appname; public Column $name; public Column $sell_listings; public Column $sell_price_usd; public Column $img; public Column $url; public Column $type; public Column $rarity; public Column $timestamp; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TUsersBadges.php
src/Database/TUsersBadges.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("users_badges")] class TUsersBadges extends Table { public Column $steam64; public Column $badge_id; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TSteamRep.php
src/Database/TSteamRep.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("steamrep")] class TSteamRep extends Table { public Column $steam64; public Column $rep; public Column $timestamp; public Column $checked; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DCurrency.php
src/Database/DCurrency.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DCurrency { private string $from; private string $to; private float $rate; private int $timestamp; public function getFrom(): string { return $this->from; } public function setFrom(string $from): self { $this->from = $from; return $this; } public function getTo(): string { return $this->to; } public function setTo(string $to): self { $this->to = $to; return $this; } public function getRate(): float { return $this->rate; } public function setRate(float $rate): self { $this->rate = $rate; return $this; } public function getTimestamp(): int { return $this->timestamp; } public function setTimestamp(int $timestamp): self { $this->timestamp = $timestamp; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/TCurrency.php
src/Database/TCurrency.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("currency")] class TCurrency extends Table { public Column $from; public Column $to; public Column $rate; public Column $timestamp; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/DMarketIndex.php
src/Database/DMarketIndex.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; class DMarketIndex { private int $appid; private int $last_update; private int $last_request; private int $request_counter; public function getAppid(): int { return $this->appid; } public function setAppid(int $appid): self { $this->appid = $appid; return $this; } public function getLastUpdate(): int { return $this->last_update; } public function setLastUpdate(int $last_update): self { $this->last_update = $last_update; return $this; } public function getLastRequest(): int { return $this->last_request; } public function setLastRequest(int $last_request): self { $this->last_request = $last_request; return $this; } public function getRequestCounter(): int { return $this->request_counter; } public function setRequestCounter(int $request_counter): self { $this->request_counter = $request_counter; return $this; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Database/THLTB.php
src/Database/THLTB.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Database; use IsThereAnyDeal\Database\Attributes\TableName; use IsThereAnyDeal\Database\Tables\Column; use IsThereAnyDeal\Database\Tables\Table; #[TableName("hltb")] class THLTB extends Table { public Column $id; public Column $appid; public Column $main; public Column $extra; public Column $complete; public Column $found_timestamp; public Column $checked_timestamp; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Config/BrightDataConfig.php
src/Config/BrightDataConfig.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Config; use Nette\Schema\Expect; use Nette\Schema\Processor; class BrightDataConfig { /** * @var object{ * url: string, * port: int, * user: string, * password: string, * zone: string * } */ private readonly object $config; public function __construct(mixed $config) { // @phpstan-ignore-next-line $this->config = (new Processor())->process(Expect::structure([ "url" => Expect::string()->required(), "port" => Expect::int()->required(), "user" => Expect::string()->required(), "password" => Expect::string()->required(), "zone" => Expect::string()->required() ]), $config); } public function getUrl(): string { return $this->config->url; } public function getPort(): int { return $this->config->port; } public function getUser(): string { return $this->config->user; } public function getPassword(): string { return $this->config->password; } public function getZone(): string { return $this->config->zone; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Config/CoreConfig.php
src/Config/CoreConfig.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Config; use Nette\Schema\Expect; use Nette\Schema\Processor; class CoreConfig { /** * @var object{ * host: string, * dev: bool, * prettyErrors: bool, * sentry: object{ * enabled: bool, * dsn: string, * environment: string * } * } */ private object $config; public function __construct(mixed $config) { // @phpstan-ignore-next-line $this->config = (new Processor())->process(Expect::structure([ "host" => Expect::string()->required(), "dev" => Expect::bool(false), "prettyErrors" => Expect::bool(false), "sentry" => Expect::structure([ "enabled" => Expect::bool(false), "dsn" => Expect::string(), "environment" => Expect::string() ]) ]), $config); } public function getHost(): string { return $this->config->host; } public function isDev(): bool { return $this->config->dev; } public function isProduction(): bool { return !$this->isDev(); } public function usePrettyErrors(): bool { return $this->config->prettyErrors; } public function isSentryEnabled(): bool { return $this->config->sentry->enabled; } public function getSentryDsn(): ?string { return $this->config->sentry->dsn; } public function getSentryEnvironment(): string { return $this->config->sentry->environment; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/SteamRepProviderInterface.php
src/Data/Interfaces/SteamRepProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; interface SteamRepProviderInterface { /** * @return ?list<string> */ public function getReputation(int $steamId): ?array; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/PricesProviderInterface.php
src/Data/Interfaces/PricesProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; use AugmentedSteam\Server\Data\Objects\Prices; interface PricesProviderInterface { /** * @param list<string> $steamIds * @param list<int> $shops */ public function fetch(array $steamIds, array $shops, string $country, bool $withVouchers): ?Prices; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/EarlyAccessProviderInterface.php
src/Data/Interfaces/EarlyAccessProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; interface EarlyAccessProviderInterface { /** @return list<int> */ public function fetch(): array; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/ExfglsProviderInterface.php
src/Data/Interfaces/ExfglsProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; use AugmentedSteam\Server\Data\Interfaces\AppData\AppDataProviderInterface; interface ExfglsProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): bool; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/TwitchProviderInterface.php
src/Data/Interfaces/TwitchProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; use AugmentedSteam\Server\Data\Objects\TwitchStream; interface TwitchProviderInterface { public function fetch(string $channel): ?TwitchStream; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/RatesProviderInterface.php
src/Data/Interfaces/RatesProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces; interface RatesProviderInterface { /** * @return list<array{ * from: string, * to: string, * rate: float * }> */ public function fetch(): array; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/SteamPeekProviderInterface.php
src/Data/Interfaces/AppData/SteamPeekProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; use AugmentedSteam\Server\Data\Objects\SteamPeak\SteamPeekResults; interface SteamPeekProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): ?SteamPeekResults; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/ReviewsProviderInterface.php
src/Data/Interfaces/AppData/ReviewsProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; use AugmentedSteam\Server\Data\Objects\Reviews\Reviews; interface ReviewsProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): Reviews; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/WSGFProviderInterface.php
src/Data/Interfaces/AppData/WSGFProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; use AugmentedSteam\Server\Data\Objects\WSGF; interface WSGFProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): ?WSGF; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/HLTBProviderInterface.php
src/Data/Interfaces/AppData/HLTBProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; use AugmentedSteam\Server\Data\Objects\HLTB; interface HLTBProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): ?HLTB; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/PlayersProviderInterface.php
src/Data/Interfaces/AppData/PlayersProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; use AugmentedSteam\Server\Data\Objects\Players; interface PlayersProviderInterface extends AppDataProviderInterface { public function fetch(int $appid): Players; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Interfaces/AppData/AppDataProviderInterface.php
src/Data/Interfaces/AppData/AppDataProviderInterface.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Interfaces\AppData; /** * @template T */ interface AppDataProviderInterface { /** * @return T */ public function fetch(int $appid): mixed; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Updaters/Market/MarketCrawler.php
src/Data/Updaters/Market/MarketCrawler.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Updaters\Market; use AugmentedSteam\Server\Data\Managers\Market\ERarity; use AugmentedSteam\Server\Data\Managers\Market\EType; use AugmentedSteam\Server\Database\DMarketData; use AugmentedSteam\Server\Database\DMarketIndex; use AugmentedSteam\Server\Database\TMarketData; use AugmentedSteam\Server\Database\TMarketIndex; use AugmentedSteam\Server\Lib\Loader\Crawler; use AugmentedSteam\Server\Lib\Loader\Item; use AugmentedSteam\Server\Lib\Loader\Loader; use AugmentedSteam\Server\Lib\Loader\Proxy\ProxyInterface; use IsThereAnyDeal\Database\DbDriver; use IsThereAnyDeal\Database\Sql\Create\SqlInsertQuery; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; class MarketCrawler extends Crawler { private const int BatchCount = 150; private const int UpdateFrequency = 60*60; private const int MaxAttempts = 3; private readonly DbDriver $db; private readonly ProxyInterface $proxy; private readonly SqlInsertQuery $insertQuery; private int $requestCounter = 0; private int $timestamp; public function __construct( DbDriver $db, Loader $loader, LoggerInterface $logger, ProxyInterface $proxy ) { parent::__construct($loader, $logger); $this->db = $db; $this->proxy = $proxy; $this->timestamp = time(); $d = new TMarketData(); $this->insertQuery = $this->db->insert($d) ->columns( $d->hash_name, $d->appid, $d->appname, $d->name, $d->sell_listings, $d->sell_price_usd, $d->img, $d->url, $d->type, $d->rarity, $d->timestamp ) ->onDuplicateKeyUpdate( $d->appname, $d->name, $d->sell_listings, $d->sell_price_usd, $d->img, $d->url, $d->type, $d->rarity, $d->timestamp ); } private function getAppid(): int { $i = new TMarketIndex(); // @phpstan-ignore-next-line return $this->db->select(<<<SQL SELECT $i->appid FROM $i WHERE $i->last_update <= :timestamp ORDER BY $i->last_update ASC, $i->request_counter DESC LIMIT 1 SQL )->params([ ":timestamp" => time() - self::UpdateFrequency ])->fetchInt(); } private function makeRequest(int $appid, int $start=0): void { $params = [ "query" => "", "start" => $start, "count" => 100, "search_description" => 0, "sort_column" => "popular", "sort_dir" => "desc", "appid" => $appid, "norender" => 1, ]; $url = "https://steamcommunity.com/market/search/render/?".http_build_query($params); $item = (new Item($url)) ->setData(["appid" => $appid]) ->setHeaders([ "User-Agent" => "Mozilla/5.0 (Windows NT 10.4; WOW64) AppleWebKit/536.14 (KHTML, like Gecko) Chrome/52.0.2935.205 Safari/601.3 Edge/13.46571", ]) ->setCurlOptions($this->proxy->getCurlOptions()); $this->enqueueRequest($item); $this->requestCounter++; } protected function successHandler(Item $request, ResponseInterface $response, string $effectiveUri): void { if (!$this->mayProcess($request, $response, self::MaxAttempts)) { return; } $data = $response->getBody()->getContents(); /** * @var array{ * success: bool, * start: int, * pagesize: int, * total_count: int, * results: list<array{ * name: string, * hash_name: string, * sell_listings: int, * sell_price: int, * app_name: string, * asset_description: array{ * appid: int, * type: string, * name: string, * icon_url: string * } * }> * } $json */ $json = json_decode($data, true); $appid = intval($request->getData()['appid']); // @phpstan-ignore-line if ($json['start'] === 0 && $json['start'] < $json['total_count']) { $pageSize = $json['pagesize']; if ($pageSize > 0) { for ($start = $pageSize; $start <= $json['total_count']; $start += $pageSize) { $this->makeRequest($appid, $start); } } } foreach($json['results'] as $item) { $asset = $item['asset_description']; $rarity = ERarity::Normal; $type = EType::Unknown; if ($item['app_name'] == "Steam") { if (preg_match( "#^(.+?)(?:\s+(Uncommon|Foil|Rare|))?\s+(Profile Background|Emoticon|Booster Pack|Trading Card|Sale Item)$#", $asset['type'] === "Booster Pack" ? $asset['name'] : $asset['type'], $m )) { $appName = $m[1]; $rarity = match($m[2]) { "Uncommon" => ERarity::Uncommon, "Foil" => ERarity::Foil, "Rare" => ERarity::Rare, default => ERarity::Normal }; $type = match($m[3]) { "Profile Background" => EType::Background, "Emoticon" => EType::Emoticon, "Booster Pack" => EType::Booster, "Trading Card" => EType::Card, "Sale Item" => EType::Item }; } else { $appName = $asset['type']; $this->logger->notice($appName); } } else { $appName = $item['app_name']; $type = match($asset['type']) { "Profile Background" => EType::Background, "Emoticon" => EType::Emoticon, "Booster Pack" => EType::Booster, "Trading Card" => EType::Card, "Sale Item" => EType::Item, default => EType::Unknown }; } list($appid) = explode("-", $item['hash_name'], 2); $this->insertQuery->stack( (new DMarketData()) ->setHashName($item['hash_name']) ->setAppid((int)$appid) ->setAppName($appName) ->setName($item['name']) ->setSellListings($item['sell_listings']) ->setSellPriceUsd($item['sell_price']) ->setImg($asset['icon_url']) ->setUrl($asset['appid']."/".rawurlencode($item['hash_name'])) ->setType($type) ->setRarity($rarity) ->setTimestamp(time()) ); } $this->insertQuery->persist(); --$this->requestCounter; $this->logger->info("", ["appid" => $appid, "start" => $json['start']]); } private function updateIndex(int $appid): void { $i = new TMarketIndex(); $this->db->updateObj($i) ->columns($i->last_update, $i->request_counter) ->where($i->appid) ->update( (new DMarketIndex()) ->setLastUpdate($this->timestamp) ->setRequestCounter(0) ->setAppid($appid) ); } private function cleanup(int $appid): void { if (empty($appid)) { return; } $d = new TMarketData(); $this->db->delete(<<<SQL DELETE FROM $d WHERE $d->appid=:appid AND $d->timestamp < :timestamp SQL )->delete([ ":appid" => $appid, ":timestamp" => $this->timestamp ]); } public function update(): void { $this->logger->info("Update start"); for ($b = 0; $b < self::BatchCount; $b++) { $appid = $this->getAppid(); if (empty($appid)) { break; } $this->makeRequest($appid, 0); $this->runLoader(); $this->updateIndex($appid); if ($this->requestCounter === 0) { $this->cleanup($appid); $this->logger->info("Batch done"); } else { $this->logger->notice("Batch failed to finish ({$this->requestCounter} requests left)"); } $this->requestCounter = 0; } $this->logger->info("Update done"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Updaters/Rates/RatesUpdater.php
src/Data/Updaters/Rates/RatesUpdater.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Updaters\Rates; use AugmentedSteam\Server\Data\Interfaces\RatesProviderInterface; use AugmentedSteam\Server\Database\DCurrency; use AugmentedSteam\Server\Database\TCurrency; use IsThereAnyDeal\Database\DbDriver; use Psr\Log\LoggerInterface; class RatesUpdater { public function __construct( private readonly DbDriver $db, private readonly RatesProviderInterface $provider, private readonly LoggerInterface $logger ) {} public function update(): void { $this->logger->info("Start"); $rates = $this->provider->fetch(); if (empty($rates)) { throw new \Exception("No data"); } $timestamp = time(); $c = new TCurrency(); $this->db->begin(); $insert = $this->db->insert($c) ->stackSize(1000) ->columns($c->from, $c->to, $c->rate, $c->timestamp) ->onDuplicateKeyUpdate($c->rate, $c->timestamp); foreach($rates as $data) { $insert->stack((new DCurrency()) ->setFrom($data['from']) ->setTo($data['to']) ->setRate($data['rate']) ->setTimestamp($timestamp) ); } $insert->persist(); $this->db->delete(<<<SQL DELETE FROM $c WHERE $c->timestamp != :timestamp SQL )->delete([ ":timestamp" => $timestamp ]); $this->db->commit(); $this->logger->info("Done"); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/UserManager.php
src/Data/Managers/UserManager.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Managers; use AugmentedSteam\Server\Database\DBadges; use AugmentedSteam\Server\Database\DUsersProfiles; use AugmentedSteam\Server\Database\TBadges; use AugmentedSteam\Server\Database\TUsersBadges; use AugmentedSteam\Server\Database\TUsersProfiles; use IsThereAnyDeal\Database\DbDriver; use IsThereAnyDeal\Database\Sql\Read\SqlResult; class UserManager { public function __construct( private readonly DbDriver $db ) {} private function cleanupProfile(int $steamId): void { $p = new TUsersProfiles(); $this->db->delete(<<<SQL DELETE FROM $p WHERE $p->steam64=:steamId AND $p->bg_img IS NULL AND $p->style IS NULL SQL )->delete([ ":steamId" => $steamId ]); } public function deleteBackground(int $steamId): void { $p = new TUsersProfiles(); $this->db->updateObj($p) ->columns($p->bg_img, $p->bg_appid) ->where($p->steam64) ->update( (new DUsersProfiles()) ->setSteam64($steamId) ->setBgImg(null) ->setBgAppid(null) ); $this->cleanupProfile($steamId); } public function saveBackground(int $steamId, int $appid, string $img): void { $p = new TUsersProfiles(); $this->db->insert($p) ->columns($p->steam64, $p->bg_img, $p->bg_appid) ->onDuplicateKeyUpdate($p->bg_img, $p->bg_appid) ->persist( (new DUsersProfiles()) ->setSteam64($steamId) ->setBgAppid($appid) ->setBgImg($img) ); } public function deleteStyle(int $steamId): void { $p = new TUsersProfiles(); $this->db->updateObj($p) ->columns($p->style) ->where($p->steam64) ->update( (new DUsersProfiles()) ->setSteam64($steamId) ->setStyle(null) ); $this->cleanupProfile($steamId); } public function saveStyle(int $steamId, string $style): void { $p = new TUsersProfiles(); $this->db->insert($p) ->columns($p->steam64, $p->style) ->onDuplicateKeyUpdate($p->style) ->persist( (new DUsersProfiles()) ->setSteam64($steamId) ->setStyle($style) ); } /** * @param int $steamId * @return SqlResult<DBadges> */ public function getBadges(int $steamId): SqlResult { $b = new TBadges(); $u = new TUsersBadges(); return $this->db->select(<<<SQL SELECT $b->title, $b->img FROM $u JOIN $b ON $u->badge_id=$b->id WHERE $u->steam64=:steamId SQL )->params([ ":steamId" => $steamId ])->fetch(DBadges::class); } public function getProfileInfo(int $steamId): ?DUsersProfiles { $p = new TUsersProfiles(); return $this->db->select(<<<SQL SELECT $p->bg_img, $p->bg_appid, $p->style FROM $p WHERE $p->steam64=:steamId SQL )->params([ ":steamId" => $steamId ])->fetch(DUsersProfiles::class) ->getOne(); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/SteamRepManager.php
src/Data/Managers/SteamRepManager.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Managers; use AugmentedSteam\Server\Data\Interfaces\SteamRepProviderInterface; use AugmentedSteam\Server\Data\Objects\DSteamRep; use AugmentedSteam\Server\Database\TSteamRep; use IsThereAnyDeal\Database\DbDriver; class SteamRepManager { private const int SuccessCacheLimit = 7*86400; private const int FailureCacheLimit = 86400; public function __construct( private readonly DbDriver $db, private readonly SteamRepProviderInterface $provider // @phpstan-ignore-line ) {} /** * @return list<string> */ public function getReputation(int $steamId): array { $r = new TSteamRep(); /** @var ?DSteamRep $obj */ $obj = $this->db->select(<<<SQL SELECT $r->rep FROM $r WHERE $r->steam64=:steamId AND (($r->checked=1 AND $r->timestamp >= :successTimestamp) OR ($r->checked=0 AND $r->timestamp >= :failureTimestamp)) SQL )->params([ ":steamId" => $steamId, ":successTimestamp" => time() - self::SuccessCacheLimit, ":failureTimestamp" => time() - self::FailureCacheLimit ])->fetch(DSteamRep::class) ->getOne(); return $obj?->getReputation() ?? []; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/Market/MarketIndex.php
src/Data/Managers/Market/MarketIndex.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Managers\Market; use AugmentedSteam\Server\Database\DMarketIndex; use AugmentedSteam\Server\Database\TMarketIndex; use IsThereAnyDeal\Database\DbDriver; readonly class MarketIndex { public function __construct( private DbDriver $db ) {} public function recordRequest(int ...$appids): void { $appids = array_unique($appids); $i = new TMarketIndex(); $insert = $this->db->insert($i) ->columns($i->appid, $i->last_request) ->onDuplicateKeyUpdate($i->last_request) ->onDuplicateKeyExpression($i->request_counter, "{$i->request_counter->name}+1"); foreach($appids as $appid) { $insert->stack( (new DMarketIndex()) ->setAppid($appid) ->setLastRequest(time()) ); } $insert->persist(); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/Market/EType.php
src/Data/Managers/Market/EType.php
<?php namespace AugmentedSteam\Server\Data\Managers\Market; enum EType: string { case Unknown = "unknown"; case Background = "background"; case Booster = "booster"; case Card = "card"; case Emoticon = "emoticon"; case Item = "item"; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/Market/MarketManager.php
src/Data/Managers/Market/MarketManager.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Managers\Market; use AugmentedSteam\Server\Database\DMarketData; use AugmentedSteam\Server\Database\TMarketData; use IsThereAnyDeal\Database\DbDriver; class MarketManager { public function __construct( private readonly DbDriver $db ) {} /** * @param list<int> $appids * @return array<int, array<"foil"|"regular", float>> */ public function getAverageCardPrices(array $appids, float $conversion): array { $d = new TMarketData(); $select = $this->db->select(<<<SQL SELECT $d->appid, $d->rarity=:foil as foil, AVG($d->sell_price_usd) as `average`, count(*) as `count` FROM $d WHERE $d->type=:card AND $d->appid IN :appids GROUP BY $d->appid, $d->rarity=:foil SQL )->params([ ":appids" => $appids, ":foil" => ERarity::Foil, ":card" => EType::Card ])->fetch(); $result = []; /** @var \stdClass $o */ foreach($select as $o) { $appid = (int)$o->appid; $isFoil = $o->foil; $avg = ($o->average/100)*$conversion; $result[$appid][$isFoil ? "foil" : "regular"] = $avg; } return $result; } /** * @return array<string, array{ * img: string, * url: string, * price: float * }> */ public function getCards(int $appid, float $conversion): array { $d = new TMarketData(); $select = $this->db->select(<<<SQL SELECT $d->name, $d->img, $d->url, $d->sell_price_usd FROM $d WHERE $d->appid=:appid AND $d->type=:card SQL )->params([ ":appid" => $appid, ":card" => EType::Card ])->fetch(DMarketData::class); $result = []; /** @var DMarketData $o */ foreach($select as $o) { $result[$o->getName()] = [ "img" => $o->getImg(), "url" => $o->getUrl(), "price" => ($o->getSellPriceUsd() / 100) * $conversion, ]; } return $result; } public function doesBackgroundExist(int $appid, string $img): bool { $d = new TMarketData(); return $this->db->select(<<<SQL SELECT 1 FROM $d WHERE $d->appid=:appid AND $d->img=:img AND $d->type=:background SQL )->exists([ ":appid" =>$appid, ":img" => $img, ":background" => EType::Background ]); } /** * @param int $appid * @return list<array{string, string}> */ public function getBackgrounds(int $appid): iterable { $d = new TMarketData(); // @phpstan-ignore-next-line return $this->db->select(<<<SQL SELECT $d->name, $d->img FROM $d WHERE $d->appid=:appid AND $d->type=:background ORDER BY $d->name ASC SQL )->params([ ":appid" => $appid, ":background" => EType::Background ])->fetch(DMarketData::class) ->toArray(fn(DMarketData $o) => [ $o->getImg(), preg_replace("#\s*\(Profile Background\)#", "", $o->getName()), ]); } /** * @return list<array{int, string}> */ public function getGamesWithBackgrounds(): array { $d = new TMarketData(); return $this->db->select(<<<SQL SELECT DISTINCT $d->appid, $d->appname FROM $d WHERE $d->type=:background ORDER BY $d->appname ASC SQL )->params([ ":background" => EType::Background ])->fetch(DMarketData::class) ->toArray(fn(DMarketData $o) => [$o->getAppid(), $o->getAppName()]); } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Managers/Market/ERarity.php
src/Data/Managers/Market/ERarity.php
<?php namespace AugmentedSteam\Server\Data\Managers\Market; enum ERarity: string { case Normal = "normal"; case Uncommon = "uncommon"; case Foil = "foil"; case Rare = "rare"; }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/DSteamRep.php
src/Data/Objects/DSteamRep.php
<?php declare(strict_types=1); namespace AugmentedSteam\Server\Data\Objects; class DSteamRep { private int $steam64; private ?string $rep; private int $timestamp; private bool $checked; public function getSteam64(): int { return $this->steam64; } public function setSteam64(int $steam64): self { $this->steam64 = $steam64; return $this; } /** * @return list<string> */ public function getReputation(): array { return empty($this->rep) ? [] : explode(",", $this->rep); } /** * @param ?list<string> $reputation */ public function setReputation(?array $reputation): self { $this->rep = empty($reputation) ? null : implode(",", $reputation); $this->checked = !is_null($reputation); return $this; } public function getTimestamp(): int { return $this->timestamp; } public function setTimestamp(int $timestamp): self { $this->timestamp = $timestamp; return $this; } public function isChecked(): bool { return $this->checked; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/TwitchStream.php
src/Data/Objects/TwitchStream.php
<?php namespace AugmentedSteam\Server\Data\Objects; use JsonSerializable; use Override; class TwitchStream implements JsonSerializable { public string $userName; public string $title; public string $thumbnailUrl; public int $viewerCount; public string $game; /** * @return array<string, int|string> */ #[Override] public function jsonSerialize(): array { return [ "user_name" => $this->userName, "game" => $this->game, "view_count" => $this->viewerCount, "thumbnail_url" => $this->thumbnailUrl ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/Prices.php
src/Data/Objects/Prices.php
<?php namespace AugmentedSteam\Server\Data\Objects; use JsonSerializable; class Prices implements JsonSerializable { public static function fromJson(string $json): self { /** @var array<string, mixed> $data */ $data = json_decode($json, associative: true, flags: JSON_THROW_ON_ERROR); $prices = new Prices(); $prices->prices = $data['prices']; // @phpstan-ignore-line $prices->bundles = $data['bundles']; // @phpstan-ignore-line return $prices; } /** * @var array<string, array{ * current: array<mixed>, * lowest: array<mixed>, * urls: array{ * info: string, * history: string * } * }> */ public array $prices; /** * @var list<array<mixed>> */ public array $bundles; /** * @return array<string, mixed> */ public function jsonSerialize(): array { return [ "prices" => $this->prices, "bundles" => $this->bundles ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/HLTB.php
src/Data/Objects/HLTB.php
<?php namespace AugmentedSteam\Server\Data\Objects; class HLTB implements \JsonSerializable { public ?int $story; public ?int $extras; public ?int $complete; public string $url; /** * @return array<string, mixed> */ #[\Override] public function jsonSerialize(): array { return [ "story" => $this->story, "extras" => $this->extras, "complete" => $this->complete, "url" => $this->url ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/WSGF.php
src/Data/Objects/WSGF.php
<?php namespace AugmentedSteam\Server\Data\Objects; class WSGF implements \JsonSerializable { public string $path; public string $wideScreenGrade; public string $multiMonitorGrade; public string $ultraWideScreenGrade; public string $grade4k; /** * @return array<string, int|string> */ #[\Override] public function jsonSerialize(): array { return [ "url" => $this->path, "wide" => $this->wideScreenGrade, "ultrawide" => $this->ultraWideScreenGrade, "multi_monitor" => $this->multiMonitorGrade, "4k" => $this->grade4k, ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/Players.php
src/Data/Objects/Players.php
<?php namespace AugmentedSteam\Server\Data\Objects; class Players implements \JsonSerializable { public int $current = 0; public int $peakToday = 0; public int $peakAll = 0; /** * @return array<string, int> */ #[\Override] public function jsonSerialize(): array { return [ "recent" => $this->current, "peak_today" => $this->peakToday, "peak_all" => $this->peakAll, ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/SteamPeak/SteamPeekResults.php
src/Data/Objects/SteamPeak/SteamPeekResults.php
<?php namespace AugmentedSteam\Server\Data\Objects\SteamPeak; class SteamPeekResults implements \JsonSerializable { /** @var list<SteamPeekGame> */ public array $games; public function shuffle(bool $shuffle): self { if ($shuffle) { shuffle($this->games); } return $this; } public function limit(int $count): self { $this->games = array_slice($this->games, 0, $count); return $this; } /** * @return array<mixed> */ #[\Override] public function jsonSerialize(): array { return $this->games; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/SteamPeak/SteamPeekGame.php
src/Data/Objects/SteamPeak/SteamPeekGame.php
<?php namespace AugmentedSteam\Server\Data\Objects\SteamPeak; class SteamPeekGame implements \JsonSerializable { public string $title; public int $appid; public float $rating; public float $score; /** * @return array<string, mixed> */ #[\Override] public function jsonSerialize(): array { return [ "title" => $this->title, "appid" => $this->appid, "sprating" => $this->rating, "score" => $this->score ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false
IsThereAnyDeal/AugmentedSteam_Server
https://github.com/IsThereAnyDeal/AugmentedSteam_Server/blob/8a46ed2ae10106c1d4f0ec516aa04f1762093007/src/Data/Objects/Reviews/Reviews.php
src/Data/Objects/Reviews/Reviews.php
<?php namespace AugmentedSteam\Server\Data\Objects\Reviews; class Reviews implements \JsonSerializable { public ?Review $metauser = null; public ?Review $opencritic = null; /** * @return array<string, mixed> */ #[\Override] public function jsonSerialize(): array { return [ "metauser" => $this->metauser, "opencritic" => $this->opencritic ]; } }
php
MIT
8a46ed2ae10106c1d4f0ec516aa04f1762093007
2026-01-05T04:53:50.744931Z
false