Files
geo/bao/bin/decrypt-entite
pierre 2f5946a184 feat: Version 3.5.2 - Configuration Stripe et gestion des immeubles
- Configuration complète Stripe pour les 3 environnements (DEV/REC/PROD)
  * DEV: Clés TEST Pierre (mode test)
  * REC: Clés TEST Client (mode test)
  * PROD: Clés LIVE Client (mode live)
- Ajout de la gestion des bases de données immeubles/bâtiments
  * Configuration buildings_database pour DEV/REC/PROD
  * Service BuildingService pour enrichissement des adresses
- Optimisations pages et améliorations ergonomie
- Mises à jour des dépendances Composer
- Nettoyage des fichiers obsolètes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-09 18:26:27 +01:00

115 lines
3.8 KiB
PHP
Executable File

#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
* Script de décryptage d'une entité (amicale) spécifique
* Usage: ./decrypt-entite <environment> <entite_id>
*/
require_once __DIR__ . '/../lib/CryptoService.php';
require_once __DIR__ . '/../lib/DatabaseConnection.php';
require_once __DIR__ . '/../lib/helpers.php';
// Vérifier les arguments
if ($argc < 3) {
error("Usage: " . basename($argv[0]) . " <environment> <entite_id>");
error("Exemple: " . basename($argv[0]) . " dva 5");
exit(1);
}
$environment = strtoupper($argv[1]);
$entiteId = (int)$argv[2];
try {
// Ouvrir le tunnel SSH si nécessaire
$tunnelScript = __DIR__ . '/_ssh-tunnel.sh';
exec("$tunnelScript open $environment 2>&1", $output, $exitCode);
if ($exitCode !== 0) {
error("Impossible d'ouvrir le tunnel SSH");
exit(1);
}
// Connexion à la base de données
$db = new DatabaseConnection($environment);
$pdo = $db->connect();
info("Environnement: $environment");
info("Recherche de l'entité #$entiteId...\n");
// Requête pour récupérer l'entité
$stmt = $pdo->prepare("
SELECT
e.*,
COUNT(DISTINCT u.id) as nb_users,
COUNT(DISTINCT o.id) as nb_operations
FROM entites e
LEFT JOIN users u ON u.fk_entite = e.id
LEFT JOIN operations o ON o.fk_entite = e.id
WHERE e.id = :entite_id
GROUP BY e.id
");
$stmt->execute(['entite_id' => $entiteId]);
$entite = $stmt->fetch();
if (!$entite) {
error("Entité #$entiteId introuvable");
exit(1);
}
// Déchiffrer les données
$config = DatabaseConfig::getInstance();
$crypto = new CryptoService($config->getEncryptionKey());
$entite['name'] = $crypto->decryptWithIV($entite['encrypted_name']);
$entite['email'] = $crypto->decryptSearchable($entite['encrypted_email']);
$entite['phone'] = $crypto->decryptWithIV($entite['encrypted_phone']);
$entite['mobile'] = $crypto->decryptWithIV($entite['encrypted_mobile']);
$entite['iban'] = $crypto->decryptWithIV($entite['encrypted_iban']);
$entite['bic'] = $crypto->decryptWithIV($entite['encrypted_bic']);
// Affichage
title("ENTITÉ (AMICALE) #" . $entite['id']);
echo color("Identité\n", 'bold');
display("Nom", $entite['name']);
display("Email", $entite['email']);
display("Téléphone", $entite['phone']);
display("Mobile", $entite['mobile']);
echo "\n" . color("Adresse\n", 'bold');
display("Adresse 1", $entite['adresse1'] ?: '-');
display("Adresse 2", $entite['adresse2'] ?: '-');
display("Code postal", $entite['code_postal'] ?: '-');
display("Ville", $entite['ville'] ?: '-');
echo "\n" . color("Coordonnées bancaires\n", 'bold');
display("IBAN", $entite['iban'] ?: '-');
display("BIC", $entite['bic'] ?: '-');
echo "\n" . color("Configuration\n", 'bold');
display("Stripe activé", $entite['chk_stripe'] ? 'Oui' : 'Non');
display("Gestion MDP manuelle", $entite['chk_mdp_manuel'] ? 'Oui' : 'Non');
display("Gestion username manuelle", $entite['chk_username_manuel'] ? 'Oui' : 'Non');
display("Copie mail reçu", $entite['chk_copie_mail_recu'] ? 'Oui' : 'Non');
display("Accepte SMS", $entite['chk_accept_sms'] ? 'Oui' : 'Non');
echo "\n" . color("Statistiques\n", 'bold');
display("Nombre d'utilisateurs", (string)$entite['nb_users']);
display("Nombre d'opérations", (string)$entite['nb_operations']);
echo "\n" . color("Dates\n", 'bold');
display("Date création", formatDate($entite['created_at']));
display("Dernière modif", formatDate($entite['updated_at']));
echo "\n";
success("Entité déchiffrée avec succès");
} catch (Exception $e) {
error("Erreur: " . $e->getMessage());
exit(1);
}