BlueGit

timfa 66wiki

add api option to search.php

timfa Tim · pushed by timfa

Authored 2025-12-23 · 10 months ago

Hash
534800bb6ec7d50399abd91cc74dc3af4073e1ed
Parent
fa83efbc
1 file changed +8 −0
web/search.php +8 −0
@@ -1,4 +1,7 @@
1 1 <?php
2
3 $api = isset($_GET['api']);
4
2 5 function flattenValues(mixed $value, string $prefix = ''): array
3 6 {
4 7 $out = [];
@@ -128,3 +131,8 @@ function makeSnippet(string $text, string $query, int $maxLen = 120): string
128 131 return $snippet;
129 132 }
130 133
134 if ($api) {
135 $query = $_GET['query'];
136 $results = searchAllJson(__DIR__ . DIRECTORY_SEPARATOR . 'data', $query);
137 echo json_encode($results);
138 }
@@ -1,4 +1,7 @@
1<?php
1<?php
2
3$api = isset($_GET['api']);
4
2function flattenValues(mixed $value, string $prefix = ''): array
5function flattenValues(mixed $value, string $prefix = ''): array
3{
6{
4 $out = [];
7 $out = [];
@@ -128,3 +131,8 @@ function makeSnippet(string $text, string $query, int $maxLen = 120): string
128 return $snippet;
131 return $snippet;
129}
132}
130
133
134if ($api) {
135 $query = $_GET['query'];
136 $results = searchAllJson(__DIR__ . DIRECTORY_SEPARATOR . 'data', $query);
137 echo json_encode($results);
138}