16 lines
464 B
PHP
Executable File
16 lines
464 B
PHP
Executable File
<?php
|
|
ini_set('display_errors', 1);
|
|
error_reporting(E_ALL);
|
|
|
|
try {
|
|
$db = new PDO("sqlite:../db/dns.sqlite");
|
|
$stmt = $db->query("SELECT domain, COUNT(*) as hits FROM logs GROUP BY domain ORDER BY hits DESC LIMIT 10");
|
|
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
header('Content-Type: application/json');
|
|
echo json_encode($data ?: []);
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(["error" => $e->getMessage()]);
|
|
}
|