From c1aaf3173d061f660d8fff3fc81804f1ed167299 Mon Sep 17 00:00:00 2001 From: Lutz Bender Date: Mon, 4 Nov 2024 09:38:32 +0100 Subject: [PATCH] fix soc module validation for second charge point --- web/settings/saveconfig.php | 77 ++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 36 deletions(-) diff --git a/web/settings/saveconfig.php b/web/settings/saveconfig.php index 78b23bc0d..8d83ba3c2 100644 --- a/web/settings/saveconfig.php +++ b/web/settings/saveconfig.php @@ -109,23 +109,6 @@ function checkModule($module){ // handling of different actions required by some modules - // check for manual ev soc module on lp1 - if( array_key_exists( 'socmodul', $_POST ) ){ - if( $_POST['socmodul'] == 'soc_manual' ){ - exec( 'mosquitto_pub -t openWB/lp/1/boolSocManual -r -m "1"' ); - } else { - exec( 'mosquitto_pub -t openWB/lp/1/boolSocManual -r -m "0"' ); - } - } - // check for manual ev soc module on lp2 - if( array_key_exists( 'socmodul1', $_POST ) ){ - if( $_POST['socmodul1'] == 'soc_manuallp2' ){ - exec( 'mosquitto_pub -t openWB/lp/2/boolSocManual -r -m "1"' ); - } else { - exec( 'mosquitto_pub -t openWB/lp/2/boolSocManual -r -m "0"' ); - } - } - // update display process if in POST data if( array_key_exists( 'displayaktiv', $_POST ) || array_key_exists( 'isss', $_POST) ){ ?> @@ -146,28 +129,50 @@ function checkModule($module){ exec( 'mosquitto_pub -t openWB/global/ETProvider/modulePath -r -m ' . $module ); } - // start ev-soc updates if in POST data - if( array_key_exists( 'socmodul', $_POST ) && ($_POST['socmodul'] != 'none') ){ - $module = checkModule($_POST['socmodul']); - if( $module === false ){ - throw new Exception('Ungültiges SoC-Modul: ' . $_POST['socmodul']); + // soc module for lp1 + if( array_key_exists( 'socmodul', $_POST ) ){ + // check for manual soc module on lp1 + if( $_POST['socmodul'] == 'soc_manual' ){ + exec( 'mosquitto_pub -t openWB/lp/1/boolSocManual -r -m "1"' ); + } else { + exec( 'mosquitto_pub -t openWB/lp/1/boolSocManual -r -m "0"' ); + } + // start soc update if in POST data + if( $_POST['socmodul'] != 'none' ){ + $module = checkModule($_POST['socmodul']); + if( $module === false ){ + throw new Exception('Ungültiges SoC-Modul: ' . $_POST['socmodul']); + } + ?> + + /dev/null &" ); } - ?> - - /dev/null &" ); } - if( array_key_exists( 'socmodul1', $_POST ) && ($_POST['socmodul1'] != 'none') ){ - $module = checkModule($_POST['socmodul1']); - if( $module === false ){ - throw new Exception('Ungültiges SoC-Modul: ' . $_POST['socmodul1']); + + // soc module for lp2 + if( array_key_exists( 'socmodul1', $_POST ) ){ + // check for manual ev soc module on lp2 + if( $_POST['socmodul1'] == 'soc_manuallp2' ){ + exec( 'mosquitto_pub -t openWB/lp/2/boolSocManual -r -m "1"' ); + } else { + exec( 'mosquitto_pub -t openWB/lp/2/boolSocManual -r -m "0"' ); + } + if( $_POST['socmodul1'] != 'none' ){ + // detect trailing "s1" or "lp2" in $POST['socmodul1'] + $moduleName = preg_replace('/(s1|lp2)$/', '', $_POST['socmodul1']); + + $module = checkModule($moduleName); + if( $module === false ){ + throw new Exception('Ungültiges SoC-Modul: ' . $_POST['socmodul1']); + } + ?> + + /dev/null &" ); } - ?> - - /dev/null &" ); } // check for rfid mode and start/stop handler