настройка регулярного выражения
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
<?php
|
||||
require_once '../config.php';
|
||||
$db = new PDO("sqlite:../db/dns.sqlite");
|
||||
|
||||
$topDomains = $db->query("SELECT domain, COUNT(*) as hits FROM logs GROUP BY domain ORDER BY hits DESC LIMIT 10")->fetchAll(PDO::FETCH_ASSOC);
|
||||
echo json_encode($topDomains);
|
||||
ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
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()]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user