<?php
require_once 'config/db.php';

// Check if activity_logs table exists
$table = $conn->query("SHOW TABLES LIKE 'activity_logs'")->num_rows;
echo "activity_logs table exists: " . ($table ? 'YES' : 'NO') . "<br>";

if ($table) {
    // Show structure
    echo "<br><strong>Columns:</strong><br>";
    $cols = $conn->query("DESCRIBE activity_logs");
    while ($c = $cols->fetch_assoc()) echo $c['Field'] . " - " . $c['Type'] . "<br>";

    // Show count
    $count = $conn->query("SELECT COUNT(*) c FROM activity_logs")->fetch_assoc()['c'];
    echo "<br><strong>Total records:</strong> $count<br>";

    // Show sample
    if ($count > 0) {
        echo "<br><strong>Latest 3 records:</strong><br>";
        $rows = $conn->query("SELECT * FROM activity_logs ORDER BY created_at DESC LIMIT 3");
        while ($r = $rows->fetch_assoc()) {
            echo "<pre>" . print_r($r, true) . "</pre>";
        }
    }
}

// Check if user_agent column exists
$ua = $conn->query("SHOW COLUMNS FROM activity_logs LIKE 'user_agent'")->num_rows;
echo "<br>user_agent column: " . ($ua ? 'YES' : 'NO') . "<br>";
$ip = $conn->query("SHOW COLUMNS FROM activity_logs LIKE 'ip_address'")->num_rows;
echo "ip_address column: " . ($ip ? 'YES' : 'NO') . "<br>";
