Files
html/api/ambre-oss-state.php
2026-04-22 03:15:02 +02:00

32 lines
992 B
PHP

<?php
header("Content-Type: application/json");
$files = [
"/var/www/html/api/oss-registry.json",
"/var/www/html/oss-registry.json",
"/var/www/html/oss-catalog.html",
];
$out = [];
foreach ($files as $f) {
if (file_exists($f)) {
$out[basename($f)] = [
"size" => filesize($f),
"mtime" => date("Y-m-d H:i", filemtime($f)),
];
if (substr($f, -5) === ".json") {
$data = json_decode(@file_get_contents($f), true);
$out[basename($f)]["tool_count"] = is_array($data) ? count($data) : 0;
if (is_array($data)) {
$cats = [];
foreach ($data as $d) {
$c = $d["category"] ?? $d["cat"] ?? "unknown";
$cats[$c] = ($cats[$c] ?? 0) + 1;
}
$out[basename($f)]["cats"] = $cats;
}
}
} else {
$out[basename($f)] = "NOT FOUND";
}
}
echo json_encode($out, JSON_PRETTY_PRINT);