From 6bbce403a6ae3ed6460983f16a712b5f034c9bb6 Mon Sep 17 00:00:00 2001 From: jhartworks Date: Thu, 19 Mar 2026 13:59:59 +0100 Subject: [PATCH] Refactor database interaction in MonitoringServer class to improve SQL execution conditions and enhance notification logic --- Monitoring Server Influx V1/module.php | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Monitoring Server Influx V1/module.php b/Monitoring Server Influx V1/module.php index f7a7951..a9cdf47 100644 --- a/Monitoring Server Influx V1/module.php +++ b/Monitoring Server Influx V1/module.php @@ -429,7 +429,9 @@ class MonitoringServer extends IPSModule { $tdOld = $this->ReadAttributeString("AtAlarmtable"); $td = $tdOld; + if ($idSql > 0 && $idSql != 12345){ MySQL_Open($idSql); + } // === Helfer: Escaping für Strings === if (function_exists('MySQL_RealEscapeString')) { @@ -449,12 +451,12 @@ class MonitoringServer extends IPSModule { if (GetValue($trigid) == true && ($this->GetBuffer($smname) == "true")) { $this->SetBuffer($smname, "false"); - - if ($sendit == true){ - VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid); - $push = 1; - } - + if($webfrontid != 0){ + if ($sendit == true){ + VISU_PostNotification($webfrontid, $art, $smname, $ico, $targetid); + $push = 1; + } + } $whatsapp = 0; $whatsapped = 0; if ($sendwhatsapp == true){ @@ -536,14 +538,20 @@ class MonitoringServer extends IPSModule { )", $esc($smname), $esc($phonenumber) ); - + if ($idSql > 0 && $idSql != 12345){ + + // === Ausführen === $okcall = MySQL_ExecuteSimple($idSql, $sqlcall); if (!$okcall) { echo "INSERT fehlgeschlagen.\n"; } + } + + $phoned = 1; + } } } @@ -607,12 +615,13 @@ class MonitoringServer extends IPSModule { (int)$mail, $esc($email_address), (int)$mailed, (int)$push ); - + if ($idSql > 0 && $idSql != 12345){ // === Ausführen === $ok = MySQL_ExecuteSimple($idSql, $sql); if (!$ok) { echo "INSERT fehlgeschlagen.\n"; } + } } elseif (GetValue($trigid) == false) { $this->SetBuffer($smname, "true");