Compare commits

...
6 Commits
Author SHA1 Message Date
Patrick Asmus 8b6a34e8d1 fix(xaseco): Neustart-Schleifen durch TS3-Plugin und Dedimania beheben
- tsstatus.php: ungefangene Exception bei fehlerhafter TS3-Query-Antwort
  beendete XAseco (auch unter PHP 7, live 58x im Log); jetzt leere Antwort
- XAsecoHealthcheck.sh: Webaccess-/Dedimania-Verbindungsfehler nicht mehr
  als XAseco-Fehler werten; das nicht erreichbare dedimania.net loeste
  sonst alle ~30 Minuten einen Neustart aus
2026-11-01 17:06:59 +01:00
Patrick Asmus 96798c2db6 fix(php8): AdminServ MatchSettings-Erstellung und Zeitlimit-Ueberlauf beheben
- folder.class.php: @array_slice(@stat()) brach unter PHP 8 mit TypeError
  ab, wenn Map-Dateinamen Sonderzeichen enthalten (MatchSettings erstellen
  -> HTTP 500)
- timedate.class.php: secToMillisec() auf int32 begrenzen; LapsTimeLimit
  wird in ms angezeigt und beim Speichern erneut mit 1000 multipliziert,
  der Server lehnte 2147483647000 ab (bestehender AdminServ-Bug)
