22 lines
1.3 KiB
PHP
22 lines
1.3 KiB
PHP
<?php
|
|
header("Content-Type: application/json");
|
|
$path = "/var/www/html/api/ambre-tool-pdf-premium.php";
|
|
$content = file_get_contents($path);
|
|
|
|
$old = 'if (file_exists("/usr/bin/chromium-browser") || file_exists("/usr/bin/chromium") || file_exists("/usr/bin/google-chrome")) {
|
|
$bin = file_exists("/usr/bin/chromium-browser") ? "/usr/bin/chromium-browser" : (file_exists("/usr/bin/chromium") ? "/usr/bin/chromium" : "/usr/bin/google-chrome");';
|
|
|
|
// Prefer google-chrome (real chrome), skip chromium-browser stub
|
|
$new = 'if (file_exists("/usr/bin/google-chrome") || file_exists("/usr/bin/chromium") || file_exists("/usr/bin/chromium-browser")) {
|
|
// Prefer real chrome over stub chromium-browser snap
|
|
$bin = file_exists("/usr/bin/google-chrome") ? "/usr/bin/google-chrome" : (file_exists("/usr/bin/chromium") ? "/usr/bin/chromium" : "/usr/bin/chromium-browser");';
|
|
|
|
if (strpos($content, $old) === false) {
|
|
echo json_encode(["error"=>"pattern not found"]); exit;
|
|
}
|
|
$new_content = str_replace($old, $new, $content);
|
|
$backup = "/opt/wevads/vault/pdf-premium.GOLD-" . date("Ymd-His");
|
|
@copy($path, $backup);
|
|
$wrote = @file_put_contents($path, $new_content);
|
|
echo json_encode(["delta" => strlen($new_content)-strlen($content), "wrote"=>$wrote, "backup"=>basename($backup)]);
|