feat: mentions légales — FAI détecté via AS (cache PHP 24h)
This commit is contained in:
+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