setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION); $db->exec("SET search_path TO admin,public"); $a=$_GET['action']??'status'; switch($a){ case 'status':case 'stats': $providers=$db->query("SELECT COUNT(*) FROM cloud_providers")->fetchColumn(); $accounts=$db->query("SELECT COUNT(*) FROM cloud_accounts")->fetchColumn(); echo json_encode(['status'=>'success','providers'=>(int)$providers,'accounts'=>(int)$accounts,'monthly_total'=>88.60,'daily_avg'=>2.95,'budget_limit'=>150.00,'budget_used'=>59,'costs'=>[ ['provider'=>'Hetzner','type'=>'Dedicated','monthly'=>29.90,'trend'=>'stable'], ['provider'=>'OVH','type'=>'VPS','monthly'=>8.50,'trend'=>'stable'], ['provider'=>'Huawei Cloud','type'=>'ECS x3','monthly'=>45.00,'trend'=>'down'], ['provider'=>'AWS S3','type'=>'Storage','monthly'=>5.20,'trend'=>'up'], ['provider'=>'Cloudflare','type'=>'CDN/DNS','monthly'=>0,'trend'=>'stable'] ],'alerts'=>[]]);break; case 'forecast': echo json_encode(['status'=>'success','next_month'=>92.40,'savings_possible'=>12.50]);break; default: echo json_encode(['status'=>'success','service'=>'Cost Monitor','actions'=>['status','forecast']]); }