fix: RemoteCP CustomPoints PHP-Warnungen behoben (undefined constants)

Bare-constant-Zugriffe (pt_custom, pt_points, ...) in CustomPoints/index.php
durch defined()-Prüfungen ersetzt, um PHP 7.2+ Warnungen zu vermeiden.
Zusätzlich werden im Produktivmodus (PHP_DISPLAY_ERRORS=false) Warnungen
und Notices in der PHP error_reporting unterdrückt.

- Gepatchte index.php als assets/config/remotecp/plugins/CustomPoints/index.php
- Dockerfile: COPY der gepatchten Datei statt fragiler sed-Patches
- RunTrackmaniaServer.sh: Auto-Patch für bestehende Volumes beim Container-Start
- error_reporting im Produktivmodus um ~E_WARNING & ~E_NOTICE ergänzt

Closes #4
This commit is contained in:
Patrick Asmus (scriptos)
2026-03-22 01:09:37 +01:00
parent ffdc11a02b
commit 5891429c83
4 changed files with 161 additions and 2 deletions
+6
View File
@@ -70,6 +70,12 @@ RUN unzip /var/www/html/remoteCP_v4.0.3.5.zip -d /var/www/html \
&& chmod -R 777 /var/www/html/remotecp/xml/settings \
&& chown -R www-data:www-data /var/www/html/remotecp/
# Fix PHP-Warnungen in RemoteCP CustomPoints-Plugin (undefined constants)
# RemoteCP nutzt bare constants (pt_custom, pt_points, ...), die in PHP 7.2+
# Warnungen ausloesen. Das gepatchte Plugin nutzt stattdessen defined()-Pruefungen.
COPY assets/config/remotecp/plugins/CustomPoints/index.php /var/www/html/remotecp/plugins/CustomPoints/index.php
RUN chown www-data:www-data /var/www/html/remotecp/plugins/CustomPoints/index.php
# AdminServ- und RemoteCP-Dateien als Default-Template sichern (wird beim ersten Start ins Volume kopiert)
RUN cp -a /var/www/html /opt/tmserver/default-controlpanel
+17 -1
View File
@@ -18,7 +18,7 @@ else
echo "==> PHP-Debug-Modus deaktiviert"
cat > "$PHP_INI_DIR/99-adminserv-debug.ini" <<EOF
display_errors = Off
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT & ~E_WARNING & ~E_NOTICE
log_errors = On
error_log = /var/log/php_errors.log
EOF
@@ -353,6 +353,22 @@ if [ "$XASECO_ENABLED" = "true" ]; then
fi
fi
# ============================================================
# RemoteCP: PHP-Warnungen in Plugins fixen (fuer bestehende Volumes)
# ============================================================
# RemoteCP nutzt bare constants (pt_custom, pt_points, ...), die in
# PHP 7.2+ Warnungen ausloesen. Die gepatchte Datei aus dem Image
# wird in das Volume kopiert, falls die alte Version noch vorhanden ist.
# ============================================================
CUSTOMPOINTS_FILE="/var/www/html/remotecp/plugins/CustomPoints/index.php"
CUSTOMPOINTS_DEFAULT="/opt/tmserver/default-controlpanel/remotecp/plugins/CustomPoints/index.php"
if [ -f "$CUSTOMPOINTS_FILE" ] && ! grep -q 'defined.*pt_custom' "$CUSTOMPOINTS_FILE"; then
echo "==> Patche CustomPoints-Plugin (PHP-Warnungen beheben)..."
cp "$CUSTOMPOINTS_DEFAULT" "$CUSTOMPOINTS_FILE"
chown www-data:www-data "$CUSTOMPOINTS_FILE"
echo " CustomPoints-Plugin erfolgreich gepatcht."
fi
echo "Starting apache server"
service apache2 start
@@ -0,0 +1,135 @@
<?php
/**
* remoteCP 4
* ütf-8 release
*
* @package remoteCP
* @author hal.sascha
* @copyright (c) 2006-2009
* @version 4.0.3.5
*
* Patched by tmserver-docker:
* - Bare-constant-Zugriffe (pt_custom, pt_points, ...) durch
* defined()-Pruefungen ersetzt, um PHP 7.2+ Warnungen zu vermeiden.
*/
class CustomPoints extends rcp_plugin
{
public $display = 'side';
public $title = 'Points';
public $author = 'hal.ko.sascha';
public $version = '4.0.3.5';
public $nservstatus = array(2,3,4,5);
public $vpermissions = array('editgamesettings');
public $apermissions = array(
'setPoints' => 'editgamesettings',
'setPointsPreset' => 'editgamesettings'
);
public $presets;
public function onLoad()
{
$this->presets = Core::getObject('session')->loadXML(
Core::getSetting('pluginpath') . $this->id . '/presets.xml'
);
}
public function onOutput()
{
$CustomPoints = array();
if (Core::getObject('gbx')->query('GetRoundCustomPoints')) {
$CustomPoints = Core::getObject('gbx')->getResponse();
}
if (!is_array($CustomPoints)) {
$CustomPoints = array();
}
if (!Core::getObject('session')->checkPerm('editgamesettings')) {
return;
}
echo "<form action='ajax.php' method='post' id='custompoints' name='custompoints' class='postcmd' rel='{$this->display}area'>";
echo "<fieldset>";
echo "<div class='legend'>" . (defined('pt_custom') ? pt_custom : 'Custom Points') . "</div>";
echo "<div class='f-row'>
<label for='points'>" . (defined('pt_points') ? pt_points : 'Points') . "</label>
<div class='f-field'>
<input type='text' name='points' id='points' value='" . implode(',', $CustomPoints) . "' />
<div class='small'>" . (defined('pt_commasep') ? pt_commasep : 'Comma separated') . "</div>
</div>";
echo "</div>";
echo "</fieldset>";
echo "<input type='hidden' name='plugin' value='{$this->id}' />";
echo "<input type='hidden' name='action' value='setPoints' />";
echo "<button type='submit' title='" . (defined('ct_submit') ? ct_submit : 'Submit') . "' class='wide'>" . (defined('ct_submit') ? ct_submit : 'Submit') . "</button>";
echo "</form>";
echo "<form action='ajax.php' method='post' id='custompointspreset' name='custompointspreset' class='postcmd' rel='{$this->display}area'>";
echo "<fieldset>";
echo "<div class='legend'>" . (defined('pt_presets') ? pt_presets : 'Presets') . "</div>";
if ($this->presets && is_object($this->presets)) {
foreach ($this->presets->children() as $preset) {
$name = isset($preset['name']) ? $preset['name'] : 'Preset';
$points = isset($preset['points']) ? (string)$preset['points'] : '';
echo "<div class='f-row'>
<label>{$name}</label>
<div class='f-field'>";
echo "<input style='width:25px;' type='radio' name='preset' value='{$points}' /> ";
if (strlen($points) > 25) {
echo substr($points, 0, 25) . "...";
} else {
echo $points;
}
echo "</div>";
echo "</div>";
}
}
echo "</fieldset>";
echo "<input type='hidden' name='plugin' value='{$this->id}' />";
echo "<input type='hidden' name='action' value='setPointsPreset' />";
echo "<button type='submit' title='" . (defined('ct_submit') ? ct_submit : 'Submit') . "' class='wide'>" . (defined('ct_submit') ? ct_submit : 'Submit') . "</button>";
echo "</form>";
}
public function setPoints()
{
if (!array_key_exists('points', $_REQUEST)) return;
$str = preg_replace("/[^0-9,]/", "", $_REQUEST['points']);
$array = $this->makeIntArray(explode(',', $str));
Core::getObject('actions')->add('SetRoundCustomPoints', $array, true);
}
public function setPointsPreset()
{
if (!array_key_exists('preset', $_REQUEST)) return;
$str = preg_replace("/[^0-9,]/", "", $_REQUEST['preset']);
$array = $this->makeIntArray(explode(',', $str));
Core::getObject('actions')->add('SetRoundCustomPoints', $array, true);
}
private function makeIntArray($array)
{
foreach ($array as $key => $value) {
$array[$key] = (int)$value;
}
return $array;
}
}
+3 -1
View File
@@ -116,9 +116,11 @@ XAseco ist ein Server-Controller für Rekorde, Karma, Jukebox und mehr. Siehe [X
| Variable | Beschreibung | Standard |
|----------|-------------|----------|
| `PHP_DISPLAY_ERRORS` | Zeigt PHP-Fehlermeldungen im Browser an (nur zur Fehlersuche!) | `false` |
| `PHP_DISPLAY_ERRORS` | Aktiviert den PHP-Debug-Modus: Fehlermeldungen im Browser + vollständige Warnungen im Log (nur zur Fehlersuche!) | `false` |
> **Hinweis:** Der Debug-Modus erfordert **keinen** Rebuild des Images. Es genügt, die Variable in der `.env`-Datei zu ändern und den Container neu zu starten (`docker compose restart`). Im Produktivbetrieb sollte `PHP_DISPLAY_ERRORS` immer auf `false` stehen.
>
> Bei `false` werden nur schwerwiegende Fehler geloggt (keine Warnungen/Notices). Bei `true` werden zusätzlich alle Warnungen und Hinweise angezeigt und geloggt nützlich zur Fehlersuche bei Problemen mit RemoteCP oder AdminServ.
> **Hinweis:** Bei `FORCE_CONFIG_UPDATE=true` wird die `dedicated_cfg.txt` aus dem Template neu erzeugt und alle Platzhalter mit den aktuellen Umgebungsvariablen ersetzt. Manuelle Änderungen gehen dabei verloren! Nach dem Update sollte `FORCE_CONFIG_UPDATE` wieder auf `false` gesetzt werden.