🆙 Add fixed cms 🆙

This commit is contained in:
Remco
2026-02-02 19:30:21 +01:00
parent b1a2cab62d
commit b67e0ec2b9
3982 changed files with 193682 additions and 0 deletions
@@ -0,0 +1,79 @@
<?php
namespace App\Services;
use GuzzleHttp\Client;
use Illuminate\Support\Facades\Cache;
/* Credits to Kani for this */
class FindRetrosService
{
/**
* The findretros verification uri.
*/
public const FIND_RETROS_VERIFY_URI = '%s/validate.php?user=%s&ip=%s';
/**
* The findretros redirect uri.
*/
public const FIND_RETROS_REDIRECT_URI = '%s/servers/%s/vote?minimal=1&return=1';
public const FIND_RETROS_CACHE_KEY = 'voted.%s';
/**
* The guzzle client instance
*/
protected Client $client;
/**
* Initialise Find Retros Service
*/
public function __construct()
{
$this->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'));
}
}