Atlas: Tile-Proxy + Leaflet lokal — DSGVO-Sanierung fuer Kartendienste

- Leaflet 1.9.4 (CSS + JS + 5 Marker-Images) lokal unter
  App/assets/vendor/leaflet/ statt via unpkg.com/Cloudflare
- Neuer PHP-Endpunkt App/php/tile-proxy.php mit Disk-Cache, liefert
  OSM- und CARTO-Kacheln serverseitig aus; Browser kontaktiert keinen
  Drittanbieter mehr
- Whitelist (osm, carto), Zoom 3-18, 30 Tage Browser-Cache, ETag +
  If-Modified-Since, sauberer User-Agent fuer OSM-Policy
- Cache-Pfad: APP_ROOT/data/tiles lokal, via .env TILE_CACHE_DIR
  auf Produktions-Volume /var/www/html/geograsim/data/tiles
- Heli (heli.php + heli-game.php), Logistik (logistik.php), Routes-
  Dev-Tool und admin-levels.html alle auf Proxy umgestellt
- Datenschutzerklaerung: alter Google-AdSense-Passus (falsch, nicht
  im Einsatz) entfernt, neuer Abschnitt zur serverseitigen
  Tile-Auslieferung mit Rechtsgrundlage Art. 6 Abs. 1 lit. f DSGVO
- .gitignore: App/data/tiles ausgeschlossen
- .env.example: TILE_CACHE_DIR + OpenAI/ElevenLabs dokumentiert

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-20 00:53:43 +02:00
parent 3885c83294
commit eac686ee1a
15 changed files with 1380 additions and 8 deletions
+21 -1
View File
@@ -9,6 +9,16 @@ require_once __DIR__ . '/../php/config/db.php';
$db = getDB();
$rows = $db->query("SELECT wp_key, name, lat, lon, wp_type, info FROM geo_waypoints")->fetchAll(PDO::FETCH_ASSOC);
// Facts pro Waypoint (geo + kids) — falls Tabelle existiert, sonst leer
$factsByKey = [];
try {
$factRows = $db->query("SELECT wp_key, kind, text_de FROM geo_waypoint_facts ORDER BY wp_key, kind, display_order")->fetchAll(PDO::FETCH_ASSOC);
foreach ($factRows as $f) {
$factsByKey[$f['wp_key']][$f['kind']][] = $f['text_de'];
}
} catch (Exception $e) { /* Tabelle fehlt → Script-freundlich weitermachen */ }
$factsJson = json_encode($factsByKey, JSON_UNESCAPED_UNICODE);
$wpJs = "{\n";
foreach ($rows as $w) {
$key = $w['wp_key'];
@@ -34,10 +44,20 @@ $html = file_get_contents(__DIR__ . '/../sims/heli/game.html');
// Placeholder ersetzen — HELI_BASE aus BASE_PATH ableiten (funktioniert lokal + produktiv)
$base = BASE_PATH . '/sims/heli/';
$html = str_replace('/*__DB_WAYPOINTS__*/',
"window.HELI_BASE = '$base';\nvar WP = $wpJs;\nvar wpLoaded = true;\nvar DB_POIS = $poisJs;", $html);
"window.HELI_BASE = '$base';\nvar WP = $wpJs;\nvar wpLoaded = true;\nvar DB_POIS = $poisJs;\nvar HELI_FACTS = $factsJson;", $html);
// Head-Asset-Pfade auf BASE_PATH umbiegen (relative ../../ greift unter /heli-game-Route falsch)
$html = str_replace('href="../../favicon-96x96.png"', 'href="' . BASE_PATH . '/favicon-96x96.png"', $html);
$html = str_replace('href="../../assets/fonts/inter.css"', 'href="' . BASE_PATH . '/assets/fonts/inter.css"', $html);
// Leaflet lokal + Tile-Proxy (DSGVO-sicher, kein Drittanbieter-Kontakt aus Browser)
$leafletCss = BASE_PATH . '/assets/vendor/leaflet/leaflet.css';
$leafletJs = BASE_PATH . '/assets/vendor/leaflet/leaflet.js';
$tileProxy = BASE_PATH . '/php/tile-proxy.php';
$html = strtr($html, [
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css' => $leafletCss,
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js' => $leafletJs,
"'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png'" => "'{$tileProxy}?z={z}&x={x}&y={y}&p=osm'",
]);
echo $html;
+3 -3
View File
@@ -19,7 +19,7 @@ $wpJson = json_encode($waypoints, JSON_UNESCAPED_UNICODE);
<title>GeoGraSim — Helikopter-Übersichtskarte</title>
<link rel="icon" type="image/png" href="favicon-96x96.png" sizes="96x96">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">
<link rel="stylesheet" href="<?= BASE_PATH ?>/assets/vendor/leaflet/leaflet.css">
<link rel="stylesheet" href="assets/fonts/inter.css">
<style>
*{margin:0;padding:0;box-sizing:border-box}
@@ -40,14 +40,14 @@ $wpJson = json_encode($waypoints, JSON_UNESCAPED_UNICODE);
</head>
<body>
<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js"></script>
<script src="<?= BASE_PATH ?>/assets/vendor/leaflet/leaflet.js"></script>
<script>
// Waypoints direkt aus der DB (PHP-injiziert)
var DB_WAYPOINTS = <?= $wpJson ?>;
var map = L.map('map', {zoomControl:false, maxBoundsViscosity:1.0, minZoom:7, maxZoom:15})
.setView([47.4, 13.2], 8);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
L.tileLayer('<?= BASE_PATH ?>/php/tile-proxy.php?z={z}&x={x}&y={y}&p=osm', {
attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>', maxZoom:18
}).addTo(map);
L.control.zoom({position:'topright'}).addTo(map);
+19
View File
@@ -51,4 +51,23 @@ window.LOGISTIK_LEVELS = {$levelsJson};
JS;
$html = str_replace('/*__LOGISTIK_INJECTION__*/', $injection, $html);
// Relative Asset-Pfade aus game.html auf BASE_PATH/LOGISTIK_BASE umbiegen
// (unter /App/logistik würden ../../ falsch aufgelöst — siehe heli-game.php).
$tileProxy = BASE_PATH . '/php/tile-proxy.php';
$html = strtr($html, [
'href="../../assets/css/design-system.css"' => 'href="' . BASE_PATH . '/assets/css/design-system.css"',
'href="../../assets/fonts/inter.css"' => 'href="' . BASE_PATH . '/assets/fonts/inter.css"',
'src="../../assets/img/bildLogo.png"' => 'src="' . BASE_PATH . '/assets/img/bildLogo.png"',
'src="../../assets/img/textlogo_geograsim.svg"' => 'src="' . BASE_PATH . '/assets/img/textlogo_geograsim.svg"',
'href="../../sim"' => 'href="' . BASE_PATH . '/sim"',
'href="../../"' => 'href="' . BASE_PATH . '/"',
'src="engine.js"' => 'src="' . $base . 'engine.js"',
'src="headless-runner.js"' => 'src="' . $base . 'headless-runner.js"',
// Leaflet lokal + Tile-Proxy (DSGVO-sicher)
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.css' => BASE_PATH . '/assets/vendor/leaflet/leaflet.css',
'https://unpkg.com/leaflet@1.9.4/dist/leaflet.js' => BASE_PATH . '/assets/vendor/leaflet/leaflet.js',
"'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png'" => "'{$tileProxy}?z={z}&x={x}&y={y}&p=carto'",
]);
echo $html;