File size: 1,011 Bytes
9d38145
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
/**
 * captures.php — returns captures/manifest.jsonl as a JSON array (newest last).
 * Each line: {ts, client_id, kind, idx, files, cloud, quality, device, bot, ip}.
 */
declare(strict_types=1);

require_once __DIR__ . '/lib.php';

header('Access-Control-Allow-Origin: *');
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store');

$out = [];
try {
    $file = __DIR__ . '/captures/manifest.jsonl';
    if (is_file($file)) {
        $raw = @file_get_contents($file);
        if (is_string($raw) && $raw !== '') {
            foreach (explode("\n", $raw) as $line) {
                $line = trim($line);
                if ($line === '') {
                    continue;
                }
                $j = json_decode($line, true);
                if (is_array($j)) {
                    $out[] = $j;
                }
            }
        }
    }
} catch (Throwable $e) {
    $out = [];
}

echo json_encode($out, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);