Erster Durchstich mit updates
This commit is contained in:
parent
d3fd60b548
commit
3331f08091
60 changed files with 693 additions and 195 deletions
|
|
@ -1,5 +0,0 @@
|
|||
# Projekt-Anweisungen
|
||||
|
||||
- **Sprache:** Antworte und kommuniziere im Terminal immer auf Deutsch.
|
||||
- **Architektur:** Dieses Projekt nutzt PHP 8.3 und kein Framework.
|
||||
- **Tests:** Führe Tests immer mit `./vendor/bin/phpunit` aus.
|
||||
30
README.md
30
README.md
|
|
@ -20,7 +20,23 @@ Die Web-Oberfläche ist anschließend unter `http://localhost:8080` erreichbar.
|
|||
|
||||
Das alte Projekt basiert auf Laravel und hat einige Features, die im neuen Projekt nicht mehr existieren (wie z.B. "Ligen" oder das "grüne Trikot"). Um mit den echten Testdaten aus dem Live-Betrieb arbeiten zu können, gibt es ein automatisiertes Import-Skript.
|
||||
|
||||
### 1. Legacy Datenbank importieren
|
||||
### Ein-Schritt-Import (empfohlen)
|
||||
|
||||
Das Skript `import_from_dump.sh` erledigt alles automatisch: Es nimmt den neuesten Dump aus dem Legacy-Projekt (`/home/torsten/repos/tippspiel/tools/pfosten*.sql`), legt die Legacy-DB `tippspiel_legacy` neu an, spielt den Dump ein und migriert die Daten anschließend in die neue Datenbank `tippspiel2027` (from scratch).
|
||||
|
||||
```bash
|
||||
./import_from_dump.sh
|
||||
```
|
||||
|
||||
Der Dump-Pfad lässt sich über die Umgebungsvariable `DUMP_DIR` überschreiben:
|
||||
|
||||
```bash
|
||||
DUMP_DIR=/anderer/pfad ./import_from_dump.sh
|
||||
```
|
||||
|
||||
### Manueller Import (einzelne Schritte)
|
||||
|
||||
#### 1. Legacy Datenbank importieren
|
||||
|
||||
Zuerst muss der Dump des alten Tippspiels in den laufenden Datenbank-Container importiert werden. Wir laden den alten SQL-Dump in eine Datenbank namens `tippspiel_legacy`:
|
||||
|
||||
|
|
@ -32,7 +48,7 @@ docker compose exec db mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS tip
|
|||
# docker exec -i $(docker compose ps -q db) mysql -uroot -proot tippspiel_legacy < /pfad/zum/dump.sql
|
||||
```
|
||||
|
||||
### 2. Import-Skript ausführen
|
||||
#### 2. Import-Skript ausführen
|
||||
|
||||
Nachdem die alten Daten in der `tippspiel_legacy` Datenbank liegen, kann das Import-Skript ausgeführt werden. Dieses Skript legt automatisch das neue bereinigte Schema (`schema.sql`) in der neuen Datenbank (`tippspiel2027`) an und migriert die Daten. Tote Features und alte Spalten werden dabei automatisch übersprungen.
|
||||
|
||||
|
|
@ -44,6 +60,16 @@ docker compose exec app php import.php
|
|||
|
||||
Sobald das Skript durchgelaufen ist, sind die sauberen Daten im System und du kannst die Anwendung auf Port 8080 testen.
|
||||
|
||||
## Deployment auf das Testsystem
|
||||
|
||||
Das Skript `deploy_test.py` lädt das Projekt per FTP nach `tippspiel.programmschmiede.de` hoch und erzeugt dabei eine `.htaccess` mit den nötigen Umgebungsvariablen (DB-Zugang, `APP_URL`) im `public/`-Verzeichnis. Die Zugangsdaten werden aus `docs/testsystem_credentials.txt` gelesen.
|
||||
|
||||
```bash
|
||||
./deploy_test.py
|
||||
```
|
||||
|
||||
> Achtung: Zugangsdaten landen als `SetEnv` in der `.htaccess` auf dem Server. Das ist für ein direkt bespielbares Testsystem bewusst so gewollt, sollte aber nicht für ein Produktivsystem übernommen werden.
|
||||
|
||||
## Mailversand
|
||||
|
||||
Rundmails und Erinnerungen werden per SMTP verschickt. Konfiguriert wird das über Umgebungsvariablen des App-Containers:
|
||||
|
|
|
|||
5
docs/testsystem_credentials.txt
Normal file
5
docs/testsystem_credentials.txt
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
mysql_db=d0489c69
|
||||
mysql_pw=$1Superspiel
|
||||
ftp_url=programmschmiede.de
|
||||
ftp_user=w00c9c8c
|
||||
ftp_pw=qreny52h
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
<?php
|
||||
use App\Models\Game;
|
||||
|
||||
$pageTitle = 'Tippspiel 2027 - Startseite';
|
||||
require __DIR__ . '/partials/header.php';
|
||||
?>
|
||||
|
||||
<h1>Willkommen bei Tippspiel 2027</h1>
|
||||
<p>Dies ist die Nachfolgeversion des alten Tippspiels (Pure PHP Variante).</p>
|
||||
|
||||
<p>Datenbank verbunden! Aktuell <strong><?php echo $userCount; ?></strong> User im System.</p>
|
||||
|
||||
<h2>Rundenübersicht</h2>
|
||||
<?php if ($currentSeason): ?>
|
||||
<p>Saison: <strong><?php echo htmlspecialchars($currentSeason['name']); ?></strong></p>
|
||||
<?php if ($rounds): ?>
|
||||
<ul>
|
||||
<?php foreach ($rounds as $round): ?>
|
||||
<li><a href="/index.php?page=round&id=<?php echo htmlspecialchars($round['id']); ?>"><?php echo htmlspecialchars($round['name']); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p>Keine Runden für die aktuelle Saison gefunden.</p>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<p>Keine Saison gefunden.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<hr>
|
||||
<h3>Debug-Informationen</h3>
|
||||
<p>Versuch, das Joker-Icon zu laden:</p>
|
||||
<ul>
|
||||
<li>Pfad im <code><img></code>-Tag: <code>/img/joker.png</code></li>
|
||||
<li>Erwarteter physischer Speicherort: <code>public/img/joker.png</code></li>
|
||||
<li>Test-Link: <a href="/img/joker.png" target="_blank">Öffne Icon in neuem Tab</a></li>
|
||||
<li>Test-Anzeige: <img src="/img/joker.png" alt="Test" style="width: 20px; height: 20px; border: 1px solid red; vertical-align: middle;"></li>
|
||||
</ul>
|
||||
<hr>
|
||||
|
||||
<h2>Portierte Backend-Logik (Test)</h2>
|
||||
|
||||
<h3>Punkteberechnung</h3>
|
||||
<p>Test: Spiel endet 2:1, getippt wurde 2:1 mit Joker. Erwartet: 4 Punkte. <strong>Berechnet: <?php echo $scoreTest; ?> Punkte</strong>.</p>
|
||||
|
||||
<h3>Spiele der letzten gespielten Runde</h3>
|
||||
<?php if ($lastRoundId && $games): ?>
|
||||
<ul>
|
||||
<?php foreach ($games as $g): ?>
|
||||
<?php
|
||||
$status = Game::getResultString($g['score1'], $g['score2'], $g['kickoff']);
|
||||
$locked = Game::isLocked($g['kickoff']) ? "Gesperrt" : "Offen";
|
||||
?>
|
||||
<li><?php echo htmlspecialchars($g['team1'] . " vs " . $g['team2']) . " | Status: $status | $locked"; ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php else: ?>
|
||||
<p>Keine gespielten Spiele gefunden.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php require __DIR__ . '/partials/footer.php'; ?>
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<?php
|
||||
use App\Models\Quota;
|
||||
|
||||
$pageTitle = 'Quoten';
|
||||
require __DIR__ . '/../partials/header.php';
|
||||
|
||||
$euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
|
||||
?>
|
||||
|
||||
<?php if (!$currentSeason): ?>
|
||||
<p>Es gibt noch keine Saison.</p>
|
||||
<?php else: ?>
|
||||
<h1><?php echo htmlspecialchars($currentSeason['name']); ?></h1>
|
||||
<h2>Ausschüttungs-Quoten</h2>
|
||||
|
||||
<h3>Spiel-Einsatz</h3>
|
||||
<table class="info-table">
|
||||
<tr><th>Aktive Spieler</th><td><?php echo $activeUserCount; ?></td></tr>
|
||||
<tr><th>Einsatz pro Spieler</th><td><?php echo $euro($stake); ?></td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Spielquoten</h3>
|
||||
<table class="info-table">
|
||||
<tr><th>Tagessieg</th><td><?php echo $euro($payouts['tagessieg']); ?></td></tr>
|
||||
</table>
|
||||
|
||||
<h3>Platzierungsquoten</h3>
|
||||
<table class="info-table">
|
||||
<?php for ($place = 1; $place <= Quota::PLACES; $place++): ?>
|
||||
<tr><th>Platz <?php echo $place; ?></th><td><?php echo $euro($payouts['platz' . $place]); ?></td></tr>
|
||||
<?php endfor; ?>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<style>
|
||||
.info-table { width: auto; min-width: 350px; }
|
||||
.info-table th { width: 200px; font-weight: normal; }
|
||||
.info-table td { text-align: right; }
|
||||
</style>
|
||||
|
||||
<?php require __DIR__ . '/../partials/footer.php'; ?>
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
</main>
|
||||
<footer class="site-footer">⚽ Tippspiel 2027</footer>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
colima start
|
||||
docker compose up -d
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
docker compose up -d
|
||||
|
||||
echo "Warte auf die Datenbank..."
|
||||
for _ in $(seq 1 30); do
|
||||
if docker compose exec -T db mysqladmin ping -uroot -proot --silent 2>/dev/null; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
|
||||
docker compose exec -T db mysqladmin ping -uroot -proot --silent
|
||||
|
||||
echo "Führe DB-Import aus..."
|
||||
docker compose exec app php import.php
|
||||
|
|
@ -28,6 +28,11 @@
|
|||
/* Grundlayout ------------------------------------------------------------- */
|
||||
* { box-sizing: border-box; }
|
||||
|
||||
/* Basis-Schriftgröße: kompakt auf Mobilgeräten, größer auf großen Bildschirmen */
|
||||
html { font-size: 100%; }
|
||||
@media (min-width: 900px) { html { font-size: 125%; } }
|
||||
@media (min-width: 1400px) { html { font-size: 150%; } }
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--font);
|
||||
|
|
@ -266,6 +271,25 @@ button.link-button {
|
|||
min-width: 100%;
|
||||
}
|
||||
|
||||
/* Vertikal scrollbare Rangliste mit angepinntem Tabellenkopf */
|
||||
.table-container.sticky-header {
|
||||
max-height: 75vh;
|
||||
overflow: auto;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.table-container.sticky-header table {
|
||||
border: none;
|
||||
border-radius: 0;
|
||||
overflow: visible;
|
||||
margin-top: 0;
|
||||
}
|
||||
.table-container.sticky-header thead th {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 5;
|
||||
}
|
||||
|
||||
/* Rangliste --------------------------------------------------------------- */
|
||||
td.tipp-cell { text-align: center !important; position: relative; font-weight: 700; }
|
||||
td.tipp-cell.col_exact { background-color: var(--col-exact) !important; color: #fff; } /* Exaktes Ergebnis */
|
||||
|
|
@ -322,7 +346,28 @@ th.game-header { white-space: normal; }
|
|||
|
||||
/* Kleine Bildschirme ------------------------------------------------------- */
|
||||
@media (max-width: 700px) {
|
||||
.page { margin: 0.6em; padding: 1em; border-radius: 6px; }
|
||||
.site-nav { padding: 0.5em 0.6em; position: static; }
|
||||
.page { margin: 0.3em; padding: 0.8em; border-radius: 6px; }
|
||||
.site-nav { padding: 0.4em 0.5em; position: static; font-size: 0.85em; }
|
||||
.nav-user { margin-left: 0; }
|
||||
|
||||
/* Formulare: Label über dem Feld statt daneben */
|
||||
.form-group label {
|
||||
display: block;
|
||||
width: auto;
|
||||
text-align: left;
|
||||
margin: 0 0 0.2em;
|
||||
}
|
||||
.form-group button:first-of-type {
|
||||
margin-left: 0;
|
||||
}
|
||||
.form-actions {
|
||||
margin-left: 0;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
/* Tabellen: kompaktere Zellen, volle Breite */
|
||||
th, td { padding: 5px 6px; }
|
||||
|
||||
h1 { font-size: 1.3em; }
|
||||
h2 { font-size: 1.1em; }
|
||||
}
|
||||
BIN
tippspiel/public/img/icon-180.png
Normal file
BIN
tippspiel/public/img/icon-180.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
BIN
tippspiel/public/img/icon-192.png
Normal file
BIN
tippspiel/public/img/icon-192.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
tippspiel/public/img/icon-512-maskable.png
Normal file
BIN
tippspiel/public/img/icon-512-maskable.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 63 KiB |
BIN
tippspiel/public/img/icon-512.png
Normal file
BIN
tippspiel/public/img/icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
|
|
@ -55,9 +55,9 @@ if ($page === 'reminder') {
|
|||
}
|
||||
exit;
|
||||
} elseif ($page === 'login') {
|
||||
// Wenn bereits eingeloggt, zur Rangliste weiterleiten
|
||||
// Wenn bereits eingeloggt, zur Startseite weiterleiten
|
||||
if (Auth::check()) {
|
||||
header('Location: /index.php?page=ranking');
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ if ($page === 'reminder') {
|
|||
$lastname = $_POST['lastname'] ?? '';
|
||||
$password = $_POST['password'] ?? '';
|
||||
if (Auth::login($firstname, $lastname, $password)) {
|
||||
header('Location: /index.php?page=ranking');
|
||||
header('Location: /');
|
||||
exit;
|
||||
} else {
|
||||
$error = 'Ungültige Anmeldedaten.';
|
||||
|
|
@ -77,7 +77,7 @@ if ($page === 'reminder') {
|
|||
}
|
||||
} elseif ($page === 'register') {
|
||||
if (Auth::check()) {
|
||||
header('Location: /index.php?page=ranking');
|
||||
header('Location: /');
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ if ($page === 'reminder') {
|
|||
if (User::create($data)) {
|
||||
// Automatically log in the new user
|
||||
if (Auth::login($data['firstname'], $data['lastname'], $data['password'])) {
|
||||
header('Location: /index.php?page=ranking');
|
||||
header('Location: /');
|
||||
exit;
|
||||
} else {
|
||||
// This should not happen if creation was successful
|
||||
|
|
@ -802,29 +802,22 @@ if ($page === 'reminder') {
|
|||
} elseif ($page === 'home') {
|
||||
Auth::requireLogin();
|
||||
try {
|
||||
$db = Database::getConnection();
|
||||
$userCount = $db->query("SELECT COUNT(*) FROM users")->fetchColumn();
|
||||
|
||||
$currentSeason = Season::getCurrent();
|
||||
|
||||
if ($currentSeason) {
|
||||
$rounds = Round::getBySeason($currentSeason['id']);
|
||||
$rounds = [];
|
||||
foreach (Round::getBySeason($currentSeason['id']) as $round) {
|
||||
if (Round::isCompleted(Game::getGamesByRound($round['id']))) {
|
||||
$rounds[] = $round;
|
||||
}
|
||||
}
|
||||
$rounds = array_reverse($rounds);
|
||||
} else {
|
||||
$rounds = [];
|
||||
}
|
||||
|
||||
// Testdaten für die Startseite
|
||||
$scoreTest = Tipp::getScoreLocal(2, 1, 2, 1, true);
|
||||
$lastRoundId = $db->query("SELECT round_id FROM games WHERE score1 > -1 ORDER BY id DESC LIMIT 1")->fetchColumn();
|
||||
|
||||
if ($lastRoundId) {
|
||||
$games = Game::getGamesByRound($lastRoundId);
|
||||
} else {
|
||||
$games = [];
|
||||
}
|
||||
|
||||
|
||||
require __DIR__ . '/../src/Views/home.php';
|
||||
|
||||
|
||||
} catch (Throwable $e) {
|
||||
echo "<p style='color:red;'>Fehler: " . $e->getMessage() . "</p>";
|
||||
}
|
||||
31
tippspiel/public/manifest.json
Normal file
31
tippspiel/public/manifest.json
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "Tippspiel 2027",
|
||||
"short_name": "Tippspiel",
|
||||
"description": "Hoschis Tippspiel 2027 – Tippgemeinschaft unter Freunden.",
|
||||
"start_url": "/",
|
||||
"scope": "/",
|
||||
"display": "standalone",
|
||||
"background_color": "#0b3d23",
|
||||
"theme_color": "#14632f",
|
||||
"lang": "de",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/img/icon-192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/img/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "any"
|
||||
},
|
||||
{
|
||||
"src": "/img/icon-512-maskable.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable"
|
||||
}
|
||||
]
|
||||
}
|
||||
58
tippspiel/public/sw.js
Normal file
58
tippspiel/public/sw.js
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
// Service Worker für Tippspiel 2027
|
||||
// Cacht statische Assets (App-Shell) für schnellen Start und eingeschränkten Offline-Betrieb.
|
||||
// Dynamische Seiten (HTML) bleiben network-first, damit keine veralteten Inhalte ausgeliefert werden.
|
||||
|
||||
const CACHE_NAME = 'tippspiel2027-v1';
|
||||
const STATIC_ASSETS = [
|
||||
'/',
|
||||
'/css/style.css',
|
||||
'/img/icon-192.png',
|
||||
'/img/icon-512.png',
|
||||
'/img/icon-512-maskable.png',
|
||||
'/manifest.json',
|
||||
];
|
||||
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
|
||||
);
|
||||
self.skipWaiting();
|
||||
});
|
||||
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) =>
|
||||
Promise.all(keys.filter((k) => k !== CACHE_NAME).map((k) => caches.delete(k)))
|
||||
)
|
||||
);
|
||||
self.clients.claim();
|
||||
});
|
||||
|
||||
self.addEventListener('fetch', (event) => {
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
if (event.request.method !== 'GET' || url.origin !== self.location.origin) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Statische Assets: Cache-First (schnell), im Hintergrund aktualisieren
|
||||
if (STATIC_ASSETS.includes(url.pathname)) {
|
||||
event.respondWith(
|
||||
caches.match(event.request).then((cached) => {
|
||||
const network = fetch(event.request).then((response) => {
|
||||
if (response && response.status === 200) {
|
||||
caches.open(CACHE_NAME).then((cache) => cache.put(event.request, response.clone()));
|
||||
}
|
||||
return response;
|
||||
});
|
||||
return cached || network;
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// Dynamische Seiten: Network-First, Fallback auf Cache (nur wenn offline)
|
||||
event.respondWith(
|
||||
fetch(event.request).catch(() => caches.match(event.request))
|
||||
);
|
||||
});
|
||||
27
tippspiel/src/Views/home.php
Normal file
27
tippspiel/src/Views/home.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
use App\Models\Round;
|
||||
|
||||
$pageTitle = 'Tippspiel 2027 - Startseite';
|
||||
require __DIR__ . '/partials/header.php';
|
||||
?>
|
||||
|
||||
<h1>Willkommen bei Tippspiel 2027</h1>
|
||||
|
||||
<h2>Rundenübersicht</h2>
|
||||
<?php if ($currentSeason): ?>
|
||||
<p>Saison: <strong><?php echo htmlspecialchars($currentSeason['name']); ?></strong></p>
|
||||
<?php if ($rounds): ?>
|
||||
<?php foreach ($rounds as $round): ?>
|
||||
<h3><a href="/index.php?page=round&id=<?php echo htmlspecialchars($round['id']); ?>"><?php echo htmlspecialchars($round['name']); ?></a></h3>
|
||||
<?php if (!empty($round['report'])): ?>
|
||||
<p><?php echo nl2br(htmlspecialchars(Round::reportToText($round['report']))); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<p>Noch keine abgeschlossenen Runden in der aktuellen Saison.</p>
|
||||
<?php endif; ?>
|
||||
<?php else: ?>
|
||||
<p>Keine Saison gefunden.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php require __DIR__ . '/partials/footer.php'; ?>
|
||||
|
|
@ -24,6 +24,7 @@ $exactExamples = ['1:0', '2:1', '2:2', '3:1', '3:2', '4:2', '5:3'];
|
|||
<a href="#rangliste">Rangliste</a>
|
||||
<a href="#tagessieg">Tagessieg</a>
|
||||
<a href="#gewinne">Gewinne</a>
|
||||
<a href="#app">Als App installieren</a>
|
||||
</nav>
|
||||
|
||||
<h2 id="tippen">1. Tippen</h2>
|
||||
|
|
@ -127,6 +128,29 @@ $exactExamples = ['1:0', '2:1', '2:2', '3:1', '3:2', '4:2', '5:3'];
|
|||
<li>Was du bisher gewonnen hast, zeigt die <a href="/index.php?page=money_ranking">Geldrangliste</a>. Damit dein Gewinn überwiesen werden kann, trage deine Bankverbindung unter <em>Einstellungen</em> ein.</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="app">7. Als App installieren</h2>
|
||||
<p>Das Tippspiel kannst du dir wie eine App auf den Startbildschirm deines Smartphones legen. Sie öffnet sich dann im Vollbild mit eigenem Symbol – ohne Adressleiste des Browsers. Der eigentliche Inhalt ist identisch mit der Webseite, und es funktioniert weiterhin nur mit Internetverbindung.</p>
|
||||
|
||||
<h3>Android (Chrome)</h3>
|
||||
<ol>
|
||||
<li>Öffne das Tippspiel in <strong>Chrome</strong>.</li>
|
||||
<li>Tippe auf das Menü <strong>⋮</strong> (drei Punkte) oben rechts.</li>
|
||||
<li>Wähle <strong>„App installieren“</strong> (oder „Zum Startbildschirm hinzufügen“).</li>
|
||||
<li>Bestätige mit <strong>„Installieren“</strong>.</li>
|
||||
<li>Die App erscheint auf dem Startbildschirm und in der App-Übersicht.</li>
|
||||
</ol>
|
||||
|
||||
<h3>iPhone (Safari)</h3>
|
||||
<ol>
|
||||
<li>Öffne das Tippspiel in <strong>Safari</strong>.</li>
|
||||
<li>Tippe unten in der Mitte auf das <strong>Teilen-Symbol</strong> <span style="font-size:1.2em;">⏏</span> (Quadrat mit Pfeil nach oben).</li>
|
||||
<li>Scrolle und wähle <strong>„Zum Home-Bildschirm“</strong>.</li>
|
||||
<li>Bestätige mit <strong>„Hinzufügen“</strong> (oben rechts).</li>
|
||||
<li>Die App erscheint auf dem Home-Bildschirm.</li>
|
||||
</ol>
|
||||
|
||||
<p class="hint">Tipp: Beim ersten Öffnen musst du dich einmal anmelden. Danach bleibst du – wie im Browser – angemeldet.</p>
|
||||
|
||||
</div>
|
||||
|
||||
<style>
|
||||
48
tippspiel/src/Views/info/quotas.php
Normal file
48
tippspiel/src/Views/info/quotas.php
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
use App\Models\Quota;
|
||||
|
||||
$pageTitle = 'Quoten';
|
||||
require __DIR__ . '/../partials/header.php';
|
||||
|
||||
$euro = fn($amount) => number_format($amount, 2, ',', '.') . ' €';
|
||||
?>
|
||||
|
||||
<?php if (!$currentSeason): ?>
|
||||
<p>Es gibt noch keine Saison.</p>
|
||||
<?php else: ?>
|
||||
<h1><?php echo htmlspecialchars($currentSeason['name']); ?></h1>
|
||||
<h2>Ausschüttungs-Quoten</h2>
|
||||
|
||||
<div class="quota-section">
|
||||
<h3>Spiel-Einsatz</h3>
|
||||
<table class="info-table">
|
||||
<tr><th>Aktive Spieler</th><td><?php echo $activeUserCount; ?></td></tr>
|
||||
<tr><th>Einsatz pro Spieler</th><td><?php echo $euro($stake); ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="quota-section">
|
||||
<h3>Spielquoten</h3>
|
||||
<table class="info-table">
|
||||
<tr><th>Tagessieg</th><td><?php echo $euro($payouts['tagessieg']); ?></td></tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="quota-section">
|
||||
<h3>Platzierungsquoten</h3>
|
||||
<table class="info-table">
|
||||
<?php for ($place = 1; $place <= Quota::PLACES; $place++): ?>
|
||||
<tr><th>Platz <?php echo $place; ?></th><td><?php echo $euro($payouts['platz' . $place]); ?></td></tr>
|
||||
<?php endfor; ?>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<style>
|
||||
.quota-section { text-align: center; }
|
||||
.info-table { width: auto; min-width: 350px; margin-left: auto; margin-right: auto; }
|
||||
.info-table th { width: 200px; font-weight: normal; }
|
||||
.info-table td { text-align: right; }
|
||||
</style>
|
||||
|
||||
<?php require __DIR__ . '/../partials/footer.php'; ?>
|
||||
|
|
@ -19,8 +19,16 @@ require __DIR__ . '/partials/header.php';
|
|||
text-align: right;
|
||||
margin-right: 10px;
|
||||
}
|
||||
.form-group button:first-of-type {
|
||||
margin-left: calc(150px + 10px);
|
||||
.form-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 10px;
|
||||
align-items: center;
|
||||
}
|
||||
@media (min-width: 701px) {
|
||||
.form-actions {
|
||||
margin-left: calc(150px + 10px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<form action="/index.php?page=login" method="post">
|
||||
|
|
@ -36,10 +44,10 @@ require __DIR__ . '/partials/header.php';
|
|||
<label for="password">Passwort:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-actions">
|
||||
<button type="submit">Anmelden</button>
|
||||
<?php if (App\Models\Setting::isRegistrationOpen()): ?>
|
||||
<button type="button" onclick="location.href='/index.php?page=register'" style="margin-left: 10px;">Registrieren</button>
|
||||
<button type="button" onclick="location.href='/index.php?page=register'">Registrieren</button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</form>
|
||||
11
tippspiel/src/Views/partials/footer.php
Normal file
11
tippspiel/src/Views/partials/footer.php
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
</main>
|
||||
<footer class="site-footer">⚽ Tippspiel 2027</footer>
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function () {
|
||||
navigator.serviceWorker.register('/sw.js');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -5,14 +5,13 @@
|
|||
<meta charset="UTF-8">
|
||||
<title><?php echo htmlspecialchars($pageTitle); ?></title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>⚽</text></svg>">
|
||||
<meta name="theme-color" content="#14632f">
|
||||
<meta name="description" content="Hoschis Tippspiel 2027 – Tippgemeinschaft unter Freunden.">
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
<link rel="icon" href="/img/icon-192.png">
|
||||
<link rel="apple-touch-icon" href="/img/icon-180.png">
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css" integrity="sha512-SnH5WK+bZxgPHs44uWIX+LLJAJ9/2PkPKZ5QiAj6Ta86w+fsb2TkcmfRyVX3pBnMFcV7oQPJkl9QevSCWr3W6A==" crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
<style>
|
||||
html {
|
||||
font-size: 150%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="site-nav">
|
||||
|
|
@ -17,10 +17,9 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
width: 100px; /* Feste Breite für die Spiele-Spalten */
|
||||
}
|
||||
.tipp-points {
|
||||
width: 30px; /* Angepasste Breite für Punkte */
|
||||
width: 55px; /* Breite für den Tipp (z.B. 2:1) */
|
||||
box-sizing: border-box;
|
||||
text-align: right;
|
||||
padding-right: 5px;
|
||||
text-align: center;
|
||||
}
|
||||
.tipp-joker {
|
||||
width: 70px; /* Breite für vergrößerten Joker */
|
||||
|
|
@ -44,35 +43,71 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
padding-top: 0.1rem;
|
||||
padding-bottom: 0.1rem;
|
||||
}
|
||||
|
||||
/* Kompakter Kopfbereich: Titel, Saison und Rundenwahl auf einer Zeile */
|
||||
.ranking-toolbar {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
gap: 0.3em 0.9em;
|
||||
margin-bottom: 0.8em;
|
||||
}
|
||||
.ranking-toolbar h1 {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border-bottom: none;
|
||||
font-size: 1.3em;
|
||||
}
|
||||
.ranking-toolbar .season {
|
||||
font-family: var(--font-display);
|
||||
font-weight: 700;
|
||||
color: var(--pitch-dark);
|
||||
}
|
||||
.ranking-toolbar .round-filter {
|
||||
margin: 0 0 0 auto;
|
||||
}
|
||||
.ranking-toolbar .round-filter label {
|
||||
margin-right: 0.3em;
|
||||
}
|
||||
|
||||
/* Legende als kompakte Fußzeile unter der Tabelle */
|
||||
.legend.legend-footer {
|
||||
margin: 10px 0 0;
|
||||
padding: 6px 10px;
|
||||
font-size: 0.8em;
|
||||
gap: 6px 12px;
|
||||
justify-content: center;
|
||||
}
|
||||
.legend.legend-footer .legend-color { width: 12px; height: 12px; }
|
||||
.legend.legend-footer .joker-icon { width: 1.1em; height: 1.1em; }
|
||||
.legend.legend-footer .daily-winner-icon { font-size: 1em; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.ranking-toolbar h1 { font-size: 1.1em; }
|
||||
.ranking-toolbar .round-filter { margin-left: 0; }
|
||||
}
|
||||
</style>
|
||||
|
||||
<h1>Rangliste</h1>
|
||||
<h2>Saison: <?php echo htmlspecialchars($currentSeason['name']); ?></h2>
|
||||
<div class="ranking-toolbar">
|
||||
<h1>Rangliste</h1>
|
||||
<span class="season"><?php echo htmlspecialchars($currentSeason['name']); ?></span>
|
||||
<?php if ($selectedRound): ?>
|
||||
<form method="get" class="round-filter">
|
||||
<input type="hidden" name="page" value="ranking">
|
||||
<label for="round_id">Runde:</label>
|
||||
<select name="round_id" id="round_id" onchange="this.form.submit()">
|
||||
<?php foreach ($allRounds as $round): ?>
|
||||
<option value="<?php echo $round['id']; ?>" <?php echo ($round['id'] == $selectedRound['id']) ? 'selected' : ''; ?>>
|
||||
<?php echo htmlspecialchars($round['name']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</form>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php if ($selectedRound): ?>
|
||||
<div class="round-filter">
|
||||
<form method="get">
|
||||
<input type="hidden" name="page" value="ranking">
|
||||
<label for="round_id">Runde auswählen:</label>
|
||||
<select name="round_id" id="round_id" onchange="this.form.submit()">
|
||||
<?php foreach ($allRounds as $round): ?>
|
||||
<option value="<?php echo $round['id']; ?>" <?php echo ($round['id'] == $selectedRound['id']) ? 'selected' : ''; ?>>
|
||||
<?php echo htmlspecialchars($round['name']); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="legend">
|
||||
<div class="legend-item"><span class="daily-winner-icon">🏆</span> Tagessieger</div>
|
||||
<div class="legend-item"><img src="/img/joker.png" alt="Joker" class="joker-icon"> Joker gesetzt</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-tendenz);"></div> Richtige Tendenz</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-exact);"></div> Richtiges Ergebnis</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-joker-exact);"></div> Richtiges Ergebnis mit Joker</div>
|
||||
</div>
|
||||
|
||||
<div class="table-container">
|
||||
<div class="table-container sticky-header">
|
||||
<?php if (!empty($ranking)): ?>
|
||||
<table>
|
||||
<thead>
|
||||
|
|
@ -97,7 +132,8 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
if ($entry['rank'] <= 3) $rowClasses[] = 'rank-' . $entry['rank'];
|
||||
if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) $rowClasses[] = 'me';
|
||||
?>
|
||||
<tr<?php if ($rowClasses) echo ' class="' . implode(' ', $rowClasses) . '"'; ?>>
|
||||
<tr<?php if ($rowClasses) echo ' class="' . implode(' ', $rowClasses) . '"'; ?>
|
||||
<?php if ((int)$entry['user_id'] === (int)App\Core\Auth::id()) echo ' id="me-row"'; ?>>
|
||||
<td class="text-center"><span class="rank-badge"><?php echo $entry['rank']; ?>.</span></td>
|
||||
<td><?php echo htmlspecialchars($entry['name']); ?></td>
|
||||
<td class="text-center"><?php echo $entry['is_day_winner'] ? '<span class="daily-winner-icon">🏆</span>' : ''; ?></td>
|
||||
|
|
@ -108,10 +144,10 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
$tipp = $entry['cells'][$game['id']];
|
||||
// Farbklasse kommt fertig aus Tipp::getCol (col_tendenz / col_exact / col_joker_exact)
|
||||
$td_class = $tipp['color'];
|
||||
$title = "Tipp: " . htmlspecialchars($tipp['text']) . " | Punkte: " . $tipp['points'];
|
||||
$title = "Punkte: " . $tipp['points'];
|
||||
?>
|
||||
<td class="tipp-cell tipp-points <?php echo htmlspecialchars($td_class); ?>" title="<?php echo $title; ?>">
|
||||
<?php echo $tipp['points']; ?>
|
||||
<?php echo htmlspecialchars($tipp['text']); ?>
|
||||
</td>
|
||||
<td class="tipp-cell tipp-joker" title="<?php echo $title; ?>">
|
||||
<?php if ($tipp['joker']): ?>
|
||||
|
|
@ -127,8 +163,26 @@ if (!isset($currentSeason) || !isset($ranking) || !isset($games) || !isset($allR
|
|||
<p>Für diese Saison gibt es noch keine Rangliste (möglicherweise haben noch keine Spieler bezahlt).</p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="legend legend-footer">
|
||||
<div class="legend-item"><span class="daily-winner-icon">🏆</span> Tagessieger</div>
|
||||
<div class="legend-item"><img src="/img/joker.png" alt="Joker" class="joker-icon"> Joker gesetzt</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-tendenz);"></div> Richtige Tendenz</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-exact);"></div> Richtiges Ergebnis</div>
|
||||
<div class="legend-item"><div class="legend-color" style="background-color: var(--col-joker-exact);"></div> Richtiges Ergebnis mit Joker</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<p>Keine Runde für die Anzeige ausgewählt oder gefunden.</p>
|
||||
<?php endif; ?>
|
||||
|
||||
<script>
|
||||
// Springe beim Laden zur eigenen Zeile, falls der eingeloggte Spieler in der Tabelle ist
|
||||
window.addEventListener('load', function () {
|
||||
var me = document.getElementById('me-row');
|
||||
if (me) {
|
||||
me.scrollIntoView({ block: 'center' });
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php require __DIR__ . '/partials/footer.php'; ?>
|
||||
BIN
tools/__pycache__/deploy_test.cpython-312.pyc
Normal file
BIN
tools/__pycache__/deploy_test.cpython-312.pyc
Normal file
Binary file not shown.
242
tools/deploy_test.py
Executable file
242
tools/deploy_test.py
Executable file
|
|
@ -0,0 +1,242 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
Deploy-Skript für das Testsystem tippspiel.programmschmiede.de.
|
||||
|
||||
Lädt das Projekt (tippspiel/public und tippspiel/src) per FTP auf den
|
||||
Testsystem-Server hoch und erzeugt dabei eine .htaccess mit den nötigen
|
||||
Environment-Variablen (SetEnv) im public/-Verzeichnis.
|
||||
|
||||
Zugangsdaten werden aus docs/testsystem_credentials.txt gelesen.
|
||||
Achtung: Zugangsdaten landen als SetEnv in der .htaccess auf dem Server.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import io
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from ftplib import FTP, error_perm
|
||||
|
||||
REPO_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
CRED_FILE = os.path.join(REPO_ROOT, "docs", "testsystem_credentials.txt")
|
||||
APP_DIR = os.path.join(REPO_ROOT, "tippspiel")
|
||||
|
||||
FTP_HOST = "programmschmiede.de"
|
||||
FTP_PORT = 21
|
||||
REMOTE_ROOT = "tippspiel.programmschmiede.de"
|
||||
|
||||
# Konfiguration des Testsystems (falls nicht in den Credentials vorhanden)
|
||||
DB_HOST = "localhost"
|
||||
DB_USER = "d0489c69"
|
||||
APP_URL = "https://tippspiel.programmschmiede.de"
|
||||
|
||||
# Quelle für den DB-Sync: lokale, bereits migrierte Datenbank (via Docker)
|
||||
LOCAL_DB_HOST = "127.0.0.1"
|
||||
LOCAL_DB_PORT = "3306"
|
||||
LOCAL_DB_USER = "root"
|
||||
LOCAL_DB_PASS = "root"
|
||||
LOCAL_DB_NAME = "tippspiel2027"
|
||||
|
||||
# Entfernte DB, in die der Dump eingespielt wird
|
||||
REMOTE_DB_HOST = "programmschmiede.de"
|
||||
REMOTE_DB_PORT = "3306"
|
||||
|
||||
|
||||
def read_credentials(path):
|
||||
creds = {}
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
for line in f:
|
||||
line = line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
key, _, value = line.partition("=")
|
||||
creds[key.strip()] = value.strip()
|
||||
return creds
|
||||
|
||||
|
||||
def build_htaccess(creds):
|
||||
return "\n".join(
|
||||
[
|
||||
"# Auto-generiert von deploy_test.py - NICHT manuell editieren",
|
||||
"Options -Indexes",
|
||||
"",
|
||||
"RewriteEngine On",
|
||||
"RewriteCond %{HTTPS} off",
|
||||
"RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]",
|
||||
"",
|
||||
"SetEnv DB_HOST " + DB_HOST,
|
||||
"SetEnv DB_USER " + DB_USER,
|
||||
"SetEnv DB_PASS " + creds["mysql_pw"],
|
||||
"SetEnv DB_NEW_NAME " + creds["mysql_db"],
|
||||
"SetEnv APP_URL " + APP_URL,
|
||||
"",
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
def run(cmd, env=None, input_data=None):
|
||||
"""Führt einen Befehl aus und gibt bei Fehlern eine verständliche Meldung aus."""
|
||||
proc = subprocess.run(
|
||||
cmd,
|
||||
env=env,
|
||||
input=input_data,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
if proc.returncode != 0:
|
||||
raise RuntimeError(
|
||||
"Befehl fehlgeschlagen: %s\n%s" % (" ".join(cmd), proc.stderr.decode("utf-8", "replace"))
|
||||
)
|
||||
return proc.stdout
|
||||
|
||||
|
||||
def sync_database(creds):
|
||||
"""Dumpt die lokale migrierte DB und spielt sie in die entfernte Test-DB ein."""
|
||||
remote_db = creds["mysql_db"]
|
||||
remote_pw = creds["mysql_pw"]
|
||||
|
||||
print("== DB-Sync: dumpe lokale '%s' ==" % LOCAL_DB_NAME)
|
||||
dump_env = dict(os.environ, MYSQL_PWD=LOCAL_DB_PASS)
|
||||
dump = run(
|
||||
[
|
||||
"mysqldump",
|
||||
"-h", LOCAL_DB_HOST, "-P", LOCAL_DB_PORT,
|
||||
"-u", LOCAL_DB_USER,
|
||||
"--no-tablespaces", "--column-statistics=0",
|
||||
"--no-create-db",
|
||||
LOCAL_DB_NAME,
|
||||
],
|
||||
env=dump_env,
|
||||
)
|
||||
|
||||
print("== DB-Sync: leere entfernte '%s' ==" % remote_db)
|
||||
remote_env = dict(os.environ, MYSQL_PWD=remote_pw)
|
||||
|
||||
# Alle vorhandenen Tabellen ermitteln und droppen
|
||||
tables_out = run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
"-N", "-e",
|
||||
"SELECT table_name FROM information_schema.tables WHERE table_schema='%s';" % remote_db,
|
||||
],
|
||||
env=remote_env,
|
||||
)
|
||||
tables = [t.strip() for t in tables_out.decode("utf-8", "replace").splitlines() if t.strip()]
|
||||
if tables:
|
||||
drop_sql = "SET FOREIGN_KEY_CHECKS=0; " + " ".join(
|
||||
"DROP TABLE IF EXISTS `%s`;" % t for t in tables
|
||||
) + " SET FOREIGN_KEY_CHECKS=1;"
|
||||
run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
"-e", drop_sql,
|
||||
],
|
||||
env=remote_env,
|
||||
)
|
||||
print(" %d Tabellen gelöscht." % len(tables))
|
||||
else:
|
||||
print(" keine Tabellen vorhanden.")
|
||||
|
||||
print("== DB-Sync: spiele Dump in '%s' ein ==" % remote_db)
|
||||
with tempfile.NamedTemporaryFile("wb", delete=False, suffix=".sql") as tmp:
|
||||
tmp.write(dump)
|
||||
dump_path = tmp.name
|
||||
try:
|
||||
with open(dump_path, "rb") as f:
|
||||
run(
|
||||
[
|
||||
"mysql",
|
||||
"-h", REMOTE_DB_HOST, "-P", REMOTE_DB_PORT,
|
||||
"-u", DB_USER, remote_db,
|
||||
],
|
||||
env=remote_env,
|
||||
input_data=f.read(),
|
||||
)
|
||||
finally:
|
||||
os.unlink(dump_path)
|
||||
|
||||
|
||||
def mkd_ignore_exists(ftp, name):
|
||||
try:
|
||||
ftp.mkd(name)
|
||||
except error_perm as e:
|
||||
if not e.args[0].startswith("550"):
|
||||
raise
|
||||
|
||||
|
||||
def upload_dir(ftp, local_dir, remote_dir):
|
||||
mkd_ignore_exists(ftp, remote_dir)
|
||||
for name in sorted(os.listdir(local_dir)):
|
||||
local_path = os.path.join(local_dir, name)
|
||||
if os.path.isfile(local_path):
|
||||
print("STOR", remote_dir + "/" + name)
|
||||
with open(local_path, "rb") as f:
|
||||
ftp.storbinary("STOR " + name, f)
|
||||
elif os.path.isdir(local_path):
|
||||
print("DIR ", remote_dir + "/" + name)
|
||||
mkd_ignore_exists(ftp, name)
|
||||
ftp.cwd(name)
|
||||
upload_dir(ftp, local_path, remote_dir + "/" + name)
|
||||
ftp.cwd("..")
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description="Deploy auf das Testsystem.")
|
||||
parser.add_argument(
|
||||
"--skip-db-import",
|
||||
action="store_true",
|
||||
help="DB-Sync überspringen (keine Daten in die entfernte DB einspielen).",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
if not os.path.isfile(CRED_FILE):
|
||||
print("Fehler: Credentials nicht gefunden:", CRED_FILE, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
creds = read_credentials(CRED_FILE)
|
||||
for key in ("ftp_user", "ftp_pw", "mysql_db", "mysql_pw"):
|
||||
if key not in creds:
|
||||
print("Fehler: Fehlender Eintrag '%s' in %s" % (key, CRED_FILE), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
htaccess = build_htaccess(creds)
|
||||
|
||||
if args.skip_db_import:
|
||||
print("== DB-Sync übersprungen (--skip-db-import) ==")
|
||||
else:
|
||||
sync_database(creds)
|
||||
|
||||
ftp = FTP()
|
||||
ftp.connect(FTP_HOST, FTP_PORT)
|
||||
ftp.login(creds["ftp_user"], creds["ftp_pw"])
|
||||
|
||||
mkd_ignore_exists(ftp, REMOTE_ROOT)
|
||||
ftp.cwd(REMOTE_ROOT)
|
||||
|
||||
for sub in ("public", "src"):
|
||||
local_sub = os.path.join(APP_DIR, sub)
|
||||
if not os.path.isdir(local_sub):
|
||||
print("Fehler: Verzeichnis fehlt:", local_sub, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
print("== Lade", sub, "hoch ==")
|
||||
mkd_ignore_exists(ftp, sub)
|
||||
ftp.cwd(sub)
|
||||
upload_dir(ftp, local_sub, REMOTE_ROOT + "/" + sub)
|
||||
ftp.cwd("..")
|
||||
|
||||
print("== Schreibe .htaccess in public/ ==")
|
||||
ftp.cwd("public")
|
||||
ftp.storbinary("STOR .htaccess", io.BytesIO(htaccess.encode("utf-8")))
|
||||
ftp.cwd("..")
|
||||
|
||||
ftp.quit()
|
||||
print("\nDeployment abgeschlossen ->", APP_URL)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -5,6 +5,8 @@ services:
|
|||
- "8080:80"
|
||||
volumes:
|
||||
- .:/var/www/html
|
||||
- ../tippspiel/public:/var/www/html/public
|
||||
- ../tippspiel/src:/var/www/html/src
|
||||
environment:
|
||||
- DB_HOST=db
|
||||
- DB_USER=root
|
||||
54
tools/import_from_dump.sh
Executable file
54
tools/import_from_dump.sh
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# Importiert den neuesten Live-Dump des Legacy-Projekts in die lokale Test-DB
|
||||
# und migriert ihn anschließend in tippspiel2027 (import.php).
|
||||
#
|
||||
# Ablauf:
|
||||
# 1. Colima (Docker-Daemon) starten, falls noch nicht aktiv
|
||||
# 2. Neuesten Dump finden (/home/torsten/repos/tippspiel/tools/pfosten*.sql)
|
||||
# 3. Container starten und auf die DB warten
|
||||
# 4. Legacy-DB "tippspiel_legacy" droppen und neu anlegen
|
||||
# 5. Dump in "tippspiel_legacy" einspielen
|
||||
# 6. import.php ausführen (befüllt tippspiel2027 von scratch)
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
DUMP_DIR="${DUMP_DIR:-/home/torsten/repos/tippspiel/tools}"
|
||||
LEGACY_DB="${DB_OLD_NAME:-tippspiel_legacy}"
|
||||
|
||||
DUMP="$(ls -1 "$DUMP_DIR"/pfosten*.sql | tail -1)"
|
||||
if [[ -z "$DUMP" ]]; then
|
||||
echo "Fehler: Kein Dump (pfosten*.sql) in $DUMP_DIR gefunden." >&2
|
||||
exit 1
|
||||
fi
|
||||
echo "Verwende Dump: $DUMP"
|
||||
|
||||
if command -v colima >/dev/null 2>&1 && ! colima status >/dev/null 2>&1; then
|
||||
echo "Colima ist nicht aktiv, starte es..."
|
||||
colima start
|
||||
fi
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
docker compose up -d
|
||||
|
||||
echo "Warte auf die Datenbank..."
|
||||
for _ in $(seq 1 60); do
|
||||
if docker compose exec -T db mysql -uroot -proot -e "SELECT 1;" >/dev/null 2>&1; then
|
||||
break
|
||||
fi
|
||||
sleep 2
|
||||
done
|
||||
docker compose exec -T db mysql -uroot -proot -e "SELECT 1;" >/dev/null
|
||||
|
||||
echo "Lege Legacy-DB '$LEGACY_DB' neu an..."
|
||||
docker compose exec -T db mysql -uroot -proot \
|
||||
-e "DROP DATABASE IF EXISTS \`$LEGACY_DB\`; CREATE DATABASE \`$LEGACY_DB\` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"
|
||||
|
||||
echo "Spiele Dump in '$LEGACY_DB' ein..."
|
||||
docker exec -i "$(docker compose ps -q db)" mysql -uroot -proot "$LEGACY_DB" < "$DUMP"
|
||||
|
||||
echo "Führe DB-Import aus (tippspiel2027)..."
|
||||
docker compose exec -T app php import.php
|
||||
|
||||
echo ""
|
||||
echo "Fertig. Öffne die Anwendung im Browser: http://localhost:8080"
|
||||
Loading…
Add table
Add a link
Reference in a new issue