diff --git a/composer.json b/composer.json index 5d3b9b5..1281136 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,8 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "flashwave/index": "*" + "flashwave/index": "*", + "twig/twig": "^3.7" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index f430525..d5f4802 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "11f8c90aff3c23a448844cee09bcd23c", + "content-hash": "90e206da96cc83682b957dc89eb26f1d", "packages": [ { "name": "flashwave/index", @@ -51,6 +51,242 @@ "description": "Composer package for the common library for my projects.", "homepage": "https://railgun.sh/index", "time": "2023-08-03T01:29:57+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.27.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.27-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-11-03T14:55:06+00:00" + }, + { + "name": "twig/twig", + "version": "v3.7.0", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "5cf942bbab3df42afa918caeba947f1b690af64b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/5cf942bbab3df42afa918caeba947f1b690af64b", + "reference": "5cf942bbab3df42afa918caeba947f1b690af64b", + "shasum": "" + }, + "require": { + "php": ">=7.2.5", + "symfony/polyfill-ctype": "^1.8", + "symfony/polyfill-mbstring": "^1.3" + }, + "require-dev": { + "psr/container": "^1.0|^2.0", + "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Twig Team", + "role": "Contributors" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "support": { + "issues": "https://github.com/twigphp/Twig/issues", + "source": "https://github.com/twigphp/Twig/tree/v3.7.0" + }, + "funding": [ + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/twig/twig", + "type": "tidelift" + } + ], + "time": "2023-07-26T07:16:09+00:00" } ], "packages-dev": [], diff --git a/mince.php b/mince.php index 6c1e9a7..72f7233 100644 --- a/mince.php +++ b/mince.php @@ -2,7 +2,6 @@ namespace Mince; use Index\Environment; -use Index\XString; use Index\Data\ConnectionFailedException; use Index\Data\DbTools; @@ -14,6 +13,7 @@ define('MCR_DIR_PUB', MCR_ROOT . '/public'); define('MCR_DIR_PRV', MCR_ROOT . '/private'); define('MCR_DIR_CFG', MCR_ROOT . '/config'); define('MCR_DIR_MIG', MCR_ROOT . '/database'); +define('MCR_DIR_TPL', MCR_ROOT . '/templates'); require_once MCR_ROOT . '/vendor/autoload.php'; @@ -30,17 +30,6 @@ try { die($ex->getMessage()); } +$db->execute('SET SESSION time_zone = "+00:00", sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"'); + $remote = new RemoteV2($config['remotev2_url'], $config['remotev2_secret']); - -if(PHP_SAPI !== 'cli') { - if(empty($_COOKIE['mc_random'])) { - $sVerification = XString::random(32); - setcookie('mc_random', $sVerification, strtotime('1 day'), '/', $_SERVER['HTTP_HOST']); - } else - $sVerification = (string)filter_input(INPUT_COOKIE, 'mc_random'); - - $sVerification = hash('sha256', $sVerification); - - // replace this with id.flashii.net shit - $userInfo = ChatAuth::attempt($db, $config['chat_endpoint'], $config['chat_secret'], (string)filter_input(INPUT_COOKIE, 'msz_auth')); -} diff --git a/public/index.php b/public/index.php index 300379e..da7f3cf 100644 --- a/public/index.php +++ b/public/index.php @@ -1,25 +1,60 @@ $cache ?? false, + 'debug' => MCR_DEBUG, + 'strict_variables' => true, +]); +$twigArgs = [ + 'global' => [ + 'title' => 'Flashii Minecraft Servers', + 'loginUrl' => $config['login_url'], + ], + 'auth' => $userInfo, + 'verification' => $sVerification, +]; + +function tpl_vars(array $args): void { + global $twigArgs; + $twigArgs = array_merge($twigArgs, $args); +} + +function tpl_render(string $name, array $args, string $suffix = '.twig'): string { + global $twigEnv, $twigArgs; + return $twigEnv->render($name . $suffix, array_merge($twigArgs, $args)); +} + $router = new HttpFx; -$loginUrl = $config['login_url']; - -$router->setDefaultErrorHandler(function($response, $request, $code, $text) use ($loginUrl, $userInfo) { - $body = HTML::getHeader($userInfo, $loginUrl, sprintf('%03d %s', $code, $text)); - $body .= '
%s
', $text); - $body .= '%s
', $mErrorComment ?? 'No further details provided.'); - $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 .= 'This will give you access to the server.
'; - $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 |
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 .= '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.
Do note that this only works for servers where both a Java and Bedrock version number is listed!
'; - $body .= '1. Observe Global Rules.
'; - $body .= '2. Don\'t be an asshole.
'; - $body .= '3. Don\'t flood.
'; - $body .= '{{ error.text }}
+{{ error.body|default('No further details provided.') }}
+This website allows you to whitelist yourself on our Minecraft servers, for which you need to be logged in.
+So it doesn't make sense to display the details either.
+This will give you access to the server.
+ +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 |
There are currently no active servers, check back later! |
This will revoke your access to the server.
+You are currently whitelisted as {{ auth.mc_username }} on {{ auth.mc_whitelisted|date('Y-m-d H:i:s T') }}.
+ {% if whitelist_pending %} +The whitelists are synchronised once every 5 minutes, you'll be able to play soon!
+If you're playing a modpack, take that time to start the game up; it'll take a while.
+ {% endif %} + +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.
+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.
+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.
Do note that this only works for servers where both a Java and Bedrock version number is listed!
+