prepare('INSERT INTO tbl_scwebhooks (cl_scwebhook_name, cl_scwebhook_url, cl_scwebhook_image_url, cl_scwebhook_border_color, cl_scwebhook_is_forum) VALUES (:name, :url, :image_url, :border_color, :is_forum)');
$stmt->execute([
'name' => $cl_scwebhook_name,
'url' => $cl_scwebhook_url,
'image_url' => $cl_scwebhook_image_url,
'border_color' => $cl_scwebhook_border_color,
'is_forum' => $cl_scwebhook_is_forum,
]);
auth_flash_set('success', 'Canal Discord ajouté avec succès.');
} else {
if ($webhook_id <= 0) {
throw new RuntimeException('ID de webhook invalide.');
}
$stmt = $db->prepare('UPDATE tbl_scwebhooks SET cl_scwebhook_name = :name, cl_scwebhook_url = :url, cl_scwebhook_image_url = :image_url, cl_scwebhook_border_color = :border_color, cl_scwebhook_is_forum = :is_forum WHERE cl_scwebhook_id = :id');
$stmt->execute([
'name' => $cl_scwebhook_name,
'url' => $cl_scwebhook_url,
'image_url' => $cl_scwebhook_image_url,
'border_color' => $cl_scwebhook_border_color,
'is_forum' => $cl_scwebhook_is_forum,
'id' => $webhook_id,
]);
auth_flash_set('success', 'Canal Discord mis à jour.');
}
} catch (Throwable $e) {
auth_flash_set('error', 'Erreur webhook : ' . $e->getMessage());
}
header('Location: scwebhook.php');
exit;
}
if ($action === 'delete_webhook') {
$webhook_id = (int) ($_POST['webhook_id'] ?? 0);
if ($webhook_id > 0) {
try {
$stmt_usage = $db->prepare('SELECT COUNT(*) FROM tbl_scnotifications WHERE cl_scnotification_webhook_id = :id');
$stmt_usage->execute(['id' => $webhook_id]);
$usage_total = (int) $stmt_usage->fetchColumn();
if ($usage_total > 0) {
auth_flash_set('error', 'Suppression refusée : ce webhook est déjà relié à l’historique des notifications.');
} else {
$stmt = $db->prepare('DELETE FROM tbl_scwebhooks WHERE cl_scwebhook_id = :id');
$stmt->execute(['id' => $webhook_id]);
auth_flash_set('success', 'Canal Discord supprimé.');
}
} catch (Throwable $e) {
auth_flash_set('error', 'Erreur suppression webhook : ' . $e->getMessage());
}
}
header('Location: scwebhook.php');
exit;
}
}
$stmt_webhooks = $db->query('SELECT * FROM tbl_scwebhooks ORDER BY cl_scwebhook_name ASC');
$webhooks = $stmt_webhooks->fetchAll();
?>
SC Discord | R.E.A.C.T. Admin
Canaux Discord enregistrés
Aucun canal Discord configuré pour le moment.
| Nomination |
Webhook |
Prévisualisation |
Couleur |
Actions |
|
|
|
|
|
|