-- ============================================ -- Migration 001 — Backoffice complet -- Portfolio Tony AVERTY -- ============================================ -- Usage : mysql -u root -p portfoliotony < 001_backoffice.sql -- (remplacer "portfoliotony" par le nom réel de ta base) -- ============================================ -- ── Administrateurs ─────────────────────────────────────── -- Le mot de passe est créé via setup.php (hash bcrypt) CREATE TABLE IF NOT EXISTS admins ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, username VARCHAR(100) NOT NULL UNIQUE, password_hash VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB; -- ── Messages du formulaire de contact ───────────────────── CREATE TABLE IF NOT EXISTS contact_messages ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, sender_name VARCHAR(255) NOT NULL, sender_email VARCHAR(255) NOT NULL, subject VARCHAR(255) DEFAULT NULL, message TEXT NOT NULL, is_read TINYINT(1) NOT NULL DEFAULT 0, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_msg_read (is_read), INDEX idx_msg_date (created_at) ) ENGINE=InnoDB; -- ── Réponses aux messages (thread email backoffice) ──────── CREATE TABLE IF NOT EXISTS message_replies ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, message_id INT UNSIGNED NOT NULL, reply_text TEXT NOT NULL, sent_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_replies_msg (message_id) ) ENGINE=InnoDB; -- ── Rate limiting (anti-spam / brute force) ─────────────── CREATE TABLE IF NOT EXISTS rate_limits ( id INT AUTO_INCREMENT PRIMARY KEY, action VARCHAR(64) NOT NULL, ip VARCHAR(45) NOT NULL, created_at DATETIME DEFAULT CURRENT_TIMESTAMP, INDEX idx_action_ip_time (action, ip, created_at) ) ENGINE=InnoDB; -- ── Projets (portfolio) ─────────────────────────────────── CREATE TABLE IF NOT EXISTS projects ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, title VARCHAR(255) NOT NULL, slug VARCHAR(255) NOT NULL UNIQUE, short_description VARCHAR(500) DEFAULT NULL, full_description TEXT DEFAULT NULL, image VARCHAR(500) DEFAULT NULL, badge ENUM('production', 'development') NOT NULL DEFAULT 'development', technologies TEXT DEFAULT NULL, project_url VARCHAR(500) DEFAULT NULL, status ENUM('published', 'draft') NOT NULL DEFAULT 'draft', display_order INT UNSIGNED NOT NULL DEFAULT 0, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_projects_status (status), INDEX idx_projects_order (display_order) ) ENGINE=InnoDB; -- ── Tracking des visites ────────────────────────────────── CREATE TABLE IF NOT EXISTS visits ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, ip_hash VARCHAR(64) NOT NULL, session_id VARCHAR(64) NOT NULL, page VARCHAR(500) NOT NULL DEFAULT '/', referrer VARCHAR(500) DEFAULT NULL, device_type ENUM('desktop', 'mobile', 'tablet') NOT NULL DEFAULT 'desktop', duration_s INT UNSIGNED DEFAULT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_visits_date (created_at), INDEX idx_visits_session (session_id), INDEX idx_visits_page (page(100)) ) ENGINE=InnoDB; -- ── Clics sur les projets ───────────────────────────────── CREATE TABLE IF NOT EXISTS project_clicks ( id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY, project_id INT UNSIGNED NOT NULL, ip_hash VARCHAR(64) NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_clicks_project (project_id), INDEX idx_clicks_date (created_at) ) ENGINE=InnoDB; -- ── Services (éditable depuis le backoffice) ────────────── CREATE TABLE IF NOT EXISTS services ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, icon VARCHAR(10) NOT NULL DEFAULT '🚀', title VARCHAR(255) NOT NULL, description TEXT NOT NULL, display_order INT UNSIGNED NOT NULL DEFAULT 0, is_active TINYINT(1) NOT NULL DEFAULT 1, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_services_order (display_order) ) ENGINE=InnoDB; -- ── Contenu du site (clé/valeur) ────────────────────────── CREATE TABLE IF NOT EXISTS site_content ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, content_key VARCHAR(100) NOT NULL UNIQUE, content_value MEDIUMTEXT DEFAULT NULL, content_type ENUM('text', 'textarea', 'html') NOT NULL DEFAULT 'text', label VARCHAR(255) NOT NULL, section VARCHAR(100) NOT NULL DEFAULT 'general', updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, INDEX idx_content_section (section) ) ENGINE=InnoDB; -- ── Paramètres globaux ──────────────────────────────────── CREATE TABLE IF NOT EXISTS site_settings ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, setting_key VARCHAR(100) NOT NULL UNIQUE, setting_value TEXT DEFAULT NULL, label VARCHAR(255) NOT NULL DEFAULT '', updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP ) ENGINE=InnoDB; -- ── Tentatives de connexion (brute force) ───────────────── CREATE TABLE IF NOT EXISTS login_attempts ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, ip VARCHAR(45) NOT NULL, username VARCHAR(100) NOT NULL, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_attempts_ip_date (ip, created_at) ) ENGINE=InnoDB; -- ── Logs des actions admin ──────────────────────────────── CREATE TABLE IF NOT EXISTS admin_logs ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, admin_id INT UNSIGNED DEFAULT NULL, username VARCHAR(100) DEFAULT NULL, action VARCHAR(100) NOT NULL, detail TEXT DEFAULT NULL, ip VARCHAR(45) NOT NULL, success TINYINT(1) NOT NULL DEFAULT 1, created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, INDEX idx_logs_date (created_at), INDEX idx_logs_admin (admin_id) ) ENGINE=InnoDB; -- ── Données par défaut : Services ───────────────────────── INSERT IGNORE INTO services (icon, title, description, display_order) VALUES ('🌐', 'Site vitrine & portfolio', 'Un site professionnel qui reflète votre activité et donne envie de vous contacter. Design soigné, contenu structuré, référencement local intégré.', 1), ('🛒', 'E-commerce & boutique en ligne', 'De la boutique simple au catalogue complet, avec paiement sécurisé, gestion des stocks et interface admin intuitive.', 2), ('⚙️', 'Application web sur mesure', 'Outils métiers, espaces clients, tableaux de bord, automatisations — développés exactement pour votre usage, pas plus, pas moins.', 3), ('🔍', 'SEO & optimisation', 'Audit, structure, contenu et vitesse optimisés pour que Google vous trouve — et surtout, vos clients locaux aussi.', 4), ('🔧', 'Maintenance & évolution', 'Mises à jour, corrections, nouvelles fonctionnalités — votre site reste en bonne santé et évolue avec votre activité.', 5), ('📱', 'Refonte & modernisation', 'Votre site est vieillissant ? Je le remets à niveau : design, performance, responsive et standards modernes.', 6); -- ── Données par défaut : Contenu ────────────────────────── INSERT IGNORE INTO site_content (content_key, content_value, content_type, label, section) VALUES -- SEO ('seo_title', 'Tony AVERTY — Développeur Web Freelance | Sites sur mesure & Applications', 'text', 'Balise ', 'seo'), ('seo_description', 'Développeur web freelance basé en Bretagne. Je crée des sites et applications sur mesure, livrés en moins de 24h de délai de réponse. Fondateur de CodeBzh.', 'textarea', 'Meta description', 'seo'), ('seo_og_title', 'Tony AVERTY — Développeur Web Freelance', 'text', 'OG Title (réseaux sociaux)', 'seo'), ('seo_og_description', 'Sites et applications sur mesure. Réponse en 24h. Fondateur de CodeBzh.', 'textarea', 'OG Description', 'seo'), -- Hero ('hero_badge', 'Disponible pour nouveaux projets', 'text', 'Badge disponibilité', 'hero'), ('hero_line1', 'Du code propre.', 'text', 'Titre ligne 1', 'hero'), ('hero_line2', 'Des interfaces claires.', 'text', 'Titre ligne 2', 'hero'), ('hero_line3', 'Des projets qui tiennent.', 'text', 'Titre ligne 3 (accentuée)', 'hero'), ('hero_subtitle', 'Je suis Tony AVERTY — développeur web freelance et fondateur de CodeBzh. Je conçois des sites et applications sur mesure : bien structurés, bien pensés, construits pour servir votre activité sur le long terme.', 'textarea', 'Sous-titre', 'hero'), ('hero_cta_primary', 'Parlons de votre projet →', 'text', 'CTA principal', 'hero'), ('hero_cta_secondary', 'Voir ce que j\'ai construit', 'text', 'CTA secondaire', 'hero'), -- À propos ('about_title', 'Développeur web freelance, basé en Bretagne.', 'text', 'Titre section', 'about'), ('about_text', 'Je construis des sites et applications web depuis plusieurs années. Mon approche : du code propre, des interfaces pensées pour l\'utilisateur, et un accompagnement direct sans intermédiaire.\n\nPas d\'agence, pas de sous-traitant. Vous travaillez directement avec moi, du brief à la mise en ligne.', 'textarea', 'Texte principal', 'about'), ('about_stat1_value', '5+', 'text', 'Stat 1 — Valeur', 'about'), ('about_stat1_label', 'Années d\'expérience', 'text', 'Stat 1 — Label', 'about'), ('about_stat2_value', '30+', 'text', 'Stat 2 — Valeur', 'about'), ('about_stat2_label', 'Projets livrés', 'text', 'Stat 2 — Label', 'about'), ('about_stat3_value', '24h', 'text', 'Stat 3 — Valeur', 'about'), ('about_stat3_label', 'Délai de réponse garanti', 'text', 'Stat 3 — Label', 'about'), -- Contact ('contact_title', 'Un projet en tête ?', 'text', 'Titre section', 'contact'), ('contact_subtitle', 'Parlez-moi de votre projet. Je vous réponds sous 24h pour un premier échange sans engagement.', 'textarea', 'Sous-titre', 'contact'), ('contact_email', 'contact@tonyaverty.fr', 'text', 'Email affiché', 'contact'), ('contact_phone', '', 'text', 'Téléphone affiché', 'contact'), ('contact_location', 'Bretagne, France', 'text', 'Localisation affichée', 'contact'), -- Footer ('footer_tagline', 'Développeur web freelance', 'text', 'Tagline footer', 'footer'), ('footer_tagline_sub', 'Fondateur de CodeBzh · Disponible pour nouveaux projets', 'text', 'Sous-tagline footer', 'footer'); -- ── Données par défaut : Paramètres ────────────────────── INSERT IGNORE INTO site_settings (setting_key, setting_value, label) VALUES ('site_name', 'Portfolio Tony AVERTY', 'Nom du site'), ('owner_name', 'Tony AVERTY', 'Nom du propriétaire'), ('owner_email', 'contact@tonyaverty.fr', 'Email principal'), ('notify_email', 'contact@tony-averty.dev', 'Email de notification (contact form)'), ('availability', '1', 'Disponible pour nouveaux projets (1=oui, 0=non)'), ('maintenance_mode', '0', 'Mode maintenance (1=activé)'), ('google_analytics_id', '', 'Google Analytics ID (optionnel)'), ('site_url', 'https://tonyaverty.fr', 'URL du site');