/dev/null | head -30"; $out["files"] = array_filter(array_map("trim", explode("\n", @shell_exec($cmd) ?: ""))); } // Nginx config that handles /api/sovereign/ $ng = @shell_exec("grep -l sovereign /etc/nginx/sites-enabled/* 2>/dev/null"); $out["nginx_configs"] = array_filter(array_map("trim", explode("\n", $ng ?: ""))); // If we have a config, extract the location block foreach ($out["nginx_configs"] ?? [] as $f) { if (!$f) continue; $content = @file_get_contents($f); if ($content) { // find any location containing /api/sovereign or similar if (preg_match_all("/location[^{]*\/api\/sovereign[^{]*\{[^}]+\}/m", $content, $matches)) { $out["nginx_blocks_$f"] = $matches[0]; } if (preg_match_all("/proxy_pass[^;]+sovereign[^;]+;/", $content, $pp)) { $out["proxy_pass_sov"] = $pp[0]; } if (preg_match_all("/\/api\/sovereign[^\s{}]+/", $content, $refs)) { $out["sovereign_refs_$f"] = array_unique($refs[0]); } } } echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);