mirror of
https://github.com/unraid/webgui.git
synced 2026-04-27 21:40:20 -05:00
script to fix selected template descriptions
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?PHP
|
||||
function startsWith($haystack, $needle) {
|
||||
if ( !is_string($haystack) || ! is_string($needle) ) return false;
|
||||
return $needle === "" || strripos($haystack, $needle, -strlen($haystack)) !== FALSE;
|
||||
}
|
||||
|
||||
$xmlFiles = glob("/boot/config/plugins/dockerMan/templates-user/*.xml");
|
||||
|
||||
foreach ($xmlFiles as $file) {
|
||||
unset($changeFlag);
|
||||
$xml = simplexml_load_file($file);
|
||||
if ( ! $xml ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($xml->Config as $id => $config) {
|
||||
if ( startsWith((string)$config->attributes()->Description,"Container ".(string)$config->attributes()->Type) ) {
|
||||
$config->attributes()->Description = "";
|
||||
$changeFlag = true;
|
||||
}
|
||||
}
|
||||
if ( $changeFlag ) {
|
||||
copy($file,"$file.bak");
|
||||
$dom = new DOMDocument('1.0');
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
$dom->loadXML($xml->asXML());
|
||||
file_put_contents($file,$dom->saveXML());
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user