diff --git a/api.php b/api.php index 78c2037..2dea153 100644 --- a/api.php +++ b/api.php @@ -230,6 +230,50 @@ if ($action === 'live_prices') { exit; } +if ($action === 'all_domains') { + $q = trim($_GET['q'] ?? ''); + $tld = trim($_GET['tld'] ?? ''); + $limit = intval($_GET['limit'] ?? 2000); + if ($limit < 1) $limit = 1; + if ($limit > 5000) $limit = 5000; + + $sql = "SELECT d.run_id, d.scanned_at, d.domain, d.tld, d.score, d.status, d.keywords_json, + ls.llm_score, ls.decision, ls.reason + FROM domains d + LEFT JOIN llm_scores ls ON ls.run_id = d.run_id AND ls.domain = d.domain + WHERE 1=1"; + + if ($q !== '') $sql .= " AND d.domain LIKE :q"; + if ($tld !== '') $sql .= " AND d.tld = :tld"; + + $sql .= " ORDER BY d.scanned_at DESC, d.score DESC, d.domain ASC LIMIT :limit"; + + $st = $db->prepare($sql); + if ($q !== '') $st->bindValue(':q', '%' . $q . '%', SQLITE3_TEXT); + if ($tld !== '') $st->bindValue(':tld', $tld, SQLITE3_TEXT); + $st->bindValue(':limit', $limit, SQLITE3_INTEGER); + + $res = $st->execute(); + $rows = []; + while ($r = $res->fetchArray(SQLITE3_ASSOC)) { + $r['keywords'] = json_decode($r['keywords_json'] ?: '[]', true) ?: []; + $r['is_new'] = false; + unset($r['keywords_json']); + $rows[] = $r; + } + + echo json_encode([ + 'ok' => true, + 'meta' => [ + 'mode' => 'all', + 'count' => count($rows), + 'limit' => $limit, + ], + 'domains' => $rows, + ], JSON_UNESCAPED_UNICODE); + exit; +} + if ($action === 'prices') { if ($_SERVER['REQUEST_METHOD'] === 'POST') { $raw = json_decode(file_get_contents('php://input'), true) ?: []; diff --git a/index.html b/index.html index 889da35..102718f 100644 --- a/index.html +++ b/index.html @@ -24,6 +24,9 @@ .pill input{width:78px;padding:4px 6px} .ok{color:#63db8f}.bad{color:#ff8b8b} .chip{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;background:#264a32;color:#9df5bc;border:1px solid #3f8b5b} + .tabbar{display:flex;gap:8px;flex-wrap:wrap;margin:8px 0 0} + .tabbtn{cursor:pointer} + .tabbtn.active{background:#2a3f86;border-color:#6e8cff;color:#fff} .small{font-size:12px} @media (max-width: 980px){.grid{grid-template-columns:1fr}} @media (max-width: 700px){ @@ -41,6 +44,10 @@