@@ -32,3 +32,25 @@ function require_login(?string $loginPage = '/login.php'): void
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function csrf_token(): string
|
||||
{
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if (empty($_SESSION['csrf_token'])) {
|
||||
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
|
||||
}
|
||||
return $_SESSION['csrf_token'];
|
||||
}
|
||||
|
||||
function verify_csrf(?string $token): bool
|
||||
{
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
if (empty($_SESSION['csrf_token']) || !$token) {
|
||||
return false;
|
||||
}
|
||||
return hash_equals($_SESSION['csrf_token'], $token);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
function hh_encrypt_secret(string $plain): string
|
||||
{
|
||||
$keyMaterial = getenv('APP_SECRET_KEY') ?: '';
|
||||
if ($keyMaterial === '') {
|
||||
throw new RuntimeException('APP_SECRET_KEY manquant');
|
||||
}
|
||||
$key = hash('sha256', $keyMaterial, true);
|
||||
$iv = random_bytes(16);
|
||||
$cipher = openssl_encrypt($plain, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
||||
if ($cipher === false) {
|
||||
throw new RuntimeException('Chiffrement impossible');
|
||||
}
|
||||
return base64_encode($iv . $cipher);
|
||||
}
|
||||
|
||||
function hh_decrypt_secret(string $encrypted): string
|
||||
{
|
||||
$keyMaterial = getenv('APP_SECRET_KEY') ?: '';
|
||||
if ($keyMaterial === '') {
|
||||
throw new RuntimeException('APP_SECRET_KEY manquant');
|
||||
}
|
||||
$raw = base64_decode($encrypted, true);
|
||||
if ($raw === false || strlen($raw) <= 16) {
|
||||
throw new RuntimeException('Secret invalide');
|
||||
}
|
||||
$key = hash('sha256', $keyMaterial, true);
|
||||
$iv = substr($raw, 0, 16);
|
||||
$cipher = substr($raw, 16);
|
||||
$plain = openssl_decrypt($cipher, 'AES-256-CBC', $key, OPENSSL_RAW_DATA, $iv);
|
||||
if ($plain === false) {
|
||||
throw new RuntimeException('Déchiffrement impossible');
|
||||
}
|
||||
return $plain;
|
||||
}
|
||||
@@ -22,6 +22,7 @@ return [
|
||||
'menu_budget' => 'Pressupost',
|
||||
'menu_holidays' => 'Viatges',
|
||||
'menu_gifts' => 'Regals',
|
||||
'menu_calendar_ios' => 'Calendari iOS',
|
||||
'nav_home' => 'Inici',
|
||||
'nav_calendar' => 'Calendari',
|
||||
'nav_budget' => 'Pressupost',
|
||||
@@ -95,6 +96,8 @@ return [
|
||||
'menu_memo' => 'Notes',
|
||||
'mod_todo_name' => 'Todo',
|
||||
'mod_todo_desc' => 'Gestioneu les vostres tasques, llistes de la compra i recordatoris familiars.',
|
||||
'mod_calendar_ios_name' => 'Calendari iOS',
|
||||
'mod_calendar_ios_desc' => 'Sincronitzeu els esdeveniments de HouseHub amb el calendari de l\'iPhone (iCloud CalDAV).',
|
||||
'menu_todo' => 'Todo',
|
||||
'cta_open' => 'Obrir',
|
||||
'cta_explore' => 'Explorar',
|
||||
@@ -103,6 +106,7 @@ return [
|
||||
'cta_service' => 'Revisar',
|
||||
'cta_jot' => 'Apuntar',
|
||||
'cta_check' => 'Marcar',
|
||||
'cta_sync' => 'Sincronitzar',
|
||||
|
||||
// ==========================================
|
||||
// FAMILY CALENDAR
|
||||
|
||||
@@ -23,6 +23,7 @@ return [
|
||||
'menu_budget' => 'Budget',
|
||||
'menu_holidays' => 'Trips',
|
||||
'menu_gifts' => 'Gifts',
|
||||
'menu_calendar_ios' => 'iOS Calendar',
|
||||
'nav_home' => 'Home',
|
||||
'nav_calendar' => 'Calendar',
|
||||
'nav_budget' => 'Budget',
|
||||
@@ -96,6 +97,8 @@ return [
|
||||
'menu_memo' => 'Notes',
|
||||
'mod_todo_name' => 'Todo',
|
||||
'mod_todo_desc' => 'Manage tasks, shopping lists and family reminders.',
|
||||
'mod_calendar_ios_name' => 'iOS Calendar',
|
||||
'mod_calendar_ios_desc' => 'Sync HouseHub events with your iPhone calendar (iCloud CalDAV).',
|
||||
'menu_todo' => 'Todo',
|
||||
'cta_open' => 'Open',
|
||||
'cta_explore' => 'Explore',
|
||||
@@ -104,6 +107,7 @@ return [
|
||||
'cta_service' => 'Service',
|
||||
'cta_jot' => 'Jot down',
|
||||
'cta_check' => 'Check off',
|
||||
'cta_sync' => 'Sync',
|
||||
|
||||
// ==========================================
|
||||
// FAMILY CALENDAR
|
||||
|
||||
@@ -24,6 +24,7 @@ return [
|
||||
'menu_budget' => 'Budget',
|
||||
'menu_holidays' => 'Voyages',
|
||||
'menu_gifts' => 'Cadeaux',
|
||||
'menu_calendar_ios' => 'Calendrier iOS',
|
||||
'nav_home' => 'Accueil',
|
||||
'nav_calendar' => 'Calendrier',
|
||||
'nav_budget' => 'Budget',
|
||||
@@ -98,6 +99,8 @@ return [
|
||||
'menu_memo' => 'Notes',
|
||||
'mod_todo_name' => 'Todo',
|
||||
'mod_todo_desc' => 'Gérez vos tâches, listes de courses et rappels en famille.',
|
||||
'mod_calendar_ios_name' => 'Calendrier iOS',
|
||||
'mod_calendar_ios_desc' => 'Synchronisez vos événements HouseHub avec votre calendrier iPhone (iCloud CalDAV).',
|
||||
'menu_todo' => 'Todo',
|
||||
'cta_open' => 'Ouvrir',
|
||||
'cta_explore' => 'Explorer',
|
||||
@@ -106,6 +109,7 @@ return [
|
||||
'cta_service' => 'Réviser',
|
||||
'cta_jot' => 'Griffonner',
|
||||
'cta_check' => 'Cocher',
|
||||
'cta_sync' => 'Synchroniser',
|
||||
|
||||
// ==========================================
|
||||
// FAMILY CALENDAR
|
||||
|
||||
Reference in New Issue
Block a user