Besucherzähler für SPA-Landing hinzugefügt

- api/counter.php: PHP-basierter Zähler mit Session-Tracking
- Zähler-Anzeige im Footer der Landingpage
- counter.txt in .gitignore aufgenommen

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
architeur
2025-12-29 13:47:00 +01:00
parent 3e27052cc1
commit dd230196ff
3 changed files with 53 additions and 6 deletions

3
.gitignore vendored
View File

@@ -13,6 +13,9 @@ node_modules/
# Temp files
*.tmp
*.bak
# Counter data
api/counter.txt
kostenschaetzung/
schadendokumentation/
zeitwert/

33
api/counter.php Normal file
View File

@@ -0,0 +1,33 @@
<?php
/**
* Besucherzähler API für SPA-Landing
* Gibt den aktuellen Zählerstand als JSON zurück und zählt bei neuen Sessions
*/
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
$counterFile = __DIR__ . '/counter.txt';
// Zähler lesen oder initialisieren
if (file_exists($counterFile)) {
$count = (int) file_get_contents($counterFile);
} else {
$count = 0;
}
// Session starten für Duplikat-Erkennung
session_start();
// Nur zählen wenn noch nicht in dieser Session gezählt
if (!isset($_SESSION['spa_counted'])) {
$count++;
file_put_contents($counterFile, $count);
$_SESSION['spa_counted'] = true;
}
// JSON-Antwort
echo json_encode([
'count' => $count,
'formatted' => number_format($count, 0, ',', '.')
]);

View File

@@ -280,12 +280,13 @@
</main>
<footer class="footer">
<p>artetui.de · SPA Platform · Alle Daten werden lokal gespeichert</p>
<p style="margin-top:0.5rem;font-size:0.85rem;opacity:0.7;">Besucher: <span id="visitor-count">...</span></p>
<p style="text-align:center;margin-top:0.5rem;font-size:0.85rem;">
<a href="#" onclick="openImpressum();return false;" style="color:#6b7280;text-decoration:none;">Impressum</a>
<span style="color:#d1d5db;margin:0 0.5rem;">|</span>
<a href="#" onclick="openDatenschutz();return false;" style="color:#6b7280;text-decoration:none;">Datenschutz</a>
</p>
</footer>
</p>
</footer>
<script>
function toggleTheme() {
const html = document.documentElement;
@@ -297,6 +298,16 @@
const savedTheme = localStorage.getItem("theme") || "light";
document.documentElement.setAttribute("data-theme", savedTheme);
})();
// Besucherzähler laden
fetch('/api/counter.php')
.then(r => r.json())
.then(data => {
document.getElementById('visitor-count').textContent = data.formatted;
})
.catch(() => {
document.getElementById('visitor-count').textContent = '-';
});
</script>