<?php
declare(strict_types=1);require __DIR__.'/bootstrap.php';require __DIR__.'/dependencies.php';
$file=$root.'/public/uploads/temp/private-upload-probe.png';file_put_contents($file,base64_decode('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII='));$app->instance('filesystem',new \think\Filesystem($app));$driver=new \app\common\library\storage\Driver(['default'=>'local','engine'=>['local'=>null]]);$engine=$driver->setUploadFileByReal($file)->setRootDirName('2147001571')->setValidationScene('image');$check($engine->upload(),'Real original local upload probe');$info=$engine->getSaveFileInfo();$check($info['storage']==='local'&&$info['file_ext']==='png'&&$info['file_size']===68,'Original file metadata probe');
$written=[];$dir=$root.'/public/uploads/aizhct/poc/2147001571';$it=new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir,FilesystemIterator::SKIP_DOTS));foreach($it as $f)if($f->isFile()){$written[]=['relative'=>substr($f->getPathname(),strlen($root.'/public/')),'sha256'=>hash_file('sha256',$f->getPathname())];unlink($f->getPathname());}unlink($file);$check(count($written)===1,'Exact private file upload removed');
$hashes=[];$deps=__DIR__.'/private/deps/';$it=new RecursiveIteratorIterator(new RecursiveDirectoryIterator($deps,FilesystemIterator::SKIP_DOTS));foreach($it as $f)if($f->isFile())$hashes[substr($f->getPathname(),strlen($deps))]=hash_file('sha256',$f->getPathname());ksort($hashes);$out=['lane'=>$lane,'business_dml'=>0,'real_local_upload_probe'=>true,'private_uploaded_file_removed'=>$written,'dependency_hashes'=>$hashes,'loaded'=>[]];foreach(['think\\File','think\\file\\UploadedFile','think\\Filesystem','think\\filesystem\\driver\\Local','League\\Flysystem\\Filesystem','League\\Flysystem\\Local\\LocalFilesystemAdapter'] as $class){$actual=(new ReflectionClass($class))->getFileName();$out['loaded'][$class]=['private_dependency'=>strpos($actual,$deps)===0,'sha256'=>hash_file('sha256',$actual)];$check($out['loaded'][$class]['private_dependency'],'Only private dependency supplementation');}file_put_contents(__DIR__.'/dependency-probe-C.json',json_encode($out,JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));echo json_encode(['lane'=>$lane,'business_dml'=>0,'real_local_upload_probe'=>true,'dependency_files'=>count($hashes),'private_file_removed'=>true]),"\n";
