<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

require_once("zklib/zklib.php");

$ip = "192.168.10.55";
$zk = new ZKLib($ip, 4370);

if ($zk->connect()) {
    echo "✅ Connected to $ip<br>";

    $users = $zk->getUser();

    echo "<pre>";
    var_dump($users); // 🔎 Debugging: see raw response
    echo "</pre>";

    if (!empty($users)) {
        echo "<h3>Users in device:</h3><ul>";
        foreach ($users as $uid => $user) {
            echo "<li>UID: $uid | ID: {$user[0]} | Name: {$user[1]}</li>";
        }
        echo "</ul>";
    } else {
        echo "❌ No users fetched from device.";
    }

    $zk->disconnect();
} else {
    echo "❌ Could not connect to device";
}
