262 lines
14 KiB
PHP
Executable File
262 lines
14 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* WEVADS Control Hub - Central Integration
|
|
* Connects: WEVADS, DELIVERADS, Brain Engine, HAMID IA, n8n
|
|
*/
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
|
|
// DB Connection
|
|
try {
|
|
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch (Exception $e) {
|
|
$dbError = $e->getMessage();
|
|
}
|
|
|
|
// Safe query functions
|
|
function safeQuery($pdo, $sql, $default = 0) {
|
|
try { return $pdo->query($sql)->fetchColumn() ?: $default; }
|
|
catch (Exception $e) { return $default; }
|
|
}
|
|
function safeQueryAll($pdo, $sql) {
|
|
try { return $pdo->query($sql)->fetchAll(PDO::FETCH_ASSOC); }
|
|
catch (Exception $e) { return []; }
|
|
}
|
|
|
|
// Get stats
|
|
$stats = [
|
|
'servers' => safeQuery($pdo, "SELECT COUNT(*) FROM admin.mta_servers WHERE status='Activated'"),
|
|
'domains' => safeQuery($pdo, "SELECT COUNT(*) FROM admin.domains"),
|
|
'brain_tests' => safeQuery($pdo, "SELECT COUNT(*) FROM admin.brain_test_results"),
|
|
'brain_winners' => safeQuery($pdo, "SELECT COUNT(*) FROM admin.brain_winners"),
|
|
'ai_providers' => safeQuery($pdo, "SELECT COUNT(*) FROM admin.ai_providers WHERE status='active'"),
|
|
'clicks_today' => safeQuery($pdo, "SELECT COUNT(*) FROM actions.clicks WHERE action_date >= CURRENT_DATE"),
|
|
'leads_month' => safeQuery($pdo, "SELECT COUNT(*) FROM actions.leads WHERE action_date >= DATE_TRUNC('month', CURRENT_DATE)"),
|
|
];
|
|
|
|
// Get recent brain results
|
|
$brainResults = safeQueryAll($pdo, "SELECT * FROM admin.brain_test_results ORDER BY id DESC LIMIT 5");
|
|
$brainWinners = safeQueryAll($pdo, "SELECT * FROM admin.brain_winners ORDER BY id DESC LIMIT 5");
|
|
$aiProviders = safeQueryAll($pdo, "SELECT * FROM admin.ai_providers ORDER BY id LIMIT 10");
|
|
|
|
// n8n workflows status
|
|
$n8nWorkflows = [];
|
|
try {
|
|
$db = new SQLite3('/opt/n8n/.n8n/database.sqlite');
|
|
$result = $db->query("SELECT id, name, active FROM workflow_entity ORDER BY name");
|
|
while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
|
|
$n8nWorkflows[] = $row;
|
|
}
|
|
} catch (Exception $e) {}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Control Hub - WEVADS</title>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
|
<style>
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
:root {
|
|
--bg: #0f172a; --card: #1e293b; --border: #334155;
|
|
--text: #f1f5f9; --dim: #94a3b8; --cyan: #22d3ee;
|
|
--green: #22c55e; --purple: #a855f7; --orange: #f97316;
|
|
--red: #ef4444; --blue: #3b82f6; --pink: #ec4899;
|
|
}
|
|
body { font-family: -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
|
|
.header { background: linear-gradient(135deg, #1e293b, #0f172a); padding: 20px 30px; border-bottom: 1px solid var(--border); }
|
|
.header h1 { font-size: 24px; display: flex; align-items: center; gap: 12px; }
|
|
.header h1 i { color: var(--cyan); }
|
|
.nav-links { display: flex; gap: 15px; margin-top: 15px; flex-wrap: wrap; }
|
|
.nav-links a { padding: 8px 16px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; color: var(--dim); text-decoration: none; font-size: 13px; transition: all 0.2s; }
|
|
.nav-links a:hover { border-color: var(--cyan); color: var(--cyan); }
|
|
.nav-links a i { margin-right: 6px; }
|
|
.main { max-width: 1600px; margin: 0 auto; padding: 24px; }
|
|
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin-bottom: 30px; }
|
|
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; position: relative; overflow: hidden; }
|
|
.stat-card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px; }
|
|
.stat-card.cyan::before { background: var(--cyan); }
|
|
.stat-card.green::before { background: var(--green); }
|
|
.stat-card.purple::before { background: var(--purple); }
|
|
.stat-card.orange::before { background: var(--orange); }
|
|
.stat-card.blue::before { background: var(--blue); }
|
|
.stat-card.pink::before { background: var(--pink); }
|
|
.stat-icon { font-size: 32px; margin-bottom: 12px; }
|
|
.stat-value { font-size: 36px; font-weight: 700; }
|
|
.stat-label { font-size: 12px; color: var(--dim); text-transform: uppercase; margin-top: 4px; }
|
|
.section { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 24px; margin-bottom: 24px; }
|
|
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
|
|
.section-title i { color: var(--cyan); }
|
|
.workflow-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
|
|
.workflow-item { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px; display: flex; justify-content: space-between; align-items: center; }
|
|
.workflow-item:hover { border-color: var(--cyan); }
|
|
.workflow-name { font-size: 13px; }
|
|
.workflow-status { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
|
|
.workflow-status.active { background: rgba(34,197,94,0.2); color: var(--green); }
|
|
.workflow-status.inactive { background: rgba(239,68,68,0.2); color: var(--red); }
|
|
.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
|
|
.action-btn { background: linear-gradient(135deg, var(--card), var(--bg)); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; cursor: pointer; transition: all 0.2s; text-decoration: none; color: var(--text); display: block; }
|
|
.action-btn:hover { border-color: var(--cyan); transform: translateY(-2px); }
|
|
.action-btn i { font-size: 28px; margin-bottom: 10px; display: block; }
|
|
.action-btn span { font-size: 13px; }
|
|
.table { width: 100%; border-collapse: collapse; }
|
|
.table th, .table td { padding: 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13px; }
|
|
.table th { color: var(--dim); font-weight: 500; }
|
|
.badge { padding: 4px 8px; border-radius: 6px; font-size: 11px; }
|
|
.badge-success { background: rgba(34,197,94,0.2); color: var(--green); }
|
|
.badge-warning { background: rgba(234,179,8,0.2); color: #eab308; }
|
|
.badge-info { background: rgba(34,211,238,0.2); color: var(--cyan); }
|
|
</style>
|
|
|
|
</head>
|
|
<body>
|
|
<div class="header">
|
|
<h1><i class="fas fa-satellite-dish"></i> WEVADS Control Hub</h1>
|
|
<div class="nav-links">
|
|
<a href="/dashboard"><i class="fas fa-home"></i> Dashboard</a>
|
|
<a href="/deliverads/"><i class="fas fa-paper-plane"></i> DELIVERADS</a>
|
|
<a href="/deliverads/brain-admin.php"><i class="fas fa-brain"></i> Brain Admin</a>
|
|
<a href="/n8n.php"><i class="fas fa-project-diagram"></i> n8n Embedded</a>
|
|
<a href="http://89.167.40.150:5825" target="_blank"><i class="fas fa-external-link-alt"></i> n8n Direct</a>
|
|
<a href="/weval-orchestrator.php"><i class="fas fa-tasks"></i> Orchestrator</a>
|
|
<a href="/hamid-control-center.php"><i class="fas fa-robot"></i> HAMID IA</a>
|
|
<a href="/api/n8n-connector.php?action=status&key=wevads-n8n-2026-secret-key" target="_blank"><i class="fas fa-plug"></i> API Status</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="main">
|
|
<!-- Stats Grid -->
|
|
<div class="grid">
|
|
<div class="stat-card cyan">
|
|
<div class="stat-icon" style="color: var(--cyan);">🖥️</div>
|
|
<div class="stat-value" style="color: var(--cyan);"><?= $stats['servers'] ?></div>
|
|
<div class="stat-label">Serveurs Actifs</div>
|
|
</div>
|
|
<div class="stat-card green">
|
|
<div class="stat-icon" style="color: var(--green);">🌐</div>
|
|
<div class="stat-value" style="color: var(--green);"><?= number_format($stats['domains']) ?></div>
|
|
<div class="stat-label">Domaines</div>
|
|
</div>
|
|
<div class="stat-card purple">
|
|
<div class="stat-icon" style="color: var(--purple);">🧠</div>
|
|
<div class="stat-value" style="color: var(--purple);"><?= $stats['brain_tests'] ?></div>
|
|
<div class="stat-label">Brain Tests</div>
|
|
</div>
|
|
<div class="stat-card orange">
|
|
<div class="stat-icon" style="color: var(--orange);">🏆</div>
|
|
<div class="stat-value" style="color: var(--orange);"><?= $stats['brain_winners'] ?></div>
|
|
<div class="stat-label">Configs Gagnantes</div>
|
|
</div>
|
|
<div class="stat-card blue">
|
|
<div class="stat-icon" style="color: var(--blue);">🤖</div>
|
|
<div class="stat-value" style="color: var(--blue);"><?= $stats['ai_providers'] ?></div>
|
|
<div class="stat-label">AI Providers</div>
|
|
</div>
|
|
<div class="stat-card pink">
|
|
<div class="stat-icon" style="color: var(--pink);">📊</div>
|
|
<div class="stat-value" style="color: var(--pink);"><?= number_format($stats['clicks_today']) ?></div>
|
|
<div class="stat-label">Clicks Today</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Actions -->
|
|
<div class="section">
|
|
<h3 class="section-title"><i class="fas fa-bolt"></i> Actions Rapides</h3>
|
|
<div class="quick-actions">
|
|
<a href="/api/brain-engine.php?action=run_test" class="action-btn" onclick="return confirm('Lancer un test Brain?');">
|
|
<i class="fas fa-flask" style="color: var(--purple);"></i>
|
|
<span>Lancer Brain Test</span>
|
|
</a>
|
|
<a href="/api/n8n-connector.php?action=health&key=wevads-n8n-2026-secret-key" class="action-btn" target="_blank">
|
|
<i class="fas fa-heartbeat" style="color: var(--green);"></i>
|
|
<span>Health Check</span>
|
|
</a>
|
|
<a href="/api/hamid-api.php?action=status" class="action-btn" target="_blank">
|
|
<i class="fas fa-robot" style="color: var(--cyan);"></i>
|
|
<span>HAMID Status</span>
|
|
</a>
|
|
<a href="http://89.167.40.150:5825/home/workflows" class="action-btn" target="_blank">
|
|
<i class="fas fa-play-circle" style="color: var(--orange);"></i>
|
|
<span>Gérer Workflows</span>
|
|
</a>
|
|
<a href="/deliverads/warmup.php" class="action-btn">
|
|
<i class="fas fa-fire" style="color: var(--red);"></i>
|
|
<span>Warmup Manager</span>
|
|
</a>
|
|
<a href="/deliverads/blacklist.php" class="action-btn">
|
|
<i class="fas fa-shield-alt" style="color: var(--blue);"></i>
|
|
<span>Blacklist Check</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- n8n Workflows -->
|
|
<div class="section">
|
|
<h3 class="section-title"><i class="fas fa-project-diagram"></i> n8n Workflows (<?= count($n8nWorkflows) ?>)</h3>
|
|
<div class="workflow-grid">
|
|
<?php foreach ($n8nWorkflows as $wf): ?>
|
|
<div class="workflow-item">
|
|
<span class="workflow-name"><?= htmlspecialchars($wf['name']) ?></span>
|
|
<span class="workflow-status <?= $wf['active'] ? 'active' : 'inactive' ?>">
|
|
<?= $wf['active'] ? 'Active' : 'Inactive' ?>
|
|
</span>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- AI Providers -->
|
|
<?php if (!empty($aiProviders)): ?>
|
|
<div class="section">
|
|
<h3 class="section-title"><i class="fas fa-microchip"></i> AI Providers</h3>
|
|
<table class="table">
|
|
<thead>
|
|
<tr><th>Provider</th><th>Model</th><th>Status</th><th>Requests</th></tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($aiProviders as $p): ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($p['name'] ?? 'N/A') ?></td>
|
|
<td><?= htmlspecialchars($p['model'] ?? 'N/A') ?></td>
|
|
<td><span class="badge badge-success"><?= htmlspecialchars($p['status'] ?? 'N/A') ?></span></td>
|
|
<td><?= $p['total_requests'] ?? 0 ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<!-- System Links -->
|
|
<div class="section">
|
|
<h3 class="section-title"><i class="fas fa-link"></i> Liens Système</h3>
|
|
<div class="quick-actions">
|
|
<a href="/api/n8n-connector.php?action=stats&key=wevads-n8n-2026-secret-key" class="action-btn" target="_blank">
|
|
<i class="fas fa-chart-bar" style="color: var(--cyan);"></i>
|
|
<span>API Stats</span>
|
|
</a>
|
|
<a href="/api/n8n-connector.php?action=servers&key=wevads-n8n-2026-secret-key" class="action-btn" target="_blank">
|
|
<i class="fas fa-server" style="color: var(--green);"></i>
|
|
<span>API Servers</span>
|
|
</a>
|
|
<a href="/api/n8n-connector.php?action=tracking&key=wevads-n8n-2026-secret-key" class="action-btn" target="_blank">
|
|
<i class="fas fa-chart-line" style="color: var(--purple);"></i>
|
|
<span>API Tracking</span>
|
|
</a>
|
|
<a href="/api/n8n-connector.php?action=brain_winners&key=wevads-n8n-2026-secret-key" class="action-btn" target="_blank">
|
|
<i class="fas fa-trophy" style="color: var(--orange);"></i>
|
|
<span>Brain Winners</span>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// Auto-refresh stats every 60s
|
|
setTimeout(() => location.reload(), 60000);
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|