12 lines
2.1 KiB
PHP
12 lines
2.1 KiB
PHP
<?php
|
|
$app=(static fn($p)=>require $p)(__DIR__.'/portal-workflow-upgrade-runtime.php');
|
|
$id=isset($argv[1])?(int)$argv[1]:null;$rows=[];
|
|
foreach(['documents','images']as$kind){$q=Illuminate\Support\Facades\DB::table('opportunity_'.$kind.' as r')->join('documents as d','d.id','=','r.document_id');if($id)$q->where('r.opportunity_id',$id);
|
|
foreach($q->get(['r.id AS resource_id','r.opportunity_id','r.version','r.payload','d.id AS document_id','d.sha256','d.malware_scan_status','d.malware_signatures_at','d.storage_key','d.storage_encryption'])as$r){$p=json_decode($r->payload,true,512,JSON_THROW_ON_ERROR);unset($r->payload);$r->kind=$kind;$r->derivatives=[];
|
|
$bytes=Illuminate\Support\Facades\Storage::disk('local')->get($r->storage_key);$r->original_cipher_sha256=hash('sha256',$bytes);$plain=Illuminate\Support\Facades\Crypt::decryptString($bytes);$r->plaintext_hash_matches=hash_equals(trim($r->sha256),hash('sha256',$plain));unset($plain,$r->storage_key);
|
|
foreach($p['derivatives']??[]as$d){$v=Illuminate\Support\Facades\DB::table('documents')->where('id',$d['document_id'])->first(['id','sha256','malware_scan_status','malware_signatures_at','malware_scan_attempts']);$r->derivatives[]=[...$d,...(array)$v];}$rows[]=$r;}}
|
|
$health=app(App\Services\Malware\MalwareScanner::class)->health();if(($health['signatures_at']??null)instanceof DateTimeInterface)$health['signatures_at']=$health['signatures_at']->format('c');
|
|
echo json_encode(['target'=>config('database.connections.pgsql.database').':55441','rows'=>$rows,'scanner'=>$health,'scanner_port'=>config('services.malware.port'),'GD_WebP'=>app(App\Services\OpportunityImageProcessor::class)->available(),
|
|
'queue_pending'=>Illuminate\Support\Facades\DB::table('jobs')->where('queue','workflow-upgrade-qa')->count(),'queue_reserved'=>Illuminate\Support\Facades\DB::table('jobs')->where('queue','workflow-upgrade-qa')->whereNotNull('reserved_at')->count(),
|
|
'country_enabled'=>config('portal.organization_country_enabled'),'190000_installed'=>Illuminate\Support\Facades\DB::table('migrations')->where('migration','2026_10_09_190000_prepare_investor_path')->exists(),'active_writes'=>0],JSON_THROW_ON_ERROR).PHP_EOL;
|