<?php
declare(strict_types=1);
$root='/tmp/zhct-dm-poc-20260928.fcpiiN/store';
if(strpos((string)file_get_contents('/proc/112175/cmdline'),$root.'/public')===false)throw new RuntimeException('Known parent identity drift');
$allowed=['PATH','LANG','LC_ALL','LC_CTYPE','TZ','NLS_LANG','DM_CHARSET','DM_SVC_PATH','DM_HOME','LD_LIBRARY_PATH','POC_HOST','POC_PORT','POC_SCHEMA','POC_USER','POC_PASSWORD','POC_DIALECT','POC_PREFIX','POC_CHARSET'];
foreach(['HOST','PORT','SCHEMA','USER','PASSWORD','PREFIX','CHARSET'] as $key)$allowed[]='POC_AI_'.$key;
$environment=[];
foreach(explode("\0",(string)file_get_contents('/proc/112175/environ')) as $pair){$parts=explode('=',$pair,2);if(count($parts)===2&&in_array($parts[0],$allowed,true))$environment[$parts[0]]=$parts[1];}
$args=['/www/server/php/73/bin/php','-c','/www/server/php/73/etc/php-cli.ini','-d','extension=/home/dmdba/dmdbms/drivers/php_pdo/libphp73_dm.so','-d','extension=/home/dmdba/dmdbms/drivers/php_pdo/php73_pdo_dm.so',__DIR__.'/preflight-db.php','C'];
if (in_array($argv[1]??'',['relations','actors','lease'],true))$args[]=$argv[1];
$process=proc_open(implode(' ',array_map('escapeshellarg',$args)),[1=>STDOUT,2=>STDERR],$pipes,null,$environment);
exit(proc_close($process));
