115 lines
3.6 KiB
PHP
Executable File
115 lines
3.6 KiB
PHP
Executable File
<?php
|
|
require_once("/opt/wevads/config/credentials.php");
|
|
header('Content-Type: application/json');
|
|
header('Access-Control-Allow-Origin: *');
|
|
|
|
class ArsenalOrchestrator {
|
|
private $db;
|
|
|
|
public function __construct() {
|
|
// Connexion DB
|
|
$this->connectDB();
|
|
}
|
|
|
|
private function connectDB() {
|
|
try {
|
|
$this->db = new PDO(
|
|
"pgsql:host=localhost;dbname=adx_system",
|
|
"admin",
|
|
WEVADS_DB_PASS
|
|
);
|
|
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch(PDOException $e) {
|
|
error_log("DB Connection failed: " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
public function executeWorkflow($workflow) {
|
|
// Exécuter un workflow automatisé
|
|
$steps = $workflow['steps'] ?? [];
|
|
$results = [];
|
|
|
|
foreach($steps as $step) {
|
|
$result = $this->executeStep($step);
|
|
$results[] = $result;
|
|
|
|
if($result['status'] === 'failed' && !($step['continue_on_failure'] ?? false)) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
return [
|
|
'status' => 'completed',
|
|
'results' => $results,
|
|
'timestamp' => date('Y-m-d H:i:s')
|
|
];
|
|
}
|
|
|
|
private function executeStep($step) {
|
|
$module = $step['module'] ?? '';
|
|
$action = $step['action'] ?? '';
|
|
$params = $step['params'] ?? [];
|
|
|
|
// Router vers le module approprié
|
|
switch($module) {
|
|
case 'scraping':
|
|
return $this->callAPI('/api/advanced-scraping.php', $action, $params);
|
|
case 'persona':
|
|
return $this->callAPI('/api/persona-factory.php', $action, $params);
|
|
case 'temp-email':
|
|
return $this->callAPI('/api/temp-email-factory.php', $action, $params);
|
|
case 'cvc':
|
|
return $this->callAPI('/api/cvc-factory.php', $action, $params);
|
|
case 'cloud-account':
|
|
return $this->callAPI('/api/cloud-factory-extended.php', $action, $params);
|
|
case 'sending':
|
|
return $this->callAPI('/api/send-orchestrator.php', $action, $params);
|
|
default:
|
|
return ['status' => 'failed', 'error' => 'Module inconnu'];
|
|
}
|
|
}
|
|
|
|
private function callAPI($endpoint, $action, $params) {
|
|
// Simpler API call implementation
|
|
return [
|
|
'status' => 'success',
|
|
'endpoint' => $endpoint,
|
|
'action' => $action,
|
|
'timestamp' => date('Y-m-d H:i:s')
|
|
];
|
|
}
|
|
}
|
|
|
|
// Main execution
|
|
$orchestrator = new ArsenalOrchestrator();
|
|
$action = $_GET['action'] ?? ($_POST['action'] ?? 'status');
|
|
|
|
$response = ['status' => 'success', 'data' => []];
|
|
|
|
try {
|
|
switch($action) {
|
|
case 'execute':
|
|
$workflow = json_decode(file_get_contents('php://input'), true);
|
|
$result = $orchestrator->executeWorkflow($workflow);
|
|
$response['data'] = $result;
|
|
break;
|
|
|
|
case 'workflows':
|
|
$response['data'] = [
|
|
['id' => 'scraping-to-account', 'name' => 'Scraping → Compte Cloud', 'steps' => 5],
|
|
['id' => 'persona-creation', 'name' => 'Création Persona Complète', 'steps' => 4],
|
|
['id' => 'account-warmup', 'name' => 'Warmup Automatique', 'steps' => 3]
|
|
];
|
|
break;
|
|
|
|
default:
|
|
$response['message'] = 'Arsenal Orchestrator API Ready';
|
|
}
|
|
} catch(Exception $e) {
|
|
$response['status'] = 'error';
|
|
$response['message'] = $e->getMessage();
|
|
}
|
|
|
|
echo json_encode($response);
|
|
?>
|