client = new Client(['verify' => false]); } /** * Check the user has voted. */ public function checkHasVoted(): bool { if (! config('habbo.findretros.enabled')) { return true; } $ip = request()->ip(); $cacheKey = sprintf(self::FIND_RETROS_CACHE_KEY, is_scalar($ip) ? (string) $ip : ''); if ($ip === '127.0.0.1') { return true; } if (request()->has('novote')) { return true; } if (Cache::has($cacheKey)) { return true; } $api = config('habbo.findretros.api'); $name = config('habbo.findretros.name'); $uri = sprintf(self::FIND_RETROS_VERIFY_URI, is_scalar($api) ? (string) $api : '', is_scalar($name) ? (string) $name : '', is_scalar($ip) ? (string) $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 { $api = config('habbo.findretros.api'); $name = config('habbo.findretros.name'); return sprintf(self::FIND_RETROS_REDIRECT_URI, is_scalar($api) ? (string) $api : '', is_scalar($name) ? (string) $name : '' ); } }