Initial commit: Modular Deploymentcenter platform

This commit is contained in:
Deploymentcenter Bot
2026-08-05 21:23:24 +02:00
commit 3a38fd4837
27 changed files with 2323 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
<?php
declare(strict_types=1);
header('Content-Type: application/json; charset=utf-8');
require_once __DIR__ . '/../../../../src/Core/Db.php';
require_once __DIR__ . '/../../../../src/Modules/License/Audit.php';
require_once __DIR__ . '/../../../../src/Modules/License/KeyGen.php';
require_once __DIR__ . '/../../../../src/Modules/License/RateLimiter.php';
require_once __DIR__ . '/../../../../src/Modules/License/LicenseService.php';
use Deploymentcenter\Core\Db;
use Deploymentcenter\Modules\License\LicenseService;
use Deploymentcenter\Modules\License\RateLimiter;
function sendResponse(array $data, int $statusCode = 200): void {
http_response_code($statusCode);
echo json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
exit;
}
try {
$config = require __DIR__ . '/../../../../config/config.php';
$pdo = Db::init($config);
$limiter = new RateLimiter($pdo, 120, 60);
$ip = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';
if (!$limiter->check($ip)) {
sendResponse(['error' => 'Too Many Requests', 'message' => 'Rate limit exceeded.'], 429);
}
$uri = parse_url($_SERVER['REQUEST_URI'] ?? '/', PHP_URL_PATH);
$method = strtoupper($_SERVER['REQUEST_METHOD'] ?? 'GET');
$rawInput = file_get_contents('php://input');
$inputData = !empty($rawInput) ? (json_decode($rawInput, true) ?? []) : $_POST;
$licenseService = new LicenseService($pdo);
if (str_ends_with($uri, '/validate') && $method === 'POST') {
$res = $licenseService->validate($inputData, $ip);
sendResponse($res);
}
if (str_ends_with($uri, '/deactivate') && $method === 'POST') {
$res = $licenseService->deactivate($inputData, $ip);
sendResponse($res);
}
if (str_ends_with($uri, '/status') && $method === 'GET') {
sendResponse(['status' => 'ok', 'module' => 'LicenseLabrador', 'version' => '1.0']);
}
sendResponse(['error' => 'Not Found', 'message' => 'Endpoint not found'], 404);
} catch (Throwable $t) {
sendResponse(['error' => 'Server Error', 'message' => $t->getMessage()], 500);
}