diff --git a/Dockerfile b/Dockerfile index 3cc1eda..9c5deaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,6 +76,13 @@ RUN unzip /var/www/html/remoteCP_v4.0.3.5.zip -d /var/www/html \ 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 +# Fix PHP-Warnungen in RemoteCP Mods-Plugin (foreach auf leere Umgebungen) +# Leere Umgebungen (Island, Bay, …) fuehrten zu "Invalid argument supplied +# for foreach()", weil $this->mods['Env'] nicht initialisiert war. +# Zusaetzlich bare-constant-Warnungen (pt_*) mit defined()-Pruefungen entschaerft. +COPY assets/config/remotecp/plugins/Mods/index.php /var/www/html/remotecp/plugins/Mods/index.php +RUN chown www-data:www-data /var/www/html/remotecp/plugins/Mods/index.php + # RemoteCP Mods-Plugin: Vorkonfigurierte Skin-Liste (techniverse.net) COPY assets/config/remotecp/plugins/Mods/settings.xml /var/www/html/remotecp/plugins/Mods/settings.xml RUN chown www-data:www-data /var/www/html/remotecp/plugins/Mods/settings.xml diff --git a/assets/config/remotecp/plugins/Mods/index.php b/assets/config/remotecp/plugins/Mods/index.php new file mode 100644 index 0000000..b2ebac6 --- /dev/null +++ b/assets/config/remotecp/plugins/Mods/index.php @@ -0,0 +1,320 @@ +mods['Env'] nicht initialisiert war. +* Zusaetzlich bare-constant-Warnungen (pt_*) mit defined()-Pruefungen entschaerft. +*/ +class Mods extends rcp_plugin +{ + public $display = 'side'; + public $title = 'Mods'; + public $author = 'hal.ko.sascha'; + public $version = '4.0.3.5'; + public $nservstatus = array(2,3,4,5); + public $vpermissions = array('editserversettings'); + public $apermissions = array( + 'setMods' => 'editserversettings', + 'setMusic' => 'editserversettings' + ); + + private $mods = array(); + private $music = array(); + + /** + * Alle bekannten Umgebungs-Keys mit leeren Arrays vorbelegen, + * damit foreach() auch bei fehlenden Eintraegen nicht warnt. + */ + private function initModDefaults() + { + $envs = array('Stadium', 'Island', 'Bay', 'Coast', 'Speed', 'Alpine', 'Rally'); + foreach($envs as $env) { + if(!isset($this->mods[$env])) { + $this->mods[$env] = array(); + } + } + } + + public function onLoadSettings($settings) + { + // Set defaults + $this->mods = array(); + $this->music = array(); + + // Alle Umgebungen vorinitialisieren + $this->initModDefaults(); + + // Read mods settings + if(!$settings->mods) return; + foreach($settings->mods->children() AS $env) + { + if(!$env) continue; + $tmp = (string) $env->getName(); + if(!isset($this->mods[$tmp])) { + $this->mods[$tmp] = array(); + } + foreach($env->children() AS $item) + { + $this->mods[$tmp][] = array( + 'url' => (string) $item, + 'name' => (string) $item['name'] + ); + } + } + + // Read music settings + if(!$settings->music) return; + foreach($settings->music->children() AS $song) + { + $this->music[] = array( + 'url' => (string) $song, + 'name' => (string) $song['name'] + ); + } + } + + public function onOutput() { + if(Core::getObject('gbx')->query('GetForcedMods')) { + $ForcedMods = Core::getObject('gbx')->getResponse(); + + if(!empty($ForcedMods)) { + echo "
"; + } + } + + echo ""; + + if(Core::getObject('gbx')->query('GetForcedMusic')) { + $ForcedMusic = Core::getObject('gbx')->getResponse(); + + if(!empty($ForcedMusic)) { + echo ""; + } + } + + echo "