260 lines
8.2 KiB
PHP
260 lines
8.2 KiB
PHP
<?php
|
|
/**
|
|
* @framework iResponse Framework
|
|
* @version 1.0
|
|
* @author Yacine
|
|
* @date 2026
|
|
* @name dashboard.php
|
|
* @description Real-time tracking dashboard
|
|
*/
|
|
|
|
error_reporting(E_ERROR | E_PARSE);
|
|
|
|
# Database configuration
|
|
$db_host = '127.0.0.1';
|
|
$db_name = 'adx_system';
|
|
$db_user = 'admin';
|
|
$db_pass = 'admin123';
|
|
|
|
try {
|
|
$pdo = new PDO("pgsql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
} catch(PDOException $e) {
|
|
die("Connection Error: " . $e->getMessage());
|
|
}
|
|
|
|
# Fetch tracking statistics
|
|
$stats = [
|
|
'opens' => 0,
|
|
'clicks' => 0,
|
|
'leads' => 0,
|
|
'unsubscribes' => 0,
|
|
'optouts' => 0,
|
|
'total' => 0
|
|
];
|
|
|
|
$tables = ['opens', 'clicks', 'leads', 'unsubscribes', 'optouts'];
|
|
|
|
foreach($tables as $table) {
|
|
try {
|
|
$stmt = $pdo->query("SELECT COUNT(*) as count FROM actions.$table");
|
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
$stats[$table] = intval($row['count']);
|
|
$stats['total'] += $stats[$table];
|
|
} catch(Exception $e) {
|
|
$stats[$table] = 0;
|
|
}
|
|
}
|
|
|
|
# Fetch recent actions
|
|
$recent_actions = [];
|
|
try {
|
|
$stmt = $pdo->query("SELECT 'OPEN' as type, created_at, process_id, client_id FROM actions.opens ORDER BY created_at DESC LIMIT 50");
|
|
$recent_actions = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
} catch(Exception $e) {
|
|
$recent_actions = [];
|
|
}
|
|
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>WEVADS Tracking Dashboard</title>
|
|
<meta charset="utf-8">
|
|
<meta http-equiv="refresh" content="30">
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
|
|
color: #fff;
|
|
padding: 30px 20px;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
.header {
|
|
margin-bottom: 40px;
|
|
border-bottom: 3px solid #00d4ff;
|
|
padding-bottom: 20px;
|
|
}
|
|
|
|
.header h1 {
|
|
color: #00d4ff;
|
|
font-size: 32px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.header p {
|
|
color: #90caf9;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.stats-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
gap: 20px;
|
|
margin-bottom: 40px;
|
|
}
|
|
|
|
.stat-card {
|
|
background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
|
|
padding: 25px;
|
|
border-radius: 12px;
|
|
border-left: 5px solid #00d4ff;
|
|
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
|
}
|
|
|
|
.stat-card:hover {
|
|
transform: translateY(-5px);
|
|
box-shadow: 0 10px 30px rgba(0, 212, 255, 0.3);
|
|
}
|
|
|
|
.stat-card.opens { border-left-color: #4caf50; }
|
|
.stat-card.clicks { border-left-color: #ff9800; }
|
|
.stat-card.leads { border-left-color: #ff4081; }
|
|
.stat-card.unsubscribes { border-left-color: #f44336; }
|
|
.stat-card.optouts { border-left-color: #9c27b0; }
|
|
.stat-card.total { border-left-color: #00d4ff; grid-column: 1 / -1; }
|
|
|
|
.stat-number {
|
|
font-size: 42px;
|
|
font-weight: bold;
|
|
margin-bottom: 10px;
|
|
color: #00d4ff;
|
|
}
|
|
|
|
.stat-card.opens .stat-number { color: #4caf50; }
|
|
.stat-card.clicks .stat-number { color: #ff9800; }
|
|
.stat-card.leads .stat-number { color: #ff4081; }
|
|
.stat-card.unsubscribes .stat-number { color: #f44336; }
|
|
.stat-card.optouts .stat-number { color: #9c27b0; }
|
|
.stat-card.total .stat-number { color: #00d4ff; }
|
|
|
|
.stat-label {
|
|
font-size: 14px;
|
|
color: #b0bec5;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.section {
|
|
background: linear-gradient(135deg, #16213e 0%, #0f3460 100%);
|
|
padding: 30px;
|
|
border-radius: 12px;
|
|
margin-bottom: 30px;
|
|
border-left: 5px solid #00d4ff;
|
|
}
|
|
|
|
.section h2 {
|
|
color: #00d4ff;
|
|
font-size: 20px;
|
|
margin-bottom: 20px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
.logs-container {
|
|
max-height: 500px;
|
|
overflow-y: auto;
|
|
background: rgba(0, 0, 0, 0.2);
|
|
padding: 15px;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.log-item {
|
|
background: rgba(15, 15, 35, 0.8);
|
|
padding: 12px 15px;
|
|
margin-bottom: 8px;
|
|
border-radius: 6px;
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 12px;
|
|
border-left: 4px solid #4caf50;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
color: #4caf50;
|
|
}
|
|
|
|
.log-type { font-weight: bold; min-width: 80px; }
|
|
.log-time { color: #90caf9; margin: 0 15px; }
|
|
.log-details { flex: 1; text-align: right; color: #b0bec5; }
|
|
|
|
.refresh-info {
|
|
text-align: center;
|
|
color: #90caf9;
|
|
font-size: 12px;
|
|
margin-top: 20px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<div class="header">
|
|
<h1>📊 WEVADS Tracking Dashboard</h1>
|
|
<p>Real-time Tracking Metrics | Auto-refresh: 30s | Last update: <?php echo date('Y-m-d H:i:s'); ?></p>
|
|
</div>
|
|
|
|
<div class="stats-grid">
|
|
<div class="stat-card total">
|
|
<div class="stat-number"><?php echo number_format($stats['total']); ?></div>
|
|
<div class="stat-label">📊 Total Events</div>
|
|
</div>
|
|
|
|
<div class="stat-card opens">
|
|
<div class="stat-number"><?php echo number_format($stats['opens']); ?></div>
|
|
<div class="stat-label">📧 Opens</div>
|
|
</div>
|
|
|
|
<div class="stat-card clicks">
|
|
<div class="stat-number"><?php echo number_format($stats['clicks']); ?></div>
|
|
<div class="stat-label">🔗 Clicks</div>
|
|
</div>
|
|
|
|
<div class="stat-card leads">
|
|
<div class="stat-number"><?php echo number_format($stats['leads']); ?></div>
|
|
<div class="stat-label">⭐ Leads</div>
|
|
</div>
|
|
|
|
<div class="stat-card unsubscribes">
|
|
<div class="stat-number"><?php echo number_format($stats['unsubscribes']); ?></div>
|
|
<div class="stat-label">📵 Unsubscribes</div>
|
|
</div>
|
|
|
|
<div class="stat-card optouts">
|
|
<div class="stat-number"><?php echo number_format($stats['optouts']); ?></div>
|
|
<div class="stat-label">❌ Optouts</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<h2>📋 Recent Activity</h2>
|
|
<div class="logs-container">
|
|
<?php if(count($recent_actions) > 0): ?>
|
|
<?php foreach($recent_actions as $action): ?>
|
|
<div class="log-item">
|
|
<span class="log-type"><?php echo $action['type']; ?></span>
|
|
<span class="log-time"><?php echo date('H:i:s', strtotime($action['created_at'])); ?></span>
|
|
<span class="log-details">Process: <?php echo $action['process_id']; ?> | Client: <?php echo $action['client_id']; ?></span>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<div style="text-align: center; padding: 30px; color: #90caf9;">No recent activity yet</div>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="refresh-info">⟳ This page automatically refreshes every 30 seconds</div>
|
|
</div>
|
|
</body>
|
|
</html>
|