true]); exit; } // Add the link in banner (find "Arsenal History" or similar anchor) // Use safer approach: add a link block AFTER or before first // Find the existing banner Mega/Arsenal link $anchors = [ "href=\"/dashboards-index.html\"" => "AFTER", "href=\"/e2e-dashboard.html\"" => "BEFORE", ]; $injected = false; foreach ($anchors as $anchor => $where) { $pos = strpos($c, $anchor); if ($pos !== false) { // Find surrounding element boundary $a_start = strrpos(substr($c, 0, $pos), " $a_end = strpos($c, "", $pos); if ($a_end !== false) { $a_end += 4; $link_html = "📊 Hub Unifié"; if ($where === "BEFORE") { $new_c = substr($c, 0, $a_start) . $link_html . substr($c, $a_start); } else { $new_c = substr($c, 0, $a_end) . $link_html . substr($c, $a_end); } $c = $new_c; $injected = true; break; } } } } if (!$injected) { echo json_encode(["error"=>"no anchor found to inject link"]); exit; } $backup = "/opt/wevads/vault/wtp.GOLD-" . date("Ymd-His") . "-wave246-hub"; @copy($path, $backup); $wrote = @file_put_contents($path, $c); echo json_encode([ "wrote" => $wrote, "size" => strlen($c), "backup" => basename($backup), ]);