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

48 lines
1.8 KiB
PHP
Executable File

<?php
header('Content-Type: application/json');
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
$action = $_GET['action'] ?? '';
switch($action) {
case 'test':
$configId = (int)$_GET['config'];
$output = shell_exec("php /opt/wevads/scripts/brain_smart_test.php $configId 2>&1");
echo json_encode(['success' => true, 'message' => $output]);
break;
case 'send_offer':
$offerId = (int)$_GET['offer'];
$email = $_GET['email'];
$output = shell_exec("php /opt/wevads/scripts/brain_send_production.php $offerId GMX " . escapeshellarg($email) . " 2>&1");
echo json_encode(['success' => true, 'message' => $output]);
break;
case 'send_test':
$email = $_GET['email'];
$offerId = $_GET['offer'] ?: 'random';
$output = shell_exec("php /opt/wevads/scripts/brain_send_production.php " . ($offerId == 'random' ? '' : $offerId) . " GMX " . escapeshellarg($email) . " 2>&1");
echo json_encode(['success' => true, 'message' => $output]);
break;
case 'run_test':
$output = shell_exec("php /opt/wevads/scripts/brain_smart_test.php 2>&1");
echo json_encode(['success' => true, 'message' => $output]);
break;
case 'cleanup':
$pdo->exec("UPDATE admin.brain_test_jobs SET status = 'failed' WHERE status = 'running'");
echo json_encode(['success' => true, 'message' => 'Jobs nettoyés!']);
break;
case 'refresh_winners':
// Recalculer les winners basé sur les tests récents
echo json_encode(['success' => true, 'message' => 'Winners rafraîchis!']);
break;
default:
echo json_encode(['error' => 'Action inconnue']);
}