<?php
$r=json_decode(file_get_contents(__DIR__.'/private/request.json'),true);$path=parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);$case=null;foreach($r['cases']as $c)if($c['path']===$path&&$c['label']===($_SERVER['HTTP_X_CDX_CASE']??''))$case=$c;
if(!$case||$_SERVER['REQUEST_METHOD']!=='POST'||($_SERVER['HTTP_TOKEN']??'')!==$r['token']||($_SERVER['HTTP_ACCEPT']??'')!=='application/json, text/plain, */*'||($_SERVER['HTTP_CACHE_CONTROL']??'')!=='max-age=28880'){http_response_code(403);exit;}$a=$_POST;$b=$case['params'];ksort($a);ksort($b);if($a!==$b){http_response_code(403);exit;}$file='wire-'.$case['label'].'.json';if(is_file(__DIR__.'/private/'.$file)){http_response_code(409);exit;}
foreach(json_decode(file_get_contents(__DIR__.'/source-lock.json'),true)as $f=>$sha)if(hash_file('sha256',__DIR__.'/source/application/'.$f)!==$sha){http_response_code(409);exit;}
require __DIR__.'/common.php';$before=$source();$base=json_decode(file_get_contents(__DIR__.'/private/before.json'),true);$a=$before;$b=$base;unset($a['active_count'],$b['active_count']);if($a!==$b)throw new RuntimeException('Own row lease before lists');require __DIR__.'/NativeGate.php';$started=microtime(true);$GLOBALS['NR_ORACLE']=[];ob_start();
register_shutdown_function(static function()use($source,$before,$case,$save,$file,$started){$body=(string)ob_get_contents();$after=$source();$a=$before;$b=$after;unset($a['active_count'],$b['active_count']);$reflection=[];foreach(['app\\p\\controller\\NutritionScheme','app\\p\\logic\\NutritionScheme','app\\p\\controller\\NutritionTemplate','app\\p\\logic\\NutritionTemplate','app\\model\\NutritionTemplateExt','app\\common\\service\\NutritionFloat82Write','app\\common\\service\\NutritionPlainFloatWeight','app\\p\\controller\\Nutrition','app\\m\\controller\\Nutrition','app\\p\\logic\\Nutrition','app\\m\\logic\\Nutrition','app\\model\\Nutrition','app\\model\\BaseModel','app\\cores\\database\\Dm','think\\db\\connector\\Mysql','think\\db\\builder\\Mysql']as $class)if(class_exists($class,false)){$f=(new ReflectionClass($class))->getFileName();$reflection[$class]=['file'=>$f,'sha256'=>hash_file('sha256',$f)];}$save($file,['label'=>$case['label'],'path'=>$case['path'],'params'=>$case['params'],'headers'=>['Accept'=>$_SERVER['HTTP_ACCEPT'],'Cache-Control'=>$_SERVER['HTTP_CACHE_CONTROL']],'status'=>http_response_code(),'body'=>$body,'body_sha256'=>hash('sha256',$body),'source_before'=>$before,'source_after'=>$after,'own_source_unchanged'=>$a===$b,'native'=>NRGate::$journal,'oracle'=>$GLOBALS['NR_ORACLE'],'reflection'=>$reflection,'included_files'=>get_included_files(),'started_epoch'=>$started,'completed_epoch'=>microtime(true),'last_error'=>error_get_last()]);});
$_SERVER['PATH_INFO']=$path;require __DIR__.'/app-init.php';\think\App::run()->send();
