Files
html/api/blade-heartbeat.php
2026-04-16 03:09:54 +02:00

22 lines
655 B
PHP

<?php
// Blade heartbeat + task delivery — called by sentinel-agent every 60s
header("Content-Type: application/json");
$k = $_GET["k"] ?? $_POST["k"] ?? "";
if ($k !== "BLADE2026") { echo json_encode(["error"=>"auth"]); exit; }
// Return pending tasks
$tasks = [];
foreach (glob("/var/www/html/api/blade-tasks/*.json") as $f) {
$t = json_decode(file_get_contents($f), true);
if (($t["status"] ?? "") === "pending") $tasks[] = $t;
}
// Also return any commands from the queue
echo json_encode([
"heartbeat" => "ok",
"server_time" => date("c"),
"pending_tasks" => count($tasks),
"tasks" => $tasks,
"poll_interval" => 60
]);