74 lines
2.3 KiB
PHP
74 lines
2.3 KiB
PHP
<?php
|
|
header('Content-Type: application/json');
|
|
$R = ['ts'=>date('c'), 'files'=>[], 'total'=>0, 'ok'=>true];
|
|
$TS = date('Ymd-Hi');
|
|
|
|
$files = [
|
|
'/opt/wevia-brain/monitor-gguf.php',
|
|
'/opt/wevia-brain/wevia-agent-loop.php',
|
|
'/opt/wevia-brain/wevia-bridge-intents.php',
|
|
'/opt/wevia-brain/wevia-director-agent.php',
|
|
'/opt/wevia-brain/wevia-dispatcher.php',
|
|
'/opt/wevia-brain/wevia-master-router.php',
|
|
'/opt/wevia-brain/wevia-rag-engine.php',
|
|
'/opt/wevia-brain/wv-llm-helper.php',
|
|
];
|
|
|
|
foreach ($files as $f) {
|
|
$info = ['path' => $f, 'exists' => file_exists($f)];
|
|
if (!$info['exists']) { $R['files'][] = $info+['skip'=>'missing']; continue; }
|
|
|
|
$content = file_get_contents($f);
|
|
$count = substr_count($content, '11435');
|
|
|
|
if ($count === 0) { $R['files'][] = $info+['skip'=>'no_11435']; continue; }
|
|
|
|
exec('lsattr '.escapeshellarg($f).' 2>&1', $lsa);
|
|
$immut = isset($lsa[0]) && strpos($lsa[0], '-i-') !== false;
|
|
|
|
// GOLD
|
|
$gold = "/opt/wevads/vault/" . basename($f) . ".GOLD-pre-11434-{$TS}";
|
|
@copy($f, $gold);
|
|
|
|
// Validate: is PHP still valid after replace?
|
|
$new = str_replace('11435', '11434', $content);
|
|
$tmp = "/tmp/check-" . basename($f) . "-{$TS}";
|
|
file_put_contents($tmp, $new);
|
|
exec("php8.4 -l $tmp 2>&1", $lo, $lr);
|
|
unlink($tmp);
|
|
|
|
if ($lr !== 0) {
|
|
$R['files'][] = $info+['skip'=>'LINT_FAIL', 'err'=>$lo];
|
|
$R['ok'] = false;
|
|
continue;
|
|
}
|
|
|
|
if ($immut) {
|
|
exec('chattr -i '.escapeshellarg($f).' 2>&1', $c1, $rc1);
|
|
$info['chattr_removed'] = ($rc1 === 0);
|
|
if (!$info['chattr_removed']) {
|
|
$R['files'][] = $info+['skip'=>'chattr_blocked'];
|
|
continue;
|
|
}
|
|
}
|
|
|
|
$w = @file_put_contents($f, $new);
|
|
|
|
if ($immut) {
|
|
exec('chattr +i '.escapeshellarg($f).' 2>&1');
|
|
}
|
|
|
|
$remaining = substr_count(@file_get_contents($f), '11435');
|
|
$info += [
|
|
'count_before' => $count,
|
|
'count_after' => $remaining,
|
|
'written' => $w,
|
|
'gold' => $gold,
|
|
'immutable' => $immut,
|
|
'ok' => ($remaining === 0)
|
|
];
|
|
$R['files'][] = $info;
|
|
if ($remaining === 0) $R['total'] += $count;
|
|
}
|
|
echo json_encode($R, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|