hash_file('sha256', $file), $protected); foreach ($plan['files'] as $file => $hash) { if (! str_starts_with($file, 'assets/') || str_contains($file, '..') || ! hash_equals($hash, hash_file('sha256', $candidate.'/'.$file)) || (is_file($root.'/public/build/'.$file) && ! hash_equals($hash, hash_file('sha256', $root.'/public/build/'.$file)))) { throw new LogicException('Interface candidate missing or existing immutable asset differs.'); } } $backup = 'C:/laragon/data/compras/backups/analytics-print-'.gmdate('Ymd-His').'-'.bin2hex(random_bytes(6)); if (! mkdir($backup, 0700, true) || ! copy($manifestPath, $backup.'/manifest.before.json') || ! hash_equals($plan['previous_manifest_sha256'], hash_file('sha256', $backup.'/manifest.before.json'))) { throw new LogicException('Interface manifest recovery copy failed.'); } foreach ($plan['files'] as $file => $hash) { $target = $root.'/public/build/'.$file; if (! is_file($target) && ! copy($candidate.'/'.$file, $target)) { throw new LogicException('Interface asset copy failed before manifest selection.'); } if (! hash_equals($hash, hash_file('sha256', $target))) { throw new LogicException('Published asset bytes differ.'); } } $temporary = $manifestPath.'.analytics-'.bin2hex(random_bytes(6)).'.tmp'; if (! copy($candidate.'/manifest.json', $temporary) || ! hash_equals($plan['manifest_sha256'], hash_file('sha256', $temporary)) || ! hash_equals($plan['previous_manifest_sha256'], hash_file('sha256', $manifestPath)) || ! rename($temporary, $manifestPath)) { throw new LogicException('Atomic interface manifest selection failed.'); } if ($hashes !== array_map(static fn ($file) => hash_file('sha256', $file), $protected)) { throw new LogicException('Protected configuration changed; inspect without overwriting concurrent edits.'); } $result = ['date' => gmdate('c'), 'state' => 'passed', 'authorization' => 'analytics-print-publication-authorization.json', 'manifest_sha256' => $plan['manifest_sha256'], 'previous_manifest_sha256' => $plan['previous_manifest_sha256'], 'backup_directory' => $backup, 'assets_verified' => count($plan['files']), 'old_assets_preserved' => true, 'database_commands_or_settings_changes' => false, 'public_runtime_activation' => false, 'application_complete' => false]; file_put_contents($resultPath, json_encode($result, JSON_PRETTY_PRINT | JSON_THROW_ON_ERROR).PHP_EOL); echo json_encode($result, JSON_THROW_ON_ERROR).PHP_EOL;