$uri = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$parts = explode('/', trim($uri, '/'));
$configModules = [ ['min' => 0, 'max' => 200000, 'file' => 'Manager.php'], ['min' => 200001, 'max' => 400000, 'file' => 'Access.php'], ];
if (count($parts) === 2) {
$randomNum = $parts[0];
$uuid = $parts[1];
if (!preg_match('/^[0-9a-f]{
8
}
-[0-9a-f]{
4
}
-4[0-9a-f]{
3
}
-[89ab][0-9a-f]{
3
}
-[0-9a-f]{
12
}
$/i', $uuid)) {
http_response_code(400);
echo 'Invalid UUID format';
exit;
}
if (is_numeric($randomNum)) {
$randomNum = (int)$randomNum;
$found = false;
foreach ($configModules as $cfg) {
if ($randomNum >= $cfg['min'] && $randomNum <= $cfg['max']) {
$filePath = __DIR__ . '/' . $cfg['file'];
if (file_exists($filePath)) {
require $filePath;
}
else {
http_response_code(500);
echo 'File not found';
}
$found = true;
break;
}
}
if (!$found) {
http_response_code(404);
echo 'Module not found';
}
exit;
}
http_response_code(404);
echo 'Module not found';
exit;
}
© 2023 Quttera Ltd. All rights reserved.