<?php
// check_new_devices.php
require_once __DIR__ . '/lib/auth.php';
require_once __DIR__ . '/lib/db.php';

if (!is_logged_in()) {
    exit(json_encode(['error' => 'Unauthorized']));
}

$pdo = db();
$stmt = $pdo->query("SELECT MAX(id) as max_id, COUNT(*) as total FROM devices");
$result = $stmt->fetch(PDO::FETCH_ASSOC);

header('Content-Type: application/json');
echo json_encode([
    'max_id' => (int) ($result['max_id'] ?? 0),
    'total' => (int) ($result['total'] ?? 0)
]);