Files
Investidor-V2/outputs/investmoz-editorial-QA-20261018/image-QA.php
T
nala cf003c8623
tests / ci (push) Canceled after 0s
versao nrgocios 4
2026-10-18 15:57:06 +02:00

9 lines
873 B
PHP

<?php
require __DIR__.'/boot-QA.php';
$r=Illuminate\Support\Facades\DB::table('portal_resources as r')->join('documents as d','d.id','=','r.document_id')->where('d.media_type','image/png')->where('r.published',true)->first(['d.storage_key','d.sha256','r.id']);
if(!$r)throw new RuntimeException('Existing QA image required');
$root=dirname(__DIR__,2).'/storage/app/private/';$from=realpath($root.$r->storage_key);$base=realpath($root);
if(!$from||!str_starts_with(strtolower($from),strtolower($base.DIRECTORY_SEPARATOR))||hash_file('sha256',$from)!==trim($r->sha256))throw new RuntimeException('Read-only image source integrity');
$to=Illuminate\Support\Facades\Storage::disk('local')->path($r->storage_key);if(!is_dir(dirname($to)))mkdir(dirname($to),0700,true);copy($from,$to);
echo json_encode(['id'=>$r->id,'sha256'=>trim($r->sha256),'active_source_read_only'=>true]);