HifiPlanet-Website/hifi/index.html
Maaxxs 3ea5bd4201 Add one-click git-based auto-update (manual trigger only)
Phase 6 of the dashboard roadmap - the largest and riskiest item, since
it overwrites live production code. Pulls the current main branch from
the public Gitea repo over plain HTTPS (archive zip download + REST API
for commit info) and applies it to the live hifi/ tree - no SSH,
git binary, exec(), or shell_exec() anywhere, so it works on plain
shared PHP hosting with no CI/deploy pipeline (exactly the hosting this
site actually runs on, per DEPLOY.md's manual-FTP fallback).

Six independent endpoints (status/check/download/extract/backup/apply)
instead of one big request, mirroring the existing multi-step
SetupController pattern - this app has no job-queue infrastructure, and
a single ~127MB download+extract+backup+copy is the most likely way to
hit an unknown host's max_execution_time or reverse-proxy timeout.
GitUpdateService.php does the actual work; UpdateController.php is a
thin adapter that marks each step in-progress/failed in a new gitignored
update-state.php (same convention as db.php) so a crashed step shows as
failed rather than stuck, and a retry starts clean.

Security-critical bits:
- The backup zip necessarily contains db.php (must be fully restorable),
  so it lives under hifi/_update/ behind a "Require all denied" .htaccess
  written the instant the directory is created, and hifi/_update/ was
  added to .gitignore in this same commit, before any code that could
  write into it - both needed since a physically-existing file bypasses
  this app's SPA-fallback/API rewrite rules entirely.
- Only hifi/'s own subtree is extracted from the archive (hifi-src/ and
  everything else ignored) via a wrapper-folder-prefix detected at
  runtime, not hardcoded.
- Copy-then-prune (not copy-only) across the whole hifi/ tree, since
  Vite renames JS/CSS chunks on every build and a copy-only updater
  would let stale chunks accumulate forever - guarded by a denylist
  (db.php, setup.php, ga-service-account.json, update-state.php,
  api/uploads/, plus local Claude-tooling dirs) that must never be
  touched in either direction.
- index.html is swapped in last via copy+rename (near-atomic), after
  the new hashed assets it references are already fully in place.
- Reuses SchemaController's existing migration logic as the last apply
  step (extracted into a new runMigration() so it's callable without
  Http::send()/exit ending the response early) and app_settings'
  existing maintenance-mode column to show visitors a maintenance page
  during the brief apply window, restoring whatever maintenance state
  existed before the update ran (not just forcing it off).

Gated behind a new, narrower system.update permission (not the broader
settings.manage), with its own settings tab hidden from anyone lacking
it - unlike this app's usual "everyone with settings.manage sees every
tab" pattern, since this one can overwrite the whole site.

Verified in isolation (synthetic zip + fixture directories in a scratch
folder, not the real hifi/ tree): wrapper-folder detection and
selective hifi/-subtree extraction, and copy+prune with denylist
enforcement. Not yet verified: behavior on an actual shared-hosting
target (max_execution_time, ZipArchive availability, outbound HTTPS
egress, disk quota vs disk_free_space()) - per the plan, validate
against the Plesk test server from DEPLOY.md before ever running this
against a real client site. Also enabled the php_zip extension in the
local XAMPP php.ini, since it was disabled and this feature needs it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-09 02:16:41 +02:00

53 lines
2.8 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="de">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/png" href="/favicon.png" />
<!-- Nur fuer die Paket-Kacheln auf der Modell-Seite (Name/Preis-Typografie im
Kunden-Referenzdesign) - der Rest der Seite bleibt beim Standard-Font. -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Barlow:wght@400;500;600;700&family=Barlow+Condensed:wght@500;600&family=Michroma&display=swap" rel="stylesheet" />
<title>HifiPlanet | Car-Hifi Umbauten nach Maß</title>
<meta name="description" content="HifiPlanet – dein Car-Hifi Spezialist. Marke und Modell wählen, passende Sound-Pakete entdecken und unverbindlich anfragen." />
<link rel="canonical" href="https://hifi-planet.de/" />
<meta property="og:type" content="website" />
<meta property="og:site_name" content="HifiPlanet" />
<meta property="og:title" content="HifiPlanet | Car-Hifi Umbauten nach Maß" />
<meta property="og:description" content="Dein Car-Hifi Spezialist: Marke und Modell wählen, passende Sound-Pakete entdecken und unverbindlich anfragen." />
<meta property="og:locale" content="de_DE" />
<meta name="twitter:card" content="summary" />
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "AutoRepair",
"name": "HifiPlanet",
"description": "Car-Hifi Spezialist für individuelle Sound-Umbauten – vom unauffälligen Upgrade bis zum Komplettumbau.",
"url": "https://hifi-planet.de/",
"telephone": "+4993732062390",
"email": "info@hifi-planet-amorbach.de",
"address": {
"@type": "PostalAddress",
"streetAddress": "Boxbrunner Str. 20a",
"postalCode": "63916",
"addressLocality": "Amorbach",
"addressCountry": "DE"
},
"openingHoursSpecification": [
{ "@type": "OpeningHoursSpecification", "dayOfWeek": ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday"], "opens": "09:00", "closes": "18:00" },
{ "@type": "OpeningHoursSpecification", "dayOfWeek": ["Saturday"], "opens": "10:00", "closes": "13:00" }
],
"sameAs": ["https://www.youtube.com/@hifiplanet2812"]
}
</script>
<script type="module" crossorigin src="/assets/index-DMjv3wnD.js"></script>
<link rel="modulepreload" crossorigin href="/assets/lucide-icons-Cg2IxtAO.js">
<link rel="stylesheet" crossorigin href="/assets/index-DHi-eHhm.css">
</head>
<body class="bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100">
<div id="root"></div>
</body>
</html>