<?php
$lane=getenv('MR3_LANE');$root=getenv('MR3_ROOT');$path=parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH);$prefix='/p/dishCustomCategory/';$action=substr((string)$path,strlen($prefix));
if(!($path==='/__poc_boundary'||(strpos((string)$path,$prefix)===0&&in_array($action,['list','options','add','update','changeStatus','delete'],true)&&$_SERVER['REQUEST_METHOD']==='POST'))){http_response_code(403);exit;}
$_SERVER['PATH_INFO']=$path;require $root.'/env.php';if(!function_exists('json')){function json($data=[],$code=200,array $header=[],$options=[]){return \think\Response::create($data,'json',$code,$header,$options);}}
require $root.'/external_stubs.php';define('APP_PATH',__DIR__.'/source/application/');define('RUNTIME_PATH',__DIR__.'/runtime/');require $root.'/thinkphp/base.php';\think\App::initCommon();\think\Log::init(['type'=>'File','path'=>__DIR__.'/runtime/safe-log/','level'=>['no_raw_application_log']]);\think\Config::set(['type'=>'File','path'=>__DIR__.'/cache/','prefix'=>'CAT10_'],'cache');\think\Config::set('redis',[]);$database=require $root.'/application/database.php';\think\Config::set($database,'database');\think\Db::clear();
if($path==='/__poc_boundary'){header('Content-Type: application/json');echo json_encode(['allowlist'=>'owned-category-only','external_stubs'=>class_exists(\app\common\Serve::class,false),'original_debug'=>$database['debug']??null]);exit;}
if(in_array($action,['add','update'],true)){$name=(string)\think\Request::instance()->post('name','');if($name!==''&&strpos(trim($name),'CDXCAT10')!==0&&mb_strlen(trim($name),'UTF-8')<=20){http_response_code(403);exit;}}
if(in_array($action,['update','changeStatus','delete'],true)){$id=(int)\think\Request::instance()->post('id',0);$own=is_file(__DIR__.'/private-own.json')?json_decode(file_get_contents(__DIR__.'/private-own.json'),true):[];if($id!==2147000811&&($id<=0||$id!==($own['id']??0))){http_response_code(403);exit;}}
\think\App::run()->send();
