<?php
final class FoodROGate {
 public static function sql($sql):void {
  if(!preg_match('/^SELECT\b/i',$sql)||preg_match('/;|--|\/\*|\b(INSERT|UPDATE|DELETE|CREATE|DROP|ALTER|TRUNCATE|MERGE|CALL|EXEC|OUTFILE|DBLINK|SLEEP|BENCHMARK)\b/i',$sql))throw new RuntimeException('Observer SELECT-only');$m=[];preg_match_all('/\b(?:FROM|JOIN)\s+([`"]?[a-zA-Z_][a-zA-Z_0-9.$]*[`"]?)/i',$sql,$m);$allow=['ydy_config','ydy_foods_composition','ydy_foods_cate','ydy_dish','ydy_user','ydy_nutrition','ydy_nutrition_template','ydy_nutrition_template_ext','ydy_nutrition_set','ydy_nutrition_category','ydy_nutrition_time','ydy_menu','ydy_role','ydy_role_data','ydy_user_data','ydy_department','ydy_staff','ydy_staff_department','ydy_project','ydy_restaurants','ydy_restaurant_area','ydy_restaurant_shop','ydy_dishes_import_task','ydy_annex','ydy_employment_state','ydy_enginery_iochemistry','dual','information_schema.columns','information_schema.triggers','information_schema.key_column_usage','information_schema.statistics','information_schema.referential_constraints','user_tab_columns','user_triggers','user_indexes','user_ind_columns','user_constraints','user_cons_columns','user_objects','user_dependencies','v$version'];foreach($m[1]as $t)if(!in_array(strtolower(str_replace(['`','"'],'',$t)),$allow,true))throw new RuntimeException('Observer table scope');
 }
}
