28 lines
1.3 KiB
PHP
28 lines
1.3 KiB
PHP
<?php
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Storage;
|
|
|
|
require dirname(__DIR__).'/vendor/autoload.php';
|
|
$app = require dirname(__DIR__).'/bootstrap/app.php';
|
|
$app->make(Kernel::class)->bootstrap();
|
|
if (config('app.demonstration') !== true || DB::connection()->getDatabaseName() !== 'compras_demo_20261129') {
|
|
throw new LogicException('Only the authorised sample installation may prepare this transition.');
|
|
}
|
|
DB::statement('SET default_transaction_read_only=on');
|
|
$pins = [];
|
|
foreach (DB::table('private_audit_exports')->where('tenant_id', 2)->where('work_context', 'legacy')->orderBy('id')->get() as $export) {
|
|
$path = Storage::disk('local')->path($export->path);
|
|
$boundary = realpath(storage_path('app/private')).'/audit-exports/2/'.$export->created_by.'/';
|
|
if (! is_file($path) || is_link($path) || ! str_starts_with(realpath($path), $boundary)
|
|
|| ! hash_equals($export->sha256, hash_file('sha256', $path))) {
|
|
throw new LogicException('Preserve and investigate the original archive before configuring a receipt.');
|
|
}
|
|
$pins[(string) $export->id] = $export->sha256;
|
|
}
|
|
if (count($pins) !== 3) {
|
|
throw new LogicException('Unexpected archive set; do not infer a wider transition.');
|
|
}
|
|
echo json_encode(['2' => $pins], JSON_THROW_ON_ERROR).PHP_EOL;
|