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

47 lines
1.5 KiB
PHP

<?php
header("Content-Type: application/json");
$wevia = @file_get_contents("/var/www/html/wevia.html");
// Find big script starting around line 718 (first <script> without src= and big content)
$pos = 0;
$big = null;
$start_abs = 0;
while (($m = strpos($wevia, "<script>", $pos)) !== false) {
$end = strpos($wevia, "</script>", $m);
if ($end === false) break;
$content = substr($wevia, $m + 8, $end - $m - 8);
if (strlen($content) > 20000) {
$big = $content;
$start_abs = substr_count(substr($wevia, 0, $m + 8), "\n") + 1;
break;
}
$pos = $end + 9;
}
$lines = explode("\n", $big);
// Browser "line 920" likely 1-indexed within script body
$out = ["script_starts_at_abs_line" => $start_abs, "total_lines" => count($lines)];
// lines 915 - 925 of script
$context = [];
for ($i = 914; $i <= 925 && $i < count($lines); $i++) {
$L = $lines[$i];
$context[] = [
"script_line" => $i + 1,
"abs_line" => $start_abs + $i,
"length" => strlen($L),
"content" => substr($L, 0, 300),
"col_100_120" => strlen($L) >= 100 ? substr($L, 99, 21) : "(short)",
];
}
$out["context"] = $context;
// Find all regex literals in lines 915-925 (they span multiple lines perhaps)
// Also check the script_line 920 col 105 exactly
if (isset($lines[919])) {
$out["line_920_full"] = $lines[919];
$out["line_920_char_at_104"] = isset($lines[919][104]) ? $lines[919][104] . " (ord " . ord($lines[919][104]) . ")" : "(out of range)";
}
echo json_encode($out, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);