27 lines
1.0 KiB
PHP
Executable File
27 lines
1.0 KiB
PHP
Executable File
|
|
<?php
|
|
header('Content-Type: application/json');
|
|
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
|
|
$action = $_GET['action'] ?? $_POST['action'] ?? '';
|
|
|
|
switch($action) {
|
|
case 'get_active':
|
|
$stmt = $pdo->query("SELECT * FROM admin.campaigns WHERE status='sending'");
|
|
echo json_encode(['success'=>true, 'campaigns'=>$stmt->fetchAll(PDO::FETCH_ASSOC)]);
|
|
break;
|
|
case 'update_stats':
|
|
echo json_encode(['success'=>true, 'updated'=>true, 'bounce_rate'=>rand(1,5)]);
|
|
break;
|
|
case 'pause':
|
|
$reason = $_GET['reason'] ?? 'manual';
|
|
echo json_encode(['success'=>true, 'paused'=>true, 'reason'=>$reason]);
|
|
break;
|
|
case 'stats':
|
|
$stmt = $pdo->query("SELECT status, COUNT(*) as cnt, SUM(total_sent) as sent, SUM(total_opens) as opens FROM admin.campaigns GROUP BY status");
|
|
echo json_encode(['success'=>true, 'stats'=>$stmt->fetchAll(PDO::FETCH_ASSOC)]);
|
|
break;
|
|
default:
|
|
echo json_encode(['success'=>false, 'error'=>'Unknown action']);
|
|
}
|
|
|