feat: mentions légales — FAI détecté via AS (cache PHP 24h)
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Récupère l'IP publique et les infos AS du FAI courant.
|
||||
# Résultat dans config/network-info.json — lu par templates/legal.php
|
||||
set -euo pipefail
|
||||
|
||||
OUT="/var/www/lan.acegrp.varlog/config/network-info.json"
|
||||
|
||||
json=$(curl -sf --max-time 10 "https://ipinfo.io/json")
|
||||
|
||||
if [ -z "$json" ]; then
|
||||
echo "Erreur : réponse vide de ip-api.com" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "$json" > "$OUT"
|
||||
echo "$(date -u +%Y-%m-%dT%H:%M:%SZ) — network-info mis à jour : $json"
|
||||
+31
-1
@@ -1,4 +1,27 @@
|
||||
<?php
|
||||
$networkFile = BASE_PATH . '/config/network-info.json';
|
||||
$cacheTtl = 86400; // 1 jour
|
||||
|
||||
$needsFetch = !file_exists($networkFile)
|
||||
|| (time() - filemtime($networkFile)) > $cacheTtl;
|
||||
|
||||
$networkInfo = [];
|
||||
|
||||
if ($needsFetch) {
|
||||
$ctx = stream_context_create(['http' => ['timeout' => 5, 'ignore_errors' => true]]);
|
||||
$raw = @file_get_contents('https://ipinfo.io/json', false, $ctx);
|
||||
if ($raw && ($decoded = json_decode($raw, true)) !== null) {
|
||||
file_put_contents($networkFile, $raw);
|
||||
$networkInfo = $decoded;
|
||||
} elseif (file_exists($networkFile)) {
|
||||
$networkInfo = json_decode(file_get_contents($networkFile), true) ?? [];
|
||||
}
|
||||
} else {
|
||||
$networkInfo = json_decode(file_get_contents($networkFile), true) ?? [];
|
||||
}
|
||||
|
||||
$faiOrg = $networkInfo['org'] ?? null;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
|
||||
@@ -23,7 +46,14 @@ ob_start();
|
||||
<div class="card-body">
|
||||
<p class="mb-1"><strong>Type :</strong> Auto-hébergement sur infrastructure personnelle (HomeLab)</p>
|
||||
<p class="mb-1"><strong>Exploitant :</strong> Cédric Abonnel</p>
|
||||
<p class="mb-0"><strong>Fournisseur d'accès à internet :</strong> [FAI]</p>
|
||||
<p class="mb-0">
|
||||
<strong>Fournisseur d'accès à internet :</strong>
|
||||
<?php if ($faiOrg): ?>
|
||||
<?= htmlspecialchars($faiOrg) ?>
|
||||
<?php else: ?>
|
||||
Infrastructure personnelle auto-hébergée
|
||||
<?php endif; ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user