From 21e046cf373d4b5db39047c133a4a1db74e9ca0d Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 19:21:16 +0200 Subject: [PATCH 01/21] 0.9.6.27: manuellen NC-Abgleich registrieren --- include/tool_registry.inc.php | 55 ++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/include/tool_registry.inc.php b/include/tool_registry.inc.php index 97ae8de..312dc91 100644 --- a/include/tool_registry.inc.php +++ b/include/tool_registry.inc.php @@ -6,7 +6,7 @@ if (!defined('PHPWG_ROOT_PATH')) if (isset($GLOBALS['template']) && is_object($GLOBALS['template']) && method_exists($GLOBALS['template'], 'func_combine_script')) { - $script_version = function_exists('bratonien_tools_current_version') ? bratonien_tools_current_version() : '0.9.6.24'; + $script_version = function_exists('bratonien_tools_current_version') ? bratonien_tools_current_version() : '0.9.6.27'; $GLOBALS['template']->func_combine_script(array( 'id'=>'bratonien_nc_connector_edit_v2', 'path'=>BRATONIEN_TOOLS_PATH.'js/nc_connector_edit_v2.js', @@ -41,6 +41,58 @@ require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_delete_safe.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_webdav.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_wizard_webdav_flow.inc.php'); require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_edit.inc.php'); +require_once(BRATONIEN_TOOLS_PATH . 'include/nc_connector_system.inc.php'); + +function bratonien_tools_nc_connector_run_now() +{ + $service = 'bratonien-nc-connector.service'; + $active = bratonien_tools_nc_connector_systemctl_value(array('is-active', $service)); + if ($active === 'active' || $active === 'activating') + { + return array('message'=>'Der NC-Abgleich läuft bereits.'); + } + + if (!function_exists('proc_open')) + { + throw new RuntimeException('Der NC-Abgleich konnte nicht gestartet werden: proc_open ist nicht verfügbar.'); + } + + $commands = array( + array('/usr/bin/sudo', '-n', '/usr/bin/systemctl', 'start', '--no-block', $service), + array('/usr/bin/systemctl', 'start', '--no-block', $service), + ); + $last_error = ''; + + foreach ($commands as $command) + { + if (!is_executable($command[0])) + { + continue; + } + $spec = array( + 0=>array('file','/dev/null','r'), + 1=>array('pipe','w'), + 2=>array('pipe','w'), + ); + $process = @proc_open($command, $spec, $pipes, null, array_merge($_ENV, array('LC_ALL'=>'C','LANG'=>'C'))); + if (!is_resource($process)) + { + continue; + } + $stdout = trim((string)stream_get_contents($pipes[1])); + $stderr = trim((string)stream_get_contents($pipes[2])); + fclose($pipes[1]); + fclose($pipes[2]); + $exit = proc_close($process); + if ($exit === 0) + { + return array('message'=>'NC-Abgleich wurde gestartet.'); + } + $last_error = $stderr !== '' ? $stderr : $stdout; + } + + throw new RuntimeException('Der NC-Abgleich konnte nicht gestartet werden'.($last_error !== '' ? ': '.$last_error : '.')); +} function bratonien_tools_get_tools() { @@ -72,6 +124,7 @@ function bratonien_tools_get_tools() 'nc_connector_delete' => array('handler' => 'bratonien_tools_nc_connector_delete_safe'), 'nc_connector_update_name' => array('handler' => 'bratonien_tools_nc_connector_update_name'), 'nc_connector_update_technical' => array('handler' => 'bratonien_tools_nc_connector_update_technical'), + 'nc_connector_run_now' => array('handler' => 'bratonien_tools_nc_connector_run_now'), 'nc_connector_wizard_scan' => array('handler' => 'bratonien_tools_nc_wizard_scan_webdav_first'), 'nc_connector_wizard_save_technical' => array('handler' => 'bratonien_tools_nc_wizard_save_technical_flow'), 'nc_connector_wizard_directory_browse' => array('handler' => 'bratonien_tools_nc_wizard_directory_browse'), From 76a182af82d9a8e0364af1c10be6f36bab9a284c Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 19:21:41 +0200 Subject: [PATCH 02/21] 0.9.6.27: Jetzt-abgleichen-Button anzeigen --- js/nc_connector_run_now.js | 56 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 js/nc_connector_run_now.js diff --git a/js/nc_connector_run_now.js b/js/nc_connector_run_now.js new file mode 100644 index 0000000..c39bccb --- /dev/null +++ b/js/nc_connector_run_now.js @@ -0,0 +1,56 @@ +(function () { + 'use strict'; + + function init() { + var section = document.getElementById('nc-connector'); + if (!section || section.querySelector('[data-nc-run-now]')) return; + + var statusHeading = Array.prototype.find.call(section.querySelectorAll('h4'), function (heading) { + return heading.textContent.trim() === 'Status'; + }); + if (!statusHeading) return; + + var card = statusHeading.closest('.bratonien-card'); + if (!card) return; + + var tokenInput = section.querySelector('input[name="pwg_token"]'); + if (!tokenInput || !tokenInput.value) return; + + var form = document.createElement('form'); + form.method = 'post'; + form.className = 'bratonien-actions'; + form.style.marginTop = '1rem'; + form.setAttribute('data-nc-run-now', '1'); + + var token = document.createElement('input'); + token.type = 'hidden'; + token.name = 'pwg_token'; + token.value = tokenInput.value; + + var tool = document.createElement('input'); + tool.type = 'hidden'; + tool.name = 'bratonien_tool'; + tool.value = 'nc_connector_run_now'; + + var button = document.createElement('button'); + button.type = 'submit'; + button.className = 'buttonLike'; + button.textContent = 'Jetzt abgleichen'; + + form.addEventListener('submit', function () { + button.disabled = true; + button.textContent = 'Abgleich wird gestartet …'; + }); + + form.appendChild(token); + form.appendChild(tool); + form.appendChild(button); + card.appendChild(form); + } + + if (document.readyState === 'loading') { + document.addEventListener('DOMContentLoaded', init); + } else { + init(); + } +})(); From 8c30edc0eeadff6b7cdbf1febaa6c6fa593185a0 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 19:22:11 +0200 Subject: [PATCH 03/21] 0.9.6.27: Jetzt-abgleichen-JavaScript laden --- include/tool_registry.inc.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/tool_registry.inc.php b/include/tool_registry.inc.php index 312dc91..2fcb325 100644 --- a/include/tool_registry.inc.php +++ b/include/tool_registry.inc.php @@ -13,6 +13,12 @@ if (isset($GLOBALS['template']) && is_object($GLOBALS['template']) && method_exi 'load'=>'footer', 'version'=>$script_version, )); + $GLOBALS['template']->func_combine_script(array( + 'id'=>'bratonien_nc_connector_run_now', + 'path'=>BRATONIEN_TOOLS_PATH.'js/nc_connector_run_now.js', + 'load'=>'footer', + 'version'=>$script_version, + )); } require_once(BRATONIEN_TOOLS_PATH . 'tools/image_cache.inc.php'); From cfea5546de9f96462e1d8911c384e28ff0ef6203 Mon Sep 17 00:00:00 2001 From: Terranom674 Date: Wed, 19 Aug 2026 19:22:32 +0200 Subject: [PATCH 04/21] 0.9.6.27: Version anheben --- main.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.inc.php b/main.inc.php index b0063c1..467fd7b 100644 --- a/main.inc.php +++ b/main.inc.php @@ -1,7 +1,7 @@ Date: Wed, 19 Aug 2026 19:22:48 +0200 Subject: [PATCH 05/21] 0.9.6.27: Jetzt-abgleichen-JavaScript in CI pruefen --- .github/workflows/lint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 956230f..f5f49d8 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -53,6 +53,7 @@ jobs: sed -n '/