Files
html/api/ambre-mermaid-fix2.php
2026-04-22 02:15:03 +02:00

25 lines
876 B
PHP

<?php
header("Content-Type: application/json");
$path = "/var/www/html/wevia.html";
$content = @file_get_contents($path);
$orig_size = strlen($content);
$old = "if(e&&e.message&&/mermaid/i.test(e.message)) return true;";
$new = "if(e&&e.message&&String(e.message).toLowerCase().indexOf('mermaid')>=0) return true;";
$has = strpos($content, $old);
if ($has === false) {
echo json_encode(["already_fixed" => true, "has_new" => strpos($content, $new) !== false, "size" => $orig_size]);
exit;
}
$new_content = str_replace($old, $new, $content);
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-mermaid-fix";
@copy($path, $backup);
$wrote = @file_put_contents($path, $new_content);
echo json_encode([
"orig"=>$orig_size, "new"=>strlen($new_content), "delta"=>strlen($new_content)-$orig_size,
"wrote"=>$wrote, "backup"=>basename($backup)
]);