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

479 lines
26 KiB
PHP
Executable File

<?php
/**
* WARMUP PRO - Système Polyvalent
* Email, IP, Domain, Subdomain Warming
* Par ISP avec headers/body optimisés
*/
$pdo = new PDO("pgsql:host=localhost;dbname=adx_system", "admin", "admin123");
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Stats
$stats = [
'email_warmup' => $pdo->query("SELECT COUNT(*) FROM admin.warmup_assets WHERE asset_type='email'")->fetchColumn() ?: 0,
'ip_warmup' => $pdo->query("SELECT COUNT(*) FROM admin.warmup_assets WHERE asset_type='ip'")->fetchColumn() ?: 0,
'domain_warmup' => $pdo->query("SELECT COUNT(*) FROM admin.warmup_assets WHERE asset_type='domain'")->fetchColumn() ?: 0,
'total_active' => $pdo->query("SELECT COUNT(*) FROM admin.warmup_assets WHERE status='active'")->fetchColumn() ?: 0,
];
// ISP configs
$ispConfigs = $pdo->query("SELECT * FROM admin.warmup_isp_config ORDER BY isp_name")->fetchAll(PDO::FETCH_ASSOC);
// Actions
$msg = '';
if ($_POST) {
$action = $_POST['action'] ?? '';
if ($action === 'add_asset') {
$stmt = $pdo->prepare("INSERT INTO admin.warmup_assets (asset_type, asset_value, provider_type, smtp_host, smtp_port, smtp_user, smtp_pass, daily_target, schedule, notes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([
$_POST['asset_type'],
$_POST['asset_value'],
$_POST['provider_type'],
$_POST['smtp_host'] ?? null,
$_POST['smtp_port'] ?? 587,
$_POST['smtp_user'] ?? null,
$_POST['smtp_pass'] ?? null,
$_POST['daily_target'] ?? 50,
$_POST['schedule'] ?? 'moderate',
$_POST['notes'] ?? null
]);
$msg = '✅ Asset ajouté au warmup!';
}
if ($action === 'delete' && isset($_POST['id'])) {
$pdo->prepare("DELETE FROM admin.warmup_assets WHERE id=?")->execute([$_POST['id']]);
$msg = '✅ Asset supprimé!';
}
if ($action === 'toggle_status' && isset($_POST['id'])) {
$pdo->prepare("UPDATE admin.warmup_assets SET status = CASE WHEN status='active' THEN 'paused' ELSE 'active' END WHERE id=?")->execute([$_POST['id']]);
$msg = '✅ Status modifié!';
}
}
// Liste des assets
$assets = $pdo->query("SELECT * FROM admin.warmup_assets ORDER BY created_at DESC")->fetchAll(PDO::FETCH_ASSOC);
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Warmup Pro - WEVAL</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; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%); min-height: 100vh; color: #e2e8f0; }
.container { max-width: 1600px; margin: 0 auto; padding: 20px; }
.header { display: flex; justify-content: space-between; align-items: center; padding: 20px 30px; background: rgba(255,255,255,0.03); border-radius: 20px; margin-bottom: 30px; border: 1px solid rgba(255,255,255,0.1); }
.header h1 { font-size: 28px; display: flex; align-items: center; gap: 15px; }
.header h1 .icon { font-size: 36px; background: linear-gradient(135deg, #f97316, #dc2626); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.nav { display: flex; gap: 10px; }
.nav a { padding: 10px 20px; background: rgba(99,102,241,0.2); color: #a5b4fc; text-decoration: none; border-radius: 10px; font-size: 13px; transition: all 0.3s; }
.nav a:hover { background: rgba(99,102,241,0.4); transform: translateY(-2px); }
.nav a.active { background: linear-gradient(135deg, #f97316, #dc2626); color: white; }
.msg { padding: 15px 25px; background: rgba(52,211,153,0.15); border: 1px solid rgba(52,211,153,0.3); border-radius: 12px; color: #6ee7b7; margin-bottom: 25px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }
.stat-card { background: rgba(255,255,255,0.03); border-radius: 16px; padding: 25px; text-align: center; border: 1px solid rgba(255,255,255,0.08); transition: all 0.3s; }
.stat-card:hover { transform: translateY(-5px); border-color: rgba(139,92,246,0.3); }
.stat-card .icon { font-size: 32px; margin-bottom: 15px; }
.stat-card .icon.email { color: #22d3ee; }
.stat-card .icon.ip { color: #f97316; }
.stat-card .icon.domain { color: #a78bfa; }
.stat-card .icon.active { color: #34d399; }
.stat-card .value { font-size: 42px; font-weight: 700; background: linear-gradient(135deg, #a78bfa, #22d3ee); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-card .label { color: #64748b; font-size: 13px; margin-top: 8px; }
.tabs { display: flex; gap: 5px; margin-bottom: 25px; background: rgba(255,255,255,0.03); padding: 8px; border-radius: 12px; }
.tab { padding: 12px 25px; background: transparent; border: none; color: #94a3b8; cursor: pointer; border-radius: 8px; font-size: 14px; font-weight: 500; transition: all 0.3s; }
.tab:hover { background: rgba(255,255,255,0.05); }
.tab.active { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; }
.grid { display: grid; grid-template-columns: 400px 1fr; gap: 25px; }
.card { background: rgba(255,255,255,0.03); border-radius: 16px; padding: 25px; border: 1px solid rgba(255,255,255,0.08); }
.card h3 { font-size: 16px; color: #e2e8f0; margin-bottom: 20px; display: flex; align-items: center; gap: 10px; }
.card h3 i { color: #a78bfa; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 12px; color: #94a3b8; margin-bottom: 6px; font-weight: 500; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 12px 15px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 10px; color: #e2e8f0; font-size: 14px; transition: all 0.3s; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #8b5cf6; box-shadow: 0 0 0 3px rgba(139,92,246,0.2); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.btn { padding: 12px 25px; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.3s; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: linear-gradient(135deg, #8b5cf6, #6366f1); color: white; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 5px 20px rgba(139,92,246,0.4); }
.btn-danger { background: rgba(239,68,68,0.2); color: #f87171; }
.btn-warning { background: rgba(251,191,36,0.2); color: #fbbf24; }
.btn-success { background: rgba(52,211,153,0.2); color: #34d399; }
.btn-sm { padding: 8px 15px; font-size: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px; text-align: left; border-bottom: 1px solid rgba(255,255,255,0.05); }
th { color: #64748b; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; background: rgba(0,0,0,0.2); }
tr:hover { background: rgba(255,255,255,0.02); }
.badge { padding: 5px 12px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-email { background: rgba(34,211,238,0.15); color: #22d3ee; }
.badge-ip { background: rgba(249,115,22,0.15); color: #f97316; }
.badge-domain { background: rgba(167,139,250,0.15); color: #a78bfa; }
.badge-subdomain { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-active { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-paused { background: rgba(251,191,36,0.15); color: #fbbf24; }
.isp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 20px; }
.isp-card { padding: 15px; background: rgba(255,255,255,0.02); border-radius: 12px; text-align: center; cursor: pointer; transition: all 0.3s; border: 2px solid transparent; }
.isp-card:hover { background: rgba(255,255,255,0.05); }
.isp-card.selected { border-color: #8b5cf6; background: rgba(139,92,246,0.1); }
.isp-card .name { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.isp-card .filter { font-size: 10px; color: #64748b; }
.isp-card .strictness { font-size: 10px; padding: 3px 8px; border-radius: 10px; margin-top: 8px; display: inline-block; }
.isp-card .strictness.strict { background: rgba(239,68,68,0.2); color: #f87171; }
.isp-card .strictness.medium { background: rgba(251,191,36,0.2); color: #fbbf24; }
.isp-card .strictness.low { background: rgba(52,211,153,0.2); color: #34d399; }
.progress-bar { height: 8px; background: rgba(255,255,255,0.1); border-radius: 4px; overflow: hidden; }
.progress-bar .fill { height: 100%; background: linear-gradient(90deg, #8b5cf6, #22d3ee); border-radius: 4px; transition: width 0.3s; }
.actions { display: flex; gap: 5px; }
.help-section { margin-top: 30px; padding: 25px; background: rgba(139,92,246,0.05); border-radius: 16px; border: 1px solid rgba(139,92,246,0.2); }
.help-section h4 { color: #a78bfa; margin-bottom: 15px; }
.help-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.help-item { padding: 15px; background: rgba(0,0,0,0.2); border-radius: 10px; }
.help-item h5 { color: #e2e8f0; margin-bottom: 8px; font-size: 13px; }
.help-item p { color: #64748b; font-size: 12px; line-height: 1.6; }
.asset-type-select { display: flex; gap: 10px; margin-bottom: 20px; }
.asset-type-btn { flex: 1; padding: 15px; background: rgba(255,255,255,0.03); border: 2px solid rgba(255,255,255,0.1); border-radius: 12px; cursor: pointer; text-align: center; transition: all 0.3s; }
.asset-type-btn:hover { border-color: rgba(139,92,246,0.3); }
.asset-type-btn.selected { border-color: #8b5cf6; background: rgba(139,92,246,0.1); }
.asset-type-btn i { font-size: 24px; margin-bottom: 8px; display: block; }
.asset-type-btn span { font-size: 12px; color: #94a3b8; }
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1><span class="icon">🔥</span> Warmup Pro</h1>
<div class="nav">
<a href="warmup-dashboard.php"><i class="fas fa-chart-bar"></i> Dashboard Simple</a>
<a href="email-warmup.php"><i class="fas fa-envelope"></i> Email Warmup</a>
<a href="hamid-dashboard.php"><i class="fas fa-brain"></i> WEVAL MIND</a>
<a href="standalone-index.php"><i class="fas fa-home"></i> Index</a>
</div>
</div>
<?php if ($msg): ?><div class="msg"><?= $msg ?></div><?php endif; ?>
<!-- Stats -->
<div class="stats-grid">
<div class="stat-card">
<div class="icon email"><i class="fas fa-envelope"></i></div>
<div class="value"><?= $stats['email_warmup'] ?></div>
<div class="label">Email Warmup</div>
</div>
<div class="stat-card">
<div class="icon ip"><i class="fas fa-server"></i></div>
<div class="value"><?= $stats['ip_warmup'] ?></div>
<div class="label">IP Warmup</div>
</div>
<div class="stat-card">
<div class="icon domain"><i class="fas fa-globe"></i></div>
<div class="value"><?= $stats['domain_warmup'] ?></div>
<div class="label">Domain Warmup</div>
</div>
<div class="stat-card">
<div class="icon active"><i class="fas fa-play-circle"></i></div>
<div class="value"><?= $stats['total_active'] ?></div>
<div class="label">Actifs</div>
</div>
</div>
<!-- Tabs -->
<div class="tabs">
<button class="tab active" onclick="showTab('all')"><i class="fas fa-list"></i> Tous</button>
<button class="tab" onclick="showTab('email')"><i class="fas fa-envelope"></i> Emails</button>
<button class="tab" onclick="showTab('ip')"><i class="fas fa-server"></i> IPs</button>
<button class="tab" onclick="showTab('domain')"><i class="fas fa-globe"></i> Domaines</button>
<button class="tab" onclick="showTab('isp')"><i class="fas fa-filter"></i> ISP Config</button>
</div>
<div class="grid">
<!-- Formulaire Ajout -->
<div>
<div class="card">
<h3><i class="fas fa-plus-circle"></i> Ajouter un Asset</h3>
<form method="POST">
<input type="hidden" name="action" value="add_asset">
<div class="form-group">
<label>Type d'Asset</label>
<div class="asset-type-select">
<div class="asset-type-btn selected" onclick="selectAssetType('email')">
<i class="fas fa-envelope" style="color:#22d3ee"></i>
<span>Email</span>
</div>
<div class="asset-type-btn" onclick="selectAssetType('ip')">
<i class="fas fa-server" style="color:#f97316"></i>
<span>IP</span>
</div>
<div class="asset-type-btn" onclick="selectAssetType('domain')">
<i class="fas fa-globe" style="color:#a78bfa"></i>
<span>Domaine</span>
</div>
<div class="asset-type-btn" onclick="selectAssetType('subdomain')">
<i class="fas fa-sitemap" style="color:#34d399"></i>
<span>Subdomain</span>
</div>
</div>
<input type="hidden" name="asset_type" id="asset_type" value="email">
</div>
<div class="form-group">
<label>Valeur (Email/IP/Domain)</label>
<input type="text" name="asset_value" placeholder="ex: user@domain.com ou 192.168.1.1" required>
</div>
<div class="form-group">
<label>Provider / ISP</label>
<select name="provider_type">
<option value="">-- Sélectionner --</option>
<?php foreach ($ispConfigs as $isp): ?>
<option value="<?= $isp['isp_name'] ?>"><?= htmlspecialchars($isp['display_name']) ?></option>
<?php endforeach; ?>
</select>
</div>
<div id="smtp-fields">
<div class="form-row">
<div class="form-group">
<label>SMTP Host</label>
<input type="text" name="smtp_host" placeholder="smtp.example.com">
</div>
<div class="form-group">
<label>SMTP Port</label>
<input type="number" name="smtp_port" value="587">
</div>
</div>
<div class="form-group">
<label>SMTP User</label>
<input type="text" name="smtp_user" placeholder="username">
</div>
<div class="form-group">
<label>SMTP Password</label>
<input type="password" name="smtp_pass">
</div>
</div>
<div class="form-row">
<div class="form-group">
<label>Objectif Quotidien</label>
<input type="number" name="daily_target" value="50">
</div>
<div class="form-group">
<label>Schedule</label>
<select name="schedule">
<option value="conservative">Conservative (6 sem)</option>
<option value="moderate" selected>Moderate (4 sem)</option>
<option value="aggressive">Aggressive (2 sem)</option>
</select>
</div>
</div>
<div class="form-group">
<label>Notes</label>
<textarea name="notes" rows="2" placeholder="Notes optionnelles..."></textarea>
</div>
<button type="submit" class="btn btn-primary" style="width:100%"><i class="fas fa-rocket"></i> Ajouter au Warmup</button>
</form>
</div>
<!-- Help Section -->
<div class="help-section">
<h4><i class="fas fa-lightbulb"></i> Guide Warmup</h4>
<div class="help-grid">
<div class="help-item">
<h5>📧 Email Warmup</h5>
<p>Gmail, Hotmail, Office365, Yahoo. Augmentation progressive 50→5000/jour sur 4-6 semaines.</p>
</div>
<div class="help-item">
<h5>🖥️ IP Warmup</h5>
<p>PowerMTA, VPS. Config max-smtp-out et msg-rate. PTR/rDNS obligatoire.</p>
</div>
<div class="help-item">
<h5>🌐 Domain Warmup</h5>
<p>SPF, DKIM, DMARC requis. Âge domaine 30+ jours recommandé.</p>
</div>
<div class="help-item">
<h5>📊 Monitoring</h5>
<p>Bounces < 2%, Complaints < 0.1%. Blacklist check quotidien.</p>
</div>
</div>
</div>
</div>
<!-- Liste Assets -->
<div class="card" id="assets-list">
<h3><i class="fas fa-list"></i> Assets en Warmup</h3>
<?php if (empty($assets)): ?>
<div style="text-align:center;padding:60px;color:#64748b">
<i class="fas fa-inbox" style="font-size:64px;opacity:0.3;margin-bottom:20px;display:block"></i>
<p>Aucun asset en warmup.</p>
<p style="font-size:13px">Ajoutez des emails, IPs ou domaines pour commencer.</p>
</div>
<?php else: ?>
<table>
<thead>
<tr>
<th>Type</th>
<th>Asset</th>
<th>Provider</th>
<th>Jour</th>
<th>Aujourd'hui</th>
<th>Objectif</th>
<th>Total</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($assets as $a):
$progress = $a['daily_target'] > 0 ? min(100, ($a['sent_today'] / $a['daily_target']) * 100) : 0;
?>
<tr class="asset-row" data-type="<?= $a['asset_type'] ?>">
<td><span class="badge badge-<?= $a['asset_type'] ?>"><?= ucfirst($a['asset_type']) ?></span></td>
<td>
<strong><?= htmlspecialchars($a['asset_value']) ?></strong>
<?php if ($a['notes']): ?><br><small style="color:#64748b"><?= htmlspecialchars($a['notes']) ?></small><?php endif; ?>
</td>
<td><?= htmlspecialchars($a['provider_type'] ?? '-') ?></td>
<td>J<?= $a['current_day'] ?></td>
<td><?= $a['sent_today'] ?></td>
<td><?= $a['daily_target'] ?>/jour</td>
<td><?= number_format($a['total_sent']) ?></td>
<td><span class="badge badge-<?= $a['status'] ?>"><?= ucfirst($a['status']) ?></span></td>
<td class="actions">
<form method="POST" style="display:inline">
<input type="hidden" name="action" value="toggle_status">
<input type="hidden" name="id" value="<?= $a['id'] ?>">
<button type="submit" class="btn btn-sm <?= $a['status'] === 'active' ? 'btn-warning' : 'btn-success' ?>" title="<?= $a['status'] === 'active' ? 'Pause' : 'Start' ?>">
<i class="fas fa-<?= $a['status'] === 'active' ? 'pause' : 'play' ?>"></i>
</button>
</form>
<form method="POST" style="display:inline" onsubmit="return confirm('Supprimer?')">
<input type="hidden" name="action" value="delete">
<input type="hidden" name="id" value="<?= $a['id'] ?>">
<button type="submit" class="btn btn-sm btn-danger"><i class="fas fa-trash"></i></button>
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>
</div>
<!-- ISP Config (hidden by default) -->
<div class="card" id="isp-config" style="display:none;grid-column:span 2">
<h3><i class="fas fa-filter"></i> Configuration ISP - Headers & Filtres</h3>
<div class="isp-grid">
<?php foreach ($ispConfigs as $isp):
$strictClass = strpos($isp['filter_strictness'], 'Strict') !== false ? 'strict' : (strpos($isp['filter_strictness'], 'Moyen') !== false ? 'medium' : 'low');
?>
<div class="isp-card" onclick="showIspDetails(<?= $isp['id'] ?>)">
<div class="name"><?= htmlspecialchars($isp['display_name']) ?></div>
<div class="filter"><?= htmlspecialchars($isp['primary_filter']) ?></div>
<div class="strictness <?= $strictClass ?>"><?= htmlspecialchars($isp['filter_strictness']) ?></div>
</div>
<?php endforeach; ?>
</div>
<div id="isp-details" style="margin-top:30px;padding:20px;background:rgba(0,0,0,0.2);border-radius:12px;display:none">
<!-- ISP details will be shown here -->
</div>
</div>
</div>
</div>
<script>
function selectAssetType(type) {
document.querySelectorAll('.asset-type-btn').forEach(b => b.classList.remove('selected'));
event.target.closest('.asset-type-btn').classList.add('selected');
document.getElementById('asset_type').value = type;
// Show/hide SMTP fields
const smtpFields = document.getElementById('smtp-fields');
smtpFields.style.display = (type === 'email') ? 'block' : 'none';
}
function showTab(type) {
document.querySelectorAll('.tab').forEach(t => t.classList.remove('active'));
event.target.classList.add('active');
if (type === 'isp') {
document.getElementById('assets-list').style.display = 'none';
document.getElementById('isp-config').style.display = 'block';
} else {
document.getElementById('assets-list').style.display = 'block';
document.getElementById('isp-config').style.display = 'none';
document.querySelectorAll('.asset-row').forEach(row => {
if (type === 'all' || row.dataset.type === type) {
row.style.display = '';
} else {
row.style.display = 'none';
}
});
}
}
function showIspDetails(id) {
const ispData = <?= json_encode($ispConfigs) ?>;
const isp = ispData.find(i => i.id == id);
if (!isp) return;
const details = document.getElementById('isp-details');
details.style.display = 'block';
details.innerHTML = `
<h4 style="color:#a78bfa;margin-bottom:15px">${isp.display_name}</h4>
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:20px">
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">DOMAINES</h5>
<p style="font-size:13px">${isp.domains || 'N/A'}</p>
</div>
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">FILTRE PRINCIPAL</h5>
<p style="font-size:13px">${isp.primary_filter}</p>
</div>
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">AUTH REQUIS</h5>
<p style="font-size:13px">${isp.auth_required}</p>
</div>
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">BLACKLISTS VÉRIFIÉES</h5>
<p style="font-size:13px">${isp.blacklists_checked}</p>
</div>
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">LIMITES PMTA</h5>
<p style="font-size:13px">max-smtp-out: ${isp.max_smtp_out}, rate: ${isp.max_msg_rate}</p>
</div>
<div>
<h5 style="color:#64748b;font-size:11px;margin-bottom:8px">REQUIREMENTS</h5>
<p style="font-size:13px">${isp.special_requirements || 'Aucun'}</p>
</div>
</div>
`;
}
</script>
<?php include("includes/chatbot-widget.php"); ?>
</body>
</html>