$id, "host" => $pcs[$id]["host"] ?? "Unknown", "last_seen" => $time ]; } } echo json_encode($online); exit; } // ------------------------- // SEND COMMAND // ------------------------- if ($action == "send") { $data = json_decode(file_get_contents("php://input"), true); $id = $data["id"]; $cmd = $data["cmd"]; $commands = json_decode(file_get_contents($commandsFile), true); if (!isset($commands[$id])) { $commands[$id] = []; } $cmd_id = uniqid(); $commands[$id][] = [ "id" => $cmd_id, "cmd" => $cmd ]; file_put_contents($commandsFile, json_encode($commands, JSON_PRETTY_PRINT), LOCK_EX); echo json_encode(["status" => "ok"]); exit; } echo json_encode(["error" => "invalid action"]);