eac686ee1a
- 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>
64 lines
2.6 KiB
PHP
64 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* Heli-Spiel — saubere PHP-Seite
|
|
* Waypoints kommen ausschließlich aus der DB
|
|
*/
|
|
require_once __DIR__ . '/../php/config/app.php';
|
|
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'];
|
|
$name = addslashes($w['name']);
|
|
$wpJs .= " '$key':{lat:{$w['lat']},lon:{$w['lon']},name:'$name'},\n";
|
|
}
|
|
$wpJs .= "}";
|
|
|
|
// POIs für die Karte (nur Basen, Städte, Gipfel)
|
|
$poisJs = "[\n";
|
|
foreach ($rows as $w) {
|
|
if (in_array($w['wp_type'], ['base','city','peak'])) {
|
|
$name = addslashes($w['name']);
|
|
$info = addslashes($w['info'] ?? '');
|
|
$poisJs .= " {key:'{$w['wp_key']}',name:'$name',lat:{$w['lat']},lon:{$w['lon']},type:'{$w['wp_type']}',info:'$info'},\n";
|
|
}
|
|
}
|
|
$poisJs .= "]";
|
|
|
|
// game.html laden
|
|
$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;\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;
|