Developers
Get players who log into your game to vote for your server. Anyone who hasn't voted today is sent to vote on Retroway, then comes back to you. They can still log in without voting, but they'll be asked again every time they log in until they vote: the voting page tells them so.
Log in: the code on this page fills itself in with your server's details.
What's your site built with? It's PHP It uses AtomCMS A link is enough
PHP site
-
Create the file
In your site's folder, next to the page that opens the game, create a file named
retroway.phpand paste this code into it. In the first few lines, enter your server's short name and your key.<?php // Retroway: sends players to vote if they log in without having voted today. // If they come back without voting they still get in, but they're asked again at their next login. const RETROWAY_URL = 'https://retroway.it'; const RETROWAY_SERVER = 'your-server'; const RETROWAY_KEY = 'YOUR_KEY'; (function () { $today = gmdate('Y-m-d'); if (($_COOKIE['retroway'] ?? '') === $today || !function_exists('curl_init')) { return; } // Coming back from the voting page: let them in this time, even if they haven't voted. // Anyone coming back from the voting page carries a pass in the address, signed with the key: it is good for fifteen minutes. $pass = $_GET['retroway'] ?? ''; [$time, $sign] = explode('-', (is_string($pass) ? $pass : '') . '-'); if (abs(time() - (int) $time) < 900 && hash_equals(hash_hmac('sha256', RETROWAY_SERVER . ':' . $time, RETROWAY_KEY), $sign)) { return; } // Asks Retroway whether a vote has already come from this address today. // Behind Cloudflare, the visitor's address arrives in HTTP_CF_CONNECTING_IP. $ip = $_SERVER['HTTP_CF_CONNECTING_IP'] ?? $_SERVER['REMOTE_ADDR']; $request = curl_init(RETROWAY_URL . '/api/v1/servers/' . RETROWAY_SERVER . '/vote'); curl_setopt_array($request, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 3, CURLOPT_HTTPHEADER => ['Authorization: Bearer ' . RETROWAY_KEY], CURLOPT_POSTFIELDS => http_build_query(['ip' => $ip]), ]); $answer = json_decode((string) curl_exec($request), true); $voted = is_array($answer) ? ($answer['voted'] ?? null) : null; // Hasn't voted: goes to the voting page. if ($voted === false) { header('Location: ' . RETROWAY_URL . '/s/' . RETROWAY_SERVER . '/vota?ingresso=1'); exit; } // Voted: no more asking until midnight UTC. If Retroway didn't answer, try again in ten minutes. $until = $voted === true ? (intdiv(time(), 86400) + 1) * 86400 : time() + 600; setcookie('retroway', $today, ['expires' => $until, 'path' => '/', 'httponly' => true, 'samesite' => 'Lax']); })(); -
Add a line
Open the page that opens the game: it's usually called
client.php,game.phporhotel.php. Paste this line at the very top, before everything else.<?php require __DIR__ . '/retroway.php'; ?> -
Test it
Open the game page: it sends you to vote, and after voting you come back to your site. After you've voted it won't ask again until tomorrow; if you come back without voting you still get in, but the next time you log in it asks again.
AtomCMS
-
Create the file
In the
app/Http/Middlewarefolder, create a file namedRetrowayMiddleware.phpand paste this code into it. In the first few lines, enter your server's short name and your key.<?php namespace App\Http\Middleware; use Closure; use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; use Symfony\Component\HttpFoundation\Response; use Throwable; // Retroway: sends players to vote if they log in without having voted today. // If they come back without voting they still get in, but they're asked again at their next login. class RetrowayMiddleware { private const URL = 'https://retroway.it'; private const SERVER = 'your-server'; private const KEY = 'YOUR_KEY'; public function handle(Request $request, Closure $next): Response { $today = gmdate('Y-m-d'); // They've already voted today, or they're coming back from the voting page: let them in. if ($request->session()->get('retroway') === $today || $this->returns($request)) { return $next($request); } // Asks Retroway whether a vote has already come from this address today. try { $voted = Http::timeout(3)->withToken(self::KEY)->asForm() ->post(self::URL . '/api/v1/servers/' . self::SERVER . '/vote', ['ip' => $request->ip()]) ->json('voted'); } catch (Throwable) { $voted = null; } // Voted: no more asking until tomorrow. If Retroway didn't answer, let them in this time. if ($voted === true) { $request->session()->put('retroway', $today); } if ($voted !== false) { return $next($request); } // Hasn't voted: goes to the voting page. return redirect()->away(self::URL . '/s/' . self::SERVER . '/vota?ingresso=1'); } // Anyone coming back from the voting page carries a pass in the address, signed with the key: it is good for fifteen minutes. private function returns(Request $request): bool { $pass = $request->query('retroway'); [$time, $sign] = explode('-', (is_string($pass) ? $pass : '') . '-'); return abs(time() - (int) $time) < 900 && hash_equals(hash_hmac('sha256', self::SERVER . ':' . $time, self::KEY), $sign); } } -
Change one line
Open
routes/web.phpand look for the line that starts withRoute::prefix('game'). Replace it with this one.Route::prefix('game')->middleware(['findretros.redirect', \App\Http\Middleware\RetrowayMiddleware::class, 'vpn.checker'])->group(function () { -
Test it
Log into the game: it sends you to vote, and after voting you come back to your site. After you've voted it won't ask again until tomorrow; if you come back without voting you still get in, but the next time you log in it asks again. If nothing changes, run
php artisan optimize:clearand try again.
Just a link
Don't want to touch the code? Paste this link anywhere on your site: it leads to the voting page and, after voting, brings people back to you. You can also leave a review from the same page.
<a href="https://retroway.it/s/your-server/vota">Vote for us on Retroway</a>
If something's wrong
- It doesn't send you to vote. If you've already voted today, it won't ask again until tomorrow. If you've just come back from the voting page without voting, you get in once: log out and back in, and it asks again. Also check that the server is in the ranking.
- You don't come back to your site after voting. Enter your site's address in the “Website” field on the server page.
- You changed the key. The old one no longer works: copy the file from this page again.
Technical details, for anyone using another language
The code above makes a single call. You can repeat it from any language, as long as it comes from your server and not from the browser: the key must not end up on the page.
POST https://retroway.it/api/v1/servers/your-server/vote
Authorization: Bearer YOUR_KEY
Content-Type: application/x-www-form-urlencoded
ip=203.0.113.7
ip: the visitor's IPv4 or IPv6 address, as your site sees it. It goes in the request body, as a form field or in JSON ({"ip": "203.0.113.7"}), never in the URL: that way it doesn't stay in the access logs.Authorization: the server's key, after the wordBearer.
Response
{
"voted": false,
"votes_left": 1,
"resets_at": "2026-12-01T00:00:00Z",
"vote_url": "https://retroway.it/s/your-server/vota"
}
voted:trueif at least one vote for the server came from that address today.votes_left: votes that address can still cast today. It's 0 or 1; with “Double vote” it can also be 2.resets_at: when the count starts over, i.e. the next midnight UTC.vote_url: the server's voting page.
Errors
400 invalid_ip:ipis missing from the request body or isn't an address.401 invalid_key: key missing, wrong or replaced by a new one.403 not_listed: the server isn't in the ranking.404 unknown_server: no server with that short name.405 use_post: the request isn't aPOST.
Good to know
- A vote counts per connection, not per account. Two users on the same connection both show as having voted after a single vote: keep that in mind if you reward people for voting. For IPv6 addresses, only the first 64 bits count.
- The day is UTC. You can vote again from 1 a.m. Italian time; from 2 a.m. during daylight saving time.
- Anyone who comes back without voting arrives at the “Website” address with
?retroway=<seconds>-<signature>. The seconds are Unix time; the signature is the HMAC-SHA256 of<short name>:<seconds>with the key, in hexadecimal. If the signature is right and the seconds are no more than 15 minutes old, let them in without calling the API again. - If Retroway doesn't respond within 3 seconds, the code lets the visitor through.
- The address you send us isn't stored. We derive from it the same code we use for votes and compare it: see the terms, point 10.