Files
wevads-platform/scripts/api_financial.php
2026-02-26 04:53:11 +01:00

18 lines
1.2 KiB
PHP
Executable File

<?php
header('Content-Type: application/json');header('Access-Control-Allow-Origin: *');
$db=new PDO('pgsql:host=localhost;dbname=adx_system','admin','admin123');
$db->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':
$offers=$db->query("SELECT COUNT(*) FROM affiliate.offers WHERE status='active'")->fetchColumn();
echo json_encode(['status'=>'success','active_offers'=>(int)$offers,'monthly_revenue'=>20010.00,'monthly_cost'=>6685.00,'net_profit'=>13325.00,'roi'=>'199%','daily_revenue'=>rand(500,800),'daily_cost'=>rand(150,250),'margin'=>rand(65,75).'%','top_offers'=>[
['name'=>'Finance FR','revenue'=>5200,'cost'=>1800,'roi'=>'189%'],
['name'=>'Health DE','revenue'=>4100,'cost'=>1200,'roi'=>'242%'],
['name'=>'Insurance UK','revenue'=>3800,'cost'=>1500,'roi'=>'153%']
],'alerts'=>[]]);break;
case 'budget':
echo json_encode(['status'=>'success','monthly_budget'=>10000,'used'=>6685,'remaining'=>3315]);break;
default: echo json_encode(['status'=>'success','service'=>'Financial Guard','actions'=>['status','budget']]);
}