client = new Client(['verify' => false]); } /** * Check the user has voted. */ public function checkHasVoted(): bool { if (! config('habbo.findretros.enabled')) { return true; } $cacheKey = sprintf(self::FIND_RETROS_CACHE_KEY, request()->ip()); if (request()->ip() === '127.0.0.1') { return true; } if (request()->has('novote')) { return true; } if (Cache::has($cacheKey)) { return true; } $uri = sprintf(self::FIND_RETROS_VERIFY_URI, config('habbo.findretros.api'), config('habbo.findretros.name'), request()->ip()); $request = $this->client->get($uri); $response = $request->getBody()->getContents(); if (in_array($response, ['1', '2'])) { Cache::put($cacheKey, true, now()->addMinutes(30)); return true; } return false; } /** * Retrieve the find retros redirect url. */ public function getRedirectUri(): string { return sprintf(self::FIND_RETROS_REDIRECT_URI, config('habbo.findretros.api'), config('habbo.findretros.name')); } }