HifiPlanet-Website/hifi/api/public/sitemap.php
Maaxxs 54928d1411 Add package badges/visibility and a download area, speed up the site
Customer feedback round (4 items):

- Packages: one-click "Sichtbar/Ausgeblendet" toggle per package (saved
  immediately). Hidden packages disappear from the model page; the tier
  look of the remaining cards is ranked across all packages so it stays
  stable.
- Packages: badge per card (Empfohlen, Am beliebtesten, Tipp, Coming soon
  or custom text) plus an optional video link shown as "Zum Video". Legacy
  is_featured maps to "Empfohlen".
- New download area (/downloads + Admin -> Downloads): upload with
  progress, inline audio player, allow-listed file types, optional access
  password, new permission downloads.manage. Files live in
  api/uploads/downloads/ (gitignored, created at runtime).
- Performance:
  - SetupGate no longer refetches and remounts the whole app on every
    navigation.
  - Page loader waits only for pending API calls and above-the-fold images
    (fixes an 8 s hang on /leistungen caused by lazy images inside the
    hidden container).
  - Admin pages lazy-loaded; icon library moved out of the main bundle
    (initial JS 2.2 MB -> 0.48 MB).
  - Background video loads only near the viewport and was re-encoded to
    720p (32 MB -> 8.5 MB).
  - Visitors without a session cookie get no PHP session, so their parallel
    API requests no longer queue on the session lock.
  - index.html is served with Cache-Control: no-cache so browsers don't
    keep a stale build after deploys.
- Fonts (Barlow, Barlow Condensed, Michroma) are self-hosted instead of
  loaded from Google Fonts; the default privacy policy mentions this, lists
  all local storage uses and uses the new TDDDG name.
- A code update that adds a table no longer sends the site into the setup
  wizard while an admin exists.

Run "Datenbankstruktur aktualisieren" after deploying (new package
columns, downloads table, app_settings.downloads_password).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 23:15:48 +02:00

52 lines
1.8 KiB
PHP

<?php
require __DIR__ . '/../vendor/autoload.php';
use App\Config\Database;
use App\Controllers\DownloadController;
$config = require __DIR__ . '/../config/config.php';
$siteUrl = rtrim($config['app']['site_url'], '/');
$db = Database::connection();
$models = $db->query(
'SELECT b.slug AS brand_slug, m.slug AS model_slug, m.updated_at
FROM car_models m JOIN brands b ON b.id = m.brand_id'
)->fetchAll();
$brands = $db->query('SELECT slug, updated_at FROM brands')->fetchAll();
$urls = [
['loc' => '/', 'priority' => '1.0'],
['loc' => '/fahrzeuge', 'priority' => '0.9'],
['loc' => '/kontakt', 'priority' => '0.5'],
];
// Passwortgeschuetzt zeigt die Seite nur ein Eingabefeld - nichts, was ein Suchmaschinen-
// Eintrag wert waere.
if (DownloadController::hasVisible() && !DownloadController::isProtected()) {
$urls[] = ['loc' => '/downloads', 'priority' => '0.4'];
}
foreach ($brands as $brand) {
$urls[] = ['loc' => "/fahrzeuge/{$brand['slug']}", 'priority' => '0.8', 'lastmod' => $brand['updated_at']];
}
foreach ($models as $model) {
$urls[] = [
'loc' => "/fahrzeuge/{$model['brand_slug']}/{$model['model_slug']}",
'priority' => '0.7',
'lastmod' => $model['updated_at'],
];
}
header('Content-Type: application/xml; charset=utf-8');
echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
foreach ($urls as $url) {
echo " <url>\n";
echo ' <loc>' . htmlspecialchars($siteUrl . $url['loc']) . "</loc>\n";
if (!empty($url['lastmod'])) {
echo ' <lastmod>' . date('Y-m-d', strtotime($url['lastmod'])) . "</lastmod>\n";
}
echo ' <priority>' . $url['priority'] . "</priority>\n";
echo " </url>\n";
}
echo '</urlset>';