Files
html/api/ambre-scripts-list.php
2026-04-22 01:55:03 +02:00

27 lines
876 B
PHP

<?php
header("Content-Type: application/json");
$wevia = @file_get_contents("/var/www/html/wevia.html");
$scripts = [];
$pos = 0;
while (($m = strpos($wevia, "<script", $pos)) !== false) {
$tag_end = strpos($wevia, ">", $m);
if ($tag_end === false) break;
$tag = substr($wevia, $m, $tag_end - $m + 1);
$content_start = $tag_end + 1;
$end = strpos($wevia, "</script>", $content_start);
if ($end === false) break;
$content = substr($wevia, $content_start, $end - $content_start);
$start_line = substr_count(substr($wevia, 0, $m), "\n") + 1;
$nlines = substr_count($content, "\n") + 1;
$scripts[] = [
"tag_start_line" => $start_line,
"tag" => substr($tag, 0, 80),
"content_size" => strlen($content),
"content_lines" => $nlines,
];
$pos = $end + 9;
}
echo json_encode($scripts, JSON_PRETTY_PRINT);