From 8c2590dd68fd6f754598bec2e556e6ad850565f2 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 21:28:21 +0100 Subject: [PATCH 01/34] VM template fixes - fix show/hide elements - fix translations --- .../templates/Custom.form.php | 182 ++++++++---------- 1 file changed, 82 insertions(+), 100 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 0cc843528..ac72d8766 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -347,11 +347,11 @@ if ($snapshots != null && count($snapshots) && !$boolNew) { - + @@ -655,7 +655,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { @@ -1066,7 +1066,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { @@ -1282,9 +1282,9 @@ foreach ($arrConfig['shares'] as $i => $arrShare) { ?> _(VM Console Port)_: - + _(VM Console WS Port)_: - + @@ -1342,7 +1342,7 @@ foreach ($arrConfig['shares'] as $i => $arrShare) { - +
_(BIOS)_: - _(vDisk Bus)_: - _(Boot Order)_: @@ -924,7 +924,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { _(SSD)_: - value=""> + value="">
_(vDisk Bus)_: - _(Boot Order)_: @@ -1076,7 +1076,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { - +
_(Graphics ROM Needed?)_: _(GPU is primary adapater, vbios may be required.)_
_(Graphics ROM Needed)_?: _(GPU is primary adapter, vbios may be required)_.
@@ -1416,7 +1416,7 @@ foreach ($arrConfig['shares'] as $i => $arrShare) { - _(Graphics ROM Needed?)_: _(GPU is primary adapater, vbios may be required.)_ + _(Graphics ROM Needed)_?: _(GPU is primary adapter, vbios may be required)_. @@ -1746,8 +1746,8 @@ foreach ($arrConfig['nic'] as $i => $arrNic) { $clockcount = 0; if (!empty($arrClocks)) { foreach ($arrClocks as $i => $arrTimer) { - if ($i == "offset") continue; - if ($clockcount == 0) $clocksourcetext = _("Timer Source").":"; else $clocksourcetext = ""; + if ($i == 'offset') continue; + if ($clockcount == 0) $clocksourcetext = _('Timer Source').':'; else $clocksourcetext = ""; ?> @@ -2033,34 +2033,25 @@ function ShareChange(share) { } } -function BusChange(bus) { - var value = bus.value; - var index = bus.name.indexOf("]") + 1; - var name = bus.name.substr(0,index); +function BusChange(value, index) { + $('input[id="disk['+index+'][rotation]"]').removeClass('hidden'); + $('span[id="disk['+index+'][rotatetext]"]').removeClass('hidden'); if (value == "virtio" || value == "usb" ) { - $('#'+name+"[rotatetext]").hide(); - $('#'+name+"[rotation]").hide(); - } else { - $('#'+name+"[rotation]").show(); - $('#'+name+"[rotatetext]").show(); + $('input[id="disk['+index+'][rotation]"]').addClass('hidden'); + $('span[id="disk['+index+'][rotatetext]"]').addClass('hidden'); } } -function updateSSDCheck(ssd) { - var value = ssd.value; - var index = ssd.name.indexOf("]") + 1; - var name = ssd.name.substr(0,index); - ssd.value = $('#'+name+"[rotation]").prop('checked') ? "1" : "0"; +function updateSSDCheck(ssd, index) { + ssd.value = $('#'+index+"[rotation]").prop('checked') ? "1" : "0"; } -function BIOSChange(bios) { - var value = bios.value; +function BIOSChange(value) { + $("#USBBoottext").removeClass('hidden'); + $("#domain_usbboot").removeClass('hidden'); if (value == "0") { - $("#USBBoottext").hide(); - $("#domain_usbboot").hide(); - } else { - $("#USBBoottext").show(); - $("#domain_usbboot").show(); + $("#USBBoottext").addClass('hidden'); + $("#domain_usbboot").addClass('hidden'); } } @@ -2119,15 +2110,17 @@ function SetBootorderfields(usbbootvalue) { function checkName(name) { /* Declare variables at the function scope */ var isValidName - $('#zfs-name').hide(); + $('#zfs-name').removeClass().addClass('hidden'); isValidName = /^[A-Za-z0-9][A-Za-z0-9\-_.: ]*$/.test(name); if (isValidName) { $('#btnSubmit').prop("disabled",false); } else { if (storageType == "zfs") { - $('#btnSubmit').prop("disabled",true); $('#zfs-name').show(); + $('#btnSubmit').prop("disabled",true); + $('#zfs-name').removeClass(); + } else { + $('#btnSubmit').prop("disabled",false); } - else $('#btnSubmit').prop("disabled",false); } } @@ -2151,54 +2144,50 @@ function USBBootChange(usbboot) { } function AutoportChange(autoport) { + $("#port").removeClass('hidden'); + $("#Porttext").removeClass('hidden'); + $("#wsport").removeClass('hidden'); + $("#WSPorttext").removeClass('hidden'); if (autoport.value == "yes") { - $("#port").hide(); - $("#Porttext").hide(); - $("#wsport").hide(); - $("#WSPorttext").hide(); + $("#port").addClass('hidden'); + $("#Porttext").addClass('hidden'); + $("#wsport").addClass('hidden'); + $("#WSPorttext").addClass('hidden'); } else { var protocol = document.getElementById("protocol").value; - $("#port").show(); - $("#Porttext").show(); - if (protocol == "vnc") { - $("#wsport").show(); - $("#WSPorttext").show(); - } else { - $("#wsport").hide(); - $("#WSPorttext").hide(); + if (protocol != "vnc") { + $("#wsport").addClass('hidden'); + $("#WSPorttext").addClass('hidden'); } } } function VMConsoleDriverChange(driver) { + $("#vncrender").removeClass('hidden'); + $("#vncrendertext").removeClass('hidden'); if (driver.value != "virtio3d") { - $("#vncrender").hide(); - $("#vncrendertext").hide(); - } else { - $("#vncrender").show(); - $("#vncrendertext").show(); + $("#vncrender").addClass('hidden'); + $("#vncrendertext").addClass('hidden'); } + $("#vncdspopt").removeClass('hidden'); + $("#vncdspopttext").removeClass('hidden'); if (driver.value != "qxl") { - $("#vncdspopt").hide(); - $("#vncdspopttext").hide(); - } else { - $("#vncdspopt").show(); - $("#vncdspopttext").show(); + $("#vncdspopt").addClass('hidden'); + $("#vncdspopttext").addClass('hidden'); } } function ProtocolChange(protocol) { var autoport = $("#autoport").val(); + $("port").removeClass('hidden'); + $("Porttext").removeClass('hidden'); + $("wsport").removeClass('hidden'); + $("WSPorttext").removeClass('hidden'); if (autoport == "yes") { - $("port").hide(); - $("Porttext").hide(); - $("wsport").hide(); - $("WSPorttext").hide(); - } else { - $("port").show(); - $("Porttext").show(); - $("wsport").show(); - $("WSPorttext").show(); + $("port").addClass('hidden'); + $("Porttext").addClass('hidden'); + $("wsport").addClass('hidden'); + $("WSPorttext").addClass('hidden'); } } @@ -2440,16 +2429,11 @@ $(function() { }); $("#vmform").on("change", ".cpu", function changeCPUEvent(){ - var myvalue = $(this).val(); - var mylabel = $(this).children('option:selected').text(); - var cpumigrate = document.getElementById("domain_cpumigrate_text"); - var cpumigrate_text = document.getElementById("domain_cpumigrate"); - if (myvalue == "custom") { - $("#domain_cpumigrate_text").hide(); - $("#domain_cpumigrate").hide(); - } else { - $("#domain_cpumigrate_text").show(); - $("#domain_cpumigrate").show(); + $("#domain_cpumigrate_text").removeClass('hidden'); + $("#domain_cpumigrate").removeClass('hidden'); + if ($(this).val() == "custom") { + $("#domain_cpumigrate_text").addClass('hidden'); + $("#domain_cpumigrate").addClass('hidden'); } }); @@ -2465,19 +2449,17 @@ $(function() { slideDownRows($vnc_sections.not(isVMAdvancedMode() ? '.basic' : '.advanced')); var MultiSel = document.getElementById("GPUMultiSel0"); MultiSel.disabled = true; - if ($("#vncmodel").val() == "virtio3d") { - $("#vncrender").show(); - $("#vncrendertext").show(); - } else { - $("#vncrender").hide(); - $("#vncrendertext").hide(); + $("#vncrender").removeClass('hidden'); + $("#vncrendertext").removeClass('hidden'); + if ($("#vncmodel").val() != "virtio3d") { + $("#vncrender").addClass('hidden'); + $("#vncrendertext").addClass('hidden'); } - if ($("#vncmodel").val() == "qxl") { - $("#vncdspopt").show(); - $("#vncdspopttext").show(); - } else { - $("#vncdspopt").hide(); - $("#vncdspopttext").hide(); + $("#vncdspopt").removeClass('hidden'); + $("#vncdspopttext").removeClass('hidden'); + if ($("#vncmodel").val() != "qxl") { + $("#vncdspopt").addClass('hidden'); + $("#vncdspopttext").addClass('hidden'); } } else { slideUpRows($vnc_sections); @@ -2486,12 +2468,12 @@ $(function() { if (myvalue=="nogpu") MultiSel.disabled = true; else MultiSel.disabled = false; } } - if (mylabel == "_(None)_") $("#gpubootvga"+myindex).hide(); - if (myvalue != "_(virtual)_" && myvalue != '' && myvalue != "_(nogpu)_") { - if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).show(); else $("#gpubootvga"+myindex).hide(); + if (mylabel == "_(None)_") $("#gpubootvga"+myindex).removeClass().addClass('hidden'); + if (myvalue != "_(virtual)_" && myvalue != "" && myvalue != "_(nogpu)_") { + if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).removeClass(); else $("#gpubootvga"+myindex).removeClass().addClass('hidden'); } $romfile = $(this).closest('table').find('.romfile'); - if (myvalue == '_(virtual)_' || myvalue == '' || myvalue =="_(nogpu)_") { + if (myvalue == "_(virtual)_" || myvalue == "" || myvalue == "_(nogpu)_") { slideUpRows($romfile.not(isVMAdvancedMode() ? '.basic' : '.advanced')); $romfile.filter('.advanced').removeClass('advanced').addClass('wasadvanced'); } else { @@ -2642,13 +2624,13 @@ $(function() { $panel.find('input').prop('disabled', true); $button.val($button.attr('busyvalue')); swal({ - title: '_(Template Name)_', - text: "_(Enter name:\nIf name already exists it will be replaced.)_", + title: "_(Template Name)_", + text: "_(Enter name)_:\n_(If name already exists it will be replaced)_.", type: "input", showCancelButton: true, closeOnConfirm: false, //animation: "slide-from-top", - inputPlaceholder: "_(Leaving blank will use OS name.)_" + inputPlaceholder: "_(Leaving blank will use OS name)_." }, function(inputValue) { postdata=postdata+"&templatename="+inputValue; @@ -2710,12 +2692,12 @@ $(function() { $button.val($button.attr('busyvalue')); swal({ title: "_(Template Name)_", - text: "_(Enter name:\nIf name already exists it will be replaced.)_", + text: "_(Enter name)_:\n_(If name already exists it will be replaced)_.", type: "input", showCancelButton: true, closeOnConfirm: false, //animation: "slide-from-top", - inputPlaceholder: "_(Leaving blank will use OS name.)_" + inputPlaceholder: "_(Leaving blank will use OS name)_." }, function(inputValue) { postdata=postdata+"&templatename="+inputValue; From b7c881af9d22e351c613e31c61f95eb6beb45ea2 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 21:45:06 +0100 Subject: [PATCH 02/34] Update Custom.form.php --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index ac72d8766..d05ee5bd9 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -2043,7 +2043,7 @@ function BusChange(value, index) { } function updateSSDCheck(ssd, index) { - ssd.value = $('#'+index+"[rotation]").prop('checked') ? "1" : "0"; + ssd.value = $('input[id="disk['+index+'][rotation]"]').prop('checked') ? "1" : "0"; } function BIOSChange(value) { From 200b7367be4aab613b4280502148fbcbe238446e Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 21:47:20 +0100 Subject: [PATCH 03/34] VM: code simplification --- .../plugins/dynamix.vm.manager/templates/Custom.form.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index d05ee5bd9..69f0c10d4 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -924,7 +924,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { _(SSD)_: - value=""> + value=""> @@ -1076,7 +1076,7 @@ if (!isset($arrValidMachineTypes[$arrConfig['domain']['machine']])) { - + @@ -2042,8 +2042,8 @@ function BusChange(value, index) { } } -function updateSSDCheck(ssd, index) { - ssd.value = $('input[id="disk['+index+'][rotation]"]').prop('checked') ? "1" : "0"; +function updateSSDCheck(ssd) { + ssd.value = $(ssd).prop('checked') ? "1" : "0"; } function BIOSChange(value) { From d84e9be3eba7789c195b283a89143f775eb179cb Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 22:05:52 +0100 Subject: [PATCH 04/34] Update Custom.form.php --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 69f0c10d4..02e2cc6ed 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -2108,18 +2108,18 @@ function SetBootorderfields(usbbootvalue) { /* Remove characters not allowed in share name. */ function checkName(name) { - /* Declare variables at the function scope */ var isValidName - $('#zfs-name').removeClass().addClass('hidden'); isValidName = /^[A-Za-z0-9][A-Za-z0-9\-_.: ]*$/.test(name); + $('#zfs-name').removeClass(); if (isValidName) { $('#btnSubmit').prop("disabled",false); + $('#zfs-name').addClass('hidden') } else { if (storageType == "zfs") { $('#btnSubmit').prop("disabled",true); - $('#zfs-name').removeClass(); } else { $('#btnSubmit').prop("disabled",false); + $('#zfs-name').addClass('hidden') } } } From 26be6290f2d7b2212dbc53d1010dab078c017d05 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 22:19:21 +0100 Subject: [PATCH 05/34] VM: textual update --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 02e2cc6ed..c30465d13 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -350,8 +350,9 @@ if ($snapshots != null && count($snapshots) && !$boolNew) { - _(Rename disabled, snapshot(s) exists)_. - _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location
Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_
+ _(Rename disabled, snapshot(s) exists)_.
+ _(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location)_
+ _(Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_ From cc44044ff2e88fa9f7fe6d5adcabb0ee423c56aa Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 22:21:53 +0100 Subject: [PATCH 06/34] Update Custom.form.php --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index c30465d13..f1a29b5b4 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -352,7 +352,7 @@ if ($snapshots != null && count($snapshots) && !$boolNew) { _(Rename disabled, snapshot(s) exists)_.
_(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location)_
- _(Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_ + _(Only these special characters are valid Underscore '_' Hyphen '-' Colon ':' Period '.')_ From b00258ab82b89cdeb95286319b6ee12e1c33c7c3 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 22:22:52 +0100 Subject: [PATCH 07/34] Update Custom.form.php --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index f1a29b5b4..7c26a9fbb 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -352,7 +352,7 @@ if ($snapshots != null && count($snapshots) && !$boolNew) { _(Rename disabled, snapshot(s) exists)_.
_(Name contains invalid characters or does not start with an alphanumberic for a ZFS storage location)_
- _(Only these special characters are valid Underscore '_' Hyphen '-' Colon ':' Period '.')_ + _(Only these special characters are valid Underscore (_) Hyphen (-) Colon (:) Period (.))_ From 49025922babb8496672ab144fd114d5c08598637 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 22:54:46 +0100 Subject: [PATCH 08/34] VM: adding missing DIV closure --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 7c26a9fbb..0614aba09 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1961,6 +1961,7 @@ foreach ($arrConfig['evdev'] as $i => $arrEvdev) { +
From f9d14436adcdd8b9e0018573219350a6de842625 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:04:27 +0100 Subject: [PATCH 09/34] VM: fixed bug: message sometimes not cleared --- .../plugins/dynamix.vm.manager/templates/Custom.form.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 0614aba09..5761c3bbb 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -2470,9 +2470,12 @@ $(function() { if (myvalue=="nogpu") MultiSel.disabled = true; else MultiSel.disabled = false; } } - if (mylabel == "_(None)_") $("#gpubootvga"+myindex).removeClass().addClass('hidden'); + $("#gpubootvga"+myindex).removeClass(); + if (mylabel == "_(None)_") $("#gpubootvga"+myindex).addClass('hidden'); if (myvalue != "_(virtual)_" && myvalue != "" && myvalue != "_(nogpu)_") { - if (ValidGPUs[myvalue].bootvga == "1") $("#gpubootvga"+myindex).removeClass(); else $("#gpubootvga"+myindex).removeClass().addClass('hidden'); + if (ValidGPUs[myvalue].bootvga != "1") $("#gpubootvga"+myindex).addClass('hidden'); + } else { + $("#gpubootvga"+myindex).addClass('hidden'); } $romfile = $(this).closest('table').find('.romfile'); if (myvalue == "_(virtual)_" || myvalue == "" || myvalue == "_(nogpu)_") { From c3558c2f8bf638da86c02895a43e691e85dcfd1b Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:16:43 +0100 Subject: [PATCH 10/34] Fix PHP errors --- emhttp/plugins/dynamix/include/NetworkInfo.php | 2 +- emhttp/plugins/dynamix/include/Wrappers.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index 186e1ff50..36171d9f4 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -24,7 +24,7 @@ function port($eth) { $sys = "/sys/class/net"; if (substr($eth,0,4)=='wlan') return $eth; $x = preg_replace('/[^0-9]/','',$eth); - return file_exists("$sys/br{$x}") ? "br${x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); + return file_exists("$sys/br{$x}") ? "br{$x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); } exec("grep -Po 'nameserver \K\S+' /etc/resolv.conf 2>/dev/null",$ns); diff --git a/emhttp/plugins/dynamix/include/Wrappers.php b/emhttp/plugins/dynamix/include/Wrappers.php index 157ae7139..1878f7793 100644 --- a/emhttp/plugins/dynamix/include/Wrappers.php +++ b/emhttp/plugins/dynamix/include/Wrappers.php @@ -270,6 +270,6 @@ function check_network_connectivity(): bool { function lan_port($port, $state=false) { $system = '/sys/class/net'; $exist = file_exists("$system/$port"); - return !$state ? $exist : ($exist ? file_get_contents("$system/$port/carrier") : false); + return !$state ? $exist : ($exist ? (@file_get_contents("$system/$port/carrier") ?: 0) : false); } ?> From 2cd4d64d024622c560e3c065c5b2b7f56b34cd4f Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:25:21 +0100 Subject: [PATCH 11/34] Revert "VM: adding missing DIV closure" This reverts commit 49025922babb8496672ab144fd114d5c08598637. --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 1 - 1 file changed, 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index 5761c3bbb..ad95c83e0 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1961,7 +1961,6 @@ foreach ($arrConfig['evdev'] as $i => $arrEvdev) { -
From 83dc36ff619e39f3c68a329a7cc7be1d0d074c95 Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:27:04 +0100 Subject: [PATCH 12/34] Update Custom.form.php --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 1 - 1 file changed, 1 deletion(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index ad95c83e0..df15aec24 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1942,7 +1942,6 @@ foreach ($arrConfig['evdev'] as $i => $arrEvdev) { - From 3a46ac1e38479d2eaa96e6ac490009d29ab11e1d Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:30:54 +0100 Subject: [PATCH 13/34] Fix PHP errors --- emhttp/plugins/dynamix/include/NetworkInfo.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index 36171d9f4..43e844f33 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -28,8 +28,8 @@ function port($eth) { } exec("grep -Po 'nameserver \K\S+' /etc/resolv.conf 2>/dev/null",$ns); -$eth = $_POST['port']; -$vlan = $_POST['vlan']; +$eth = $_POST['port'] ?? ''; +$vlan = $_POST['vlan'] ?? ''; $port = port($eth).($vlan ? ".$vlan" : ""); $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))==='0'; $none = _('None'); From c1b6fd1b6481ebcd6382bf9d7a21dcedb10aa09e Mon Sep 17 00:00:00 2001 From: bergware Date: Thu, 13 Feb 2025 23:39:18 +0100 Subject: [PATCH 14/34] Added DIV closure --- emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php | 1 + 1 file changed, 1 insertion(+) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index df15aec24..d0027160b 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -1960,6 +1960,7 @@ foreach ($arrConfig['evdev'] as $i => $arrEvdev) {
+
From 6ad120e03713178d211c3a21d0ad4530975b56d1 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 02:40:41 +0100 Subject: [PATCH 15/34] Wireless: faster initial loading of wireless page --- emhttp/plugins/dynamix/Wireless.page | 8 ++++---- emhttp/plugins/dynamix/include/Wireless.php | 17 +++++++++++++++-- emhttp/plugins/dynamix/nchan/wlan0 | 8 +++++--- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index 07cff7675..fb8e8611c 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -64,8 +64,8 @@ function enable_wifi(state) { $('input[name="#arg[1]"]').val(state); } -function update_wifi() { - $.post('/webGui/include/Wireless.php',{cmd:'list'},function(text) { +function update_wifi(load) { + $.post('/webGui/include/Wireless.php',{cmd:'list',load:load},function(text) { if (text.length > 0) { var wifi = JSON.parse(text); $('#connected').html(wifi.active); @@ -73,7 +73,7 @@ function update_wifi() { $('#other_networks').html(wifi.other); } }); - timers.wifi = setTimeout(update_wifi,10000); + timers.wifi = setTimeout(update_wifi,5000); } function manage_wifi(ssid,task) { @@ -146,7 +146,7 @@ function showSecurity(val) { $(function() { $('#wifi').show(); - update_wifi(); + update_wifi(1); }); diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 54e82c1a8..87fdcac7f 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -74,14 +74,27 @@ function saveAttr() { switch ($cmd) { case 'list': + $load = $_POST['load'] ?? false; $title = _('Connect to WiFi network'); $port = array_key_first($wifi); $carrier = "/sys/class/net/$port/carrier"; - $wlan = scanWifi($port); $echo = []; $index = 0; + if ($load && count(array_keys($wifi)) > 1) { + foreach ($wifi as $network => $block) { + if ($network == $port) continue; + $wlan[$index]['bss'] = $block['ATTR1']; + $wlan[$index]['signal'] = $block['ATTR2']; + $wlan[$index]['security'] = $block['ATTR3'] ?? $block['SECURITY']; + $wlan[$index]['ssid'] = $network; + $index++; + } + $index = 0; + } else { + $wlan = scanWifi($port); + } if (count(array_column($wlan,'ssid'))) { - $up = file_exists($carrier) && file_get_contents($carrier)==1; + $up = is_readable($carrier) && file_get_contents($carrier)==1; $alive = $up ? exec("iw ".escapeshellarg($port)." link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; $state = $up ? _('Connected') : _('Disconnected'); $color = $up ? 'blue' : 'red'; diff --git a/emhttp/plugins/dynamix/nchan/wlan0 b/emhttp/plugins/dynamix/nchan/wlan0 index 543086726..5ec3e1b08 100755 --- a/emhttp/plugins/dynamix/nchan/wlan0 +++ b/emhttp/plugins/dynamix/nchan/wlan0 @@ -53,10 +53,12 @@ while (true) { $locale_init = _var($display,'locale'); update_translation($locale_init); } - if (file_exists($ini) && file_exists($wlan0)) { + if (is_readable($ini) && is_readable($wlan0)) { + $wifi = parse_ini_file($ini); $up = file_get_contents($wlan0)==1; - $echo['color'] = $up ? 'blue-text' : 'red-text'; - $echo['title'] = $up ? _('WiFi connected') : _('WiFi disconnected'); + $alive = $up ? exec("iw wlan0 link 2>/dev/null | grep -Pom1 'SSID: \K.+'") : ''; + $echo['color'] = $alive==$wifi['SSID'] ? 'blue-text' : 'red-text'; + $echo['title'] = $alive==$wifi['SSID'] ? _('WiFi connected') : _('WiFi disconnected'); } else { $echo['color'] = 'grey-text'; $echo['title'] = _('No active WiFi'); From 3c6301d1187294395ff9c0dd36c7da1ea7c1c09e Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 02:56:57 +0100 Subject: [PATCH 16/34] Wireless - fine tuning --- emhttp/plugins/dynamix/Wireless.page | 2 +- emhttp/plugins/dynamix/include/Wireless.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index fb8e8611c..e20af45a8 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -70,7 +70,7 @@ function update_wifi(load) { var wifi = JSON.parse(text); $('#connected').html(wifi.active); $('#my_networks').html(wifi.saved); - $('#other_networks').html(wifi.other); + if (wifi.other.length) $('#other_networks').html(wifi.other); } }); timers.wifi = setTimeout(update_wifi,5000); diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 87fdcac7f..55a8d99ed 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -119,7 +119,7 @@ case 'list': } if (empty($echo['active'])) $echo['active'][] = "
"._('Connected').":
"._('None')."
"; if (empty($echo['saved'])) $echo['saved'][] = "
"._('My networks').":
"._('None')."
"; - if (empty($echo['other'])) $echo['other'][] = "
"._('Other networks').":
"._('None')."
"; + if (empty($echo['other'])) $echo['other'][] = $load ? "" : "
"._('Other networks').":
"._('None')."
"; $echo['active'] = implode($echo['active']); $echo['saved'] = implode($echo['saved']); $echo['other'] = implode($echo['other']); From c7cac788862fdd2852f736218bb3f0b45cf3827b Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 02:58:27 +0100 Subject: [PATCH 17/34] Update Wireless.page --- emhttp/plugins/dynamix/Wireless.page | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index e20af45a8..f0f5f5847 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -73,7 +73,7 @@ function update_wifi(load) { if (wifi.other.length) $('#other_networks').html(wifi.other); } }); - timers.wifi = setTimeout(update_wifi,5000); + timers.wifi = setTimeout(update_wifi,6000); } function manage_wifi(ssid,task) { From 068b5c44175cb661947a18fbfea3229f01ba2bc0 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 03:37:12 +0100 Subject: [PATCH 18/34] wireless - fine tuning --- emhttp/plugins/dynamix/Wireless.page | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/Wireless.page b/emhttp/plugins/dynamix/Wireless.page index f0f5f5847..c2da55b00 100644 --- a/emhttp/plugins/dynamix/Wireless.page +++ b/emhttp/plugins/dynamix/Wireless.page @@ -78,10 +78,10 @@ function update_wifi(load) { function manage_wifi(ssid,task) { if (task==2) { + clearTimeout(timers.wifi); $.post('/webGui/include/Wireless.php',{cmd:'forget',ssid:ssid},function(){ - clearTimeout(timers.wifi); swal.close(); - setTimeout(update_wifi); + setTimeout(function(){update_wifi(1);}); }); return; } From a7a38ab5a1f116e6550d0bf30a45fc6ae90bad82 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 11:21:40 +0100 Subject: [PATCH 19/34] VM edit: visual updates - make separate warnings for snapshots and user input - widen vncrender and vncdspopt selection --- .../dynamix.vm.manager/templates/Custom.form.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php index d0027160b..6c42ebf9c 100644 --- a/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php +++ b/emhttp/plugins/dynamix.vm.manager/templates/Custom.form.php @@ -325,10 +325,12 @@ $xml2 = build_xml_templates($strXML); #disable rename if snapshots exist $snapshots = getvmsnapshots($arrConfig['domain']['name']); -if ($snapshots != null && count($snapshots) && !$boolNew) { +if ($snapshots!=null && count($snapshots) && !$boolNew) { + $snaphidden = ""; $namedisable = "disabled"; $snapcount = count($snapshots); } else { + $snaphidden = "hidden"; $namedisable = ""; $snapcount = "0"; } @@ -347,10 +349,14 @@ if ($snapshots != null && count($snapshots) && !$boolNew) { + + + + + @@ -1297,7 +1303,7 @@ foreach ($arrConfig['shares'] as $i => $arrShare) { _(Render GPU)_: - $arrShare) { if ($arrGPU['model'] == "qxl") $vncdspopt = ""; else $vncdspopt = "hidden"; ?> _(Display(s) and RAM)_: - $value) echo mk_option($arrGPU['DisplayOptions'], htmlentities($value['qxlxml'],ENT_QUOTES), _($value['text'])); ?> From fe35a8af40bc6228a0d4d09277c72ff26151e555 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 12:10:51 +0100 Subject: [PATCH 20/34] Array Operation: hide "Clear Stats" button when disk I/O is visible --- emhttp/plugins/dynamix/ArrayOperation.page | 28 +++++++++++++++++-- .../plugins/dynamix/sheets/ArrayOperation.css | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/ArrayOperation.page b/emhttp/plugins/dynamix/ArrayOperation.page index 6c59f0fd6..c4682f30a 100644 --- a/emhttp/plugins/dynamix/ArrayOperation.page +++ b/emhttp/plugins/dynamix/ArrayOperation.page @@ -48,6 +48,7 @@ function check_encryption() { echo ""; echo ""; } + function maintenance_mode() { echo ""; echo ""; @@ -55,6 +56,7 @@ function maintenance_mode() { echo ""; echo ""; } + function status_indicator() { global $var; switch (_var($var,'mdColor')) { @@ -65,15 +67,18 @@ function status_indicator() { } echo "$help"; } + function missing_cache() { global $disks; $missing = false; foreach (cache_filter($disks) as $disk) $missing |= (strpos(_var($disk,'status'),'_MISSING')!==false); return $missing; } + function resync($d) { return in_array($d,['P','Q']) ? 'Parity-Sync' : 'Data-Rebuild'; } + function print_error($error) { return sprintf(_('Finding **%s** error'.($error==1?'':'s')),$error?:'0'); } @@ -111,6 +116,7 @@ function toggle_state(device,name,action) { devices.stop(); $.post('/webGui/include/ToggleState.php',{device:device,name:name,action:action},function(){setTimeout(function(){devices.start();},1000);if (button) $(button).prop('disabled',false);}); } + function display_diskio() { if ($.cookie('diskio')===undefined) { $('span.diskio').show(); $('span.number').hide(); @@ -118,20 +124,25 @@ function display_diskio() { $('span.number').show(); $('span.diskio').hide(); } } + function toggle_diskio(init) { if (!init) { if ($.cookie('diskio')===undefined) $.cookie('diskio','diskio',{expires:3650}); else $.removeCookie('diskio'); } if ($.cookie('diskio')===undefined) { $('i.toggle').removeClass('fa-list').addClass('fa-tachometer'); + $('#clearstats').addClass('hidden'); } else { $('i.toggle').removeClass('fa-tachometer').addClass('fa-list'); + $('#clearstats').removeClass('hidden'); } display_diskio(); } + function base64(str) { return window.btoa(unescape(encodeURIComponent(str))); } + function selectInput(form) { form.input.value = 'file'; @@ -175,12 +186,14 @@ function selectInput(form) { item.prop('disabled',!form.file.value); } } + function getFileContent(event,form) { var input = event.target; var reader = new FileReader(); reader.onload = function(){form.file.value=reader.result;selectInput(form);}; reader.readAsDataURL(input.files[0]); } + function prepareInput(form,button) { if (button) button.disabled = true; $.post('/webGui/include/Report.php',{cmd:'state',pools:''},function(state) { @@ -220,6 +233,7 @@ function prepareInput(form,button) { } }); } + function parityWarning(form) { if (form.md_invalidslot.checked) { @@ -232,10 +246,12 @@ function parityWarning(form) { } swal({title:"_(Proceed to start)_",text:text,html:true,type:'warning',showCancelButton:true,confirmButtonText:"_(Proceed)_",cancelButtonText:"_(Cancel)_"},function(){prepareInput(form);}); } + function tab0() { $.removeCookie('one'); $.cookie('tab','tab0'); } + function stopArray(form) { $(form).append(''); @@ -244,6 +260,7 @@ function stopArray(form) { form.submit(); } + function stopParity(form,text) { $(form).append(''); @@ -252,6 +269,7 @@ function stopParity(form,text) { form.submit(); } + function pauseParity(form) { $.post('/webGui/include/ParityControl.php',{action:'pause'},function(){ $('#pauseButton').val("_(Resume)_").prop('disabled',true).prop('onclick',null).off('click').click(function(){resumeParity(form);}); @@ -259,6 +277,7 @@ function pauseParity(form) { form.submit(); }); } + function resumeParity(form) { $.post('/webGui/include/ParityControl.php',{action:'resume'},function(){ $('#pauseButton').val("_(Pause)_").prop('disabled',true).prop('onclick',null).off('click').click(function(){pauseParity(form);}); @@ -266,9 +285,11 @@ function resumeParity(form) { form.submit(); }); } + function parityHistory() { openChanges("parity_history", "_(Parity Operation History)_", "phistory"); } + function shutdown_now(form,cmd) { $(form).append(''); @@ -281,9 +302,11 @@ function shutdown_now(form,cmd) { form.submit(); } + function toggleApply(checked) { $('input[name="#apply"]').prop('disabled',!checked); } + $('.tabs').append(ctrl); if ($.cookie('tab')=='tab0') $('i.toggle').hide(); @@ -292,7 +315,6 @@ $('#tab'+$('input[name$="tabs"]').length).click(function(){tab0(); $('i.toggle') $('div[class=title]:not(":last, .disable_diskio")').each(function(){$(this).append(ctrl);}); $('.tooltip_diskio').tooltipster({delay:100,trigger:'custom',triggerOpen:{mouseenter:true},triggerClose:{click:false,scroll:true,mouseleave:true}}); -toggle_diskio(true); var mymonitor = new NchanSubscriber('/sub/mymonitor',{subscriber:'websocket'}); @@ -422,7 +444,9 @@ setTimeout(function(){paritymonitor.start();},5000); $(function(){ var form = document.arrayOps; if (form.input !== undefined) selectInput(form); + toggle_diskio(true); }); + function formatWarning(val) { if (val==true) { swal({ @@ -720,7 +744,7 @@ endswitch;
_(Rename disabled, snapshot(s) exists)_.
",_('Retype passphrase'),":
",_('Keyfile'),":
",_('Maintenance mode')," - ",_('if checked, Start array but do not mount disks'),"
- +
**_(Spin Up)_** _(will immediately spin up all disks)_.
**_(Spin Down)_** _(will immediately spin down all disks)_.
**_(Clear Stats)_** _(will immediately clear all disk statistics)_.
diff --git a/emhttp/plugins/dynamix/sheets/ArrayOperation.css b/emhttp/plugins/dynamix/sheets/ArrayOperation.css index 938141281..184e8de9c 100644 --- a/emhttp/plugins/dynamix/sheets/ArrayOperation.css +++ b/emhttp/plugins/dynamix/sheets/ArrayOperation.css @@ -3,3 +3,4 @@ td.gap{padding-left:26px!important} td.wrap{white-space:normal!important} span#pass{display:none;margin-left:20px} input[type=checkbox]{margin-left:0} +.hidden{display:none} \ No newline at end of file From 0471cf96523b5177415e3a24fe1e33fbeac72d0b Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 18:02:54 +0100 Subject: [PATCH 21/34] wireless: fix typo --- emhttp/plugins/dynamix/include/Wireless.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 55a8d99ed..98189252a 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -146,7 +146,7 @@ case 'join': $dns6 = _var($wifi[$ssid],'DNS6','no'); $ip6 = _var($wifi[$ssid],'IP6'); $mask6 = _var($wifi[$ssid],'MASK6','64'); - $gwv6 = _var($wifi[$ssid],'GATEWAY6'); + $gw6 = _var($wifi[$ssid],'GATEWAY6'); $server6 = _var($wifi[$ssid],'SERVER6'); $safe = _var($wifi[$ssid],'SECURITY'); $attr1 = $attr[$ssid]['ATTR1']; From c21358142eb0fcc8b47e08199b363962ebe4bc79 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 18:31:11 +0100 Subject: [PATCH 22/34] fix typo --- emhttp/plugins/dynamix/scripts/netconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/scripts/netconfig b/emhttp/plugins/dynamix/scripts/netconfig index 1f0879134..81d12d4ab 100755 --- a/emhttp/plugins/dynamix/scripts/netconfig +++ b/emhttp/plugins/dynamix/scripts/netconfig @@ -26,7 +26,7 @@ $cfg = '/boot/config/network.cfg'; function port($x) { $sys = "/sys/class/net"; - return file_exists("$sys/br{$x}") ? "br${x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); + return file_exists("$sys/br{$x}") ? "br{$x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); } function update_wireguard($ifname) { From 688109a2cf5ea87c47d462255e4e366b56c82095 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 20:32:39 +0100 Subject: [PATCH 23/34] Add more information to wireless network info --- .../plugins/dynamix/include/NetworkInfo.php | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index 43e844f33..acd53232d 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -30,13 +30,13 @@ function port($eth) { exec("grep -Po 'nameserver \K\S+' /etc/resolv.conf 2>/dev/null",$ns); $eth = $_POST['port'] ?? ''; $vlan = $_POST['vlan'] ?? ''; +$wlan0 = $eth == 'wlan0'; $port = port($eth).($vlan ? ".$vlan" : ""); $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))==='0'; $none = _('None'); $error = ""._('Missing').""; $note = in_array($eth,['eth0','wlan0']) && !$vlan ? $error : $none; $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; -$speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); $ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show $port scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); $gw4 = exec("ip -4 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns4 = array_filter($ns,function($ns){return strpos($ns,':')===false;}); @@ -50,23 +50,22 @@ if ($v6on) { echo ""; echo ""; -echo ""; -echo ""; -if ($eth=='wlan0') { - $ini = '/boot/config/wireless-networks.cfg'; - $wifi = (array)@parse_ini_file($ini,true); - $att1 = $att2 = $att3 = ''; - foreach ($wifi as $network => $option) { - if (isset($option['GROUP']) && $option['GROUP']=='active') { - $att1 = $network; - $att2 = $option['ATTR2']; - $att3 = $option['ATTR3']; - break; - } - } - if ($att1) echo ""; - if ($att2) echo ""; - if ($att3) echo ""; +if ($wlan0) { + $ini = '/var/local/emhttp/wireless.ini'; + $wifi = (array)@parse_ini_file($ini); + $attr1 = $wifi['SSID'] ?? _('Unknown'); + $attr2 = $wifi['ATTR2'] ?? _('Unknown'); + exec("iw wlan0 link | awk '/[rt]x bitrate:/{print $1,$2,$3,$4}'",$speed); + [$name0, $rate0] = isset($speed[0]) ? explode(': ',$speed[0]) : ['rx bitrate', _('Unknown')]; + [$name1, $rate1] = isset($speed[1]) ? explode(': ',$speed[1]) : ['tx bitrate', _('Unknown')]; + echo ""; + echo ""; + echo ""; + echo ""; +} else { + $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); + echo ""; + echo ""; } if (count($ipv4)) foreach ($ipv4 as $ip) { echo ""; From 98a77f873415c24cd5643940b72637f7fbf26b49 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 20:35:15 +0100 Subject: [PATCH 24/34] Update NetworkInfo.php --- emhttp/plugins/dynamix/include/NetworkInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index acd53232d..cda219a54 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -36,7 +36,6 @@ $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))= $none = _('None'); $error = ""._('Missing').""; $note = in_array($eth,['eth0','wlan0']) && !$vlan ? $error : $none; -$link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; $ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show $port scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); $gw4 = exec("ip -4 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns4 = array_filter($ns,function($ns){return strpos($ns,':')===false;}); @@ -63,6 +62,7 @@ if ($wlan0) { echo ""; echo ""; } else { + $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); echo ""; echo ""; From 93e75ef141281f5e30a05ddab26f69cdf2ec3f52 Mon Sep 17 00:00:00 2001 From: bergware Date: Fri, 14 Feb 2025 21:01:29 +0100 Subject: [PATCH 25/34] Add more information to wireless network info --- .../plugins/dynamix/include/NetworkInfo.php | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index cda219a54..d274fd1f2 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -50,19 +50,21 @@ if ($v6on) { echo "
  
"._('Interface link').":$link
"._('Interface speed').":$speed
"._('Network').":$att1
"._('Health').":$att2
"._('Security').":$att3
"._('Network').":$attr1
"._('Health').":$attr2
"._(ucfirst($name0)).":$rate0
"._(ucfirst($name1)).":$rate1
"._('Interface link').":$link
"._('Interface speed').":$speed
"._('IPv4 address').":$ip
"._(ucfirst($name0)).":$rate0
"._(ucfirst($name1)).":$rate1
"._('Interface link').":$link
"._('Interface speed').":$speed
"; echo ""; if ($wlan0) { - $ini = '/var/local/emhttp/wireless.ini'; - $wifi = (array)@parse_ini_file($ini); - $attr1 = $wifi['SSID'] ?? _('Unknown'); - $attr2 = $wifi['ATTR2'] ?? _('Unknown'); - exec("iw wlan0 link | awk '/[rt]x bitrate:/{print $1,$2,$3,$4}'",$speed); - [$name0, $rate0] = isset($speed[0]) ? explode(': ',$speed[0]) : ['rx bitrate', _('Unknown')]; - [$name1, $rate1] = isset($speed[1]) ? explode(': ',$speed[1]) : ['tx bitrate', _('Unknown')]; - echo ""; - echo ""; - echo ""; - echo ""; + exec("iw wlan0 link | awk '/^\s+(SSID|signal|[rt]x bitrate): /{print $1,$2,$3,$4}'",$speed); + if (count($speed)==4) { + $network = explode(': ',$speed[0])[1]; + $signal = explode(': ',$speed[1])[1]; + $rxrate = explode(': ',$speed[2])[1]; + $txrate = explode(': ',$speed[3])[1]; + } else { + $network = $signal = $rxrate = $txrate = _('Unknown'); + } + echo ""; + echo ""; + echo ""; + echo ""; } else { - $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: ($eth=='wlan0' ? 'wifi' :'not present')).")"; + $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: 'not present').")"; $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); echo ""; echo ""; From 0ef5cdafe2908bcb846323b31499e3783f20a243 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 10:03:34 +0100 Subject: [PATCH 26/34] security enhancements --- emhttp/plugins/dynamix/include/NetworkInfo.php | 12 ++++++------ emhttp/plugins/dynamix/include/Wireless.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index d274fd1f2..926dbde2a 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -36,14 +36,14 @@ $v6on = trim(file_get_contents("/proc/sys/net/ipv6/conf/$port/disable_ipv6"))= $none = _('None'); $error = ""._('Missing').""; $note = in_array($eth,['eth0','wlan0']) && !$vlan ? $error : $none; -$ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show $port scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); -$gw4 = exec("ip -4 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; +$ipv4 = array_filter(explode(' ',exec("ip -4 -br addr show ".escapeshellarg($port)." scope global 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); +$gw4 = exec("ip -4 route show default dev ".escapeshellarg($port)." 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns4 = array_filter($ns,function($ns){return strpos($ns,':')===false;}); $domain = exec("grep -Pom1 'domain \K.*' /etc/resolv.conf 2>/dev/null") ?: '---'; if ($v6on) { - $ipv6 = array_filter(explode(' ',exec("ip -6 -br addr show $port scope global -temporary 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); - $gw6 = exec("ip -6 route show default dev $port 2>/dev/null | awk '{print \$3;exit}'") ?: $note; + $ipv6 = array_filter(explode(' ',exec("ip -6 -br addr show ".escapeshellarg($port)." scope global -temporary 2>/dev/null | awk '{\$1=\$2=\"\";print;exit}' | sed -r 's/ metric [0-9]+//g; s/\/[0-9]+//g'"))); + $gw6 = exec("ip -6 route show default dev ".escapeshellarg($port)." 2>/dev/null | awk '{print \$3;exit}'") ?: $note; $dns6 = array_filter($ns,function($ns){return strpos($ns,':')!==false;}); } @@ -64,8 +64,8 @@ if ($wlan0) { echo ""; echo ""; } else { - $link = _(ucfirst(exec("ethtool $eth 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool $eth 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: 'not present').")"; - $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool $eth 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); + $link = _(ucfirst(exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | awk '$1==\"Link\" {print $3;exit}'")) ?: 'Unknown')." ("._(exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | grep -Pom1 '^\s+Port: \K.*'") ?: 'not present').")"; + $speed = _(preg_replace(['/^(\d+)/','/!/'],['$1 ',''],exec("ethtool ".escapeshellarg($eth)." 2>/dev/null | awk '$1==\"Speed:\" {print $2;exit}'")) ?: 'Unknown'); echo ""; echo ""; } diff --git a/emhttp/plugins/dynamix/include/Wireless.php b/emhttp/plugins/dynamix/include/Wireless.php index 98189252a..77a5b0099 100644 --- a/emhttp/plugins/dynamix/include/Wireless.php +++ b/emhttp/plugins/dynamix/include/Wireless.php @@ -20,7 +20,7 @@ $tmp = '/var/tmp/attr'; $wifi = is_readable($cfg) ? (array)parse_ini_file($cfg,true) : []; $attr = is_readable($tmp) ? (array)parse_ini_file($tmp,true) : []; $md5 = md5(json_encode($attr),true); -$cmd = $_POST['cmd']; +$cmd = $_POST['cmd'] ?? ''; $masks = [ '255.0.0.0' => '8', '255.255.0.0' => '16', '255.255.128.0' => '17', '255.255.192.0' => '18', '255.255.224.0' => '19', '255.255.240.0' => '20', '255.255.248.0' => '21', '255.255.252.0' => '22', From e16fb7ba3711e1ae26ff8b5578487744ee2f4fe4 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 10:16:45 +0100 Subject: [PATCH 27/34] Networkinfo: default to port zero --- emhttp/plugins/dynamix/include/NetworkInfo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/NetworkInfo.php b/emhttp/plugins/dynamix/include/NetworkInfo.php index 926dbde2a..0c9d33891 100644 --- a/emhttp/plugins/dynamix/include/NetworkInfo.php +++ b/emhttp/plugins/dynamix/include/NetworkInfo.php @@ -23,7 +23,7 @@ if (isset($_POST['listen'])) { function port($eth) { $sys = "/sys/class/net"; if (substr($eth,0,4)=='wlan') return $eth; - $x = preg_replace('/[^0-9]/','',$eth); + $x = preg_replace('/[^0-9]/','',$eth) ?: '0'; return file_exists("$sys/br{$x}") ? "br{$x}" : (file_exists("$sys/bond{$x}") ? "bond{$x}" : "eth{$x}"); } From 642e2215563eb06e210c440f0b69c03da2c52918 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 19:51:55 +0100 Subject: [PATCH 28/34] Fix wireless at boot: don't start when not enabled --- emhttp/plugins/dynamix/scripts/wireless | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/wireless b/emhttp/plugins/dynamix/scripts/wireless index 2b522f62f..ca72260a3 100755 --- a/emhttp/plugins/dynamix/scripts/wireless +++ b/emhttp/plugins/dynamix/scripts/wireless @@ -28,10 +28,10 @@ if ($arg == 'yes') { } elseif ($arg == 'no') { exec("/etc/rc.d/rc.wireless stop"); exec("$docroot/webGui/scripts/update_services 5"); -} else { +} elseif (($wifi['wlan0']['WIFI']??'') == 'yes') { foreach ($wifi as $network => $block) { if ($network == $port) continue; - if ($block['GROUP'] == $state && (!$arg || $arg == $network)) { + if (($block['GROUP']??'') == $state && (!$arg || $arg == $network)) { $text[] = "SSID=\"$network\""; unset($block['GROUP']); foreach ($block as $key => $value) $text[] = "$key=\"$value\""; From 06c2852313d7bebbc77f58e665c48558c7030fd6 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 19:52:49 +0100 Subject: [PATCH 29/34] Docker: fix regression error: don't delete IP address from main interface --- etc/rc.d/rc.docker | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index b633c9352..a66afc405 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -468,7 +468,7 @@ docker_network_start(){ # copy IPv4 address to vhost interface run ip -4 addr add $IPV4 dev $VHOST metric 0 log "prepared network $VHOST for host access" - elif [[ -e $SYSTEM/$VHOST ]]; then + elif [[ ${VHOST:0:5} == vhost && -e $SYSTEM/$VHOST ]]; then # remove IP addresses run ip addr flush dev $VHOST fi From 561e9b4e4988520fb5180bc1d145f0cf2749db91 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 20:04:48 +0100 Subject: [PATCH 30/34] Docker: fix regression error: don't delete IP address from main interface --- etc/rc.d/rc.docker | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index a66afc405..87d8f3e57 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -468,9 +468,12 @@ docker_network_start(){ # copy IPv4 address to vhost interface run ip -4 addr add $IPV4 dev $VHOST metric 0 log "prepared network $VHOST for host access" - elif [[ ${VHOST:0:5} == vhost && -e $SYSTEM/$VHOST ]]; then - # remove IP addresses - run ip addr flush dev $VHOST + else + VHOST=vhost${NETWORK//[^0-9.]/} + if [[ -e $SYSTEM/$VHOST ]]; then + # remove IP addresses + run ip addr flush dev $VHOST + fi fi fi fi From 4ee7a14d5fac2b733f05ffa8bfa848e93843f383 Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 20:15:42 +0100 Subject: [PATCH 31/34] fix ipv6 routing : missing default route in list --- emhttp/plugins/dynamix/include/RoutingTable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/emhttp/plugins/dynamix/include/RoutingTable.php b/emhttp/plugins/dynamix/include/RoutingTable.php index 7908083f5..2bfa73efb 100644 --- a/emhttp/plugins/dynamix/include/RoutingTable.php +++ b/emhttp/plugins/dynamix/include/RoutingTable.php @@ -27,7 +27,7 @@ case 'Add Route': break; default: exec("ip -4 route show table all|grep -Pv '^(127\\.0\\.0\\.0)|table local|unreachable'",$ipv4); - exec("ip -6 route show table all|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|expires|table local|unreachable'",$ipv6); + exec("ip -6 route show table all|grep -Pv '^([am:]|(f[ef][0-9][0-9])::)|table local|unreachable'",$ipv6); foreach ($ipv4 as $info) { $cell = explode(' ',$info); $route = $cell[0]; From bda43f7920b9bf0c37b8b01b4adedf99c4ad7a3b Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 20:20:40 +0100 Subject: [PATCH 32/34] rc.docker: remove IP and routing from virtual interface when not in use --- etc/rc.d/rc.docker | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index 87d8f3e57..f91f5f8f6 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -471,8 +471,11 @@ docker_network_start(){ else VHOST=vhost${NETWORK//[^0-9.]/} if [[ -e $SYSTEM/$VHOST ]]; then - # remove IP addresses + # remove IP addresses of vhost run ip addr flush dev $VHOST + # remove routing of vhost + run ip -4 route flush dev $VHOST + run ip -6 route flush dev $VHOST fi fi fi From 28d620e7c75244fbfbbcbaa822fde045c14a9b0c Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 20:42:49 +0100 Subject: [PATCH 33/34] rc.docker: only flush global addresses (keep link addresses) --- etc/rc.d/rc.docker | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/etc/rc.d/rc.docker b/etc/rc.d/rc.docker index f91f5f8f6..c86d8c1a3 100755 --- a/etc/rc.d/rc.docker +++ b/etc/rc.d/rc.docker @@ -438,7 +438,7 @@ docker_network_start(){ if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then # create shim interface and copy parent IPv4 address to shim interface [[ -e $SYSTEM/$LINK ]] || run ip link add link $NETWORK name $LINK type $ATTACH mode $MODE - run ip addr flush dev $LINK + run ip addr flush dev $LINK scope global run ip -4 addr add $IPV4 dev $LINK metric 0 # disable IPv6 on shim interface echo 1 >$CONF6/$LINK/disable_ipv6 @@ -464,7 +464,7 @@ docker_network_start(){ fi elif [[ $TYPE != wlan ]]; then if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then - run ip addr flush dev $VHOST + run ip addr flush dev $VHOST scope global # copy IPv4 address to vhost interface run ip -4 addr add $IPV4 dev $VHOST metric 0 log "prepared network $VHOST for host access" @@ -472,7 +472,7 @@ docker_network_start(){ VHOST=vhost${NETWORK//[^0-9.]/} if [[ -e $SYSTEM/$VHOST ]]; then # remove IP addresses of vhost - run ip addr flush dev $VHOST + run ip addr flush dev $VHOST scope global # remove routing of vhost run ip -4 route flush dev $VHOST run ip -6 route flush dev $VHOST From de3b154a709efdc682a6c68d05a7247c5ce6099b Mon Sep 17 00:00:00 2001 From: bergware Date: Sat, 15 Feb 2025 20:58:22 +0100 Subject: [PATCH 34/34] Fix PHP errors --- emhttp/plugins/dynamix/scripts/notify | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/emhttp/plugins/dynamix/scripts/notify b/emhttp/plugins/dynamix/scripts/notify index cbf0c0fb8..8a5adc246 100755 --- a/emhttp/plugins/dynamix/scripts/notify +++ b/emhttp/plugins/dynamix/scripts/notify @@ -211,9 +211,9 @@ case 'add': $noBrowser = true; break; case 'l': - $nginx = parse_ini_file('/var/local/emhttp/nginx.ini'); + $nginx = (array)@parse_ini_file('/var/local/emhttp/nginx.ini'); $link = $value; - $fqdnlink = (strpos($link,"http") === 0) ? $link : $nginx['NGINX_DEFAULTURL'].$link; + $fqdnlink = (strpos($link,"http") === 0) ? $link : ($nginx['NGINX_DEFAULTURL']??'').$link; break; } }
  
"._('Network').":$attr1
"._('Health').":$attr2
"._(ucfirst($name0)).":$rate0
"._(ucfirst($name1)).":$rate1
"._('Network name').":$network
"._('Signal level').":$signal
"._('Receive bitrate').":$rxrate
"._('Transmit bitrate').":$txrate
"._('Interface link').":$link
"._('Interface speed').":$speed
"._('Receive bitrate').":$rxrate
"._('Transmit bitrate').":$txrate
"._('Interface link').":$link
"._('Interface speed').":$speed