[], 'ok'=>false]; $SRC = '/var/www/weval/wevia-ia/weval-chatbot-api.php'; $TS = date('Ymd-Hi'); $content = file_get_contents($SRC); if (strpos($content, 'OPUS4-TRACE-V1') !== false) { $R['already'] = true; die(json_encode($R)); } // Ajoute trace tout au début - juste après &1", $lo, $lr); if ($lr !== 0) { unlink($TMP); $R['err']='LINT'; $R['lint']=$lo; die(json_encode($R)); } // GOLD + write copy($SRC, "/opt/wevads/vault/weval-chatbot-TRACE-{$TS}.gold.php"); exec('chattr -i '.escapeshellarg($SRC).' 2>&1'); $w = file_put_contents($SRC, $newContent); exec('chattr +i '.escapeshellarg($SRC).' 2>&1'); exec("php8.4 -l $SRC 2>&1", $flo, $flr); @opcache_invalidate($SRC, true); @opcache_reset(); unlink($TMP); $R['ok'] = ($flr === 0); $R['written'] = $w; $R['final_lint'] = $flr; echo json_encode($R, JSON_PRETTY_PRINT);