<?php
declare(strict_types=1);$_SERVER['HTTP_HOST']='owned-scale.invalid';$_SERVER['HTTP_PLATFORM']='POC';$_SERVER['REQUEST_METHOD']='GET';$_SERVER['REQUEST_URI']='/api/WellandScale/byDate';$_SERVER['SCRIPT_NAME']='/index.php';require __DIR__.'/app.php';require __DIR__.'/data.php';ck(file_exists($runtime.'/preflight-ready.json')&&!file_exists($runtime.'/guard-attempt.json'),'Whole constructor prewarm and one token only');saveOnce('guard-attempt.json',['actor'=>actor(),'at'=>date('c')]);$app=coreApp('GUARD');require_once $root.'/app/api/common.php';$files=readNative('AI','SELECT logo_image_id FROM yoshop_store WHERE store_id=?',[10001]);ck(count($files)===1,'Exact tenant file lease');saveOnce('tenant-file-lease.json',['allowed_file_ids'=>array_values(array_unique(['0',(string)$files[0]['logo_image_id']]))]);$token='CDXOWNSCALE11_'.$lane.'_'.bin2hex(random_bytes(24));saveOnce('tokens.json',['U1'=>$token]);ck(\think\facade\Cache::set($token,['user'=>['user_id'=>actor()['user_id']],'password_version'=>0,'login_type'=>'thirdparty'],1800),'Only one original owned Auth token');$u=\app\api\model\User::getUserByToken($token);ck($u&&(int)$u['user_id']===actor()['user_id']&&(int)$u['store_id']===10001,'Actual source Auth');$c=new \app\api\controller\WellandScale($app);saveOnce('guard.json',['actor'=>actor(),'original_API_auth'=>true,'original_store_controller'=>true,'HTTP'=>0,'DML'=>0]);echo json_encode(['lane'=>$lane,'Auth'=>1,'HTTP'=>0,'DML'=>0]),"\n";
