$v){putenv($k.'='.$v);$_ENV[$k]=$_SERVER[$k]=$v;} require $s['HOST_ROOT'].'/vendor/autoload.php';$app=require $s['HOST_ROOT'].'/bootstrap/app.php';$app->make(\Illuminate\Contracts\Console\Kernel::class)->bootstrap(); $db=\Illuminate\Support\Facades\DB::connection();if(!preg_match('/^(compras_receipts_test_|payable_sgf_)[a-f0-9]{12}$/D',$db->getDatabaseName())||$db->selectOne('select current_database() as d')->d!==$s['DB_DATABASE'])throw new LogicException('Wrong QA database'); $role=$db->selectOne('select rolsuper,rolcreatedb,rolcreaterole from pg_roles where rolname=current_user');if($role->rolsuper||$role->rolcreatedb||$role->rolcreaterole)throw new LogicException('Restricted role required'); $counts=[];foreach(['sources','proposals','obligations','events','outbox'] as $t)$counts[$t]=$db->table('pa_'.$t)->count(); $report=['host'=>$mode,'isolated'=>true,'restricted_role'=>true,'counts'=>$counts,'core_sha256'=>hash_file('sha256',__DIR__.'/../packages/payables/src/Payables.php'),'checked_at'=>gmdate('c')]; file_put_contents(__DIR__.'/../docs/proofs/payables-demo-'.$mode.'.json',json_encode($report,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR).PHP_EOL);echo json_encode($report,JSON_PRETTY_PRINT|JSON_THROW_ON_ERROR).PHP_EOL;