$root, 'config' => $config] = require __DIR__ . '/_bootstrap.php'; if ($_SERVER['REQUEST_METHOD'] !== 'POST') { Http::methodNotAllowed(['POST']); exit; } Security::validateCsrf(); (new RateLimiter($root, $config, RateLimiter::clientIp()))->check('notify'); $maxBody = (int) ($config['max_body_bytes'] ?? 1_048_576); $body = Http::readJsonBody($maxBody > 0 ? $maxBody : null); $email = (string) ($body['email'] ?? ''); $tool = (string) ($body['tool'] ?? ''); $allowedTools = (array) ($config['allowed_notify_tools'] ?? ['process-mapper']); if ($tool === '' || !in_array($tool, $allowedTools, true)) { Http::json(['error' => 'Outil invalide ou non autorisé'], 400); exit; } if ($email === '' || !filter_var($email, FILTER_VALIDATE_EMAIL)) { Http::json(['error' => 'Email invalide'], 400); exit; } $outboxDir = $root . '/storage/outbox'; if (!is_dir($outboxDir)) { @mkdir($outboxDir, 0775, true); } $id = date('Ymd_His') . '_' . bin2hex(random_bytes(4)); $meta = [ 'id' => $id, 'type' => 'notify_interest', 'tool' => $tool, 'email' => $email, 'created_at' => date(DATE_ATOM), ]; file_put_contents( $outboxDir . DIRECTORY_SEPARATOR . $id . '_notify.json', json_encode($meta, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) ); Http::json(['status' => 'ok']);