init: projet complet copymail pour Raspberry Pi

Stack: Nginx + PHP 8.2 + MariaDB + Postfix + Dovecot + Samba
- install.sh: script installation automatisé pour RPi OS Bookworm
- Interface web: visionneuse mails + admin (comptes, domaine, dashboard)
- Chaque compte mail génère automatiquement un share Samba
- Processeur cron: extraction pièces jointes via zbateson/mail-mime-parser
- Zéro injection SQL (PDO + prepared statements)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jules
2026-05-04 09:36:35 +02:00
commit 0be1b9119a
21 changed files with 1627 additions and 0 deletions

31
web/includes/db.php Normal file
View File

@@ -0,0 +1,31 @@
<?php
function db(): PDO {
static $pdo = null;
if ($pdo !== null) return $pdo;
$cfg = require __DIR__ . '/../../config.php';
$dsn = "mysql:host={$cfg['db_host']};dbname={$cfg['db_name']};charset=utf8mb4";
$pdo = new PDO($dsn, $cfg['db_user'], $cfg['db_pass'], [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
]);
return $pdo;
}
function cfg(string $key, string $default = ''): string {
static $cache = [];
if (!isset($cache[$key])) {
$st = db()->prepare('SELECT value FROM config WHERE `key` = ?');
$st->execute([$key]);
$row = $st->fetch();
$cache[$key] = $row ? $row['value'] : $default;
}
return $cache[$key];
}
function cfg_set(string $key, string $value): void {
db()->prepare('INSERT INTO config (`key`, value) VALUES (?, ?) ON DUPLICATE KEY UPDATE value = ?')
->execute([$key, $value, $value]);
}