2026-11-01 14:07:01 +01:00
Patrick Asmus 9f8f0f00d6 fix(php8): RemoteCP-Log-Rauschen reduzieren und errors.log rotieren
Unter PHP 8 sind viele fruehere Notices (Undefined array key, Attempt to
read property ...) Warnings. Der RemoteCP-Errorhandler ignoriert diese
ohne Debug-Modus wie bisher unter PHP 7; im Test wuchs errors.log sonst
um rund 500 KB in 15 Minuten. Zusaetzlich rotiere ich remotecp/cache/*.log
per logrotate (10 MB, 5 Dateien).
2026-11-01 13:51:55 +01:00
Patrick Asmus 1ecb6c93b3 fix(php8): statische Aufrufe, XAseco-Webaccess und TS3-count() fuer PHP 8 anpassen
- Php8Compat.php: nicht-statische Methoden, die als Klasse::methode()
  aufgerufen werden und kein $this nutzen, als static markieren
  (RemoteCP Core/Plugins, AdminServ Zip)
- web_access.inc.php: Response als array() statt '' initialisieren
  (behebt Illegal string offset in web_access, xmlrpc_db, mania_karma)
- plugin.teamspeak3.php: count() auf null entschaerft
2026-11-01 13:25:23 +01:00
Patrick Asmus b13b524ad5 feat(php8): Umstieg auf Debian Trixie mit PHP 8.4 (WIP)
PHP 7.4 ist seit 2022 EOL und bekommt keine Fixes mehr (u. a. PHP2Shell,
CVE-2026-109618/109619). Ich stelle das Image deshalb auf debian:trixie-slim
mit PHP 8.4.27 um.

- Php8Compat.php: ergaenzt __construct() fuer PHP-4-Konstruktoren und stellt
  String-Offsets $str{0} auf $str[0] um (AdminServ, RemoteCP, XAseco)
- RunTrackmaniaServer.sh: Patcher bei jedem Start auf die Volumes anwenden,
  mysqli_report(MYSQLI_REPORT_OFF) fuer den mysql_*-Shim von XAseco
- Bullseye-Archive-Repositories entfernt
2026-11-01 13:16:00 +01:00
Patrick Asmus 5ca2f1587f fix(remotecp): PHP-7.4-Deprecations beheben und PHP_DISPLAY_ERRORS respektieren
RemoteCP 4.0.3.5 hat nach jedem Neustart Deprecation-Meldungen oben auf der
Seite ausgegeben, obwohl PHP_DISPLAY_ERRORS=false gesetzt war.

Ich patche RemoteCP jetzt bei jedem Containerstart idempotent (greift auch
bei bestehenden Volumes):
- rcp_textparser.class.php: $hex{n} -> $hex[n], TMFColorParser-Konstruktor
  auf __construct() umgestellt
- GbxRemote.inc.php: $f_v{n} -> $f_v[n]
- core.functions.php: display_errors/display_startup_errors an
  PHP_DISPLAY_ERRORS gekoppelt statt hart auf 1; PHP-Warnings werden ohne
  Debug-Modus nur noch in cache/errors.log geschrieben
2026-11-01 12:47:14 +01:00
5 changed files with 458 additions and 8 deletions

No files matched your search

+6 -6
View File
@@ -1,15 +1,11 @@
FROM debian:bullseye-slim # Debian 13 Trixie liefert PHP 8.4 mit regulaeren Security-Updates
FROM debian:trixie-slim
RUN mkdir /opt/tmserver RUN mkdir /opt/tmserver
WORKDIR /opt/tmserver WORKDIR /opt/tmserver
# Alle benoetigten Pakete in einem Layer installieren und Cache aufraeumen # Alle benoetigten Pakete in einem Layer installieren und Cache aufraeumen
# Debian Bullseye Archive-Repositories konfigurieren (Bullseye ist archiviert)
RUN echo "deb http://archive.debian.org/debian bullseye main" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security bullseye-security main" >> /etc/apt/sources.list \
&& echo "Acquire::Check-Valid-Until false;" > /etc/apt/apt.conf.d/99no-check-valid-until
RUN apt-get update && apt-get install -y --no-install-recommends \ RUN apt-get update && apt-get install -y --no-install-recommends \
unzip \ unzip \
apache2 \ apache2 \
@@ -53,6 +49,10 @@ COPY assets/bin/RunTrackmaniaServer.sh /opt/tmserver/
RUN sed -i 's/\r$//' /opt/tmserver/RunTrackmaniaServer.sh \ RUN sed -i 's/\r$//' /opt/tmserver/RunTrackmaniaServer.sh \
&& chmod +x /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/ COPY assets/bin/XAsecoHealthcheck.sh /opt/tmserver/
RUN sed -i 's/\r$//' /opt/tmserver/XAsecoHealthcheck.sh \ RUN sed -i 's/\r$//' /opt/tmserver/XAsecoHealthcheck.sh \
&& chmod +x /opt/tmserver/XAsecoHealthcheck.sh && chmod +x /opt/tmserver/XAsecoHealthcheck.sh
+325
View File
@@ -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;
}
+108
View File
@@ -244,6 +244,54 @@ else
echo "==> Vorhandene AdminServ-Daten gefunden. Keine Aenderungen." echo "==> Vorhandene AdminServ-Daten gefunden. Keine Aenderungen."
fi 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 # XAseco: First-Run-Logik
# ============================================================ # ============================================================
@@ -365,6 +413,66 @@ if [ "$XASECO_ENABLED" = "true" ]; then
fi fi
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) # XAseco: TeamSpeak3-Plugin Gateway aktualisieren (fuer bestehende Volumes)
# ============================================================ # ============================================================
+6 -2
View File
@@ -94,8 +94,12 @@ check_xaseco_log() {
if [ ! -f "$LOG_FILE" ]; then if [ ! -f "$LOG_FILE" ]; then
return 0 return 0
fi fi
# Letzte 20 Zeilen auf fatale Fehler / Verbindungsabbrueche pruefen # Letzte 20 Zeilen auf fatale Fehler / Verbindungsabbrueche pruefen.
LAST_LINES=$(tail -20 "$LOG_FILE" 2>/dev/null) # 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 # 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 if echo "$LAST_LINES" | grep -qi "connection refused\|broken pipe\|server not responding\|transport error\|socket error\|fatal error"; then
return 1 return 1
+13
View File
@@ -42,6 +42,19 @@
copytruncate 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) # AdminServ-Logs (liegen im persistenten Volume)
/var/www/html/logs/*.log /var/www/html/logs/*.log
{ {