Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by http://DeZender.Net
- * @ deZender (PHP7 Decoder for SourceGuardian Encoder)
- *
- * @ Version : 5.0.1.0
- * @ Author : DeZender
- * @ Release on : 22.04.2022
- * @ Official site : http://DeZender.Net
- *
- */
- namespace App\Http\Controllers\StreamPlayApi\Integration;
- class StalkerApiIntegrationController extends \App\Http\Controllers\Api\ApiController
- {
- private $serverRepository = null;
- private $streamRepository = null;
- private $seriesRepository = null;
- private $lineRepository = null;
- private $logger = null;
- private $idResolver = null;
- private $deviceSettingService = null;
- private $generalSettings = null;
- private $streamFormat = null;
- private $allowedNoAuth = ['stb_get_profile', 'stb_get_modules', 'stb_get_localization'];
- public function __construct(\App\Http\Repositories\StreamingServerRepository $serverRepository, \App\Http\Repositories\StreamRepository $streamRepository, \App\Http\Repositories\SeriesRepository $seriesRepository, \App\Http\Repositories\LineRepository $lineRepository, \Psr\Log\LoggerInterface $logger, \App\Http\Services\UuidToIntResolver $idResolver, \App\Http\Repositories\SettingsRepository $generalSettings)
- {
- $this->serverRepository = $serverRepository;
- $this->streamRepository = new \App\Http\Services\PersistentCache\Repositories\ProxyRepository($streamRepository);
- $this->seriesRepository = new \App\Http\Services\PersistentCache\Repositories\ProxyRepository($seriesRepository);
- $this->lineRepository = $lineRepository;
- $this->logger = $logger;
- $this->idResolver = $idResolver;
- $this->streamFormat = '';
- $this->generalSettings = $generalSettings->magDevice();
- $this->localisationSettings = $generalSettings->localisation();
- }
- private function getOrderBy($type)
- {
- return $this->generalSettings->default_ord[$type] ?? '';
- }
- public function index(\Illuminate\Http\Request $request, \App\Http\Services\Device\AuthService $authService, \App\Http\Services\Device\SettingsService $deviceSettingService)
- {
- \is_cache_loaded();
- fad0d5ca831cd5aeba3a7c835dc7808f673843d63089d856f94f59ff8c9d06fcb();
- if (!method_exists('\\Illuminate\\Redis\\RedisManager', 'persistent')) {
- echo 'Could not connect to Redis at 127.0.0.1:6379: Connection refused';
- exit();
- }
- $type = $request->get('type');
- $action = $request->get('action');
- $method = $type . '_' . $action;
- if (!method_exists($this, $method)) {
- return $this->respond([
- 'js' => []
- ]);
- }
- $line = $request->input('__line');
- if (!$line && !in_array($method, $this->allowedNoAuth)) {
- return $this->respond([
- 'js' => ['Auth Required']
- ], 401);
- }
- $authService->setRequest($request);
- $this->deviceSettingService = $deviceSettingService;
- $this->deviceSettingService->setDeviceId($authService->getDeviceId());
- try {
- $response = ['js' => $this->{$method}($request)];
- }
- catch (\Symfony\Component\HttpKernel\Exception\HttpException $e) {
- throw $e;
- }
- catch (\Exception $e) {
- \Illuminate\Support\Facades\Log::error('Stalker api exception: ' . $e->getMessage() . ' ' . $e->getTraceAsString());
- $response = [
- 'js' => []
- ];
- }
- return $this->respond($response);
- }
- public function handshake(\Illuminate\Http\Request $request, \App\Http\Services\Device\AuthService $authService, \App\Http\Services\Subscriptions\TokenService $tokenService)
- {
- $authService->setRequest($request);
- $ip = $request->ip();
- $rateLimitService = new \App\Http\Services\RateLimit\RateLimitService($ip);
- if ($rateLimitService->isTooManyAttempts()) {
- throw new \Symfony\Component\HttpKernel\Exception\HttpException(\Symfony\Component\HttpFoundation\Response::HTTP_TOO_MANY_REQUESTS, 'Too many attempts');
- }
- $line = $authService->auth();
- if (!$line) {
- $rateLimitService->registerAttempts();
- $token = strtoupper(md5(uniqid(rand(), true)));
- }
- else {
- $lineDto = new \App\Structs\Dto\LineDto($request, $line);
- $locks = \App\Http\Services\LineLock\LineLockFactory::createFromLine($line, $request);
- $this->checkLocks($locks, $lineDto, $line);
- $type = 'short';
- $token = $tokenService->generateToken($type, $line, 120)[0];
- }
- $response = ['js' => $this->doHandshake($token)];
- return $this->respond($response);
- }
- public function doHandshake($token)
- {
- $response['token'] = (string) $token;
- return $response;
- }
- public function stb_log()
- {
- return true;
- }
- public function stb_get_profile(\Illuminate\Http\Request $request)
- {
- $profile = $request->input('__line') ?: new \App\Models\Line();
- $profile['mac'] = $request->cookie('mac');
- $profile['ip'] = $request->ip();
- $settingsRepository = new \App\Http\Repositories\SettingsRepository();
- $profile['use_password'] = !$settingsRepository->magDevice()->disable_password;
- $line = $request->input('__line');
- if ($line) {
- $lineDto = new \App\Structs\Dto\LineDto($request, $line);
- $locks = \App\Http\Services\LineLock\LineLockFactory::createFromLine($line, $request, ['stb']);
- $this->checkLocks($locks, $lineDto, $line);
- }
- $serializer = new \App\Http\Serializers\StreamPlayApi\StalkerPlayer\ProfileSerializer($this->generalSettings);
- $response = $serializer->transform($profile);
- return $response;
- }
- public function stb_get_localization(\Illuminate\Http\Request $request)
- {
- $localeLang = $this->deviceSettingService->getLang();
- if ($request->hasCookie('locale') && !!$request->cookie('locale')) {
- $localeLang = $request->cookie('locale');
- }
- $serializer = new \App\Http\Serializers\StreamPlayApi\StalkerPlayer\LocalizationSerializer();
- ...............................................................
- ......................................
- ...............
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement