date('c'), 'steps' => []]; $F = '/var/www/html/faq-knowledge-base.html'; // Content actuel $content = @file_get_contents($F); $before = substr_count($content, '11435'); $R['steps'][] = ['read' => strlen($content) . 'B', 'count_11435' => $before]; // GOLD $GOLD = "/opt/wevads/vault/faq-knowledge-base.GOLD-pre-11434-" . date('Ymd-Hi'); @copy($F, $GOLD); $R['steps'][] = ['gold' => $GOLD]; // Fix via rename: écrire le nouveau à côté + renommer $new_content = str_replace('11435', '11434', $content); $temp_F = '/var/www/html/faq-knowledge-base.html.tmp-opus5'; $w = @file_put_contents($temp_F, $new_content); $R['steps'][] = ['temp_write' => $w]; // rename nécessite write sur parent dir (777 confirmé) $renamed = @rename($temp_F, $F); $R['steps'][] = ['rename_old_to_new' => $renamed]; clearstatcache(); $after = substr_count(@file_get_contents($F), '11435'); $R['steps'][] = ['count_11435_after' => $after]; $R['ok'] = ($after === 0); echo json_encode($R, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);