Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9a19e40e3d | ||
|
|
7578e72334 | ||
|
|
8b6a34e8d1 | ||
|
|
96798c2db6 | ||
|
|
9f8f0f00d6 | ||
|
|
1ecb6c93b3 | ||
|
|
b13b524ad5 | ||
|
|
5ca2f1587f | ||
|
|
592f047274 | ||
|
|
d550e814e2 | ||
|
|
9ac5c997a2 | ||
|
|
49bc08129a | ||
|
|
7325400175 | ||
|
|
22733ce651 |
No files matched your search
@@ -28,14 +28,22 @@ jobs:
|
||||
--username "${{ secrets.REGISTRY_USER }}" \
|
||||
--password-stdin
|
||||
|
||||
- name: Docker Image bauen
|
||||
# Der TM-Dedicated-Server ist ein x86-Binary -> Image immer fuer
|
||||
# linux/amd64 bauen, auch wenn der Job auf einem arm64-Runner landet
|
||||
# (v1.4.0 wurde versehentlich als arm64 gebaut: "exec format error").
|
||||
- name: QEMU einrichten
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: amd64
|
||||
|
||||
- name: Buildx einrichten
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Docker Image bauen und pushen (linux/amd64)
|
||||
run: |
|
||||
docker build \
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
-t git.techniverse.net/scriptos/trackmania-server:${{ steps.version.outputs.VERSION }} \
|
||||
-t git.techniverse.net/scriptos/trackmania-server:latest \
|
||||
--push \
|
||||
.
|
||||
|
||||
- name: Docker Image pushen
|
||||
run: |
|
||||
docker push git.techniverse.net/scriptos/trackmania-server:${{ steps.version.outputs.VERSION }}
|
||||
docker push git.techniverse.net/scriptos/trackmania-server:latest
|
||||
@@ -5,3 +5,6 @@
|
||||
data/
|
||||
|
||||
.ki-workspace/
|
||||
backups/
|
||||
dockernet-inspector.v1.sh
|
||||
script.sh
|
||||
+6
-1
@@ -1,4 +1,5 @@
|
||||
FROM debian:bullseye-slim
|
||||
# Debian 13 Trixie liefert PHP 8.4 mit regulaeren Security-Updates
|
||||
FROM debian:trixie-slim
|
||||
|
||||
RUN mkdir /opt/tmserver
|
||||
|
||||
@@ -48,6 +49,10 @@ COPY assets/bin/RunTrackmaniaServer.sh /opt/tmserver/
|
||||
RUN sed -i 's/\r$//' /opt/tmserver/RunTrackmaniaServer.sh \
|
||||
&& chmod +x /opt/tmserver/RunTrackmaniaServer.sh
|
||||
|
||||
# PHP-8-Kompatibilitaet: ergaenzt __construct() fuer PHP-4-Konstruktoren
|
||||
# (wird bei jedem Start auf die Volumes angewendet)
|
||||
COPY assets/bin/Php8Compat.php /opt/tmserver/
|
||||
|
||||
COPY assets/bin/XAsecoHealthcheck.sh /opt/tmserver/
|
||||
RUN sed -i 's/\r$//' /opt/tmserver/XAsecoHealthcheck.sh \
|
||||
&& chmod +x /opt/tmserver/XAsecoHealthcheck.sh
|
||||
|
||||
@@ -1,6 +1,27 @@
|
||||
# tmserver-docker
|
||||
<p align="center">
|
||||
<a href="https://techniverse.net">
|
||||
<img src="https://assets.techniverse.net/f1/git/graphics/repo-techniverse-logo.png" alt="Techniverse Community" height="70" />
|
||||
</a>
|
||||
</p>
|
||||
|
||||
Ein vollständiges Docker-Setup für einen **TrackMania Nations Forever**-Server – inklusive Web-Verwaltung und Server-Controller:
|
||||
<h1 align="center">TM-Server Docker</h1>
|
||||
|
||||
<h4 align="center">
|
||||
Ein vollständiges Docker-Setup für einen TrackMania Nations Forever-Server – inklusive Web-Verwaltung und Server-Controller
|
||||
</h4>
|
||||
|
||||
<h6 align="center">
|
||||
<a href="https://www.cleveradmin.de">🏰 Website</a>
|
||||
·
|
||||
<a href="https://techniverse.net">📰 Community</a>
|
||||
·
|
||||
<a href="https://social.techniverse.net/@donnerwolke">🐘 Mastodon</a>
|
||||
·
|
||||
<a href="https://matrix.to/#/#support:techniverse.net">💬 Support</a>
|
||||
</h6>
|
||||
<br><br>
|
||||
|
||||
## ✨ Übersicht
|
||||
|
||||
- **TrackMania Dedicated Server** – der eigentliche Spielserver für Internet- oder LAN-Betrieb
|
||||
- **[XAseco](docs/xaseco.md)** – Server-Controller, der lokale Rekorde, Dedimania-Weltrekorde, Karma/Votes und eine Track-Jukebox direkt im Spielchat verwaltet
|
||||
@@ -13,7 +34,20 @@ Alle Komponenten laufen in einem einzigen Container und werden über Umgebungsva
|
||||
|
||||
Der Server unterstützt sowohl den **Internet-Dedicated-Modus** (Standard) als auch den **LAN-Dedicated-Modus**.
|
||||
|
||||
## Schnellstart
|
||||
## ⚠️ PHP 8 – bitte lesen (ab v1.4.1)
|
||||
|
||||
Seit **v1.4.0** (lauffähiges Image ab **v1.4.1**) basiert das Image auf **Debian 13 (Trixie) mit PHP 8.4**. PHP 7.4 ist seit 2022 ohne Sicherheitsupdates und von kritischen Lücken wie *PHP2Shell* (CVE-2026-109618, CVE-2026-109619) betroffen – deshalb habe ich den Umstieg vorgenommen.
|
||||
|
||||
AdminServ, RemoteCP und XAseco stammen allerdings aus PHP-5-Zeiten. Damit sie unter PHP 8 laufen, patcht der Container sie beim Start automatisch (PHP-4-Konstruktoren, veraltete Syntax, statische Aufrufe und einige bekannte Laufzeitfehler). Die Anpassungen sind idempotent und greifen auch bei bestehenden Volumes.
|
||||
|
||||
Ich habe die gängigen Funktionen getestet, aber **es kann durchaus noch zu Fehlern kommen** – vor allem in selten genutzten Plugins oder Menüs. Wenn dir etwas auffällt (weiße Seite, HTTP 500, XAseco-Absturz, Funktion ohne Wirkung), eröffne bitte ein [Issue](https://git.techniverse.net/scriptos/tmserver-docker/issues) und gib möglichst an:
|
||||
|
||||
- was du gemacht hast (Seite/Plugin/Chat-Befehl) und ungefähr wann,
|
||||
- die passende Meldung aus `docker logs tmserver`, dem Apache-Log (`docker exec tmserver tail -n 50 /var/log/apache2/error.log`), `data/xaseco/aseco.log` oder `data/controlpanel/remotecp/cache/errors.log`.
|
||||
|
||||
Ich schaue mir das dann an. Wer PHP 7.4 behalten möchte, bleibt vorerst beim Image-Tag `1.3.3`.
|
||||
|
||||
## 🚀 Schnellstart
|
||||
|
||||
### 1. Umgebungsvariablen einrichten
|
||||
|
||||
@@ -48,7 +82,7 @@ git.techniverse.net/scriptos/trackmania-server:latest
|
||||
|
||||
> **Hinweis:** Für den Internet-Modus müssen `SERVER_LOGIN` und `SERVER_VALIDATION_KEY` in der `.env`-Datei gesetzt sein. Einen Server-Account kannst du auf [players.trackmaniaforever.com](https://players.trackmaniaforever.com) erstellen. Für den LAN-Modus setze `SERVER_MODE=lan`.
|
||||
|
||||
## Dokumentation
|
||||
## 📚 Dokumentation
|
||||
|
||||
Die vollständige Dokumentation befindet sich im Ordner [`docs/`](docs/README.md):
|
||||
|
||||
@@ -63,27 +97,25 @@ Die vollständige Dokumentation befindet sich im Ordner [`docs/`](docs/README.md
|
||||
- [Ports](docs/ports.md) – Freigegebene Ports und deren Verwendung
|
||||
- [Update](docs/update.md) – Bestehende Installation aktualisieren
|
||||
|
||||
## Danksagung
|
||||
## 🙏 Danksagung
|
||||
|
||||
Ein herzliches Dankeschön an **[Thomas](https://retronerd.at)** – für seine tatkräftige Unterstützung, sein wertvolles Wissen und seine Mitwirkung an diesem Projekt. Ohne ihn wäre dieses Projekt nicht das, was es heute ist!
|
||||
|
||||
## Spiegelung
|
||||
## 🔄 Spiegelung
|
||||
|
||||
Dieses Repository wird von **Gitea** auf **GitHub** gespiegelt. Das Master-Repository befindet sich auf Gitea:
|
||||
|
||||
- **Gitea (Master):** [git.techniverse.net/scriptos/tmserver-docker](https://git.techniverse.net/scriptos/tmserver-docker.git)
|
||||
- **GitHub (Spiegel):** [github.com/pscriptos/tmserver-docker](https://github.com/pscriptos/tmserver-docker.git)
|
||||
|
||||
---
|
||||
|
||||
📝 **Blog:** [www.cleveradmin.de](https://www.cleveradmin.de)
|
||||
🌐 **Webseite:** [www.patrick-asmus.de](https://www.patrick-asmus.de)
|
||||
📧 **E-Mail:** [support@techniverse.net](mailto:support@techniverse.net)
|
||||
|
||||
<br><br>
|
||||
<p align="center">
|
||||
<img src="https://assets.techniverse.net/f1/git/graphics/gray0-catonline.svg" alt="">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<img src="https://assets.techniverse.net/f1/logos/small/license.png" alt="License" width="15" height="15"> <a href="./LICENSE">License</a> | <img src="https://assets.techniverse.net/f1/logos/small/matrix2.svg" alt="Matrix" width="15" height="15"> <a href="https://matrix.to/#/#community:techniverse.net">Matrix</a> | <img src="https://assets.techniverse.net/f1/logos/small/mastodon2.svg" alt="Mastodon" width="15" height="15"> <a href="https://social.techniverse.net/@donnerwolke">Mastodon</a>
|
||||
</p>
|
||||
<sub>
|
||||
© Patrick Asmus · Techniverse Network · <a href="./LICENSE">Lizenz</a>
|
||||
</sub>
|
||||
</p>
|
||||
@@ -0,0 +1,325 @@
|
||||
<?php
|
||||
/**
|
||||
* Php8Compat.php - PHP-8-Kompatibilitaet fuer AdminServ, RemoteCP und XAseco
|
||||
*
|
||||
* Aufruf: php Php8Compat.php <verzeichnis> [<verzeichnis> ...]
|
||||
*
|
||||
* PHP 8 behandelt Methoden mit dem Namen der Klasse (PHP-4-Konstruktoren)
|
||||
* nicht mehr als Konstruktor. Die alten Tools nutzen das an vielen Stellen,
|
||||
* Objekte blieben dadurch uninitialisiert.
|
||||
*
|
||||
* Fuer jede Klasse mit PHP-4-Konstruktor und ohne __construct() wird direkt
|
||||
* nach der oeffnenden Klammer ein __construct() eingefuegt, der die alte
|
||||
* Methode aufruft. Die alte Methode bleibt erhalten, damit Aufrufe wie
|
||||
* parent::IXR_Client(...) weiter funktionieren.
|
||||
*
|
||||
* Ausserdem werden String-Offsets mit geschweiften Klammern ($str{0}) auf
|
||||
* eckige Klammern umgestellt (unter PHP 8 ein Parse-Error).
|
||||
*
|
||||
* Nicht-statische Methoden, die statisch aufgerufen werden (Core::getObject()),
|
||||
* sind unter PHP 8 ein Fatal Error. Solche Methoden werden als static markiert,
|
||||
* sofern sie $this nicht verwenden und keine Unterklasse sie nicht-statisch
|
||||
* ueberschreibt.
|
||||
*
|
||||
* Idempotent: Klassen mit vorhandenem __construct() werden uebersprungen.
|
||||
* Dateien werden in-place geschrieben (Besitzer und Rechte bleiben erhalten).
|
||||
*/
|
||||
|
||||
if ($argc < 2) {
|
||||
fwrite(STDERR, "Aufruf: php {$argv[0]} <verzeichnis> [...]\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$files = array();
|
||||
for ($i = 1; $i < $argc; $i++) {
|
||||
if (!is_dir($argv[$i])) continue;
|
||||
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($argv[$i], FilesystemIterator::SKIP_DOTS));
|
||||
foreach ($it as $file) {
|
||||
if (strtolower($file->getExtension()) === 'php') $files[] = $file->getPathname();
|
||||
}
|
||||
}
|
||||
|
||||
$changed = array();
|
||||
$totalClasses = 0;
|
||||
$totalCurly = 0;
|
||||
$totalStatic = 0;
|
||||
|
||||
// Durchlauf 1: Konstruktoren und String-Offsets (pro Datei)
|
||||
foreach ($files as $path) {
|
||||
$src = file_get_contents($path);
|
||||
if ($src === false) continue;
|
||||
list($new, $count) = patchConstructors($src);
|
||||
list($new, $curly) = patchCurlyOffsets($new);
|
||||
if ($new !== $src) {
|
||||
file_put_contents($path, $new);
|
||||
$changed[$path] = true;
|
||||
$totalClasses += $count;
|
||||
$totalCurly += $curly;
|
||||
}
|
||||
}
|
||||
|
||||
// Durchlauf 2: statisch aufgerufene Methoden (dateiuebergreifend)
|
||||
foreach (patchStaticCalls($files) as $path => $count) {
|
||||
$changed[$path] = true;
|
||||
$totalStatic += $count;
|
||||
}
|
||||
|
||||
echo " PHP-8-Kompatibilitaet: $totalClasses Konstruktor(en), $totalCurly Offset(s), $totalStatic static-Methode(n) in " . count($changed) . " Datei(en) angepasst.\n";
|
||||
|
||||
/**
|
||||
* Markiert nicht-statische Methoden als static, wenn sie irgendwo als
|
||||
* Klasse::methode() aufgerufen werden, $this nicht verwenden und von keiner
|
||||
* Unterklasse nicht-statisch ueberschrieben werden.
|
||||
*
|
||||
* Liefert [Pfad => Anzahl geaenderter Methoden].
|
||||
*/
|
||||
function patchStaticCalls($files)
|
||||
{
|
||||
$methods = array(); // "klasse::methode" => [pfad, token-index, static, usesThis]
|
||||
$parents = array(); // "klasse" => "elternklasse"
|
||||
$calls = array(); // "klasse::methode" => true
|
||||
$tokensByFile = array();
|
||||
|
||||
foreach ($files as $path) {
|
||||
$src = file_get_contents($path);
|
||||
if ($src === false || strpos($src, '::') === false && stripos($src, 'class') === false) continue;
|
||||
$t = @token_get_all($src);
|
||||
$tokensByFile[$path] = $t;
|
||||
$n = count($t);
|
||||
$depth = 0;
|
||||
$cls = null;
|
||||
$clsDepth = -1;
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$x = $t[$i];
|
||||
if ($x === '{' || (is_array($x) && in_array($x[0], array(T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES), true))) {
|
||||
$depth++;
|
||||
} elseif ($x === '}') {
|
||||
$depth--;
|
||||
if ($depth === $clsDepth) { $cls = null; $clsDepth = -1; }
|
||||
} elseif (is_array($x) && $x[0] === T_CLASS) {
|
||||
$prev = prevSignificant($t, $i);
|
||||
if ($prev !== null && is_array($t[$prev]) && in_array($t[$prev][0], array(T_DOUBLE_COLON, T_NEW), true)) continue;
|
||||
$j = nextSignificant($t, $i);
|
||||
if ($j !== null && is_array($t[$j]) && $t[$j][0] === T_STRING) {
|
||||
$cls = strtolower($t[$j][1]);
|
||||
$clsDepth = $depth;
|
||||
$e = nextSignificant($t, $j);
|
||||
if ($e !== null && is_array($t[$e]) && $t[$e][0] === T_EXTENDS) {
|
||||
$pc = nextSignificant($t, $e);
|
||||
if ($pc !== null && is_array($t[$pc])) $parents[$cls] = strtolower(ltrim($t[$pc][1], '\\'));
|
||||
}
|
||||
}
|
||||
} elseif ($cls !== null && is_array($x) && $x[0] === T_FUNCTION && $depth === $clsDepth + 1) {
|
||||
$static = false;
|
||||
for ($k = $i - 1; $k >= 0; $k--) {
|
||||
if (is_array($t[$k]) && $t[$k][0] === T_STATIC) $static = true;
|
||||
if ($t[$k] === ';' || $t[$k] === '{' || $t[$k] === '}') break;
|
||||
}
|
||||
$j = nextSignificant($t, $i);
|
||||
if ($j !== null && $t[$j] === '&') $j = nextSignificant($t, $j);
|
||||
if ($j === null || !is_array($t[$j])) continue;
|
||||
$m = strtolower($t[$j][1]);
|
||||
$usesThis = false;
|
||||
$k = $j;
|
||||
while ($k < $n && $t[$k] !== '{' && $t[$k] !== ';') $k++;
|
||||
if ($k < $n && $t[$k] === '{') {
|
||||
$d = 0;
|
||||
for ($q = $k; $q < $n; $q++) {
|
||||
$y = $t[$q];
|
||||
if ($y === '{' || (is_array($y) && in_array($y[0], array(T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES), true))) $d++;
|
||||
elseif ($y === '}') { $d--; if ($d === 0) break; }
|
||||
elseif (is_array($y) && $y[0] === T_VARIABLE && $y[1] === '$this') $usesThis = true;
|
||||
}
|
||||
}
|
||||
$methods["$cls::$m"] = array($path, $i, $static, $usesThis);
|
||||
} elseif (is_array($x) && $x[0] === T_DOUBLE_COLON && $i > 0 && isset($t[$i + 1])) {
|
||||
$p = $t[$i - 1];
|
||||
$nx = $t[$i + 1];
|
||||
if (is_array($p) && $p[0] === T_STRING && is_array($nx) && $nx[0] === T_STRING) {
|
||||
$j = nextSignificant($t, $i + 1);
|
||||
$c = strtolower($p[1]);
|
||||
if ($j !== null && $t[$j] === '(' && !in_array($c, array('parent', 'self', 'static'), true)) {
|
||||
$calls[$c . '::' . strtolower($nx[1])] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Kandidaten je Datei sammeln (Token-Index der function-Deklaration)
|
||||
$todo = array();
|
||||
foreach ($calls as $key => $_) {
|
||||
if (!isset($methods[$key])) continue;
|
||||
list($path, $idx, $static, $usesThis) = $methods[$key];
|
||||
if ($static || $usesThis) continue;
|
||||
// Nicht anfassen, wenn eine Unterklasse die Methode nicht-statisch ueberschreibt
|
||||
list($target, $m) = explode('::', $key);
|
||||
$overridden = false;
|
||||
foreach ($methods as $other => $info) {
|
||||
list($oc, $om) = explode('::', $other);
|
||||
if ($om !== $m || $oc === $target || $info[2]) continue;
|
||||
for ($a = $oc, $guard = 0; isset($parents[$a]) && $guard < 20; $a = $parents[$a], $guard++) {
|
||||
if ($parents[$a] === $target) { $overridden = true; break 2; }
|
||||
}
|
||||
}
|
||||
if ($overridden) continue;
|
||||
$todo[$path][] = $idx;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
foreach ($todo as $path => $indexes) {
|
||||
$t = $tokensByFile[$path];
|
||||
foreach ($indexes as $idx) {
|
||||
$t[$idx] = array(T_FUNCTION, 'static ' . $t[$idx][1], 0);
|
||||
}
|
||||
$out = '';
|
||||
foreach ($t as $tok) $out .= is_array($tok) ? $tok[1] : $tok;
|
||||
file_put_contents($path, $out);
|
||||
$result[$path] = count($indexes);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ersetzt String-Offsets mit geschweiften Klammern ($str{0}) durch eckige
|
||||
* Klammern ($str[0]); unter PHP 8 ist die alte Syntax ein Parse-Error.
|
||||
* Erfasst wird nur "{" direkt nach einer Variablen oder "]" (ohne
|
||||
* Leerzeichen), dort hat "{" keine andere Bedeutung.
|
||||
*
|
||||
* Liefert [neuer Quelltext, Anzahl ersetzter Offsets].
|
||||
*/
|
||||
function patchCurlyOffsets($src)
|
||||
{
|
||||
if (strpos($src, '{') === false) return array($src, 0);
|
||||
$tokens = @token_get_all($src);
|
||||
$n = count($tokens);
|
||||
$count = 0;
|
||||
for ($i = 1; $i < $n; $i++) {
|
||||
if ($tokens[$i] !== '{') continue;
|
||||
$prev = $tokens[$i - 1];
|
||||
if (!($prev === ']' || (is_array($prev) && $prev[0] === T_VARIABLE))) continue;
|
||||
// Passende schliessende Klammer suchen
|
||||
$depth = 0;
|
||||
for ($j = $i; $j < $n; $j++) {
|
||||
$t = $tokens[$j];
|
||||
if ($t === '{' || (is_array($t) && in_array($t[0], array(T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES), true))) $depth++;
|
||||
elseif ($t === '}') { $depth--; if ($depth === 0) break; }
|
||||
}
|
||||
if ($j >= $n) continue;
|
||||
$tokens[$i] = '[';
|
||||
$tokens[$j] = ']';
|
||||
$count++;
|
||||
}
|
||||
if ($count === 0) return array($src, 0);
|
||||
$out = '';
|
||||
foreach ($tokens as $t) $out .= is_array($t) ? $t[1] : $t;
|
||||
return array($out, $count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Liefert [neuer Quelltext, Anzahl eingefuegter Konstruktoren].
|
||||
*/
|
||||
function patchConstructors($src)
|
||||
{
|
||||
if (stripos($src, 'class') === false) return array($src, 0);
|
||||
$eol = (strpos($src, "\r\n") !== false) ? "\r\n" : "\n";
|
||||
$tokens = @token_get_all($src);
|
||||
$n = count($tokens);
|
||||
$inserts = array(); // Byte-Offset => einzufuegender Text
|
||||
|
||||
// Byte-Offsets aller Tokens berechnen
|
||||
$offsets = array();
|
||||
$pos = 0;
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
$offsets[$i] = $pos;
|
||||
$pos += strlen(is_array($tokens[$i]) ? $tokens[$i][1] : $tokens[$i]);
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $n; $i++) {
|
||||
if (!is_array($tokens[$i]) || $tokens[$i][0] !== T_CLASS) continue;
|
||||
|
||||
// "Foo::class" und anonyme Klassen ("new class") ignorieren
|
||||
$prev = prevSignificant($tokens, $i);
|
||||
if ($prev !== null && is_array($tokens[$prev]) && in_array($tokens[$prev][0], array(T_DOUBLE_COLON, T_NEW), true)) continue;
|
||||
|
||||
$nameIdx = nextSignificant($tokens, $i);
|
||||
if ($nameIdx === null || !is_array($tokens[$nameIdx]) || $tokens[$nameIdx][0] !== T_STRING) continue;
|
||||
$className = $tokens[$nameIdx][1];
|
||||
|
||||
// Oeffnende Klammer des Klassenkoerpers suchen
|
||||
$open = $nameIdx;
|
||||
while ($open < $n && $tokens[$open] !== '{') $open++;
|
||||
if ($open >= $n) continue;
|
||||
|
||||
// Methoden auf Klassenebene einsammeln
|
||||
$depth = 0;
|
||||
$hasConstruct = false;
|
||||
$oldCtor = null;
|
||||
for ($j = $open; $j < $n; $j++) {
|
||||
$t = $tokens[$j];
|
||||
if ($t === '{' || (is_array($t) && in_array($t[0], array(T_CURLY_OPEN, T_DOLLAR_OPEN_CURLY_BRACES), true))) {
|
||||
$depth++;
|
||||
} elseif ($t === '}') {
|
||||
$depth--;
|
||||
if ($depth === 0) break;
|
||||
} elseif ($depth === 1 && is_array($t) && $t[0] === T_FUNCTION) {
|
||||
$k = nextSignificant($tokens, $j);
|
||||
if ($k !== null && $tokens[$k] === '&') $k = nextSignificant($tokens, $k);
|
||||
if ($k === null || !is_array($tokens[$k])) continue;
|
||||
$method = $tokens[$k][1];
|
||||
if (strcasecmp($method, '__construct') === 0) $hasConstruct = true;
|
||||
if (strcasecmp($method, $className) === 0) $oldCtor = $k;
|
||||
}
|
||||
}
|
||||
if ($hasConstruct || $oldCtor === null) continue;
|
||||
|
||||
// Parameterliste der alten Methode uebernehmen
|
||||
$p = $oldCtor;
|
||||
while ($p < $n && $tokens[$p] !== '(') $p++;
|
||||
$params = '';
|
||||
$vars = array();
|
||||
$byRef = false;
|
||||
$pd = 0;
|
||||
for ($q = $p; $q < $n; $q++) {
|
||||
$t = $tokens[$q];
|
||||
if ($t === '(') { $pd++; if ($pd === 1) continue; }
|
||||
if ($t === ')') { $pd--; if ($pd === 0) break; }
|
||||
$txt = is_array($t) ? $t[1] : $t;
|
||||
$params .= $txt;
|
||||
if ($pd === 1 && is_array($t) && $t[0] === T_VARIABLE) $vars[] = $t[1];
|
||||
if ($pd === 1 && $t === '&') $byRef = true;
|
||||
}
|
||||
|
||||
// Ohne Referenzparameter func_get_args() nutzen (gleiche Semantik bei
|
||||
// optionalen Parametern), sonst die Variablen direkt durchreichen.
|
||||
$call = $byRef ? implode(', ', $vars) : '...func_get_args()';
|
||||
$shim = "{$eol}\t// tmserver-docker: Php8Compat{$eol}"
|
||||
. "\tfunction __construct(" . trim($params) . ") { \$this->{$tokens[$oldCtor][1]}($call); }";
|
||||
$inserts[$offsets[$open] + 1] = $shim;
|
||||
}
|
||||
|
||||
if (empty($inserts)) return array($src, 0);
|
||||
krsort($inserts);
|
||||
foreach ($inserts as $off => $txt) {
|
||||
$src = substr($src, 0, $off) . $txt . substr($src, $off);
|
||||
}
|
||||
return array($src, count($inserts));
|
||||
}
|
||||
|
||||
function nextSignificant($tokens, $i)
|
||||
{
|
||||
for ($j = $i + 1, $n = count($tokens); $j < $n; $j++) {
|
||||
if (is_array($tokens[$j]) && in_array($tokens[$j][0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT), true)) continue;
|
||||
return $j;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function prevSignificant($tokens, $i)
|
||||
{
|
||||
for ($j = $i - 1; $j >= 0; $j--) {
|
||||
if (is_array($tokens[$j]) && in_array($tokens[$j][0], array(T_WHITESPACE, T_COMMENT, T_DOC_COMMENT), true)) continue;
|
||||
return $j;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -39,7 +39,7 @@ DEFAULT_CONTROLPANEL="/opt/tmserver/default-controlpanel"
|
||||
if [ ! -f "$ADMINSERV_DIR/index.php" ]; then
|
||||
echo "==> Erster Start erkannt: Kopiere AdminServ-Dateien ins Volume..."
|
||||
cp -a "$DEFAULT_CONTROLPANEL"/* "$ADMINSERV_DIR/"
|
||||
chmod 755 "$ADMINSERV_DIR/logs/"
|
||||
chmod 777 "$ADMINSERV_DIR/logs/"
|
||||
chmod 666 "$ADMINSERV_DIR/config/adminlevel.cfg.php"
|
||||
chmod 666 "$ADMINSERV_DIR/config/servers.cfg.php"
|
||||
chmod 666 "$ADMINSERV_DIR/config/adminserv.cfg.php"
|
||||
@@ -244,6 +244,54 @@ else
|
||||
echo "==> Vorhandene AdminServ-Daten gefunden. Keine Aenderungen."
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# RemoteCP: PHP-7.4-Kompatibilitaet & Fehleranzeige (bei jedem Start)
|
||||
# ============================================================
|
||||
# RemoteCP 4.0.3.5 nutzt veraltete Syntax ($str{0}, PHP4-Konstruktor), die
|
||||
# unter PHP 7.4 Deprecation-Meldungen im Browser erzeugt (unter PHP 8 fatal).
|
||||
# Ausserdem erzwingt core.functions.php display_errors=1 per ini_set() und
|
||||
# ignoriert damit PHP_DISPLAY_ERRORS. Die Patches sind idempotent und greifen
|
||||
# auch bei bestehenden Volumes.
|
||||
RCP_INC="$ADMINSERV_DIR/remotecp/includes"
|
||||
if [ -d "$RCP_INC" ]; then
|
||||
echo "==> Patche RemoteCP fuer PHP 7.4..."
|
||||
|
||||
# Geschweifte Klammern fuer String-Offsets -> eckige Klammern
|
||||
[ -f "$RCP_INC/core/rcp_textparser.class.php" ] && sed -i -E \
|
||||
-e 's/\$hex\{([0-9])\}/$hex[\1]/g' \
|
||||
-e 's/function TMFColorParser\(/function __construct(/' \
|
||||
"$RCP_INC/core/rcp_textparser.class.php"
|
||||
[ -f "$RCP_INC/core/GbxRemote.inc.php" ] && sed -i -E \
|
||||
-e 's/\$f_v\{([0-9])\}/$f_v[\1]/g' \
|
||||
"$RCP_INC/core/GbxRemote.inc.php"
|
||||
|
||||
# display_errors an PHP_DISPLAY_ERRORS koppeln
|
||||
if [ -f "$RCP_INC/core.functions.php" ]; then
|
||||
sed -i -E \
|
||||
-e "s/^ini_set\('display_errors', 1\);/ini_set('display_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
|
||||
-e "s/^ini_set\('display_startup_errors', 1\);/ini_set('display_startup_errors', getenv('PHP_DISPLAY_ERRORS') === 'true' ? 1 : 0);/" \
|
||||
"$RCP_INC/core.functions.php"
|
||||
# PHP-Warnings ohne Debug-Modus nur loggen, nicht im Browser anzeigen.
|
||||
# v2: Unter PHP 8 sind viele fruehere Notices (Undefined array key, ...)
|
||||
# Warnings; die werden wie unter PHP 7 ignoriert, sonst waechst das Log
|
||||
# um mehrere MB pro Tag. Alte v1-Variante wird ersetzt.
|
||||
if ! grep -q 'tmserver-docker: PHP_DISPLAY_ERRORS v2' "$RCP_INC/core.functions.php"; then
|
||||
sed -i '/tmserver-docker: PHP_DISPLAY_ERRORS - /,/^\t}$/d' "$RCP_INC/core.functions.php"
|
||||
sed -i "/if(error_reporting() == 0) return;/a\\
|
||||
\\t//tmserver-docker: PHP_DISPLAY_ERRORS v2 - PHP-Warnings ohne Debug-Modus nur loggen\\
|
||||
\\tif(\$errno == E_WARNING \&\& !ini_get('display_errors')) {\\
|
||||
\\t\\tif(preg_match('/^(Undefined (array key|variable|property|offset)|Attempt to read property|Trying to access array offset|Constant .* already defined|Array to string conversion)/', \$errstr)) return true;\\
|
||||
\\t\\twriteLog('errors', \"[PHP Warning] \$errstr on line \$errline in file \$errfile\");\\
|
||||
\\t\\treturn true;\\
|
||||
\\t}" "$RCP_INC/core.functions.php"
|
||||
fi
|
||||
fi
|
||||
|
||||
# sed -i legt neue Dateien als root an -> Besitzer wiederherstellen
|
||||
chown www-data:www-data "$RCP_INC/core.functions.php" \
|
||||
"$RCP_INC/core/rcp_textparser.class.php" "$RCP_INC/core/GbxRemote.inc.php" 2>/dev/null
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# XAseco: First-Run-Logik
|
||||
# ============================================================
|
||||
@@ -365,6 +413,66 @@ if [ "$XASECO_ENABLED" = "true" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# PHP-8-Kompatibilitaet (bei jedem Start, auch fuer bestehende Volumes)
|
||||
# ============================================================
|
||||
# AdminServ, RemoteCP und XAseco stammen aus PHP-5-Zeiten. Php8Compat.php
|
||||
# ergaenzt __construct() fuer PHP-4-Konstruktoren und stellt String-Offsets
|
||||
# mit geschweiften Klammern ($str{0}) auf eckige Klammern um. Idempotent.
|
||||
echo "==> Pruefe PHP-8-Kompatibilitaet..."
|
||||
php /opt/tmserver/Php8Compat.php "$ADMINSERV_DIR" /opt/tmserver/xaseco | tail -n 1
|
||||
|
||||
# XAseco: mysql_*-Shim (modernizer.inc.php) erwartet false bei SQL-Fehlern.
|
||||
# Seit PHP 8.1 wirft mysqli standardmaessig Exceptions -> abschalten.
|
||||
XASECO_MODERNIZER="/opt/tmserver/xaseco/includes/modernizer.inc.php"
|
||||
if [ -f "$XASECO_MODERNIZER" ] && ! grep -q 'mysqli_report' "$XASECO_MODERNIZER"; then
|
||||
sed -i '0,/^<?php/s//<?php\nmysqli_report(MYSQLI_REPORT_OFF); \/\/ tmserver-docker: PHP 8.1+/' "$XASECO_MODERNIZER"
|
||||
echo " modernizer.inc.php: mysqli_report(MYSQLI_REPORT_OFF) ergaenzt."
|
||||
fi
|
||||
|
||||
# XAseco: Webaccess initialisiert Antworten als '' statt array(). Schreib- und
|
||||
# Lesezugriffe wie $response['Code'] waren unter PHP 7 nur Warnings
|
||||
# ("Illegal string offset"), unter PHP 8 beenden sie XAseco (TypeError).
|
||||
XASECO_WEBACCESS="/opt/tmserver/xaseco/includes/web_access.inc.php"
|
||||
if [ -f "$XASECO_WEBACCESS" ] && grep -q "\['Response'\] = '';" "$XASECO_WEBACCESS"; then
|
||||
sed -i "s/\['Response'\] = '';/['Response'] = array();/" "$XASECO_WEBACCESS"
|
||||
echo " web_access.inc.php: Response als array() initialisiert."
|
||||
fi
|
||||
|
||||
# XAseco TeamSpeak3-Plugin: count() auf null ist unter PHP 8 ein TypeError
|
||||
XASECO_TS3="/opt/tmserver/xaseco/plugins/plugin.teamspeak3.php"
|
||||
if [ -f "$XASECO_TS3" ] && grep -qF "if ( count(\$info['players']) > 0 ) {" "$XASECO_TS3"; then
|
||||
sed -i "s/if ( count(\$info\['players'\]) > 0 ) {/if ( !empty(\$info['players']) \&\& is_array(\$info['players']) ) {/" "$XASECO_TS3"
|
||||
echo " plugin.teamspeak3.php: count()-Pruefung entschaerft."
|
||||
fi
|
||||
|
||||
# XAseco TeamSpeak3-Plugin: Antwortet der TS3-Query-Port nicht korrekt, wirft
|
||||
# tsstatus.php eine Exception, die niemand faengt -> XAseco stirbt (auch unter
|
||||
# PHP 7). Wie bei den uebrigen, bereits auskommentierten throws: leer zurueck.
|
||||
XASECO_TSSTATUS="/opt/tmserver/xaseco/includes/tsstatus.php"
|
||||
if [ -f "$XASECO_TSSTATUS" ] && grep -qF 'if(!$isTs3) throw new Exception("Not a Teamspeak 3 server/bad query port");' "$XASECO_TSSTATUS"; then
|
||||
sed -i 's|if(!\$isTs3) throw new Exception("Not a Teamspeak 3 server/bad query port");|if(!$isTs3) { $this->disconnect(); return ""; } // tmserver-docker: kein Absturz|' "$XASECO_TSSTATUS"
|
||||
echo " tsstatus.php: Exception bei fehlerhaftem TS3-Query entschaerft."
|
||||
fi
|
||||
|
||||
# AdminServ: stat() liefert bei Dateinamen mit Sonderzeichen false (AdminServ
|
||||
# wandelt sie vorher per utf8_encode um). @array_slice(false) war unter PHP 7
|
||||
# still, unter PHP 8 ein TypeError -> "MatchSettings erstellen" brach ab.
|
||||
ADMINSERV_FOLDER="$ADMINSERV_DIR/resources/class/folder.class.php"
|
||||
if [ -f "$ADMINSERV_FOLDER" ] && grep -qF '@array_slice(@stat($pathToEntry), 20, 3)' "$ADMINSERV_FOLDER"; then
|
||||
sed -i 's/@array_slice(@stat(\$pathToEntry), 20, 3)/((\$st = @stat(\$pathToEntry)) ? array_slice(\$st, 20, 3) : array())/' "$ADMINSERV_FOLDER"
|
||||
echo " folder.class.php: stat()-Fehler abgefangen."
|
||||
fi
|
||||
|
||||
# AdminServ: Felder wie LapsTimeLimit werden in ms angezeigt, beim Speichern
|
||||
# aber nochmals mit 1000 multipliziert. Beim Maximalwert 2147483647 lehnt der
|
||||
# Server den Aufruf ab (Numerical result out of range) -> auf int32 begrenzen.
|
||||
ADMINSERV_TIMEDATE="$ADMINSERV_DIR/resources/class/timedate.class.php"
|
||||
if [ -f "$ADMINSERV_TIMEDATE" ] && grep -qF 'if($millisec > 0){ return $millisec; }' "$ADMINSERV_TIMEDATE"; then
|
||||
sed -i 's/if(\$millisec > 0){ return \$millisec; }/if($millisec > 0){ return min($millisec, 2147483647); }/' "$ADMINSERV_TIMEDATE"
|
||||
echo " timedate.class.php: secToMillisec() auf int32 begrenzt."
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# XAseco: TeamSpeak3-Plugin Gateway aktualisieren (fuer bestehende Volumes)
|
||||
# ============================================================
|
||||
@@ -493,22 +601,21 @@ if [ -f "$ADMINSERV_CFG_VOL" ] && grep -q "0b28a5799a32c687dad2c5183718ceac" "$A
|
||||
fi
|
||||
|
||||
# ============================================================
|
||||
# AdminServ: Logs-Verzeichnis-Berechtigungen korrigieren (fuer bestehende Volumes)
|
||||
# AdminServ: Berechtigungen fuer Logs und Configs sicherstellen
|
||||
# ============================================================
|
||||
# In aelteren Versionen wurde /var/www/html/logs/ mit chmod 777
|
||||
# (world-writable) angelegt. logrotate verweigert die Rotation von
|
||||
# Log-Dateien in world-writable Verzeichnissen aus Sicherheitsgruenden.
|
||||
# Die korrekte Berechtigung ist 755: www-data (Owner) behaelt
|
||||
# Schreibzugriff, anderen Nutzern wird Write entzogen.
|
||||
# AdminServ verlangt Schreibrechte (777 fuer ./logs/ und 666 fuer Configs).
|
||||
# Beim Containerstart stellen wir sicher, dass das Verzeichnis existiert,
|
||||
# www-data gehoert und die noetigen Berechtigungen gesetzt sind.
|
||||
# ============================================================
|
||||
ADMINSERV_LOGS_DIR="/var/www/html/logs"
|
||||
if [ -d "$ADMINSERV_LOGS_DIR" ]; then
|
||||
CURRENT_PERMS=$(stat -c '%a' "$ADMINSERV_LOGS_DIR")
|
||||
if [ "$CURRENT_PERMS" != "755" ]; then
|
||||
echo "==> Korrigiere Berechtigungen fuer AdminServ-Logs-Verzeichnis (${CURRENT_PERMS} -> 755)..."
|
||||
chmod 755 "$ADMINSERV_LOGS_DIR"
|
||||
echo " Berechtigungen erfolgreich korrigiert."
|
||||
fi
|
||||
mkdir -p "$ADMINSERV_LOGS_DIR"
|
||||
chmod 777 "$ADMINSERV_LOGS_DIR"
|
||||
chown -R www-data:www-data "$ADMINSERV_LOGS_DIR" 2>/dev/null || true
|
||||
|
||||
ADMINSERV_CONFIG_DIR="/var/www/html/config"
|
||||
if [ -d "$ADMINSERV_CONFIG_DIR" ]; then
|
||||
chmod 666 "$ADMINSERV_CONFIG_DIR"/*.cfg.php 2>/dev/null || true
|
||||
chown -R www-data:www-data "$ADMINSERV_CONFIG_DIR" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "Starting apache server"
|
||||
|
||||
@@ -94,8 +94,12 @@ check_xaseco_log() {
|
||||
if [ ! -f "$LOG_FILE" ]; then
|
||||
return 0
|
||||
fi
|
||||
# Letzte 20 Zeilen auf fatale Fehler / Verbindungsabbrueche pruefen
|
||||
LAST_LINES=$(tail -20 "$LOG_FILE" 2>/dev/null)
|
||||
# Letzte 20 Zeilen auf fatale Fehler / Verbindungsabbrueche pruefen.
|
||||
# Fehlschlaege externer Webdienste (Dedimania, ManiaKarma, ...) laufen ueber
|
||||
# Webaccess/fsockopen und betreffen nicht die Verbindung zum TM-Server.
|
||||
# Ohne Filter loeste das nicht erreichbare dedimania.net alle ~30 Minuten
|
||||
# einen XAseco-Neustart aus.
|
||||
LAST_LINES=$(tail -20 "$LOG_FILE" 2>/dev/null | grep -v -i "webaccess\|fsockopen\|dedimania")
|
||||
# Typische Fehlermeldungen bei XAseco-Verbindungsverlust
|
||||
if echo "$LAST_LINES" | grep -qi "connection refused\|broken pipe\|server not responding\|transport error\|socket error\|fatal error"; then
|
||||
return 1
|
||||
|
||||
@@ -42,6 +42,19 @@
|
||||
copytruncate
|
||||
}
|
||||
|
||||
# RemoteCP-Logs (liegen im persistenten Volume)
|
||||
/var/www/html/remotecp/cache/*.log
|
||||
{
|
||||
su www-data www-data
|
||||
size 10M
|
||||
rotate 5
|
||||
missingok
|
||||
notifempty
|
||||
compress
|
||||
delaycompress
|
||||
copytruncate
|
||||
}
|
||||
|
||||
# AdminServ-Logs (liegen im persistenten Volume)
|
||||
/var/www/html/logs/*.log
|
||||
{
|
||||
|
||||
+12
-9
@@ -1,6 +1,6 @@
|
||||
services:
|
||||
tmserver:
|
||||
image: git.techniverse.net/scriptos/trackmania-server:1.3.2
|
||||
image: git.techniverse.net/scriptos/trackmania-server:1.4.1
|
||||
build:
|
||||
context: .
|
||||
container_name: tmserver
|
||||
@@ -13,16 +13,19 @@ services:
|
||||
- "${SERVER_PORT:-2350}:${SERVER_PORT:-2350}/tcp"
|
||||
- "${SERVER_PORT:-2350}:${SERVER_PORT:-2350}/udp"
|
||||
- "${SERVER_P2P_PORT:-3450}:${SERVER_P2P_PORT:-3450}/tcp"
|
||||
- "80:80/tcp"
|
||||
- "16080:80/tcp"
|
||||
- "3450:3450/udp"
|
||||
env_file:
|
||||
- .env
|
||||
dns:
|
||||
- 1.1.1.1
|
||||
volumes:
|
||||
- ./data/gamedata:/opt/tmserver/GameData
|
||||
- ./data/controlpanel:/var/www/html
|
||||
- ./data/xaseco:/opt/tmserver/xaseco
|
||||
networks:
|
||||
tmserver_net:
|
||||
ipv4_address: 172.20.60.10
|
||||
ipv4_address: 172.20.72.10
|
||||
|
||||
mariadb:
|
||||
image: mariadb:11.4
|
||||
@@ -51,10 +54,10 @@ services:
|
||||
start_period: 30s
|
||||
networks:
|
||||
tmserver_net:
|
||||
ipv4_address: 172.20.60.11
|
||||
ipv4_address: 172.20.72.11
|
||||
|
||||
ip-watcher:
|
||||
image: alpine:3.21
|
||||
image: alpine:3.24
|
||||
container_name: tmserver-ip-watcher
|
||||
restart: unless-stopped
|
||||
depends_on:
|
||||
@@ -67,7 +70,7 @@ services:
|
||||
- ./assets/bin/WatchPublicIP.sh:/opt/WatchPublicIP.sh:ro
|
||||
networks:
|
||||
tmserver_net:
|
||||
ipv4_address: 172.20.60.12
|
||||
ipv4_address: 172.20.72.12
|
||||
|
||||
networks:
|
||||
tmserver_net:
|
||||
@@ -75,6 +78,6 @@ networks:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
- subnet: 172.20.60.0/25
|
||||
gateway: 172.20.60.1
|
||||
ip_range: 172.20.60.64/26
|
||||
- subnet: 172.20.72.0/25
|
||||
gateway: 172.20.72.1
|
||||
ip_range: 172.20.72.64/26
|
||||
+1
-1
@@ -165,6 +165,6 @@ Falls RemoteCP nicht erreichbar ist oder Fehler anzeigt:
|
||||
|
||||
### Bekannte Hinweise
|
||||
|
||||
- RemoteCP ist ein älteres Tool (Version 4.0.3.5) und wurde für PHP 5.x entwickelt, läuft aber mit PHP 7.4
|
||||
- RemoteCP ist ein älteres Tool (Version 4.0.3.5) und wurde für PHP 5.x entwickelt. Ab v1.4.0 läuft es dank automatischer Kompatibilitäts-Patches beim Containerstart unter PHP 8.4 (siehe README)
|
||||
- Die Live-Funktionen (`remoteCP[Live]`) benötigen eine laufende Serververbindung
|
||||
- **Sicherheitshinweis:** Die Registrierung neuer Benutzer ist standardmäßig aktiviert. Aus Sicherheitsgründen sollte diese deaktiviert werden, damit sich keine unbefugten Nutzer einen Zugang anlegen können. Dazu in der Datei `data/controlpanel/remotecp/xml/settings/settings.xml` den Wert `<register>false</register>` setzen
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
XAseco ist ein Server-Controller für TrackMania Nations Forever. Er verwaltet lokale Rekorde, Dedimania-Weltrekorde, Karma/Votes, eine Track-Jukebox und vieles mehr direkt im Spielchat.
|
||||
|
||||
Im Container wird die modifizierte Version **XAseco 1.16** verwendet, die für PHP 7.x angepasst wurde (Patches von Bueddel, Xymph, undef.de und reaby).
|
||||
Im Container wird die modifizierte Version **XAseco 1.16** verwendet, die für PHP 7.x angepasst wurde (Patches von Bueddel, Xymph, undef.de und reaby). Ab v1.4.0 wird sie beim Containerstart zusätzlich automatisch für PHP 8.4 gepatcht (siehe README).
|
||||
|
||||
## Funktionsweise
|
||||
|
||||
|
||||
Reference in new issue
Block a user