Merged key.php into the main codebase and removed all non-index.php PHP files.

This commit is contained in:
flash 2023-05-28 18:22:55 +00:00
parent 62af057893
commit 6960a14d9d
5 changed files with 19 additions and 31 deletions

2
.gitignore vendored
View file

@ -1,5 +1,3 @@
/public/volatile
/public/whois/vendor
.DS_Store .DS_Store
[Dd]esktop.ini [Dd]esktop.ini
/.debug /.debug

@ -1 +1 @@
Subproject commit ac2255d24d7dd39ac91fa50d3a7aa71ce0a92188 Subproject commit bce5ba77a268ecd6338d0e3520e41ff4c40cbeda

View file

@ -1,2 +0,0 @@
<?php
require_once __DIR__ . '/index.php';

View file

@ -1,6 +1,7 @@
<?php <?php
namespace Makai; namespace Makai;
use Index\XString;
use Index\Http\HttpFx; use Index\Http\HttpFx;
require_once __DIR__ . '/../makai.php'; require_once __DIR__ . '/../makai.php';
@ -43,6 +44,7 @@ define('MKI_REDIRS', [
'/nintendo' => '/contact', '/nintendo' => '/contact',
'/nintendo.php' => '/contact', '/nintendo.php' => '/contact',
'/ascii.php' => '/ascii', '/ascii.php' => '/ascii',
'/key.php' => '/rngstr',
]); ]);
$router = new HttpFx; $router = new HttpFx;
@ -179,6 +181,22 @@ $router->get('/ascii', function() use ($ctx) {
return $ctx->getTemplating()->render('ascii'); return $ctx->getTemplating()->render('ascii');
}); });
$router->get('/rngstr', function($response, $request) {
$response->setTypePlain();
$length = (int)$request->getParam('length', FILTER_SANITIZE_NUMBER_INT);
if($length > 0 && $length <= 1024)
return XString::random($length);
$out = '8: ' . XString::random(8) . PHP_EOL;
$out .= '16: ' . XString::random(16) . PHP_EOL;
$out .= '32: ' . XString::random(32) . PHP_EOL;
$out .= '64: ' . XString::random(64) . PHP_EOL;
$out .= '128: ' . XString::random(128) . PHP_EOL;
return $out;
});
$router->get('/ssh.php', function() { $router->get('/ssh.php', function() {
$query = ''; $query = '';

View file

@ -1,26 +0,0 @@
<?php
define('KEY_CHARS', 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789');
define('KEY_CHARS_LENGTH', strlen(KEY_CHARS));
function generateKey(int $length): string {
$bytes = str_repeat("\0", $length);
for($i = 0; $i < $length; ++$i)
$bytes[$i] = KEY_CHARS[random_int(0, KEY_CHARS_LENGTH - 1)];
return $bytes;
}
header('Content-Type: text/plain');
if(isset($_GET['length'])) {
$length = (int)filter_input(INPUT_GET, 'length', FILTER_SANITIZE_NUMBER_INT);
if($length > 0 && $length < 1000) {
echo generateKey($length);
return;
}
}
echo '8: ' . generateKey(8) . PHP_EOL;
echo '16: ' . generateKey(16) . PHP_EOL;
echo '32: ' . generateKey(32) . PHP_EOL;
echo '64: ' . generateKey(64) . PHP_EOL;
echo '128: ' . generateKey(128) . PHP_EOL;