Files
html/api/ambre-v10-css.php
2026-04-22 03:30:04 +02:00

29 lines
1.5 KiB
PHP

<?php
header("Content-Type: application/json");
$path = "/var/www/html/wevia.html";
$c = @file_get_contents($path);
// In the inline mermaid div, ensure min-height and visible styling
$old = '<div class="mermaid" id="" + uniqId + "" style="text-align:center">" + mcode + "</div>';
// Actually the style is inside the string. Let me use pattern
$old_esc = '<div class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\">" + mcode + "</div>';
$new_esc = '<div class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center;min-height:200px;font-size:14px;color:#333;background:#fff;padding:12px\\">" + mcode + "</div>';
if (strpos($c, $old_esc) === false) {
// Simpler check
if (strpos($c, 'class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\"') !== false) {
$c = str_replace('class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center\\"', 'class=\\"mermaid\\" id=\\"" + uniqId + "\\" style=\\"text-align:center;min-height:200px;font-size:14px;color:#333\\"', $c);
echo json_encode(["patch"=>"style expanded", "size"=>strlen($c)]);
} else {
echo json_encode(["error"=>"pattern not found for style fix"]);
exit;
}
} else {
$c = str_replace($old_esc, $new_esc, $c);
}
$backup = "/opt/wevads/vault/wevia.html.GOLD-" . date("Ymd-His") . "-mermaid-css";
@copy($path, $backup);
$wrote = @file_put_contents($path, $c);
echo json_encode(["wrote"=>$wrote, "backup"=>basename($backup)]);