/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Interface Administrateur - Onglet Cyberdéfense et Modération * ========================================================================= */ window.pano_AdminCyberdefenseTab = ({ data, refreshData, openLocalDialog, closeCurrentLayer, activeDialog }) => { const { useState, useEffect } = React; const routerActiveDialog = activeDialog || new URLSearchParams(window.location.search).get('dialog'); const routerCloseLayer = closeCurrentLayer || (() => window.history.back()); const routerOpenDialog = openLocalDialog || ((type) => { const u = new URL(window.location); u.searchParams.set('dialog', type); window.history.pushState({ dialog: type }, '', u); window.dispatchEvent(new Event('popstate')); }); const [isSaving, setIsSaving] = useState(false); const [settings, setSettings] = useState(data.settings || {}); const [pwdRequestData, setPwdRequestData] = useState(null); const { ShieldAlertIcon, ShieldCheckIcon, SaveIcon, LoaderIcon, ActivityIcon, MailIcon, LockIcon } = window.pano_getIcons(); const FormInput = window.pano_FormInput || (() => null); const FormTextarea = window.pano_FormTextarea || (() => null); const Toggle = window.pano_Toggle || (() => null); const Button = window.pano_Button || (() => null); const PasswordPromptModal = window.pano_PasswordPromptModal || (() => null); const updateSetting = (key, val) => setSettings({ ...settings, [key]: val }); const handleSave = async () => { const payload = {}; let hasChanges = false; const protectedFields = [ 'maintenance', 'allow_new_purchases', 'blacklist', 'greylist', 'sec_ip_limit', 'mail_limit_count', 'mail_limit_window', 'sec_global_limit', 'sec_lock_min', 'sec_lock_max' ]; for (const key of protectedFields) { const oldVal = String(data.settings?.[key] ?? '').replace(/\r\n/g, '\n'); const newVal = String(settings[key] ?? '').replace(/\r\n/g, '\n'); if (oldVal !== newVal) { payload[key] = settings[key]; hasChanges = true; } } if (!hasChanges) { window.pano_showToast("Aucune modification à sauvegarder.", "info"); return; } setPwdRequestData({ title: "Confirmation de sécurité", desc: "La modification des paramètres de sécurité ou d'accès nécessite le mot de passe administrateur :", onConfirm: async (pwd) => { await executeSave({ ...payload, pwd }); } }); routerOpenDialog('pwd_request'); }; const executeSave = async (finalPayload) => { const d = await window.pano_apiFetch('settings/update', { body: finalPayload, setLoading: setIsSaving, successMessage: "Règles de cyberdéfense mises à jour !" }); if (d) { refreshData(); routerCloseLayer(); } }; return ( <>

Cyberdéfense

Contrôle des boucliers réseau, filtres sémantiques et accès globaux.

Contrôle d'accès global

updateSetting('maintenance', settings.maintenance === '1' ? '0' : '1')} className="flex items-center justify-between p-4 bg-slate-50 border border-slate-100 rounded-xl cursor-pointer hover:bg-slate-100 transition shadow-sm">

Mode Maintenance

Verrouille l'accès public et client au portail.

{Toggle && updateSetting('maintenance', v ? '1' : '0')} variant="danger" />}
updateSetting('allow_new_purchases', settings.allow_new_purchases !== '0' ? '0' : '1')} className="flex items-center justify-between p-4 bg-slate-50 border border-slate-100 rounded-xl cursor-pointer hover:bg-slate-100 transition shadow-sm">

Nouvelles commandes

Autoriser la validation et le paiement de nouveaux panneaux.

{Toggle && updateSetting('allow_new_purchases', v ? '1' : '0')} variant="success" />}

Moteur Sémantique

{FormTextarea && ( <> updateSetting('blacklist', e.target.value)} hint="Mots séparés par des virgules. Rejet silencieux immédiat." rows={3} /> updateSetting('greylist', e.target.value)} hint="Tolérance max : 2 occurrences. Au-delà, validation requise." rows={3} /> )}

Filtres IP & Anti-Spam (L4)

{FormInput && ( <> updateSetting('sec_ip_limit', e.target.value)} hint="Nb. max d'échecs (15 min)" className="col-span-full" /> updateSetting('mail_limit_count', e.target.value)} hint="Messages max / IP" /> updateSetting('mail_limit_window', e.target.value)} hint="Durée en minutes" /> )}

Bouclier Anti-DDoS (L7)

{FormInput && ( <> updateSetting('sec_global_limit', e.target.value)} hint="IPs distinctes / 60s" className="col-span-full" /> updateSetting('sec_lock_min', e.target.value)} hint="Durée min. (minutes)" /> updateSetting('sec_lock_max', e.target.value)} hint="Durée max. (minutes)" /> )}
{routerActiveDialog === 'pwd_request' && pwdRequestData && PasswordPromptModal && ( )} ); }; /* EOF ========== [_react/_admin_cyberdefense.jsx] */