<?php
// No common/init/driver/bootstrap: pure gate counterexamples only.
require __DIR__.'/Gate.php';FoodGate::$dry=true;FoodGate::$case=['readonly'=>true];$checks=[];
foreach(['INSERT INTO ydy_user (id) VALUES(1)','UPDATE ydy_staff SET name=1','DELETE FROM ydy_staff','CREATE TABLE x(id INT)','DROP TABLE ydy_user','DO 1','CALL SP_TABLEDEF(?, ?);','SELECT * FROM wrong_table','SELECT * FROM ydy_user;DELETE FROM ydy_user']as $sql){try{FoodGate::readonlySql($sql,'store');throw new LogicException('Rejected mutation accepted');}catch(RuntimeException $e){$checks[]=['sql'=>$sql,'rejected'=>true];}}
foreach(['SELECT uuid,name FROM ydy_staff WHERE is_show=?','SHOW FULL COLUMNS FROM ydy_user','CALL SP_TABLEDEF(?, ?)']as $sql){FoodGate::readonlySql($sql,'store');$checks[]=['sql'=>$sql,'accepted'=>true];}
foreach([['OTHER','YDY_USER'],['ZHCT_APP','OTHER']]as $v){$bind=[1=>['value'=>$v[0]],2=>['value'=>$v[1]]];try{FoodGate::execute('CALL SP_TABLEDEF(?, ?)',$bind,null,'store');throw new LogicException('Metadata escape accepted');}catch(RuntimeException $e){$checks[]=['metadata_binds'=>$v,'rejected'=>true];}}
$r=['checks'=>$checks,'count'=>count($checks),'DB'=>0,'HTTP'=>0,'gate_sha256'=>hash_file('sha256',__DIR__.'/Gate.php')];$f=__DIR__.'/private/read8-pureguard.json';$h=fopen($f,'xb');if(!$h)throw new RuntimeException('No overwrite');fwrite($h,json_encode($r,JSON_PRETTY_PRINT));fclose($h);chmod($f,0600);echo json_encode(['pure_checks'=>count($checks),'DB'=>0,'HTTP'=>0]),PHP_EOL;
