setDefaultErrorHandler(function($response, $request, $code, $text) use ($loginUrl, $userInfo) { $body = HTML::getHeader($userInfo, $loginUrl, sprintf('%03d %s', $code, $text)); $body .= '
'; $body .= sprintf('

HTTP %03d

', $code); $body .= sprintf('

%s

', $text); $body .= '
'; $body .= HTML::getFooter(); $response->setContent($body); }); $router->use('/', function($response) { $response->setPoweredBy('Mince'); }); $router->get('/index.php', function($response) { $response->redirect('/', true); }); $router->get('/', function($response, $request) use ($db, $remote, $loginUrl, $userInfo, $sVerification) { $name = (string)$request->getParam('name'); $error = (string)$request->getParam('error'); if(!empty($error) && ctype_lower($error)) { $errors = [ 'request' => ['Invalid request type.', 'Try to reload the page and try again.'], 'verify' => ['Request verification failed.', 'Try to reload the page and try again.'], 'itainthappenin' => ['Haha', 'No'], 'short' => ['Invalid username', 'The provided name is too short.'], 'long' => ['Invalid username', 'The provided name is too long.'], 'invalid' => ['Invalid username', 'The provided name contains invalid characters.'], 'conflict' => ['Username conflict', 'This username is already whitelisted with someone, contact flashwave if this is unexpected.'], 'connect' => ['Failed to connect to the server', 'The server is probably offline, pope flashwave if this is not expected.'], 'not-listed' => ['You have not been whitelisted yet', 'Add yourself to the whitelist before trying to remove yourself from it.'], ]; if(array_key_exists($error, $errors)) { $mErrorTitle = $errors[$error][0]; $mErrorComment = $errors[$error][1]; } else { $mErrorTitle = 'Unexpected response from server'; $mErrorComment = $error; } } $body = HTML::getHeader($userInfo, $loginUrl); if(!empty($mErrorTitle)) { $body .= '
'; $body .= sprintf('

%s

', $mErrorTitle); $body .= sprintf('

%s

', $mErrorComment ?? 'No further details provided.'); $body .= '
'; } if(!$userInfo->success) { $body .= '
'; $body .= '

You must be logged in to use this website!

'; $body .= '

This website allows you to whitelist yourself on our Minecraft servers, for which you need to be logged in.

'; $body .= '

So it doesn\'t make sense to display the details either.

'; $body .= '
'; } else { if($userInfo->mc_whitelisted < 1) { $body .= '
'; $body .= '

Add to Whitelist

'; $body .= '

This will give you access to the server.

'; $body .= '
'; $body .= sprintf(' ', $sVerification); $body .= ' '; $body .= ' '; $body .= '
'; $body .= '
'; } $body .= '
'; $body .= '

Servers

'; $body .= ' '; $body .= ' '; $body .= ' '; $body .= ' '; $body .= ' '; // $body .= ' '; // $body .= ' '; // $body .= ' '; $body .= ' '; $body .= ' '; $body .= '
Name Address Java version Bedrock version Details
Vanilla Survival mc-survival.flashii.net 1.19.2 N/A Regular Minecraft Survival with some server-side extensions.
Beta Survival mc-beta.flashii.net Beta 1.7.3 N/A Classic Minecraft Survival!
Tekkit Classic mc-tekkit.flashii.net 1.2.5 N/A Page for this modpack on the Technic Platform
All of Fabric 6 mc-aof6.flashii.net 1.19.2 N/A Page for this modpack on CurseForge
'; $body .= '
'; if($userInfo->mc_whitelisted > 0) { $body .= '
'; $body .= '

Remove from Whitelist

'; $body .= '

This will revoke your access to the server.

'; $body .= sprintf('

You are currently whitelisted as %s on %s.

', $userInfo->mc_username, date('Y-m-d H:i:s T', $userInfo->mc_whitelisted)); if(floor($userInfo->mc_whitelisted / 300) === floor(time() / 300)) { $body .= '

The whitelists are synchronised once every 5 minutes, you\'ll be able to play soon!

'; $body .= '

If you\'re playing a modpack, take that time to start the game up; it\'ll take a while.

'; } $body .= '
'; $body .= sprintf(' ', $sVerification); $body .= ' '; $body .= '
'; $body .= '
'; } $body .= '
'; $body .= '

Bedrock versions

'; $body .= '

Through the black magic bestowed upon us by GeyserMC it\'s possible to play on the server through any of the updated Bedrock versions of Minecraft.

'; $body .= '

This should allow you to play on the server from a phone, a tablet or a console, provided you also have an account for the original version of the game.

'; $body .= '

You will need to link your Minecraft and Bedrock accounts, you can do this by connecting to link.geysermc.org in both versions of the game and following the on-screen instructions.

'; $body .= '

Do note that this only works for servers where both a Java and Bedrock version number is listed!

'; $body .= '
'; } $body .= '
'; $body .= '

Rules

'; $body .= '

1. Observe Global Rules.

'; $body .= '

2. Don\'t be an asshole.

'; $body .= '

3. Don\'t flood.

'; $body .= '
'; $body .= HTML::getFooter(); return $body; }); $router->use('/whitelist', function($response, $request) use ($sVerification) { if(!$request->isFormContent()) { $response->redirect('/?error=request'); return true; } $body = $request->getContent(); if(!$body->hasParam('boob') || !hash_equals($sVerification, (string)$body->getParam('boob'))) { $response->redirect('/?error=verify'); return true; } }); $router->post('/whitelist/add', function($response, $request) use ($db, $userInfo) { if($userInfo->user_id == 45) { $response->redirect('/?error=itainthappenin'); return true; } $body = $request->getContent(); $name = (string)$body->getParam('name'); $resp = (new Whitelist($db))->add($userInfo, $name); if($resp === '') $response->redirect('/'); else { if($resp === 'invalid') $name = ''; $response->redirect("/?error={$resp}&name={$name}"); } }); $router->post('/whitelist/remove', function($response) use ($db, $userInfo) { $resp = (new Whitelist($db))->remove($userInfo); if($resp === '') $response->redirect('/'); else $response->redirect("/?error={$resp}"); }); $router->get('/errors/:code', function($res, $req, $code) { $code = intval($code); if($code < 100 || $code >= 600) $code = 400; return $code; }); $router->dispatch();