isLoggedIn()) { throw new Exception('Unauthorized'); } $input = json_decode(file_get_contents('php://input'), true); if (!isset($input['id'])) { throw new Exception('Missing directive ID'); } $id = (int)$input['id']; $db = Database::getInstance(); // Delete directive $stmt = $db->prepare("DELETE FROM panel_directives WHERE id = ?"); $stmt->bind_param('i', $id); if (!$stmt->execute()) { throw new Exception('Failed to delete directive'); } if ($stmt->affected_rows === 0) { throw new Exception('Directive not found'); } echo json_encode([ 'success' => true, 'message' => 'Directive deleted successfully' ]); } catch (Exception $e) { http_response_code(500); echo json_encode([ 'success' => false, 'error' => $e->getMessage() ]); } ?>