Files
html/api/ambre-scan-wtp.php
2026-04-22 04:00:07 +02:00

69 lines
2.6 KiB
PHP

<?php
header("Content-Type: application/json");
$out = [];
chdir("/var/www/html");
$out["recent_commits_30m"] = array_filter(array_map("trim", explode("\n", @shell_exec("git log --since='30 minutes ago' --oneline 2>&1 | head -15"))));
$out["recent_tags_today"] = array_filter(array_map("trim", explode("\n", @shell_exec("git tag -l 'wave-*' --sort=-creatordate 2>&1 | head -10"))));
// WTP state (point entrée architecture)
$wtp = "/var/www/html/weval-technology-platform.html";
if (file_exists($wtp)) {
$w = @file_get_contents($wtp);
$out["wtp"] = [
"size" => filesize($wtp),
"mtime" => date("Y-m-d H:i", filemtime($wtp)),
"banner_links" => preg_match_all("/href=[\"'][^\"']+\.html/", $w),
"has_banner" => strpos($w, "banner") !== false,
];
}
// Sitemap API for orphans tracking
$sitemap_api = @file_get_contents("https://weval-consulting.com/api/sitemap-api.php", false, stream_context_create(["http"=>["timeout"=>5]]));
if ($sitemap_api) {
$d = @json_decode($sitemap_api, true);
$out["sitemap"] = [
"total_pages" => is_array($d) ? count($d["pages"] ?? $d) : 0,
"raw_size" => strlen($sitemap_api),
];
}
// All-IA Hub state
$iahub = "/var/www/html/all-ia-hub.html";
if (file_exists($iahub)) {
$out["all_ia_hub"] = ["size" => filesize($iahub), "mtime" => date("Y-m-d H:i", filemtime($iahub))];
}
// WEVIA Master state
$master = "/var/www/html/wevia-master.html";
if (file_exists($master)) {
$out["wevia_master"] = ["size" => filesize($master), "mtime" => date("Y-m-d H:i", filemtime($master))];
}
// Orchestrator
$orch = "/var/www/html/wevia-orchestrator.html";
if (file_exists($orch)) {
$out["orchestrator"] = ["size" => filesize($orch), "mtime" => date("Y-m-d H:i", filemtime($orch))];
}
// Dashboards available
$dashboards = array_map("basename", glob("/var/www/html/*dashboard*.html") ?: []);
$out["dashboards_count"] = count($dashboards);
$out["dashboards_sample"] = array_slice($dashboards, 0, 15);
// Business KPI endpoint check
$biz_kpi = @file_get_contents("https://weval-consulting.com/api/v83-business-kpi-latest.json", false, stream_context_create(["http"=>["timeout"=>5]]));
if ($biz_kpi) {
$d = @json_decode($biz_kpi, true);
$out["biz_kpi"] = [
"keys" => is_array($d) ? array_slice(array_keys($d), 0, 10) : "invalid",
"size" => strlen($biz_kpi),
];
}
// Current load + recent PW runs
$out["load"] = trim(@shell_exec("uptime"));
$out["recent_pw_runs"] = trim(@shell_exec("ls -1t /tmp/ambre-pw-run-*.log 2>/dev/null | head -3"));
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);