43 lines
1.5 KiB
PHP
43 lines
1.5 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$c = @file_get_contents("/var/www/html/wevia.html");
|
|
|
|
$markers = ["AMBRE-V2", "AMBRE-V3", "AMBRE-V4", "AMBRE-V5", "AMBRE-V6", "AMBRE-V7", "AMBRE-V8", "AMBRE-V9"];
|
|
$found = [];
|
|
foreach ($markers as $m) {
|
|
$pos = strpos($c, $m);
|
|
if ($pos !== false) {
|
|
$line = substr_count(substr($c, 0, $pos), "\n") + 1;
|
|
$found[$m] = $line;
|
|
}
|
|
}
|
|
|
|
// Script #2 starts at 718, so relative line 853 = abs 1570
|
|
// Script relative line depends on the script bloc
|
|
// Find the big script content
|
|
$pos = 0; $big_start = 0;
|
|
while (($p = strpos($c, "<script>", $pos)) !== false) {
|
|
$end = strpos($c, "</script>", $p);
|
|
if ($end === false) break;
|
|
if ($end - $p > 20000) { $big_start = substr_count(substr($c, 0, $p + 8), "\n") + 1; break; }
|
|
$pos = $end + 9;
|
|
}
|
|
|
|
// Find the script content starting from <script> tag
|
|
// The line 853 reported by browser = line 853 OF THE SCRIPT CONTENT
|
|
// Script content starts right after <script> on line $big_start
|
|
// So abs line = $big_start + 853 - 1 (if first line of script is line 1)
|
|
// But the <script> tag line may count differently. Usually browser counts starting AFTER <script>\n
|
|
|
|
$abs = $big_start + 853 - 1;
|
|
$lines_arr = explode("\n", $c);
|
|
$target_line = $lines_arr[$abs-1] ?? "";
|
|
|
|
echo json_encode([
|
|
"markers_found" => $found,
|
|
"big_script_start_line" => $big_start,
|
|
"target_abs_line" => $abs,
|
|
"target_line_content" => substr($target_line, 0, 300),
|
|
"target_length" => strlen($target_line),
|
|
], JSON_PRETTY_PRINT);
|